mutate_nodes: Mutate nodes

View source: R/generic_reshape.r

mutate_nodesR Documentation

Mutate nodes

Description

Mutate nodes

Usage

mutate_nodes(.tokens, node, ..., subset = NULL)

Arguments

.tokens

A tokenIndex in which nodes are selected with select_nodes.

node

The name of the node that is to be mutated

...

named arguments. The name should be a column in tokens

subset

A subset expression (that evaluates to a logical vector). The token column for each labeled node in the tquery can be referred to as label$column.

Value

A tokenIndex with a .nodes attribute

Examples

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

rsyntax documentation built on June 7, 2022, 9:07 a.m.