NAME

Treex::Core::Phrase::Term

VERSION

version 2.20210102

SYNOPSIS

use Treex::Core::Document;
use Treex::Core::Phrase::Term;

my $document = new Treex::Core::Document;
my $bundle   = $document->create_bundle();
my $zone     = $bundle->create_zone('en');
my $root     = $zone->create_atree();
my $phrase   = new Treex::Core::Phrase::Term ('node' => $root);

DESCRIPTION

Term is a terminal Phrase. It contains (refers to) one Node and it can be part of nonterminal phrases (NTerm). See Treex::Core::Phrase for more details.

ATTRIBUTES

node

Refers to the Node wrapped in this terminal phrase.

deprel

Any label describing the type of the dependency relation between this phrase (its node) and the governing phrase (node of the first ancestor phrase where this one does not act as head). This label is typically taken from the underlying node when the phrase is built, but it may be translated or modified and it is not kept synchronized with the underlying dependency tree during transformations of the phrase structure. Nevertheless it is assumed that once the transformations are done, the final dependency relations will be projected back to the dependency tree.

The deprel attribute can also be supplied separately when creating the Phrase::Term. If it is not supplied, it will be copied from the Node to which the node attribute refers.

nodes

Returns the list of all nodes covered by the phrase, which in the case of a terminal phrase means just the node wrapped in it.

terminals

Returns a one-element list containing this phrase. This method is used to collect all terminal descendants of a phrase. It is similar to nodes() but instead of Node objects, it returns phrases that wrap the nodes.

dependents

Returns the list of dependents of the phrase. Terminal phrases return an empty list by definition.

children

Returns the list of children of the phrase. Terminal phrases return an empty list by definition.

span

Returns the lowest and the highest ord values of the nodes covered by this phrase. For a terminal phrase, the result is just the ord repeated twice.

project_dependencies

Projects dependencies between the head and the dependents back to the underlying dependency structure. There is not much to do in the terminal phrase as it does not have any dependents. However, we will attach all nodes to the root, to prevent temporary cycles during the tree construction.

as_string

Returns a textual representation of the phrase and all subphrases. Useful for debugging.

AUTHORS

Daniel Zeman <zeman@ufal.mff.cuni.cz>

COPYRIGHT AND LICENSE

Copyright © 2013, 2015 by Institute of Formal and Applied Linguistics, Charles University in Prague This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.