Skip to content

Instantly share code, notes, and snippets.

@vanatteveldt
Created November 23, 2022 08:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vanatteveldt/bf9a4572bc18b19e97dc156ebffc96b7 to your computer and use it in GitHub Desktop.
Save vanatteveldt/bf9a4572bc18b19e97dc156ebffc96b7 to your computer and use it in GitHub Desktop.
install.packages("udpipe")
install.packages("rsyntax")
library(udpipe)
tokens = udpipe('John Doe, who is a great guy, said yesterday that all was well', 'english') |>
as_tokenindex()
plot_tree(tokens, token, lemma, upos)
verbs = c("tell", "show", "acknowledge", "admit", "affirm", "allege",
"announce", "assert", "attest", "avow", "call", "claim", "comment",
"concede", "confirm", "declare", "deny", "exclaim", "insist", "mention",
"note", "post","predict", "proclaim", "promise", "reply", "remark",
"report", "say", "speak", "state", "suggest", "talk", "tell", "think",
"warn","write", "add")
direct = tquery(lemma = verbs, label='verb',
children(req=FALSE, relation = c('npadvmod'), block=TRUE),
children(relation=c('su','nsubj','agent','nmod:agent'), label='source'),
children(label='quote'))
tokens = annotate_tqueries(tokens, 'quote', dir=direct)
syntax_reader(tokens, annotation = 'quote', value = 'source')
plot_tree(tokens, token, lemma, upos, annotation='quote', )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment