chop {rsyntax} | R Documentation |
Chop of a branch of the tree
Description
Using the query language for tquery, chop of the branch down from the node that is found
Usage
chop(.tokens, ...)
Arguments
.tokens |
A tokenIndex |
... |
Arguments passed to tquery. For instance, relation = 'punct' cuts off all punctuation dependencies (in universal dependencies) |
Value
A tokenIndex with the rows of the nodes in the selected branches removed
Examples
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)
[Package rsyntax version 0.1.4 Index]