Chop of a branch of the tree
Using the query language for tquery, chop of the branch down from the node that is found
chop(.tokens, ...)
.tokens |
A tokenIndex |
... |
Arguments passed to tquery. For instance, relation = 'punct' cuts off all punctuation dependencies (in universal dependencies) |
A tokenIndex with the rows of the nodes in the selected branches removed
spacy_conjunctions <- function(tokens) { no_fill = c('compound*','case', 'relcl') tq = tquery(label='target', NOT(relation = 'conj'), rsyntax::fill(NOT(relation = no_fill), max_window = c(Inf,0)), children(relation = 'conj', label='origin', rsyntax::fill(NOT(relation = no_fill), max_window=c(0,Inf)))) tokens = climb_tree(tokens, tq) chop(tokens, relation = 'cc') } ## spacy tokens for "Bob and John ate bread and drank wine" tokens = tokens_spacy[tokens_spacy$doc_id == 'text5',] tokens = spacy_conjunctions(tokens) tokens if (interactive()) plot_tree(tokens)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.