NAME

Lingua::CollinsParser::Node - Syntax tree node

SYNOPSIS

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;

DESCRIPTION

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.

METHODS

The following methods are available in the Lingua::CollinsParser::Node class:

new(...)

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.

head()

Returns the head child node of this node, or undef if this node has no head.

children()

In list context, returns the child nodes of this node. In scalar context, returns the number of child nodes.

token()

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).

head_token()

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.

node_type()

Returns the type of this node. The current allowable values are leaf, nonterminal, and unary; these values may change in future versions.

label()

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.

as_xml()

Returns a string representing this node as XML. The exact names of the tags in the output are subject to change in future versions.

AUTHOR

Ken Williams, ken.williams@thomson.com