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.
Lingua::CollinsParser->parse_sentence
The following methods are available in the Lingua::CollinsParser::Node class:
Lingua::CollinsParser::Node
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.
new()
children
head_token
head_child
node_type
label
token
Returns the head child node of this node, or undef if this node has no head.
undef
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.
head()
token()
Returns the type of this node. The current allowable values are leaf, nonterminal, and unary; these values may change in future versions.
leaf
nonterminal
unary
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
To install Lingua::CollinsParser, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Lingua::CollinsParser
CPAN shell
perl -MCPAN -e shell install Lingua::CollinsParser
For more information on module installation, please visit the detailed CPAN module installation guide.