# NOT RUN {
tokens = tokens_spacy[tokens_spacy$doc_id == 'text4',]
## use a tquery to label the nodes that you want to manipulate
tq = tquery(relation = "relcl", label = "relative_clause")
## apply query to select nodes
tokens2 = select_nodes(tokens, tq)
## as an example, we make the parent of the relative_clause
## nodes NA, effectively cutting of the relcl from the tree
tokens2 = mutate_nodes(tokens2, "relative_clause", parent=NA)
tokens2
# }
# NOT RUN {
if (interactive()) plot_tree(tokens2)
## this is designed to work nicely with magrittr piping
if (interactive()) {
tokens %>%
select_nodes(tq) %>%
mutate_nodes("relative_clause", parent=NA) %>%
plot_tree()
}
# }
Run the code above in your browser using DataLab