class

Zh2Vi::Node

Inherits Reference < Object

Node represents a node in the syntax tree Can be either a phrasal node (NP, VP, etc.) or a leaf node with token

Constructors

entity(label : String, children : Array(Node)) : Node

Create an atomic NER node

Source
leaf(label : String, token : Token, index : Int32) : Node

Create a leaf node with token

Source
new(label : String, children : Array(Node) = [] of Node, token : Token | Nil = nil, vietnamese : String | Nil = nil, index : Int32 | Nil = nil, is_atomic : Bool = false)
Source
phrase(label : String, children : Array(Node)) : Node

Create a phrasal node with children

Source

Instance methods

children

Child nodes (empty for leaf nodes)

Source
children=(children : Array(Node))

Child nodes (empty for leaf nodes)

Source
deprel

Get dependency relation of this node

Source
dup

Deep copy the node

Source
find_node

Find first node matching the block

Source
head_child

Get the head child based on CTB head-finding rules

Source
index

Index in the original sentence (for leaf nodes)

Source
index=(index : Int32 | Nil)

Index in the original sentence (for leaf nodes)

Source
is_atomic=(is_atomic : Bool)

Whether this node is atomic (NER entity - cannot be restructured)

Source
is_atomic?

Whether this node is atomic (NER entity - cannot be restructured)

Source
label

Constituency label (NP, VP, IP, etc.) or NER label for atomic entities

Source
label=(label : String)

Constituency label (NP, VP, IP, etc.) or NER label for atomic entities

Source
leaf?

Check if this is a leaf node

Source
leaves

Get all leaf nodes (tokens) in left-to-right order

Source
phrase?

Check if this is a phrasal node

Source
remove_descendant(target : Node) : Bool

Remove a descendant node (recursive)

Source
text

Get all tokens text joined

Source
to_bracket(io : IO) : Nil

Bracket notation output (like Penn Treebank)

Source
to_bracket
Source
to_s(io : IO) : Nil

Pretty print the tree

Source
token

Token information (only for leaf nodes)

Source
token=(token : Token | Nil)

Token information (only for leaf nodes)

Source
traverse_postorder

Traverse all nodes in post-order (children first, then parent)

Source
traverse_preorder

Traverse all nodes in pre-order (parent first, then children)

Source
vietnamese

Vietnamese translation result

Source
vietnamese=(vietnamese : String | Nil)

Vietnamese translation result

Source