| Lingua-CollinsParser documentation | view source | Contained in the Lingua-CollinsParser distribution. |
Lingua::CollinsParser::Node - Syntax tree node
use Lingua::CollinsParser; my $p = Lingua::CollinsParser->new(); ... my $node = $p->parse_sentence(\@words, \@tags); my $head = $node->head; my @children = $node->children; print $node->as_xml;
This class represents a node in a syntax tree generated by Lingua::CollinsParser->parse_sentence. Each node may contain zero
or more child nodes - thus the tree structure. This class provides no
methods for altering the tree structure, so the trees are effectively
read-only objects.
The following methods are available in the
Lingua::CollinsParser::Node class:
Creates a new Lingua::CollinsParser::Node object and returns it.
For initialization, new() accepts a list of key-value pairs
corresponding to the data fields children, head_token,
head_child, node_type, label, and token.
Returns the head child node of this node, or undef if this node has
no head.
In list context, returns the child nodes of this node. In scalar context, returns the number of child nodes.
Returns the token associated with this node, or undef if this node
is not associated with a token (i.e. if this node isn't a leaf).
Returns the token representing the head of this node. This is
equivalent to following head() to a leaf node and then returning
token(), but faster.
Returns the type of this node. The current allowable values are
leaf, nonterminal, and unary; these values may change in
future versions.
For leaf nodes, returns the part-of-speech associated with this node. For other nodes, returns the syntactic label of the constituent represented by this node.
Returns a string representing this node as XML. The exact names of the tags in the output are subject to change in future versions.
Ken Williams, ken.williams@thomson.com
| Lingua-CollinsParser documentation | view source | Contained in the Lingua-CollinsParser distribution. |