|
Lingua::Treebank - Perl extension for manipulating the Penn Treebank format |
Lingua::Treebank - Perl extension for manipulating the Penn Treebank format
use Lingua::Treebank;
my @utterances = Lingua::Treebank->from_penn_file($filename);
foreach (@utterances) {
# $_ is a Lingua::Treebank::Const now
foreach ($_->get_all_terminals) {
# $_ is a Lingua::Treebank::Const that is a terminal (word)
print $_->word(), ' ' $_->tag(), "\n";
}
print "\n\n";
}
Modules for abstracting out the "natural" objects in the Penn Treebank format.
This class knows how to read two treebank formats, the Penn format and the Chomsky Normal Form (CNF) format. These formats differ in how they handle terminal nodes. The Penn format places pre-terminal part of speech tags in the left-hand position of a parenthesis-delimited pair, just like it does non-terminal nodes. The CNF format attaches pre-terminal tags to the word with an underscore. For example, the sentence ``I spoke'' would be rendered in each format as follows:
(S
(NP
(N I))
(VP
(V spoke)))
Penn
(S
(NP
I_N)
(VP
spoke_V))
Chomsky Normal Form
Almost all the interesting tree-functionality is in the constituent-forming package (included in this distribution, see the Lingua::Treebank::Const manpage).
PLEASE NOTE: The format expected here is the .mrg format, not the
.psd format. In other words, one POS-tag per word is required. (In
response to CPAN bug 15079.)
Lingua::Treebank::CONST_CLASS indicates what class should
be used as the class for constituents. The default is
Lingua::Treebank::Const; it will generate an error to use a value
for $Lingua::Treebank::CONST_CLASS that is not a subclass of
Lingua::Treebank::Const.
None by default.
-CAX
Lingua::Treebank
Added some documentation distinguishing that .mrg (and not .psd files) are supported.
text() method now suppresses anything with a -NONE- tag.
$VERSION for the Lingua::Treebank manpage and the Lingua::Treebank::Const manpage now
tied.
TO DO: mention documentation of Penn Treebank
Jeremy Gillmor Kahn, <kahn@cpan.org>
Copyright 2003-2005 by Jeremy Gillmor Kahn with additional support from Bill McNeill
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
|
Lingua::Treebank - Perl extension for manipulating the Penn Treebank format |