Treex::Core::Node::EffectiveRelations
version 2.20151210
Moose role for nodes with a notion of so called effective parents and effective children. This notion is used both on the a-layer (Treex::Core::Node::A) and on the t-layer (Treex::Core::Node::T).
TODO: explain it, some examples, reference to PDT manual
Eg. in the sentence "Martin and Rudolph came", the tree structure is
came(and(Martin,Rudolph))
where "and" is a head of a coordination with members "Martin" and "Rudolph". See what the methods get_children, get_echildren, get_parent and get_eparents return when called on various nodes (some pseudocode used for better readability):
get_children
get_echildren
get_parent
get_eparents
# CHILDREN AND EFFECTIVE CHILDREN "came"->get_children() # returns "and" "came"->get_echildren() # returns ("Martin", "Rudolph") "and"->get_children() # returns ("Martin", "Rudolph") "and"->get_echildren() # returns ("Martin", "Rudolph") and issues a warning: # get_echildren called on coap root ([id_of_and]). Fallback to topological one. "and"->get_echildren({or_topological => 1}) # returns ("Martin", "Rudolph") with no warning # PARENTS AND EFFECTIVE PARENTS "Rudolph"->get_parent() # returns "and" "Rudolph"->get_eparents() # returns "came" "and"->get_parent() # returns "came" "and"->get_eparents() # returns "came" and issues a warning: # get_eparents called on coap root ([id_of_and]). Fallback to topological one. "and"->get_eparents({or_topological => 1}) # returns "came" with no warning
Note that to skip prepositions and subordinating conjunctions on the a-layer, you must use option dive, e.g.:
dive
my $eff_children = $node->get_echildren({dive=>'AuxCP'});
Methods get_eparents and get_echildren produce a warning "called on coap root ($id). Fallback to topological one." when called on a root of coordination or apposition, because effective children/parents are not properly defined in this case. This warning can be supressed by option or_topological.
called on coap root ($id). Fallback to topological one.
or_topological
Returns a list of effective children of the $node. It means that a) instead of coordination/aposition heads, their members are returned b) shared modifiers of a coord/apos (technically hanged on the head of coord/apos) count as effective children of the members.
$node
OPTIONS:
Using dive, you can define nodes to be skipped (or dived). dive is a reference to a subroutine that decides whether the given node should be skipped or not. Typically this is used for prepositions and subord. conjunctions on a-layer. You can set dive to the string AuxCP which is a shortcut for sub {my $self=shift;return $self-afun =~ /^Aux[CP]$/;}>.
AuxCP
sub {my $self=shift;return $self-
If the notion of effective child is not defined (if $node is a head of coordination), return the topological children without warnings.
You can specify the same options as in Treex::Core::Node::get_children().
Returns a list of effective parents of the $node.
OPTIONS
see get_echildren
If the notion of effective parent is not defined (if $node is a head of coordination), return the topological parent without warnings.
If there is an error in the tree structure, eg. there is a coordination with no members or a non-root node with no parent, a warning is issued (The node [node_id] has no effective parent, using the topological one.). This option supresses the warning. Use thoughtfully (preferably do not use at all).
The node [node_id] has no effective parent, using the topological one.
If the node is a coordination/apposition head (see Node::A::is_coap_root() and Node::T::is_coap_root()) a list of all coordinated members is returned. Otherwise, the node itself is returned.
In case of nested coordinations return only "first-level" members. The default is to return transitive members. For example "(A and B) or C":
$or->get_coap_members(); # returns A,B,C $or->get_coap_members({direct_only=>1}); # returns and,C
Martin Popel <popel@ufal.mff.cuni.cz>
Copyright © 2011 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.
To install Treex::Core, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Treex::Core
CPAN shell
perl -MCPAN -e shell install Treex::Core
For more information on module installation, please visit the detailed CPAN module installation guide.