| 1 | package Treex::Core::Phrase::Coordination; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | 2 | $Treex::Core::Phrase::Coordination::VERSION = '2.20210102'; | |||||||||||||||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use utf8; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use namespace::autoclean; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||
| 6 | 2 | ▶ | use Moose; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 2 | ▶ | use Treex::Core::Log; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||
| 9 | 2 | extends 'Treex::Core::Phrase::BaseNTerm'; | |||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||
| 13 | # We will keep the array of conjuncts (and of coordinators and punctuation symbols) ordered at all times. | ||||||||||||||||||||||||||||||||||||||||||
| 14 | # New members are added relatively rarely. But every head() call (which also means every deprel(), node(), ord() etc. call) | ||||||||||||||||||||||||||||||||||||||||||
| 15 | # needs the first conjunct, last coordinator and the like. Thus asking anything means sorting a lot. | ||||||||||||||||||||||||||||||||||||||||||
| 16 | # And if there are many levels of nested coordination, we may not live long enough to see the output. | ||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||
| 18 | has '_conjuncts_ref' => | ||||||||||||||||||||||||||||||||||||||||||
| 19 | ( | ||||||||||||||||||||||||||||||||||||||||||
| 20 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||
| 21 | isa => 'ArrayRef[Treex::Core::Phrase]', | ||||||||||||||||||||||||||||||||||||||||||
| 22 | 0 | ▶ | default => sub { [] }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 23 | 2 | documentation => 'The public should not access directly the array reference. '. | |||||||||||||||||||||||||||||||||||||||||
| 24 | 'They may use the public method conjuncts() to get the list. '. | ||||||||||||||||||||||||||||||||||||||||||
| 25 | 'The array must be always ordered according to ord().' | ||||||||||||||||||||||||||||||||||||||||||
| 26 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||
| 28 | has '_coordinators_ref' => | ||||||||||||||||||||||||||||||||||||||||||
| 29 | ( | ||||||||||||||||||||||||||||||||||||||||||
| 30 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||
| 31 | isa => 'ArrayRef[Treex::Core::Phrase]', | ||||||||||||||||||||||||||||||||||||||||||
| 32 | 0 | ▶ | default => sub { [] }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 33 | 2 | documentation => 'Coordinating conjunctions and similarly working words but not punctuation. '. | |||||||||||||||||||||||||||||||||||||||||
| 34 | 'The public should not access directly the array reference. '. | ||||||||||||||||||||||||||||||||||||||||||
| 35 | 'They may use the public method coordinators() to get the list. '. | ||||||||||||||||||||||||||||||||||||||||||
| 36 | 'The array must be always ordered according to ord().' | ||||||||||||||||||||||||||||||||||||||||||
| 37 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||
| 39 | has '_punctuation_ref' => | ||||||||||||||||||||||||||||||||||||||||||
| 40 | ( | ||||||||||||||||||||||||||||||||||||||||||
| 41 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||
| 42 | isa => 'ArrayRef[Treex::Core::Phrase]', | ||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | ▶ | default => sub { [] }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 44 | 2 | documentation => 'Punctuation between conjuncts. '. | |||||||||||||||||||||||||||||||||||||||||
| 45 | 'The public should not access directly the array reference. '. | ||||||||||||||||||||||||||||||||||||||||||
| 46 | 'They may use the public method punctuation() to get the list. '. | ||||||||||||||||||||||||||||||||||||||||||
| 47 | 'The array must be always ordered according to ord().' | ||||||||||||||||||||||||||||||||||||||||||
| 48 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||
| 50 | 2 | has 'head_rule' => | |||||||||||||||||||||||||||||||||||||||||
| 51 | ( | ||||||||||||||||||||||||||||||||||||||||||
| 52 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 53 | isa => 'Str', | ||||||||||||||||||||||||||||||||||||||||||
| 54 | required => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 55 | default => 'first_conjunct', | ||||||||||||||||||||||||||||||||||||||||||
| 56 | documentation => | ||||||||||||||||||||||||||||||||||||||||||
| 57 | 'first_conjunct ..... first conjunct is the head (there is always at least one conjunct); '. | ||||||||||||||||||||||||||||||||||||||||||
| 58 | 'last_coordinator ... last coordinating conjunction, if any, is the head; '. | ||||||||||||||||||||||||||||||||||||||||||
| 59 | ' last punctuation is head in asyndetic coordination; '. | ||||||||||||||||||||||||||||||||||||||||||
| 60 | ' if there are neither conjunctions nor punctuation, the first conjunct is the head.' | ||||||||||||||||||||||||||||||||||||||||||
| 61 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||
| 63 | 2 | has '_deprel' => | |||||||||||||||||||||||||||||||||||||||||
| 64 | ( | ||||||||||||||||||||||||||||||||||||||||||
| 65 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||
| 66 | isa => 'Str', | ||||||||||||||||||||||||||||||||||||||||||
| 67 | required => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 68 | documentation => | ||||||||||||||||||||||||||||||||||||||||||
| 69 | 'We need to know the dependency relation between the coordination and its parent in the dependency structure. '. | ||||||||||||||||||||||||||||||||||||||||||
| 70 | 'Depending on the selected annotation style, we will either store it at the head node, or distribute it among conjuncts. '. | ||||||||||||||||||||||||||||||||||||||||||
| 71 | 'Subsequent calls to set_deprel(), if any, will do the right thing based on the annotation style; '. | ||||||||||||||||||||||||||||||||||||||||||
| 72 | 'but we have to take care of the initial deprel setting, just in case there will be no further changes.' | ||||||||||||||||||||||||||||||||||||||||||
| 73 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||
| 77 | #------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||
| 78 | # This block will be called before object construction. It will modify and | ||||||||||||||||||||||||||||||||||||||||||
| 79 | # complete attribute list if needed. Then it will pass all the attributes to | ||||||||||||||||||||||||||||||||||||||||||
| 80 | # the constructor. | ||||||||||||||||||||||||||||||||||||||||||
| 81 | #------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||
| 82 | around BUILDARGS => sub | ||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=9 SCAR=45.0
| |||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | my $orig = shift; | |||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||
| 86 | # Call the default BUILDARGS in Moose::Object. It will take care of distinguishing between a hash reference and a plain hash. | ||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | my $attr = $class->$orig(@_); | |||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | ▶ | if(defined($attr->{conjuncts}) && ref($attr->{conjuncts}) eq 'ARRAY') | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $attr->{"conjuncts"} and ref $attr->{"conjuncts"} eq "ARRAY"
MC/DC0%0/2
defined $attr->{"conjuncts"} and ref $attr->{"conjuncts"} eq "ARRAY"
defined $attr->{"conjuncts"}
ref $attr->{"conjuncts"} eq "ARRAY"
Truth table0%0/3
A and B
A= defined $attr->{"conjuncts"}B= ref $attr->{"conjuncts"} eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||
| 89 | { | ||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | $attr->{_conjuncts_ref} = $attr->{conjuncts}; | |||||||||||||||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | ▶ | if(defined($attr->{coordinators}) && ref($attr->{coordinators}) eq 'ARRAY') | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $attr->{"coordinators"} and ref $attr->{"coordinators"} eq "ARRAY"
MC/DC0%0/2
defined $attr->{"coordinators"} and ref $attr->{"coordinators"} eq "ARRAY"
defined $attr->{"coordinators"}
ref $attr->{"coordinators"} eq "ARRAY"
Truth table0%0/3
A and B
A= defined $attr->{"coordinators"}B= ref $attr->{"coordinators"} eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||
| 93 | { | ||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | $attr->{_coordinators_ref} = $attr->{coordinators}; | |||||||||||||||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | ▶ | if(defined($attr->{punctuation}) && ref($attr->{punctuation}) eq 'ARRAY') | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $attr->{"punctuation"} and ref $attr->{"punctuation"} eq "ARRAY"
MC/DC0%0/2
defined $attr->{"punctuation"} and ref $attr->{"punctuation"} eq "ARRAY"
defined $attr->{"punctuation"}
ref $attr->{"punctuation"} eq "ARRAY"
Truth table0%0/3
A and B
A= defined $attr->{"punctuation"}B= ref $attr->{"punctuation"} eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||
| 97 | { | ||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | $attr->{_punctuation_ref} = $attr->{punctuation}; | |||||||||||||||||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | ▶ | if(defined($attr->{deprel}) && !defined($attr->{_deprel})) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $attr->{"deprel"} and not defined $attr->{"_deprel"}
MC/DC0%0/2
defined $attr->{"deprel"} and not defined $attr->{"_deprel"}
defined $attr->{"deprel"}
not defined $attr->{"_deprel"}
Truth table0%0/3
A and not(B)
A= defined $attr->{"deprel"}B= not defined $attr->{"_deprel"}
| |||||||||||||||||||||||||||||||||||||||||||
| 101 | { | ||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | $attr->{_deprel} = $attr->{deprel}; | |||||||||||||||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | return $attr; | |||||||||||||||||||||||||||||||||||||||||
| 105 | 2 | }; | |||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||
| 109 | #------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||
| 110 | # After the object is constructed, this block makes sure that the core children | ||||||||||||||||||||||||||||||||||||||||||
| 111 | # refer back to it as their parent. Also, at least one conjunct is required and | ||||||||||||||||||||||||||||||||||||||||||
| 112 | # making the conjuncts parameter required is not enough to enforce that. | ||||||||||||||||||||||||||||||||||||||||||
| 113 | #------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||
| 114 | sub BUILD | ||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BUILD: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 117 | # Check that there is at least one conjunct. | ||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | ▶ | if(scalar($self->conjuncts())==0) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 119 | { | ||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | log_fatal("There must be at least one conjunct"); | |||||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||||||
| 122 | # Make sure that all core children refer to me as their parent. | ||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | my @children = $self->core_children(); | |||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | my %ord; | |||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | foreach my $child (@children) | |||||||||||||||||||||||||||||||||||||||||
| 126 | { | ||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | ▶ | if(defined($child->parent())) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 128 | { | ||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | foreach my $child1 (@children) | |||||||||||||||||||||||||||||||||||||||||
| 130 | { | ||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | log_warn('CORE CHILD: '.$child1->as_string()); | |||||||||||||||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | log_warn('CHILDX: '.$child->as_string()); | |||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | log_warn('PARENT: '.$child->parent()->as_string()); | |||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | log_fatal("The core child already has another parent"); | |||||||||||||||||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | $child->_set_parent($self); | |||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | $ord{$child} = $child->ord(); | |||||||||||||||||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||||||||||||||||
| 140 | # Make sure that the lists of core children are sorted. | ||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | @{$self->{_conjuncts_ref}} = sort {$ord{$a} <=> $ord{$b}} (@{$self->{_conjuncts_ref}}); | |||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | @{$self->{_coordinators_ref}} = sort {$ord{$a} <=> $ord{$b}} (@{$self->{_coordinators_ref}}); | |||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | @{$self->{_punctuation_ref}} = sort {$ord{$a} <=> $ord{$b}} (@{$self->{_punctuation_ref}}); | |||||||||||||||||||||||||||||||||||||||||
| 144 | # Take care of the initial deprel setting. Deprel is stored at individual | ||||||||||||||||||||||||||||||||||||||||||
| 145 | # nodes, so make sure that the nodes responsible for storing the deprel | ||||||||||||||||||||||||||||||||||||||||||
| 146 | # of the entire coordination (according to the current annotation style) | ||||||||||||||||||||||||||||||||||||||||||
| 147 | # have it. (We cannot rely on the original dependency tree because it may | ||||||||||||||||||||||||||||||||||||||||||
| 148 | # have used a different annotation style.) | ||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | $self->set_deprel($self->_deprel()); | |||||||||||||||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||
| 154 | #------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||
| 155 | # Tells whether this phrase is coordination. We could probably use the Moose's | ||||||||||||||||||||||||||||||||||||||||||
| 156 | # methods to query the class name but this will be more convenient. | ||||||||||||||||||||||||||||||||||||||||||
| 157 | #------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||
| 158 | sub is_coordination | ||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_coordination: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 161 | # Default is FALSE, to be overridden here. | ||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||
| 167 | #------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||
| 168 | # Returns the list of conjuncts in the coordination. The only difference from | ||||||||||||||||||||||||||||||||||||||||||
| 169 | # the getter _conjuncts_ref() is that the getter returns a reference to the | ||||||||||||||||||||||||||||||||||||||||||
| 170 | # array of conjuncts, while this method returns a list of conjuncts, hence it | ||||||||||||||||||||||||||||||||||||||||||
| 171 | # is more similar to the other methods that return lists of children. | ||||||||||||||||||||||||||||||||||||||||||
| 172 | #------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||
| 173 | sub conjuncts | ||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
conjuncts: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | ▶ | log_fatal('Dead') if($self->dead()); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | my @conjuncts = @{$self->_conjuncts_ref()}; | |||||||||||||||||||||||||||||||||||||||||
| 178 | # No need to ask about _order_required() and to order_phrases(); conjuncts are pre-ordered. | ||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | return @conjuncts; | |||||||||||||||||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||
| 184 | #------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||
| 185 | # Adds a phrase as a new conjunct to this coordination. The phrase may be | ||||||||||||||||||||||||||||||||||||||||||
| 186 | # currently a dependent of another phrase and will be correctly re-linked. | ||||||||||||||||||||||||||||||||||||||||||
| 187 | # However, it must not be a core child of any phrase. | ||||||||||||||||||||||||||||||||||||||||||
| 188 | #------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||
| 189 | sub add_conjunct | ||||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_conjunct: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | ▶ | log_fatal('Incorrect number of arguments') if(scalar(@_) != 2); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | my $new_conjunct = shift; | |||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | ▶ | log_fatal('Dead') if($self->dead()); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 195 | # First make it my dependent. This ensures that the new conjunct is | ||||||||||||||||||||||||||||||||||||||||||
| 196 | # correctly detached from its current parent, if any. If it is already my | ||||||||||||||||||||||||||||||||||||||||||
| 197 | # dependent, nothing will happen. But if it is my or someone else's core | ||||||||||||||||||||||||||||||||||||||||||
| 198 | # child, an exception will be thrown. The set_parent() method also checks | ||||||||||||||||||||||||||||||||||||||||||
| 199 | # that no cycle will be created. | ||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | $new_conjunct->set_parent($self); | |||||||||||||||||||||||||||||||||||||||||
| 201 | # Now remove it from my dependents and add it to my conjuncts. | ||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | my $nhc = $self->_dependents_ref(); | |||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | my $found = 0; | |||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | ▶ | for(my $i = 0; $i <= $#{$nhc}; $i++) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 205 | { | ||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | ▶ | if($nhc->[$i] == $new_conjunct) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 207 | { | ||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | $found = 1; | |||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | splice(@{$nhc}, $i, 1); | |||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | ▶ | if(!$found) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 214 | { | ||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | log_fatal("Could not find the phrase among my non-core children"); | |||||||||||||||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||||||||||||||||
| 217 | # Add it to my conjuncts. | ||||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | my $cnj = $self->_conjuncts_ref(); | |||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | push(@{$cnj}, $new_conjunct); | |||||||||||||||||||||||||||||||||||||||||
| 220 | # Make sure that the lists of core children are sorted. | ||||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | my %ord; | |||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | foreach my $conjunct (@{$cnj}) | |||||||||||||||||||||||||||||||||||||||||
| 223 | { | ||||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | $ord{$conjunct} = $conjunct->ord(); | |||||||||||||||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | @{$cnj} = sort {$ord{$a} <=> $ord{$b}} (@{$cnj}); | |||||||||||||||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||||||
| 231 | #------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||
| 232 | # Returns the list of coordinators. The only difference from the getter | ||||||||||||||||||||||||||||||||||||||||||
| 233 | # _coordinators_ref() is that the getter returns a reference to the array of | ||||||||||||||||||||||||||||||||||||||||||
| 234 | # coordinators, while this method returns a list, hence it is more similar to | ||||||||||||||||||||||||||||||||||||||||||
| 235 | # the other methods that return lists of children. | ||||||||||||||||||||||||||||||||||||||||||
| 236 | #------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||
| 237 | sub coordinators | ||||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
coordinators: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 239 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | ▶ | log_fatal('Dead') if($self->dead()); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | my @coordinators = @{$self->_coordinators_ref()}; | |||||||||||||||||||||||||||||||||||||||||
| 242 | # No need to ask about _order_required() and to order_phrases(); coordinators are pre-ordered. | ||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | return @coordinators; | |||||||||||||||||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||||||
| 248 | #------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||
| 249 | # Adds a phrase as a new coordinator to this coordination. The phrase may be | ||||||||||||||||||||||||||||||||||||||||||
| 250 | # currently a dependent of another phrase and will be correctly re-linked. | ||||||||||||||||||||||||||||||||||||||||||
| 251 | # However, it must not be a core child of any phrase. | ||||||||||||||||||||||||||||||||||||||||||
| 252 | #------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||
| 253 | sub add_coordinator | ||||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_coordinator: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | ▶ | log_fatal('Incorrect number of arguments') if(scalar(@_) != 2); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | my $new_coordinator = shift; | |||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | ▶ | log_fatal('Dead') if($self->dead()); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 259 | # First make it my dependent. This ensures that the new coordinator is | ||||||||||||||||||||||||||||||||||||||||||
| 260 | # correctly detached from its current parent, if any. If it is already my | ||||||||||||||||||||||||||||||||||||||||||
| 261 | # dependent, nothing will happen. But if it is my or someone else's core | ||||||||||||||||||||||||||||||||||||||||||
| 262 | # child, an exception will be thrown. The set_parent() method also checks | ||||||||||||||||||||||||||||||||||||||||||
| 263 | # that no cycle will be created. | ||||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | $new_coordinator->set_parent($self); | |||||||||||||||||||||||||||||||||||||||||
| 265 | # Now remove it from my dependents and add it to my coordinators. | ||||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | my $nhc = $self->_dependents_ref(); | |||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | my $found = 0; | |||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | ▶ | for(my $i = 0; $i <= $#{$nhc}; $i++) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 269 | { | ||||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | ▶ | if($nhc->[$i] == $new_coordinator) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 271 | { | ||||||||||||||||||||||||||||||||||||||||||
| 272 | 0 | $found = 1; | |||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | splice(@{$nhc}, $i, 1); | |||||||||||||||||||||||||||||||||||||||||
| 274 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||
| 275 | } | ||||||||||||||||||||||||||||||||||||||||||
| 276 | } | ||||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | ▶ | if(!$found) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 278 | { | ||||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | log_fatal("Could not find the phrase among my non-core children"); | |||||||||||||||||||||||||||||||||||||||||
| 280 | } | ||||||||||||||||||||||||||||||||||||||||||
| 281 | # Add it to my coordinators. | ||||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | my $cnj = $self->_coordinators_ref(); | |||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | push(@{$cnj}, $new_coordinator); | |||||||||||||||||||||||||||||||||||||||||
| 284 | # Make sure that the lists of core children are sorted. | ||||||||||||||||||||||||||||||||||||||||||
| 285 | 0 | my %ord; | |||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | foreach my $coordinator (@{$cnj}) | |||||||||||||||||||||||||||||||||||||||||
| 287 | { | ||||||||||||||||||||||||||||||||||||||||||
| 288 | 0 | $ord{$coordinator} = $coordinator->ord(); | |||||||||||||||||||||||||||||||||||||||||
| 289 | } | ||||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | @{$cnj} = sort {$ord{$a} <=> $ord{$b}} (@{$cnj}); | |||||||||||||||||||||||||||||||||||||||||
| 291 | } | ||||||||||||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||||||||||||
| 295 | #------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||
| 296 | # Returns the list of punctuation symbols between conjuncts. The only | ||||||||||||||||||||||||||||||||||||||||||
| 297 | # difference from the getter _punctuation_ref() is that the getter returns a | ||||||||||||||||||||||||||||||||||||||||||
| 298 | # reference to the array, while this method returns a list, hence it is more | ||||||||||||||||||||||||||||||||||||||||||
| 299 | # similar to the other methods that return lists of children. | ||||||||||||||||||||||||||||||||||||||||||
| 300 | #------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||
| 301 | sub punctuation | ||||||||||||||||||||||||||||||||||||||||||
| 302 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
punctuation: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 303 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 304 | 0 | ▶ | log_fatal('Dead') if($self->dead()); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 305 | 0 | my @punctuation = @{$self->_punctuation_ref()}; | |||||||||||||||||||||||||||||||||||||||||
| 306 | # No need to ask about _order_required() and to order_phrases(); punctuation children are pre-ordered. | ||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | return @punctuation; | |||||||||||||||||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||||||||||
| 312 | #------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||
| 313 | # Adds a phrase as a new punctuation delimiter to this coordination. The phrase | ||||||||||||||||||||||||||||||||||||||||||
| 314 | # may be currently a dependent of another phrase and will be correctly | ||||||||||||||||||||||||||||||||||||||||||
| 315 | # re-linked. However, it must not be a core child of any phrase. | ||||||||||||||||||||||||||||||||||||||||||
| 316 | #------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||
| 317 | sub add_punctuation | ||||||||||||||||||||||||||||||||||||||||||
| 318 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_punctuation: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 319 | 0 | ▶ | log_fatal('Incorrect number of arguments') if(scalar(@_) != 2); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 320 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 321 | 0 | my $new_punctuation = shift; | |||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | ▶ | log_fatal('Dead') if($self->dead()); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 323 | # First make it my dependent. This ensures that the new phrase is | ||||||||||||||||||||||||||||||||||||||||||
| 324 | # correctly detached from its current parent, if any. If it is already my | ||||||||||||||||||||||||||||||||||||||||||
| 325 | # dependent, nothing will happen. But if it is my or someone else's core | ||||||||||||||||||||||||||||||||||||||||||
| 326 | # child, an exception will be thrown. The set_parent() method also checks | ||||||||||||||||||||||||||||||||||||||||||
| 327 | # that no cycle will be created. | ||||||||||||||||||||||||||||||||||||||||||
| 328 | 0 | $new_punctuation->set_parent($self); | |||||||||||||||||||||||||||||||||||||||||
| 329 | # Now remove it from my dependents and add it to my coordinators. | ||||||||||||||||||||||||||||||||||||||||||
| 330 | 0 | my $nhc = $self->_dependents_ref(); | |||||||||||||||||||||||||||||||||||||||||
| 331 | 0 | my $found = 0; | |||||||||||||||||||||||||||||||||||||||||
| 332 | 0 | ▶ | for(my $i = 0; $i <= $#{$nhc}; $i++) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 333 | { | ||||||||||||||||||||||||||||||||||||||||||
| 334 | 0 | ▶ | if($nhc->[$i] == $new_punctuation) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 335 | { | ||||||||||||||||||||||||||||||||||||||||||
| 336 | 0 | $found = 1; | |||||||||||||||||||||||||||||||||||||||||
| 337 | 0 | splice(@{$nhc}, $i, 1); | |||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||
| 339 | } | ||||||||||||||||||||||||||||||||||||||||||
| 340 | } | ||||||||||||||||||||||||||||||||||||||||||
| 341 | 0 | ▶ | if(!$found) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 342 | { | ||||||||||||||||||||||||||||||||||||||||||
| 343 | 0 | log_fatal("Could not find the phrase among my non-core children"); | |||||||||||||||||||||||||||||||||||||||||
| 344 | } | ||||||||||||||||||||||||||||||||||||||||||
| 345 | # Add it to my coordinators. | ||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | my $cnj = $self->_punctuation_ref(); | |||||||||||||||||||||||||||||||||||||||||
| 347 | 0 | push(@{$cnj}, $new_punctuation); | |||||||||||||||||||||||||||||||||||||||||
| 348 | # Make sure that the lists of core children are sorted. | ||||||||||||||||||||||||||||||||||||||||||
| 349 | 0 | my %ord; | |||||||||||||||||||||||||||||||||||||||||
| 350 | 0 | foreach my $p (@{$cnj}) | |||||||||||||||||||||||||||||||||||||||||
| 351 | { | ||||||||||||||||||||||||||||||||||||||||||
| 352 | 0 | $ord{$p} = $p->ord(); | |||||||||||||||||||||||||||||||||||||||||
| 353 | } | ||||||||||||||||||||||||||||||||||||||||||
| 354 | 0 | @{$cnj} = sort {$ord{$a} <=> $ord{$b}} (@{$cnj}); | |||||||||||||||||||||||||||||||||||||||||
| 355 | } | ||||||||||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||||||||||||||
| 359 | #------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||
| 360 | # Returns the head child of the phrase. Depending on the current preference, | ||||||||||||||||||||||||||||||||||||||||||
| 361 | # it is either the preposition or its argument. | ||||||||||||||||||||||||||||||||||||||||||
| 362 | #------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||
| 363 | sub head | ||||||||||||||||||||||||||||||||||||||||||
| 364 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
head: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 365 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 366 | 0 | ▶ | log_fatal('Dead') if($self->dead()); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 367 | 0 | my $rule = $self->head_rule(); | |||||||||||||||||||||||||||||||||||||||||
| 368 | 0 | ▶ | if($rule eq 'first_conjunct') | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 369 | { | ||||||||||||||||||||||||||||||||||||||||||
| 370 | # There is always at least one conjunct. | ||||||||||||||||||||||||||||||||||||||||||
| 371 | # The list of conjuncts is always ordered. | ||||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | return ($self->conjuncts())[0]; | |||||||||||||||||||||||||||||||||||||||||
| 373 | } | ||||||||||||||||||||||||||||||||||||||||||
| 374 | elsif($rule eq 'last_coordinator') | ||||||||||||||||||||||||||||||||||||||||||
| 375 | { | ||||||||||||||||||||||||||||||||||||||||||
| 376 | # It is not guaranteed that there are coordinators or punctuation. | ||||||||||||||||||||||||||||||||||||||||||
| 377 | # But it is guaranteed that the list of coordinators is always ordered, so we do not need to ask for 'ordered'=>1 now. (Same for punctuation.) | ||||||||||||||||||||||||||||||||||||||||||
| 378 | 0 | my @coordinators = $self->coordinators(); | |||||||||||||||||||||||||||||||||||||||||
| 379 | 0 | ▶ | if(scalar(@coordinators) > 0) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 380 | { | ||||||||||||||||||||||||||||||||||||||||||
| 381 | 0 | return $coordinators[-1]; | |||||||||||||||||||||||||||||||||||||||||
| 382 | } | ||||||||||||||||||||||||||||||||||||||||||
| 383 | # No coordinators found. What about punctuation? | ||||||||||||||||||||||||||||||||||||||||||
| 384 | 0 | my @punctuation = $self->punctuation(); | |||||||||||||||||||||||||||||||||||||||||
| 385 | 0 | ▶ | if(scalar(@punctuation) > 0) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 386 | { | ||||||||||||||||||||||||||||||||||||||||||
| 387 | 0 | return $punctuation[-1]; | |||||||||||||||||||||||||||||||||||||||||
| 388 | } | ||||||||||||||||||||||||||||||||||||||||||
| 389 | # No delimiters found. We have to pick a conjunct, whether we like it or not. | ||||||||||||||||||||||||||||||||||||||||||
| 390 | 0 | return ($self->conjuncts())[0]; | |||||||||||||||||||||||||||||||||||||||||
| 391 | } | ||||||||||||||||||||||||||||||||||||||||||
| 392 | else | ||||||||||||||||||||||||||||||||||||||||||
| 393 | { | ||||||||||||||||||||||||||||||||||||||||||
| 394 | 0 | log_fatal("Unknown head rule '$rule'"); | |||||||||||||||||||||||||||||||||||||||||
| 395 | } | ||||||||||||||||||||||||||||||||||||||||||
| 396 | } | ||||||||||||||||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||||||||||||||||
| 400 | #------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||
| 401 | # Returns the list of non-head children of the phrase, i.e. the dependents plus | ||||||||||||||||||||||||||||||||||||||||||
| 402 | # all core children except the one that currently serves as the head. | ||||||||||||||||||||||||||||||||||||||||||
| 403 | #------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||
| 404 | sub nonhead_children | ||||||||||||||||||||||||||||||||||||||||||
| 405 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
nonhead_children: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 406 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 407 | 0 | ▶ | log_fatal('Dead') if($self->dead()); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 408 | 0 | my $head = $self->head(); | |||||||||||||||||||||||||||||||||||||||||
| 409 | 0 | my @children = grep {$_ != $head} ($self->children()); | |||||||||||||||||||||||||||||||||||||||||
| 410 | 0 | ▶ | return $self->_order_required(@_) ? $self->order_phrases(@children) : @children; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 411 | } | ||||||||||||||||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||||||||||||||||
| 414 | |||||||||||||||||||||||||||||||||||||||||||
| 415 | #------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||
| 416 | # Returns the list of the children of the phrase that are not dependents, i.e. | ||||||||||||||||||||||||||||||||||||||||||
| 417 | # all conjuncts, coordinators and punctuation. | ||||||||||||||||||||||||||||||||||||||||||
| 418 | #------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||
| 419 | sub core_children | ||||||||||||||||||||||||||||||||||||||||||
| 420 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
core_children: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 421 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 422 | 0 | ▶ | log_fatal('Dead') if($self->dead()); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 423 | 0 | my @children = ($self->conjuncts(), $self->coordinators(), $self->punctuation()); | |||||||||||||||||||||||||||||||||||||||||
| 424 | 0 | ▶ | return $self->_order_required(@_) ? $self->order_phrases(@children) : @children; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 425 | } | ||||||||||||||||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||||||||||||||||
| 427 | |||||||||||||||||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||||||||||||||||
| 429 | #------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||
| 430 | # Returns the type of the dependency relation of the coordination to its | ||||||||||||||||||||||||||||||||||||||||||
| 431 | # governing phrase. | ||||||||||||||||||||||||||||||||||||||||||
| 432 | #------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||
| 433 | sub deprel | ||||||||||||||||||||||||||||||||||||||||||
| 434 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
deprel: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 435 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 436 | 0 | ▶ | log_fatal('Dead') if($self->dead()); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 437 | 0 | my @conjuncts = $self->conjuncts(); | |||||||||||||||||||||||||||||||||||||||||
| 438 | 0 | return $conjuncts[0]->deprel(); | |||||||||||||||||||||||||||||||||||||||||
| 439 | } | ||||||||||||||||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||||||||||||||||
| 441 | |||||||||||||||||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||||||||||||||||
| 443 | #------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||
| 444 | # Sets a new type of the dependency relation of the coordination to its | ||||||||||||||||||||||||||||||||||||||||||
| 445 | # governing phrase. For nonterminal phrases the label is propagated to one (or | ||||||||||||||||||||||||||||||||||||||||||
| 446 | # several) of their children. It is not propagated to the underlying dependency | ||||||||||||||||||||||||||||||||||||||||||
| 447 | # tree (the project_dependencies() method would have to be called to achieve | ||||||||||||||||||||||||||||||||||||||||||
| 448 | # that). | ||||||||||||||||||||||||||||||||||||||||||
| 449 | #------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||
| 450 | sub set_deprel | ||||||||||||||||||||||||||||||||||||||||||
| 451 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_deprel: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 452 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 453 | 0 | ▶ | log_fatal('Dead') if($self->dead()); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 454 | 0 | my @conjuncts = $self->conjuncts('ordered' => 1); | |||||||||||||||||||||||||||||||||||||||||
| 455 | 0 | ▶ | if($self->head_rule() eq 'last_coordinator') | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 456 | { | ||||||||||||||||||||||||||||||||||||||||||
| 457 | ###!!! Orphans from elided conjuncts are labeled 'ExD' in the Prague | ||||||||||||||||||||||||||||||||||||||||||
| 458 | ###!!! annotation style. This is the only legitimate case where two | ||||||||||||||||||||||||||||||||||||||||||
| 459 | ###!!! "conjuncts" have different deprels. Beware! In some languages | ||||||||||||||||||||||||||||||||||||||||||
| 460 | ###!!! it is possible that the initial "conjuncts" are 'ExD' and the | ||||||||||||||||||||||||||||||||||||||||||
| 461 | ###!!! final conjuncts are real. Therefore it is not enough to look at | ||||||||||||||||||||||||||||||||||||||||||
| 462 | ###!!! the first conjunct. | ||||||||||||||||||||||||||||||||||||||||||
| 463 | 0 | my $exd_means_orphan = scalar(grep {$_->deprel() ne 'ExD'} (@conjuncts)) > 0; | |||||||||||||||||||||||||||||||||||||||||
| 464 | 0 | foreach my $c (@conjuncts) | |||||||||||||||||||||||||||||||||||||||||
| 465 | { | ||||||||||||||||||||||||||||||||||||||||||
| 466 | 0 | ▶ | unless($exd_means_orphan && $c->deprel() eq 'ExD') | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$exd_means_orphan and $c->deprel eq "ExD"
MC/DC0%0/2
$exd_means_orphan and $c->deprel eq "ExD"
$exd_means_orphan
$c->deprel eq "ExD"
Truth table0%0/3
A and B
A= $exd_means_orphanB= $c->deprel eq "ExD"
| |||||||||||||||||||||||||||||||||||||||||||
| 467 | { | ||||||||||||||||||||||||||||||||||||||||||
| 468 | 0 | $c->set_deprel(@_); | |||||||||||||||||||||||||||||||||||||||||
| 469 | } | ||||||||||||||||||||||||||||||||||||||||||
| 470 | } | ||||||||||||||||||||||||||||||||||||||||||
| 471 | 0 | $self->head()->set_deprel('Coord'); | |||||||||||||||||||||||||||||||||||||||||
| 472 | } | ||||||||||||||||||||||||||||||||||||||||||
| 473 | else # head_rule eq 'first_conjunct' | ||||||||||||||||||||||||||||||||||||||||||
| 474 | { | ||||||||||||||||||||||||||||||||||||||||||
| 475 | 0 | $self->head()->set_deprel(@_); | |||||||||||||||||||||||||||||||||||||||||
| 476 | } | ||||||||||||||||||||||||||||||||||||||||||
| 477 | } | ||||||||||||||||||||||||||||||||||||||||||
| 478 | |||||||||||||||||||||||||||||||||||||||||||
| 479 | |||||||||||||||||||||||||||||||||||||||||||
| 480 | |||||||||||||||||||||||||||||||||||||||||||
| 481 | #------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||
| 482 | # Returns the deprel that should be used when the phrase tree is projected back | ||||||||||||||||||||||||||||||||||||||||||
| 483 | # to a dependency tree (see the method project_dependencies()). In most cases | ||||||||||||||||||||||||||||||||||||||||||
| 484 | # this is identical to what deprel() returns. However, for instance | ||||||||||||||||||||||||||||||||||||||||||
| 485 | # coordinations in Prague treebanks are attached using Coord. Their | ||||||||||||||||||||||||||||||||||||||||||
| 486 | # relation to the parent (returned by deprel()) is projected to the conjuncts. | ||||||||||||||||||||||||||||||||||||||||||
| 487 | #------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||
| 488 | sub project_deprel | ||||||||||||||||||||||||||||||||||||||||||
| 489 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
project_deprel: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 490 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 491 | 0 | ▶ | log_fatal('Dead') if($self->dead()); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 492 | 0 | ▶ | if($self->head_rule() eq 'last_coordinator') | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 493 | { | ||||||||||||||||||||||||||||||||||||||||||
| 494 | 0 | return 'Coord'; ###!!! attribute / dialect? | |||||||||||||||||||||||||||||||||||||||||
| 495 | } | ||||||||||||||||||||||||||||||||||||||||||
| 496 | else | ||||||||||||||||||||||||||||||||||||||||||
| 497 | { | ||||||||||||||||||||||||||||||||||||||||||
| 498 | 0 | return $self->head()->project_deprel(); | |||||||||||||||||||||||||||||||||||||||||
| 499 | } | ||||||||||||||||||||||||||||||||||||||||||
| 500 | } | ||||||||||||||||||||||||||||||||||||||||||
| 501 | |||||||||||||||||||||||||||||||||||||||||||
| 502 | |||||||||||||||||||||||||||||||||||||||||||
| 503 | |||||||||||||||||||||||||||||||||||||||||||
| 504 | #------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||
| 505 | # Replaces one of the core children (conjunct, coordinator or punctuation) by | ||||||||||||||||||||||||||||||||||||||||||
| 506 | # another phrase. This is used when we want to transform the child to a | ||||||||||||||||||||||||||||||||||||||||||
| 507 | # different class of phrase. The replacement must not have a parent yet. | ||||||||||||||||||||||||||||||||||||||||||
| 508 | #------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||
| 509 | sub replace_core_child | ||||||||||||||||||||||||||||||||||||||||||
| 510 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
replace_core_child: not called CC=8 SCAR=42.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 511 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 512 | 0 | my $old_child = shift; # Treex::Core::Phrase | |||||||||||||||||||||||||||||||||||||||||
| 513 | 0 | my $new_child = shift; # Treex::Core::Phrase | |||||||||||||||||||||||||||||||||||||||||
| 514 | 0 | ▶ | log_fatal('Dead') if($self->dead()); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 515 | 0 | $self->_check_old_new_child($old_child, $new_child); | |||||||||||||||||||||||||||||||||||||||||
| 516 | 0 | $old_child->_set_parent(undef); | |||||||||||||||||||||||||||||||||||||||||
| 517 | 0 | $new_child->_set_parent($self); | |||||||||||||||||||||||||||||||||||||||||
| 518 | # Find out what type of core child this is (in which array we have it). | ||||||||||||||||||||||||||||||||||||||||||
| 519 | 0 | my $ar = $self->_conjuncts_ref(); | |||||||||||||||||||||||||||||||||||||||||
| 520 | 0 | my $imax = $#{$ar}; | |||||||||||||||||||||||||||||||||||||||||
| 521 | 0 | ▶ | for(my $i = 0; $i <= $imax; $i++) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 522 | { | ||||||||||||||||||||||||||||||||||||||||||
| 523 | 0 | ▶ | if($ar->[$i] == $old_child) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 524 | { | ||||||||||||||||||||||||||||||||||||||||||
| 525 | 0 | splice(@{$ar}, $i, 1, $new_child); | |||||||||||||||||||||||||||||||||||||||||
| 526 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 527 | } | ||||||||||||||||||||||||||||||||||||||||||
| 528 | } | ||||||||||||||||||||||||||||||||||||||||||
| 529 | # Not found among conjuncts. Try coordinators. | ||||||||||||||||||||||||||||||||||||||||||
| 530 | 0 | $ar = $self->_coordinators_ref(); | |||||||||||||||||||||||||||||||||||||||||
| 531 | 0 | $imax = $#{$ar}; | |||||||||||||||||||||||||||||||||||||||||
| 532 | 0 | ▶ | for(my $i = 0; $i <= $imax; $i++) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 533 | { | ||||||||||||||||||||||||||||||||||||||||||
| 534 | 0 | ▶ | if($ar->[$i] == $old_child) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 535 | { | ||||||||||||||||||||||||||||||||||||||||||
| 536 | 0 | splice(@{$ar}, $i, 1, $new_child); | |||||||||||||||||||||||||||||||||||||||||
| 537 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 538 | } | ||||||||||||||||||||||||||||||||||||||||||
| 539 | } | ||||||||||||||||||||||||||||||||||||||||||
| 540 | # Not found among coordinators. Try punctuation. | ||||||||||||||||||||||||||||||||||||||||||
| 541 | 0 | $ar = $self->_punctuation_ref(); | |||||||||||||||||||||||||||||||||||||||||
| 542 | 0 | $imax = $#{$ar}; | |||||||||||||||||||||||||||||||||||||||||
| 543 | 0 | ▶ | for(my $i = 0; $i <= $imax; $i++) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 544 | { | ||||||||||||||||||||||||||||||||||||||||||
| 545 | 0 | ▶ | if($ar->[$i] == $old_child) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 546 | { | ||||||||||||||||||||||||||||||||||||||||||
| 547 | 0 | splice(@{$ar}, $i, 1, $new_child); | |||||||||||||||||||||||||||||||||||||||||
| 548 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 549 | } | ||||||||||||||||||||||||||||||||||||||||||
| 550 | } | ||||||||||||||||||||||||||||||||||||||||||
| 551 | # We should not ever get here. | ||||||||||||||||||||||||||||||||||||||||||
| 552 | 0 | log_fatal("The child to be replaced is not in my core"); | |||||||||||||||||||||||||||||||||||||||||
| 553 | } | ||||||||||||||||||||||||||||||||||||||||||
| 554 | |||||||||||||||||||||||||||||||||||||||||||
| 555 | |||||||||||||||||||||||||||||||||||||||||||
| 556 | |||||||||||||||||||||||||||||||||||||||||||
| 557 | #------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||
| 558 | # Projects dependencies between the head and the dependents back to the | ||||||||||||||||||||||||||||||||||||||||||
| 559 | # underlying dependency structure. | ||||||||||||||||||||||||||||||||||||||||||
| 560 | #------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||
| 561 | sub project_dependencies | ||||||||||||||||||||||||||||||||||||||||||
| 562 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
project_dependencies: not called CC=30 SCAR=68.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 563 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 564 | 0 | ▶ | log_fatal('Dead') if($self->dead()); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 565 | # Recursion first, we work bottom-up. | ||||||||||||||||||||||||||||||||||||||||||
| 566 | # Note that even the order of conjuncts may change if a nested coordination is forced to change the head rule and becomes represented by another node! | ||||||||||||||||||||||||||||||||||||||||||
| 567 | 0 | my @children = $self->children(); | |||||||||||||||||||||||||||||||||||||||||
| 568 | 0 | foreach my $child (@children) | |||||||||||||||||||||||||||||||||||||||||
| 569 | { | ||||||||||||||||||||||||||||||||||||||||||
| 570 | 0 | $child->project_dependencies(); | |||||||||||||||||||||||||||||||||||||||||
| 571 | } | ||||||||||||||||||||||||||||||||||||||||||
| 572 | 0 | my $head_rule = $self->head_rule(); | |||||||||||||||||||||||||||||||||||||||||
| 573 | 0 | my @conjuncts = $self->conjuncts('ordered' => 1); | |||||||||||||||||||||||||||||||||||||||||
| 574 | 0 | my @coordinators = $self->coordinators('ordered' => 1); | |||||||||||||||||||||||||||||||||||||||||
| 575 | 0 | my @punctuation = $self->punctuation('ordered' => 1); | |||||||||||||||||||||||||||||||||||||||||
| 576 | 0 | my @dependents = $self->dependents(); | |||||||||||||||||||||||||||||||||||||||||
| 577 | 0 | ▶ | if($head_rule eq 'last_coordinator' && scalar(@coordinators) == 0 && scalar(@punctuation) == 0) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$head_rule eq "last_coordinator" and scalar @coordinators == 0 and scalar @punctuation == 0
$head_rule eq "last_coordinator" and scalar @coordinators == 0
MC/DC0%0/3
$head_rule eq "last_coordinator" and scalar @coordinators == 0 and scalar @punctuation == 0
$head_rule eq "last_coordinator"
scalar @coordinators == 0
scalar @punctuation == 0
Truth table0%0/4
A and B and C
A= $head_rule eq "last_coordinator"B= scalar @coordinators == 0C= scalar @punctuation == 0
| |||||||||||||||||||||||||||||||||||||||||||
| 578 | { | ||||||||||||||||||||||||||||||||||||||||||
| 579 | 0 | log_warn("Coordination without delimiters cannot use the 'last_coordinator' head rule."); | |||||||||||||||||||||||||||||||||||||||||
| 580 | 0 | $head_rule = 'first_conjunct'; ###!!! But then it should be possible to define deprels for this head rule in the current dialect. | |||||||||||||||||||||||||||||||||||||||||
| 581 | 0 | $self->set_head_rule($head_rule); | |||||||||||||||||||||||||||||||||||||||||
| 582 | } | ||||||||||||||||||||||||||||||||||||||||||
| 583 | 0 | my $head_node = $self->node(); | |||||||||||||||||||||||||||||||||||||||||
| 584 | # We also have to change selected deprels. It depends on the current head rule. | ||||||||||||||||||||||||||||||||||||||||||
| 585 | 0 | ▶ | if($head_rule eq 'first_conjunct') | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 586 | { | ||||||||||||||||||||||||||||||||||||||||||
| 587 | # If the first conjunct has a deprel other than 'dep', and another conjunct has 'dep', | ||||||||||||||||||||||||||||||||||||||||||
| 588 | # then the other conjunct is an orphan caused by ellipsis. This is specific to the | ||||||||||||||||||||||||||||||||||||||||||
| 589 | # conversion from the Prague style to Universal Dependencies. | ||||||||||||||||||||||||||||||||||||||||||
| 590 | ###!!! It should be solved elsewhere because orphans are not the main business of coordination. | ||||||||||||||||||||||||||||||||||||||||||
| 591 | ###!!! A group of sibling orphans could be a phrase type of its own. However, it is difficult | ||||||||||||||||||||||||||||||||||||||||||
| 592 | ###!!! to separate the issue from coordination and at present we just hack it here. | ||||||||||||||||||||||||||||||||||||||||||
| 593 | 0 | my $dep_means_orphan = $self->deprel() ne 'dep'; | |||||||||||||||||||||||||||||||||||||||||
| 594 | 0 | ▶ | if($dep_means_orphan) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 595 | { | ||||||||||||||||||||||||||||||||||||||||||
| 596 | 0 | my $first_orphan_node; | |||||||||||||||||||||||||||||||||||||||||
| 597 | 0 | ▶ | for(my $i = 0; $i <= $#conjuncts; $i++) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 598 | { | ||||||||||||||||||||||||||||||||||||||||||
| 599 | 0 | my $c = $conjuncts[$i]; | |||||||||||||||||||||||||||||||||||||||||
| 600 | 0 | ▶ | if($c->deprel() eq 'dep') | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 601 | { | ||||||||||||||||||||||||||||||||||||||||||
| 602 | 0 | ▶ | if(defined($first_orphan_node)) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 603 | { | ||||||||||||||||||||||||||||||||||||||||||
| 604 | 0 | splice(@conjuncts, $i--, 1); | |||||||||||||||||||||||||||||||||||||||||
| 605 | 0 | my $orphan_node = $c->node(); | |||||||||||||||||||||||||||||||||||||||||
| 606 | ###!!! We group all orphans together although there may be two or more orphan groups | ||||||||||||||||||||||||||||||||||||||||||
| 607 | ###!!! (example: Jane won gold, [Mary silver] and [Cathy bronze].) | ||||||||||||||||||||||||||||||||||||||||||
| 608 | ###!!! We should at least check whether there are any delimiters between the current orphan and the head orphan. | ||||||||||||||||||||||||||||||||||||||||||
| 609 | 0 | $orphan_node->set_parent($first_orphan_node); | |||||||||||||||||||||||||||||||||||||||||
| 610 | 0 | $orphan_node->set_deprel('orphan'); | |||||||||||||||||||||||||||||||||||||||||
| 611 | } | ||||||||||||||||||||||||||||||||||||||||||
| 612 | else | ||||||||||||||||||||||||||||||||||||||||||
| 613 | { | ||||||||||||||||||||||||||||||||||||||||||
| 614 | 0 | $first_orphan_node = $c->node(); | |||||||||||||||||||||||||||||||||||||||||
| 615 | } | ||||||||||||||||||||||||||||||||||||||||||
| 616 | } | ||||||||||||||||||||||||||||||||||||||||||
| 617 | } | ||||||||||||||||||||||||||||||||||||||||||
| 618 | } | ||||||||||||||||||||||||||||||||||||||||||
| 619 | 0 | shift(@conjuncts); | |||||||||||||||||||||||||||||||||||||||||
| 620 | 0 | foreach my $c (@conjuncts) | |||||||||||||||||||||||||||||||||||||||||
| 621 | { | ||||||||||||||||||||||||||||||||||||||||||
| 622 | 0 | my $conj_node = $c->node(); | |||||||||||||||||||||||||||||||||||||||||
| 623 | 0 | $conj_node->set_parent($head_node); | |||||||||||||||||||||||||||||||||||||||||
| 624 | 0 | $conj_node->set_deprel('conj'); | |||||||||||||||||||||||||||||||||||||||||
| 625 | } | ||||||||||||||||||||||||||||||||||||||||||
| 626 | # Since UD v2, delimiters are not attached to the first conjunct. They are attached to the immediately following conjunct. | ||||||||||||||||||||||||||||||||||||||||||
| 627 | 0 | my $fc = $head_node; | |||||||||||||||||||||||||||||||||||||||||
| 628 | 0 | my $ifc = 0; | |||||||||||||||||||||||||||||||||||||||||
| 629 | 0 | foreach my $c (@coordinators) | |||||||||||||||||||||||||||||||||||||||||
| 630 | { | ||||||||||||||||||||||||||||||||||||||||||
| 631 | 0 | my $coor_node = $c->node(); | |||||||||||||||||||||||||||||||||||||||||
| 632 | 0 | ▶ | unless($coor_node->ord() < $head_node->ord()) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 633 | { | ||||||||||||||||||||||||||||||||||||||||||
| 634 | 0 | ▶ | while($ifc < $#conjuncts && $coor_node->ord() > $conjuncts[$ifc]->ord()) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$ifc < $#conjuncts and $coor_node->ord > $conjuncts[$ifc]->ord
MC/DC0%0/2
$ifc < $#conjuncts and $coor_node->ord > $conjuncts[$ifc]->ord
$ifc < $#conjuncts
$coor_node->ord > $conjuncts[$ifc]->ord
Truth table0%0/3
A and B
A= $ifc < $#conjunctsB= $coor_node->ord > $conjuncts[$ifc]->ord
| |||||||||||||||||||||||||||||||||||||||||||
| 635 | { | ||||||||||||||||||||||||||||||||||||||||||
| 636 | 0 | $ifc++; | |||||||||||||||||||||||||||||||||||||||||
| 637 | } | ||||||||||||||||||||||||||||||||||||||||||
| 638 | 0 | ▶ | $fc = $conjuncts[$ifc]->node() if($ifc <= $#conjuncts); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 639 | } | ||||||||||||||||||||||||||||||||||||||||||
| 640 | 0 | $coor_node->set_parent($fc); | |||||||||||||||||||||||||||||||||||||||||
| 641 | 0 | $coor_node->set_deprel('cc'); | |||||||||||||||||||||||||||||||||||||||||
| 642 | } | ||||||||||||||||||||||||||||||||||||||||||
| 643 | 0 | $fc = $head_node; | |||||||||||||||||||||||||||||||||||||||||
| 644 | 0 | $ifc = 0; | |||||||||||||||||||||||||||||||||||||||||
| 645 | 0 | foreach my $p (@punctuation) | |||||||||||||||||||||||||||||||||||||||||
| 646 | { | ||||||||||||||||||||||||||||||||||||||||||
| 647 | 0 | my $punct_node = $p->node(); | |||||||||||||||||||||||||||||||||||||||||
| 648 | 0 | ▶ | unless($punct_node->ord() < $head_node->ord()) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 649 | { | ||||||||||||||||||||||||||||||||||||||||||
| 650 | 0 | ▶ | while($ifc < $#conjuncts && $punct_node->ord() > $conjuncts[$ifc]->ord()) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$ifc < $#conjuncts and $punct_node->ord > $conjuncts[$ifc]->ord
MC/DC0%0/2
$ifc < $#conjuncts and $punct_node->ord > $conjuncts[$ifc]->ord
$ifc < $#conjuncts
$punct_node->ord > $conjuncts[$ifc]->ord
Truth table0%0/3
A and B
A= $ifc < $#conjunctsB= $punct_node->ord > $conjuncts[$ifc]->ord
| |||||||||||||||||||||||||||||||||||||||||||
| 651 | { | ||||||||||||||||||||||||||||||||||||||||||
| 652 | 0 | $ifc++; | |||||||||||||||||||||||||||||||||||||||||
| 653 | } | ||||||||||||||||||||||||||||||||||||||||||
| 654 | 0 | ▶ | $fc = $conjuncts[$ifc]->node() if($ifc <= $#conjuncts); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 655 | } | ||||||||||||||||||||||||||||||||||||||||||
| 656 | 0 | $punct_node->set_parent($fc); | |||||||||||||||||||||||||||||||||||||||||
| 657 | 0 | $punct_node->set_deprel('punct'); | |||||||||||||||||||||||||||||||||||||||||
| 658 | } | ||||||||||||||||||||||||||||||||||||||||||
| 659 | 0 | foreach my $d (@dependents) | |||||||||||||||||||||||||||||||||||||||||
| 660 | { | ||||||||||||||||||||||||||||||||||||||||||
| 661 | 0 | my $dep_node = $d->node(); | |||||||||||||||||||||||||||||||||||||||||
| 662 | 0 | $dep_node->set_parent($head_node); | |||||||||||||||||||||||||||||||||||||||||
| 663 | 0 | $dep_node->set_deprel($d->project_deprel()); | |||||||||||||||||||||||||||||||||||||||||
| 664 | ###!!! Warning: We did not check whether any other nodes had the flag set in the input data! | ||||||||||||||||||||||||||||||||||||||||||
| 665 | 0 | $dep_node->set_is_shared_modifier(1); | |||||||||||||||||||||||||||||||||||||||||
| 666 | } | ||||||||||||||||||||||||||||||||||||||||||
| 667 | } | ||||||||||||||||||||||||||||||||||||||||||
| 668 | elsif($head_rule eq 'last_coordinator') | ||||||||||||||||||||||||||||||||||||||||||
| 669 | { | ||||||||||||||||||||||||||||||||||||||||||
| 670 | 0 | ▶ | my $head = scalar(@coordinators) > 0 ? pop(@coordinators) : pop(@punctuation); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 671 | 0 | $head->set_deprel('Coord'); | |||||||||||||||||||||||||||||||||||||||||
| 672 | 0 | $head_node = $head->node(); | |||||||||||||||||||||||||||||||||||||||||
| 673 | 0 | foreach my $c (@conjuncts) | |||||||||||||||||||||||||||||||||||||||||
| 674 | { | ||||||||||||||||||||||||||||||||||||||||||
| 675 | 0 | my $conj_node = $c->node(); | |||||||||||||||||||||||||||||||||||||||||
| 676 | 0 | $conj_node->set_parent($head_node); | |||||||||||||||||||||||||||||||||||||||||
| 677 | 0 | $conj_node->set_deprel($c->project_deprel()); | |||||||||||||||||||||||||||||||||||||||||
| 678 | 0 | $conj_node->set_is_member(1); | |||||||||||||||||||||||||||||||||||||||||
| 679 | } | ||||||||||||||||||||||||||||||||||||||||||
| 680 | 0 | foreach my $c (@coordinators) | |||||||||||||||||||||||||||||||||||||||||
| 681 | { | ||||||||||||||||||||||||||||||||||||||||||
| 682 | 0 | my $coor_node = $c->node(); | |||||||||||||||||||||||||||||||||||||||||
| 683 | 0 | $coor_node->set_parent($head_node); | |||||||||||||||||||||||||||||||||||||||||
| 684 | 0 | $coor_node->set_deprel('AuxY'); | |||||||||||||||||||||||||||||||||||||||||
| 685 | } | ||||||||||||||||||||||||||||||||||||||||||
| 686 | 0 | foreach my $p (@punctuation) | |||||||||||||||||||||||||||||||||||||||||
| 687 | { | ||||||||||||||||||||||||||||||||||||||||||
| 688 | 0 | my $punct_node = $p->node(); | |||||||||||||||||||||||||||||||||||||||||
| 689 | 0 | $punct_node->set_parent($head_node); | |||||||||||||||||||||||||||||||||||||||||
| 690 | 0 | ▶ | $punct_node->set_deprel($punct_node->form() eq ',' ? 'AuxX' : 'AuxG'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 691 | } | ||||||||||||||||||||||||||||||||||||||||||
| 692 | 0 | foreach my $d (@dependents) | |||||||||||||||||||||||||||||||||||||||||
| 693 | { | ||||||||||||||||||||||||||||||||||||||||||
| 694 | 0 | my $dep_node = $d->node(); | |||||||||||||||||||||||||||||||||||||||||
| 695 | 0 | $dep_node->set_parent($head_node); | |||||||||||||||||||||||||||||||||||||||||
| 696 | 0 | $dep_node->set_deprel($d->project_deprel()); | |||||||||||||||||||||||||||||||||||||||||
| 697 | ###!!! Warning: We did not check whether any other nodes had the flag set in the input data! | ||||||||||||||||||||||||||||||||||||||||||
| 698 | 0 | $dep_node->set_is_shared_modifier(1); | |||||||||||||||||||||||||||||||||||||||||
| 699 | } | ||||||||||||||||||||||||||||||||||||||||||
| 700 | } | ||||||||||||||||||||||||||||||||||||||||||
| 701 | else | ||||||||||||||||||||||||||||||||||||||||||
| 702 | { | ||||||||||||||||||||||||||||||||||||||||||
| 703 | 0 | log_fatal("Unknown coordination head rule '$head_rule'."); | |||||||||||||||||||||||||||||||||||||||||
| 704 | } | ||||||||||||||||||||||||||||||||||||||||||
| 705 | } | ||||||||||||||||||||||||||||||||||||||||||
| 706 | |||||||||||||||||||||||||||||||||||||||||||
| 707 | |||||||||||||||||||||||||||||||||||||||||||
| 708 | |||||||||||||||||||||||||||||||||||||||||||
| 709 | #------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||
| 710 | # Returns a textual representation of the phrase and all subphrases. Useful for | ||||||||||||||||||||||||||||||||||||||||||
| 711 | # debugging. | ||||||||||||||||||||||||||||||||||||||||||
| 712 | #------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||
| 713 | sub as_string | ||||||||||||||||||||||||||||||||||||||||||
| 714 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
as_string: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 715 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 716 | 0 | my @conjuncts = $self->conjuncts('ordered' => 1); | |||||||||||||||||||||||||||||||||||||||||
| 717 | 0 | my $conj = 'CONJ '.join(', ', map {$_->as_string()} (@conjuncts)); | |||||||||||||||||||||||||||||||||||||||||
| 718 | 0 | my @coordinators = $self->coordinators('ordered' => 1); | |||||||||||||||||||||||||||||||||||||||||
| 719 | 0 | my $coor = join(', ', map {$_->as_string()} (@coordinators)); | |||||||||||||||||||||||||||||||||||||||||
| 720 | 0 | ▶ | $coor = 'COOR '.$coor if($coor); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 721 | 0 | my @punctuation = $self->punctuation('ordered' => 1); | |||||||||||||||||||||||||||||||||||||||||
| 722 | 0 | my $punc = join(', ', map {$_->as_string()} (@punctuation)); | |||||||||||||||||||||||||||||||||||||||||
| 723 | 0 | ▶ | $punc = 'PUNC '.$punc if($punc); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 724 | 0 | my @dependents = $self->dependents('ordered' => 1); | |||||||||||||||||||||||||||||||||||||||||
| 725 | 0 | my $deps = join(', ', map {$_->as_string()} (@dependents)); | |||||||||||||||||||||||||||||||||||||||||
| 726 | 0 | ▶ | $deps = 'DEPS '.$deps if($deps); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 727 | 0 | my $subtree = join(' ', ($conj, $coor, $punc, $deps)); | |||||||||||||||||||||||||||||||||||||||||
| 728 | 0 | ▶ | $subtree .= ' _M' if($self->is_member()); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 729 | 0 | return "(CO $subtree)"; | |||||||||||||||||||||||||||||||||||||||||
| 730 | } | ||||||||||||||||||||||||||||||||||||||||||
| 731 | |||||||||||||||||||||||||||||||||||||||||||
| 732 | |||||||||||||||||||||||||||||||||||||||||||
| 733 | |||||||||||||||||||||||||||||||||||||||||||
| 734 | 2 | __PACKAGE__->meta->make_immutable(); | |||||||||||||||||||||||||||||||||||||||||
| 735 | |||||||||||||||||||||||||||||||||||||||||||
| 736 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 737 | |||||||||||||||||||||||||||||||||||||||||||
| 738 | |||||||||||||||||||||||||||||||||||||||||||
| 739 | |||||||||||||||||||||||||||||||||||||||||||
| 740 | =for Pod::Coverage BUILD | ||||||||||||||||||||||||||||||||||||||||||
| 741 | |||||||||||||||||||||||||||||||||||||||||||
| 742 | =encoding utf-8 | ||||||||||||||||||||||||||||||||||||||||||
| 743 | |||||||||||||||||||||||||||||||||||||||||||
| 744 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||
| 745 | |||||||||||||||||||||||||||||||||||||||||||
| 746 | Treex::Core::Phrase::Coordination | ||||||||||||||||||||||||||||||||||||||||||
| 747 | |||||||||||||||||||||||||||||||||||||||||||
| 748 | =head1 VERSION | ||||||||||||||||||||||||||||||||||||||||||
| 749 | |||||||||||||||||||||||||||||||||||||||||||
| 750 | version 2.20210102 | ||||||||||||||||||||||||||||||||||||||||||
| 751 | |||||||||||||||||||||||||||||||||||||||||||
| 752 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||
| 753 | |||||||||||||||||||||||||||||||||||||||||||
| 754 | use Treex::Core::Document; | ||||||||||||||||||||||||||||||||||||||||||
| 755 | use Treex::Core::Phrase::Term; | ||||||||||||||||||||||||||||||||||||||||||
| 756 | use Treex::Core::Phrase::Coordination; | ||||||||||||||||||||||||||||||||||||||||||
| 757 | |||||||||||||||||||||||||||||||||||||||||||
| 758 | my $document = new Treex::Core::Document; | ||||||||||||||||||||||||||||||||||||||||||
| 759 | my $bundle = $document->create_bundle(); | ||||||||||||||||||||||||||||||||||||||||||
| 760 | my $zone = $bundle->create_zone('en'); | ||||||||||||||||||||||||||||||||||||||||||
| 761 | my $root = $zone->create_atree(); | ||||||||||||||||||||||||||||||||||||||||||
| 762 | my $coord = $root->create_child(); | ||||||||||||||||||||||||||||||||||||||||||
| 763 | my $conj1 = $coord->create_child(); | ||||||||||||||||||||||||||||||||||||||||||
| 764 | my $conj2 = $coord->create_child(); | ||||||||||||||||||||||||||||||||||||||||||
| 765 | $coord->set_deprel('Coord'); | ||||||||||||||||||||||||||||||||||||||||||
| 766 | $conj1->set_deprel('Pred_M'); | ||||||||||||||||||||||||||||||||||||||||||
| 767 | $conj2->set_deprel('Pred_M'); | ||||||||||||||||||||||||||||||||||||||||||
| 768 | my $coordphr = new Treex::Core::Phrase::Term ('node' => $coord); | ||||||||||||||||||||||||||||||||||||||||||
| 769 | my $conj1phr = new Treex::Core::Phrase::Term ('node' => $conj1); | ||||||||||||||||||||||||||||||||||||||||||
| 770 | my $conj2phr = new Treex::Core::Phrase::Term ('node' => $conj2); | ||||||||||||||||||||||||||||||||||||||||||
| 771 | my $cphrase = new Treex::Core::Phrase::Coordination ('conjuncts' => [$conj1phr, $conj2phr], 'coordinators' => [$coordphr], 'head_rule' => 'last_coordinator', 'deprel' => 'Pred'); | ||||||||||||||||||||||||||||||||||||||||||
| 772 | |||||||||||||||||||||||||||||||||||||||||||
| 773 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||
| 774 | |||||||||||||||||||||||||||||||||||||||||||
| 775 | C<Treex::Core::Phrase::Coordination> is a special case of | ||||||||||||||||||||||||||||||||||||||||||
| 776 | C<Treex::Core::Phrase::NTerm>. It does not have a fixed head but it has a head | ||||||||||||||||||||||||||||||||||||||||||
| 777 | rule that specifies how the head child should be determined if needed. On the | ||||||||||||||||||||||||||||||||||||||||||
| 778 | other hand, there are several sets of core children that are not ordinary | ||||||||||||||||||||||||||||||||||||||||||
| 779 | dependents. They are conjuncts (i.e. the phrases that are coordinated), | ||||||||||||||||||||||||||||||||||||||||||
| 780 | coordinators (coordinating conjunctions and similar words) and | ||||||||||||||||||||||||||||||||||||||||||
| 781 | conjunct-delimiting punctuation. | ||||||||||||||||||||||||||||||||||||||||||
| 782 | |||||||||||||||||||||||||||||||||||||||||||
| 783 | =head1 ATTRIBUTES | ||||||||||||||||||||||||||||||||||||||||||
| 784 | |||||||||||||||||||||||||||||||||||||||||||
| 785 | =over | ||||||||||||||||||||||||||||||||||||||||||
| 786 | |||||||||||||||||||||||||||||||||||||||||||
| 787 | =item _conjuncts_ref | ||||||||||||||||||||||||||||||||||||||||||
| 788 | |||||||||||||||||||||||||||||||||||||||||||
| 789 | Reference to array of sub-C<Phrase>s (children) that are coordinated in this | ||||||||||||||||||||||||||||||||||||||||||
| 790 | phrase. The conjuncts are counted among the I<core children> of C<Coordination>. | ||||||||||||||||||||||||||||||||||||||||||
| 791 | Every C<Coordination> must always have at least one conjunct. | ||||||||||||||||||||||||||||||||||||||||||
| 792 | |||||||||||||||||||||||||||||||||||||||||||
| 793 | =item _coordinators_ref | ||||||||||||||||||||||||||||||||||||||||||
| 794 | |||||||||||||||||||||||||||||||||||||||||||
| 795 | Reference to array of sub-C<Phrase>s (children) that act as coordinating conjunctions | ||||||||||||||||||||||||||||||||||||||||||
| 796 | and that are words, not punctuation. | ||||||||||||||||||||||||||||||||||||||||||
| 797 | The coordinators are counted among the I<core children> of C<Coordination>. | ||||||||||||||||||||||||||||||||||||||||||
| 798 | However, their presence is not required. | ||||||||||||||||||||||||||||||||||||||||||
| 799 | |||||||||||||||||||||||||||||||||||||||||||
| 800 | =item _punctuation_ref | ||||||||||||||||||||||||||||||||||||||||||
| 801 | |||||||||||||||||||||||||||||||||||||||||||
| 802 | Reference to array of sub-C<Phrase>s (children) that contain punctuation between | ||||||||||||||||||||||||||||||||||||||||||
| 803 | conjuncts. | ||||||||||||||||||||||||||||||||||||||||||
| 804 | The punctuation phrases are counted among the I<core children> of C<Coordination>. | ||||||||||||||||||||||||||||||||||||||||||
| 805 | However, their presence is not required. | ||||||||||||||||||||||||||||||||||||||||||
| 806 | |||||||||||||||||||||||||||||||||||||||||||
| 807 | =item head_rule | ||||||||||||||||||||||||||||||||||||||||||
| 808 | |||||||||||||||||||||||||||||||||||||||||||
| 809 | A string that says how the head of the coordination should be selected. | ||||||||||||||||||||||||||||||||||||||||||
| 810 | C<first_conjunct> means that the first conjunct is the head (there is always at | ||||||||||||||||||||||||||||||||||||||||||
| 811 | least one conjunct). | ||||||||||||||||||||||||||||||||||||||||||
| 812 | C<last_coordinator> means that the last coordinating conjunction, if any, is | ||||||||||||||||||||||||||||||||||||||||||
| 813 | the head; in asyndetic coordination (no conjunctions) the last punctuation | ||||||||||||||||||||||||||||||||||||||||||
| 814 | symbol is the head; if there are neither conjunctions nor punctuation, the | ||||||||||||||||||||||||||||||||||||||||||
| 815 | first conjunct is the head. | ||||||||||||||||||||||||||||||||||||||||||
| 816 | |||||||||||||||||||||||||||||||||||||||||||
| 817 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 818 | |||||||||||||||||||||||||||||||||||||||||||
| 819 | =head1 METHODS | ||||||||||||||||||||||||||||||||||||||||||
| 820 | |||||||||||||||||||||||||||||||||||||||||||
| 821 | =over | ||||||||||||||||||||||||||||||||||||||||||
| 822 | |||||||||||||||||||||||||||||||||||||||||||
| 823 | =item head | ||||||||||||||||||||||||||||||||||||||||||
| 824 | |||||||||||||||||||||||||||||||||||||||||||
| 825 | A sub-C<Phrase> of this phrase that is at the moment considered the head phrase | ||||||||||||||||||||||||||||||||||||||||||
| 826 | (in the sense of dependency syntax). It depends on the current C<head_rule>. | ||||||||||||||||||||||||||||||||||||||||||
| 827 | |||||||||||||||||||||||||||||||||||||||||||
| 828 | =item conjuncts | ||||||||||||||||||||||||||||||||||||||||||
| 829 | |||||||||||||||||||||||||||||||||||||||||||
| 830 | Returns the list of conjuncts. The only difference from the | ||||||||||||||||||||||||||||||||||||||||||
| 831 | getter C<_conjuncts_ref()> is that the getter returns a reference to the array | ||||||||||||||||||||||||||||||||||||||||||
| 832 | of conjuncts, while this method returns a list of conjuncts. Hence this method is | ||||||||||||||||||||||||||||||||||||||||||
| 833 | more similar to the other methods that return lists of children. | ||||||||||||||||||||||||||||||||||||||||||
| 834 | |||||||||||||||||||||||||||||||||||||||||||
| 835 | =item add_conjunct | ||||||||||||||||||||||||||||||||||||||||||
| 836 | |||||||||||||||||||||||||||||||||||||||||||
| 837 | Adds a phrase as a new conjunct to this coordination. The phrase may be | ||||||||||||||||||||||||||||||||||||||||||
| 838 | currently a dependent of another phrase and will be correctly re-linked. | ||||||||||||||||||||||||||||||||||||||||||
| 839 | However, it must not be a core child of any phrase. | ||||||||||||||||||||||||||||||||||||||||||
| 840 | |||||||||||||||||||||||||||||||||||||||||||
| 841 | =item coordinators | ||||||||||||||||||||||||||||||||||||||||||
| 842 | |||||||||||||||||||||||||||||||||||||||||||
| 843 | Returns the list of coordinating conjunctions (but not punctuation). | ||||||||||||||||||||||||||||||||||||||||||
| 844 | The only difference from the | ||||||||||||||||||||||||||||||||||||||||||
| 845 | getter C<_coordinators_ref()> is that the getter returns a reference to array, | ||||||||||||||||||||||||||||||||||||||||||
| 846 | while this method returns a list. Hence this method is | ||||||||||||||||||||||||||||||||||||||||||
| 847 | more similar to the other methods that return lists of children. | ||||||||||||||||||||||||||||||||||||||||||
| 848 | |||||||||||||||||||||||||||||||||||||||||||
| 849 | =item add_coordinator | ||||||||||||||||||||||||||||||||||||||||||
| 850 | |||||||||||||||||||||||||||||||||||||||||||
| 851 | Adds a phrase as a new coordinator to this coordination. The phrase may be | ||||||||||||||||||||||||||||||||||||||||||
| 852 | currently a dependent of another phrase and will be correctly re-linked. | ||||||||||||||||||||||||||||||||||||||||||
| 853 | However, it must not be a core child of any phrase. | ||||||||||||||||||||||||||||||||||||||||||
| 854 | |||||||||||||||||||||||||||||||||||||||||||
| 855 | =item punctuation | ||||||||||||||||||||||||||||||||||||||||||
| 856 | |||||||||||||||||||||||||||||||||||||||||||
| 857 | Returns the list of punctuation symbols between conjuncts. | ||||||||||||||||||||||||||||||||||||||||||
| 858 | The only difference from the | ||||||||||||||||||||||||||||||||||||||||||
| 859 | getter C<_punctuation_ref()> is that the getter returns a reference to array, | ||||||||||||||||||||||||||||||||||||||||||
| 860 | while this method returns a list. Hence this method is | ||||||||||||||||||||||||||||||||||||||||||
| 861 | more similar to the other methods that return lists of children. | ||||||||||||||||||||||||||||||||||||||||||
| 862 | |||||||||||||||||||||||||||||||||||||||||||
| 863 | =item add_punctuation | ||||||||||||||||||||||||||||||||||||||||||
| 864 | |||||||||||||||||||||||||||||||||||||||||||
| 865 | Adds a phrase as a new punctuation delimiter to this coordination. The phrase | ||||||||||||||||||||||||||||||||||||||||||
| 866 | may be currently a dependent of another phrase and will be correctly | ||||||||||||||||||||||||||||||||||||||||||
| 867 | re-linked. However, it must not be a core child of any phrase. | ||||||||||||||||||||||||||||||||||||||||||
| 868 | |||||||||||||||||||||||||||||||||||||||||||
| 869 | =item nonhead_children | ||||||||||||||||||||||||||||||||||||||||||
| 870 | |||||||||||||||||||||||||||||||||||||||||||
| 871 | Returns the list of non-head children of the phrase, i.e. the dependents plus | ||||||||||||||||||||||||||||||||||||||||||
| 872 | all core children except the one that currently serves as the head. | ||||||||||||||||||||||||||||||||||||||||||
| 873 | |||||||||||||||||||||||||||||||||||||||||||
| 874 | =item core_children | ||||||||||||||||||||||||||||||||||||||||||
| 875 | |||||||||||||||||||||||||||||||||||||||||||
| 876 | Returns the list of the children of the phrase that are not dependents, i.e. | ||||||||||||||||||||||||||||||||||||||||||
| 877 | all conjuncts, coordinators and punctuation. | ||||||||||||||||||||||||||||||||||||||||||
| 878 | |||||||||||||||||||||||||||||||||||||||||||
| 879 | =item deprel | ||||||||||||||||||||||||||||||||||||||||||
| 880 | |||||||||||||||||||||||||||||||||||||||||||
| 881 | Returns the type of the dependency relation of the coordination to the governing | ||||||||||||||||||||||||||||||||||||||||||
| 882 | phrase. | ||||||||||||||||||||||||||||||||||||||||||
| 883 | |||||||||||||||||||||||||||||||||||||||||||
| 884 | =item set_deprel | ||||||||||||||||||||||||||||||||||||||||||
| 885 | |||||||||||||||||||||||||||||||||||||||||||
| 886 | Sets a new type of the dependency relation of the phrase to the governing | ||||||||||||||||||||||||||||||||||||||||||
| 887 | phrase. For nonterminal phrases the label is propagated to one (or several) | ||||||||||||||||||||||||||||||||||||||||||
| 888 | of their children. It is not propagated to the underlying dependency tree | ||||||||||||||||||||||||||||||||||||||||||
| 889 | (the C<project_dependencies()> method would have to be called to achieve that). | ||||||||||||||||||||||||||||||||||||||||||
| 890 | |||||||||||||||||||||||||||||||||||||||||||
| 891 | Depending on the current annotation style, deprel of coordination is propagated | ||||||||||||||||||||||||||||||||||||||||||
| 892 | either to just the first conjunct, or to all conjuncts (except for orphans from | ||||||||||||||||||||||||||||||||||||||||||
| 893 | elided conjuncts). | ||||||||||||||||||||||||||||||||||||||||||
| 894 | |||||||||||||||||||||||||||||||||||||||||||
| 895 | =item project_deprel | ||||||||||||||||||||||||||||||||||||||||||
| 896 | |||||||||||||||||||||||||||||||||||||||||||
| 897 | Returns the deprel that should be used when the phrase tree is projected back | ||||||||||||||||||||||||||||||||||||||||||
| 898 | to a dependency tree (see the method project_dependencies()). In most cases | ||||||||||||||||||||||||||||||||||||||||||
| 899 | this is identical to what deprel() returns. However, for instance | ||||||||||||||||||||||||||||||||||||||||||
| 900 | coordinations in Prague treebanks are attached using C<Coord>. Their | ||||||||||||||||||||||||||||||||||||||||||
| 901 | relation to the parent (returned by deprel()) is projected to the conjuncts. | ||||||||||||||||||||||||||||||||||||||||||
| 902 | |||||||||||||||||||||||||||||||||||||||||||
| 903 | =item project_dependencies | ||||||||||||||||||||||||||||||||||||||||||
| 904 | |||||||||||||||||||||||||||||||||||||||||||
| 905 | Projects dependencies between the head and the dependents back to the | ||||||||||||||||||||||||||||||||||||||||||
| 906 | underlying dependency structure. | ||||||||||||||||||||||||||||||||||||||||||
| 907 | For coordinations the behavior depends on the currently selected head rule: | ||||||||||||||||||||||||||||||||||||||||||
| 908 | certain deprels may have to be adjusted. | ||||||||||||||||||||||||||||||||||||||||||
| 909 | |||||||||||||||||||||||||||||||||||||||||||
| 910 | =item as_string | ||||||||||||||||||||||||||||||||||||||||||
| 911 | |||||||||||||||||||||||||||||||||||||||||||
| 912 | Returns a textual representation of the phrase and all subphrases. Useful for | ||||||||||||||||||||||||||||||||||||||||||
| 913 | debugging. | ||||||||||||||||||||||||||||||||||||||||||
| 914 | |||||||||||||||||||||||||||||||||||||||||||
| 915 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 916 | |||||||||||||||||||||||||||||||||||||||||||
| 917 | =head1 AUTHORS | ||||||||||||||||||||||||||||||||||||||||||
| 918 | |||||||||||||||||||||||||||||||||||||||||||
| 919 | Daniel Zeman <zeman@ufal.mff.cuni.cz> | ||||||||||||||||||||||||||||||||||||||||||
| 920 | |||||||||||||||||||||||||||||||||||||||||||
| 921 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||||||||||||||||
| 922 | |||||||||||||||||||||||||||||||||||||||||||
| 923 | Copyright © 2013, 2015 by Institute of Formal and Applied Linguistics, Charles University in Prague | ||||||||||||||||||||||||||||||||||||||||||
| 924 | |||||||||||||||||||||||||||||||||||||||||||
| 925 | This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. | ||||||||||||||||||||||||||||||||||||||||||