NAME

Treex::Core::Phrase::Coordination

VERSION

version 2.20210102

SYNOPSIS

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

my $document = new Treex::Core::Document;
my $bundle   = $document->create_bundle();
my $zone     = $bundle->create_zone('en');
my $root     = $zone->create_atree();
my $coord    = $root->create_child();
my $conj1    = $coord->create_child();
my $conj2    = $coord->create_child();
$coord->set_deprel('Coord');
$conj1->set_deprel('Pred_M');
$conj2->set_deprel('Pred_M');
my $coordphr = new Treex::Core::Phrase::Term ('node' => $coord);
my $conj1phr = new Treex::Core::Phrase::Term ('node' => $conj1);
my $conj2phr = new Treex::Core::Phrase::Term ('node' => $conj2);
my $cphrase  = new Treex::Core::Phrase::Coordination ('conjuncts' => [$conj1phr, $conj2phr], 'coordinators' => [$coordphr], 'head_rule' => 'last_coordinator', 'deprel' => 'Pred');

DESCRIPTION

Treex::Core::Phrase::Coordination is a special case of Treex::Core::Phrase::NTerm. It does not have a fixed head but it has a head rule that specifies how the head child should be determined if needed. On the other hand, there are several sets of core children that are not ordinary dependents. They are conjuncts (i.e. the phrases that are coordinated), coordinators (coordinating conjunctions and similar words) and conjunct-delimiting punctuation.

ATTRIBUTES

_conjuncts_ref

Reference to array of sub-Phrases (children) that are coordinated in this phrase. The conjuncts are counted among the core children of Coordination. Every Coordination must always have at least one conjunct.

_coordinators_ref

Reference to array of sub-Phrases (children) that act as coordinating conjunctions and that are words, not punctuation. The coordinators are counted among the core children of Coordination. However, their presence is not required.

_punctuation_ref

Reference to array of sub-Phrases (children) that contain punctuation between conjuncts. The punctuation phrases are counted among the core children of Coordination. However, their presence is not required.

head_rule

A string that says how the head of the coordination should be selected. first_conjunct means that the first conjunct is the head (there is always at least one conjunct). last_coordinator means that the last coordinating conjunction, if any, is the head; in asyndetic coordination (no conjunctions) the last punctuation symbol is the head; if there are neither conjunctions nor punctuation, the first conjunct is the head.

METHODS

A sub-Phrase of this phrase that is at the moment considered the head phrase (in the sense of dependency syntax). It depends on the current head_rule.

conjuncts

Returns the list of conjuncts. The only difference from the getter _conjuncts_ref() is that the getter returns a reference to the array of conjuncts, while this method returns a list of conjuncts. Hence this method is more similar to the other methods that return lists of children.

add_conjunct

Adds a phrase as a new conjunct to this coordination. The phrase may be currently a dependent of another phrase and will be correctly re-linked. However, it must not be a core child of any phrase.

coordinators

Returns the list of coordinating conjunctions (but not punctuation). The only difference from the getter _coordinators_ref() is that the getter returns a reference to array, while this method returns a list. Hence this method is more similar to the other methods that return lists of children.

add_coordinator

Adds a phrase as a new coordinator to this coordination. The phrase may be currently a dependent of another phrase and will be correctly re-linked. However, it must not be a core child of any phrase.

punctuation

Returns the list of punctuation symbols between conjuncts. The only difference from the getter _punctuation_ref() is that the getter returns a reference to array, while this method returns a list. Hence this method is more similar to the other methods that return lists of children.

add_punctuation

Adds a phrase as a new punctuation delimiter to this coordination. The phrase may be currently a dependent of another phrase and will be correctly re-linked. However, it must not be a core child of any phrase.

nonhead_children

Returns the list of non-head children of the phrase, i.e. the dependents plus all core children except the one that currently serves as the head.

core_children

Returns the list of the children of the phrase that are not dependents, i.e. all conjuncts, coordinators and punctuation.

deprel

Returns the type of the dependency relation of the coordination to the governing phrase.

set_deprel

Sets a new type of the dependency relation of the phrase to the governing phrase. For nonterminal phrases the label is propagated to one (or several) of their children. It is not propagated to the underlying dependency tree (the project_dependencies() method would have to be called to achieve that).

Depending on the current annotation style, deprel of coordination is propagated either to just the first conjunct, or to all conjuncts (except for orphans from elided conjuncts).

project_deprel

Returns the deprel that should be used when the phrase tree is projected back to a dependency tree (see the method project_dependencies()). In most cases this is identical to what deprel() returns. However, for instance coordinations in Prague treebanks are attached using Coord. Their relation to the parent (returned by deprel()) is projected to the conjuncts.

project_dependencies

Projects dependencies between the head and the dependents back to the underlying dependency structure. For coordinations the behavior depends on the currently selected head rule: certain deprels may have to be adjusted.

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.