copy_fill: Copy nodes

Description Usage Arguments Value Examples

View source: R/generic_reshape.r

Description

Copy nodes

Usage

1
2
3
4
5
6
7
8
copy_fill(
  .tokens,
  from_node,
  to_node,
  subset = NULL,
  subset_fill = NULL,
  only_new = NULL
)

Arguments

.tokens

A tokenIndex in which nodes are selected with select_nodes.

from_node

The name of the node from which fill is copied

to_node

The name of the node to which fill is copied

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.

subset_fill

A subset on the fill nodes. Can only directly use token column. For example, use pos == 'VERB' to copy only verbs

only_new

If TRUE, direct fill children will only be copied to to_node if it does not already have nodes of this relation. This is a good heuristic for dealing with argument drop.

Value

A tokenIndex with a .nodes attribute

Examples

1
2
3
4
5
6
7
8
9
tokens = tokens_spacy[tokens_spacy$doc_id == 'text1',]

tq = tquery(label='object', relation='dobj')
            
tokens2 = select_nodes(tokens, tq)
selected_nodes(tokens2)

tokens3 = copy_nodes(tokens2, 'object', 'new_object')
copy_fill(tokens3, 'object', 'new_object')

rsyntax documentation built on June 13, 2021, 9:07 a.m.