Treex/Core/Node/A.pm

filter: Statementstmt 13.5% 33 / 243 Branchbran 3.4% 3 / 88 Conditioncond 9.5% 2 / 21 MC/DCmcdc 7.1% 1 / 14 Subroutinesub 15.0% 9 / 60 Podpod 21.8% 12 / 55 totaltotal 12.4% 60 / 481 CC 57 SCAR 36.7
CC
57
Cov
11%
set_real_afun
156.0
get_real_afun
110.0
get_subtree_dependency_string
90.0
CRAP 39.1
« Treex/Core/RememberArgs.pm ↑ Summary Treex/Core/TredView/Vallex.pm »
1 package Treex::Core::Node::A;
2 36 $Treex::Core::Node::A::VERSION = '2.20210102';
3 36 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 36 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 36 ▶use Treex::Core::Common;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 36 ▶use Storable;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 36 extends 'Treex::Core::Node';
8 36 with 'Treex::Core::Node::Ordered';
9 36 with 'Treex::Core::Node::InClause';
10 36 with 'Treex::Core::Node::EffectiveRelations';
11 36 with 'Treex::Core::Node::Interset' => { interset_attribute => 'iset' };
12  
13 36 has [qw(form lemma tag no_space_after fused_with_next fused_form fused_misc)] => ( is => 'rw' );
14  
15 36 has [
16 qw(deprel afun is_parenthesis_root edge_to_collapse is_auxiliary translit ltranslit gloss)
17 ] => ( is => 'rw' );
18  
19 79 ▶sub get_pml_type_name {
Subroutine get_pml_type_name: called CC=2 SCAR=6.9
Pod documented
20 79 my ($self) = @_;
21 79 ▶ return $self->is_root() ? 'a-root.type' : 'a-node.type';
Branch: 1 branch
BranchTrueFalseTotal
$self->is_root ? : 25 54 79
22 }
23  
24 # the node is a root of a coordination/apposition construction
25 51 ▶sub is_coap_root {
Subroutine is_coap_root: called CC=3 SCAR=11.4
Pod documented
26 51 my ($self) = @_;
27 51 ▶ log_fatal('Incorrect number of arguments') if @_ != 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ != 1 0 51 51
28 51 ▶ return defined $self->afun && $self->afun =~ /^(Coord|Apos)$/;
Condition66%2/3
defined $self->afun && $self->afun =~ /^(Coord|Apos)$/
!ll&&!rl&&r
03714
MC/DC50%1/2
defined $self->afun && $self->afun =~ /^(Coord|Apos)$/
defined $self->afun $self->afun =~ /^(Coord|Apos)$/
Truth table66%2/3
A && B
A= defined $self->afunB= $self->afun =~ /^(Coord|Apos)$/
ABresult
0X0
100
111
29 }
30  
31 7 ▶sub n_node {
Subroutine n_node: called CC=1 SCAR=0.0
Pod documented
32 7 my ($self) = @_;
33 7 my ($first_n_node) = $self->get_referencing_nodes('a.rf');
34 7 return $first_n_node;
35 }
36  
37 #------------------------------------------------------------------------------
38 # Figures out the real function of the subtree. If its own afun is AuxP or
39 # AuxC, finds the first descendant with a real afun and returns it. If this is
40 # a coordination or apposition root, finds the first member and returns its
41 # afun (but note that members of the same coordination can differ in afuns if
42 # some of them have 'ExD').
43 #------------------------------------------------------------------------------
44 sub get_real_afun
45 0 ▶{
Subroutine get_real_afun: not called CC=10 SCAR=47.0
Pod documented
46 0 my $self = shift;
47 0 my $warnings = shift;
48 0 my $afun = $self->afun();
49 0 ▶ if ( not defined($afun) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $afun) 0 0 0
50 0 $afun = '';
51 }
52 0 ▶ if ( $afun =~ m/^Aux[PC]$/ )
Branch: 2 branches
BranchTrueFalseTotal
if ($afun =~ /^Aux[PC]$/) { } 0 0 0
elsif ($self->is_coap_root) { } 0 0 0
53 {
54 0 my @children = $self->children();
55 # Exclude punctuation children (afun-wise, not POS-tag-wise: we do not want to exclude coordination heads).
56 0 @children = grep {$_->afun() !~ m/^Aux[XGK]$/} (@children);
57 0 my $n = scalar(@children);
58 0 ▶ if ( $n < 1 )
Branch: 1 branch
BranchTrueFalseTotal
if ($n < 1) { } 0 0 0
59 {
60 0 ▶ if ($warnings)
Branch: 1 branch
BranchTrueFalseTotal
if ($warnings) 0 0 0
61 {
62 0 my $i_sentence = $self->get_bundle()->get_position() + 1; # tred numbers from 1
63 0 my $form = $self->form();
64 0 log_warn("$afun node does not have children (sentence $i_sentence, '$form')");
65 }
66 }
67 else
68 {
69 0 ▶ if ( $n > 1 && $warnings )
Branch: 1 branch
BranchTrueFalseTotal
if ($n > 1 and $warnings) 0 0 0
Condition0%0/3
$n > 1 and $warnings
!ll&&!rl&&r
000
MC/DC0%0/2
$n > 1 and $warnings
$n > 1 $warnings
Truth table0%0/3
A and B
A= $n > 1B= $warnings
ABresult
0X0
100
111
70 {
71 0 my $i_sentence = $self->get_bundle()->get_position() + 1; # tred numbers from 1
72 0 my $form = $self->form();
73 0 log_warn("$afun node has $n children so it is not clear which one bears the real afun (sentence $i_sentence, '$form')");
74 }
75 0 return $children[0]->get_real_afun();
76 }
77 }
78 elsif ( $self->is_coap_root() )
79 {
80 0 my @members = $self->get_coap_members();
81 0 my $n = scalar(@members);
82 0 ▶ if ( $n < 1 )
Branch: 1 branch
BranchTrueFalseTotal
if ($n < 1) { } 0 0 0
83 {
84 0 ▶ if ($warnings)
Branch: 1 branch
BranchTrueFalseTotal
if ($warnings) 0 0 0
85 {
86 0 my $i_sentence = $self->get_bundle()->get_position() + 1; # tred numbers from 1
87 0 my $form = $self->form();
88 0 log_warn("$afun does not have members (sentence $i_sentence, '$form')");
89 }
90 }
91 else
92 {
93 0 return $members[0]->get_real_afun();
94 }
95 }
96 0 return $afun;
97 }
98  
99 #------------------------------------------------------------------------------
100 # Sets the real function of the subtree. If its current afun is AuxP or AuxC,
101 # finds the first descendant with a real afun replaces it. If this is
102 # a coordination or apposition root, finds all the members and replaces their
103 # afuns (but note that members of the same coordination can differ in afuns if
104 # some of them have 'ExD'; this method can only set the same afun for all).
105 #------------------------------------------------------------------------------
106 sub set_real_afun
107 0 ▶{
Subroutine set_real_afun: not called CC=12 SCAR=50.5
Pod documented
108 0 my $self = shift;
109 0 my $new_afun = shift;
110 0 my $warnings = shift;
111 0 my $afun = $self->afun();
112 0 ▶ if ( not defined($afun) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $afun) 0 0 0
113 0 $afun = '';
114 }
115 0 ▶ if ( $afun =~ m/^Aux[PC]$/ )
Branch: 2 branches
BranchTrueFalseTotal
if ($afun =~ /^Aux[PC]$/) { } 0 0 0
elsif ($self->is_coap_root) { } 0 0 0
116 {
117 0 my @children = $self->children();
118 # Exclude punctuation children (afun-wise, not POS-tag-wise: we do not want to exclude coordination heads).
119 0 @children = grep {$_->afun() !~ m/^Aux[XGK]$/} (@children);
120 0 my $n = scalar(@children);
121 0 ▶ if ( $n < 1 )
Branch: 1 branch
BranchTrueFalseTotal
if ($n < 1) { } 0 0 0
122 {
123 0 ▶ if ($warnings)
Branch: 1 branch
BranchTrueFalseTotal
if ($warnings) 0 0 0
124 {
125 0 my $i_sentence = $self->get_bundle()->get_position() + 1; # tred numbers from 1
126 0 my $form = $self->form();
127 0 log_warn("$afun node does not have children (sentence $i_sentence, '$form')");
128 }
129 }
130 else
131 {
132 0 ▶ if ( $warnings && $n > 1 )
Branch: 1 branch
BranchTrueFalseTotal
if ($warnings and $n > 1) 0 0 0
Condition0%0/3
$warnings and $n > 1
!ll&&!rl&&r
000
MC/DC0%0/2
$warnings and $n > 1
$warnings $n > 1
Truth table0%0/3
A and B
A= $warningsB= $n > 1
ABresult
0X0
100
111
133 {
134 0 my $i_sentence = $self->get_bundle()->get_position() + 1; # tred numbers from 1
135 0 my $form = $self->form();
136 0 log_warn("$afun node has $n children so it is not clear which one bears the real afun (sentence $i_sentence, '$form')");
137 }
138 0 foreach my $child (@children)
139 {
140 0 $child->set_real_afun($new_afun);
141 }
142 0 return;
143 }
144 }
145 elsif ( $self->is_coap_root() )
146 {
147 0 my @members = $self->get_coap_members();
148 0 my $n = scalar(@members);
149 0 ▶ if ( $n < 1 )
Branch: 1 branch
BranchTrueFalseTotal
if ($n < 1) { } 0 0 0
150 {
151 0 ▶ if ($warnings)
Branch: 1 branch
BranchTrueFalseTotal
if ($warnings) 0 0 0
152 {
153 0 my $i_sentence = $self->get_bundle()->get_position() + 1; # tred numbers from 1
154 0 my $form = $self->form();
155 0 log_warn("$afun does not have members (sentence $i_sentence, '$form')");
156 }
157 }
158 else
159 {
160 0 foreach my $member (@members)
161 {
162 0 $member->set_real_afun($new_afun);
163 }
164 0 return;
165 }
166 }
167 0 $self->set_afun($new_afun);
168 0 return $afun;
169 }
170  
171 #------------------------------------------------------------------------------
172 # Recursively copy attributes and children from myself to another node.
173 # This function is specific to the A layer because it contains the list of
174 # attributes. If we could figure out the list automatically, the function would
175 # become general enough to reside directly in Node.pm.
176 #
177 # NOTE: We could possibly make just copy_attributes() layer-dependent and unify
178 # the main copy_atree code.
179 #------------------------------------------------------------------------------
180 sub copy_atree
181 0 ▶{
Subroutine copy_atree: not called CC=2 SCAR=17.9
Pod documented
182 0 my $self = shift;
183 0 my $target = shift;
184  
185 # Copy all attributes of the original node to the new one.
186 # We do this for all the nodes including the ‘root’ (which may actually be
187 # an ordinary node if we are copying a subtree).
188 0 $self->copy_attributes($target);
189  
190 0 my @children0 = $self->get_children( { ordered => 1 } );
191 0 foreach my $child0 (@children0)
192 {
193 # Create a copy of the child node.
194 0 my $child1 = $target->create_child();
195 # Call recursively on the subtrees of the children.
196 0 $child0->copy_atree($child1);
197 }
198  
199 0 return;
200 }
201  
202 #------------------------------------------------------------------------------
203 # Copies values of all attributes from one node to another. The only difference
204 # between the two nodes afterwards should be their ids.
205 #------------------------------------------------------------------------------
206 sub copy_attributes
207 0 ▶{
Subroutine copy_attributes: not called CC=2 SCAR=17.9
Pod undocumented
208 0 my ( $self, $other ) = @_;
209 # We should copy all attributes that the node has but it is not easy to figure out which these are.
210 # TODO: As a workaround, we list the attributes here directly.
211 0 foreach my $attribute (
212 'form', 'lemma', 'tag', 'no_space_after', 'translit', 'ltranslit', 'gloss',
213 'fused_with_next', 'fused_form', 'fused_misc',
214 'ord', 'deprel', 'afun', 'is_member', 'is_parenthesis_root',
215 'conll/deprel', 'conll/cpos', 'conll/pos', 'conll/feat', 'is_shared_modifier', 'morphcat',
216 'clause_number', 'is_clause_head',
217 )
218 {
219 0 my $value = $self->get_attr($attribute);
220 0 $other->set_attr( $attribute, $value );
221 }
222 # copy values of interset features
223 0 my $f = $self->get_iset_structure();
224 0 $other->set_iset($f);
225 # deep copy of wild attributes
226 0 $other->set_wild( Storable::dclone( $self->wild ) );
227 0 return;
228 }
229  
230 # -- linking to p-layer --
231  
232 0 ▶sub get_terminal_pnode {
Subroutine get_terminal_pnode: not called CC=2 SCAR=17.9
Pod documented
233 0 my ($self) = @_;
234 0 ▶ my $p_rf = $self->get_attr('p_terminal.rf') or return;
Branch: 1 branch
BranchTrueFalseTotal
my $p_rf = $self->get_attr("p_terminal.rf") or return 0 0 0
235 0 my $doc = $self->get_document();
236 0 return $doc->get_node_by_id($p_rf);
237 }
238  
239 0 ▶sub set_terminal_pnode {
Subroutine set_terminal_pnode: not called CC=2 SCAR=17.9
Pod documented
240 0 my ( $self, $pnode ) = @_;
241 0 ▶ my $new_id = defined $pnode ? $pnode->id : undef;
Branch: 1 branch
BranchTrueFalseTotal
defined $pnode ? : 0 0 0
242 0 $self->set_attr( 'p_terminal.rf', $new_id );
243 0 return;
244 }
245  
246 0 ▶sub get_nonterminal_pnodes {
Subroutine get_nonterminal_pnodes: not called CC=3 SCAR=24.8
Pod documented
247 0 my ($self) = @_;
248 0 ▶ my $pnode = $self->get_terminal_pnode() or return;
Branch: 1 branch
BranchTrueFalseTotal
my $pnode = $self->get_terminal_pnode or return 0 0 0
249 0 my @nonterminals = ();
250 0 ▶ while ( $pnode->is_head ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pnode->is_head) 0 0 0
251 0 $pnode = $pnode->get_parent();
252 0 push @nonterminals, $pnode;
253 }
254 0 return @nonterminals;
255 }
256  
257 0 ▶sub get_pnodes {
Subroutine get_pnodes: not called CC=1 SCAR=6.9
Pod documented
258 0 my ($self) = @_;
259 0 return ( $self->get_terminal_pnode, $self->get_nonterminal_pnodes );
260 }
261  
262 # -- referenced node ids --
263  
264 97 ▶override '_get_reference_attrs' => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
265 97 my ($self) = @_;
266 97 return ('p_terminal.rf');
267 36 };
268  
269 # -- other --
270  
271 # Used only for Czech, so far.
272 0 ▶sub reset_morphcat {
Subroutine reset_morphcat: not called CC=3 SCAR=24.8
Pod documented
273 0 my ($self) = @_;
274 0 foreach my $category (
275 qw(pos subpos gender number case possgender possnumber
276 person tense grade negation voice reserve1 reserve2)
277 )
278 {
279 0 my $old_value = $self->get_attr("morphcat/$category");
280 0 ▶ if ( !defined $old_value ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $old_value) 0 0 0
281 0 $self->set_attr( "morphcat/$category", '.' );
282 }
283 }
284 0 return;
285 }
286  
287 # Used only for reading from PCEDT/PDT trees, so far.
288 0 ▶sub get_subtree_string {
Subroutine get_subtree_string: not called CC=3 SCAR=24.8
Pod documented
289 0 my ($self) = @_;
290 0 ▶ return join '', map { defined( $_->form ) ? ( $_->form . ( $_->no_space_after ? '' : ' ' ) ) : '' } $self->get_descendants( { ordered => 1 } );
Branch: 2 branches
BranchTrueFalseTotal
defined $_->form ? : 0 0 0
$_->no_space_after ? : 0 0 0
291 }
292  
293 #------------------------------------------------------------------------------
294 # Serializes a tree to a string of dependencies (similar to the Stanford
295 # dependency format). Useful for debugging (quick comparison of two tree
296 # structures and an info string for the error message at the same time).
297 #------------------------------------------------------------------------------
298 sub get_subtree_dependency_string
299 0 ▶{
Subroutine get_subtree_dependency_string: not called CC=9 SCAR=45.0
Pod undocumented
300 0 my $self = shift;
301 0 my $for_brat = shift; # Do we want a format that spans multiple lines but can be easily visualized in Brat?
302 0 my @nodes = $self->get_descendants({'ordered' => 1});
303 0 ▶ my $offset = $for_brat ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$for_brat ? : 0 0 0
304 my @dependencies = map
305 {
306 0 my $n = $_;
307 0 my $no = $n->ord()+$offset;
308 0 my $nf = $n->form();
309 0 my $p = $n->parent();
310 0 my $po = $p->ord()+$offset;
311 0 ▶ my $pf = $p->is_root() ? 'ROOT' : $p->form();
Branch: 1 branch
BranchTrueFalseTotal
$p->is_root ? : 0 0 0
312 0 ▶ my $d = defined($n->deprel()) ? $n->deprel() : defined($n->afun()) ? $n->afun() : defined($n->conll_deprel()) ? $n->conll_deprel() : 'NR';
Branch: 3 branches
BranchTrueFalseTotal
defined $n->deprel ? : 0 0 0
defined $n->afun ? : 0 0 0
defined $n->conll_deprel ? : 0 0 0
313 0 ▶ if($n->is_member())
Branch: 1 branch
BranchTrueFalseTotal
if ($n->is_member) 0 0 0
314 {
315 0 ▶ if(defined($n->deprel()))
Branch: 1 branch
BranchTrueFalseTotal
if (defined $n->deprel) { } 0 0 0
316 {
317 0 $d .= ':member';
318 }
319 else
320 {
321 0 $d .= '_M';
322 }
323 }
324 "$d($pf-$po, $nf-$no)"
325 0 }
326 (@nodes);
327 0 my $sentence = join(' ', map {$_->form()} (@nodes));
328 0 ▶ if($for_brat)
Branch: 1 branch
BranchTrueFalseTotal
if ($for_brat) { } 0 0 0
329 {
330 0 $sentence = "ROOT $sentence";
331 0 my $tree = join("\n", @dependencies);
332 0 return "~~~ sdparse\n$sentence\n$tree\n~~~\n";
333 }
334 else
335 {
336 0 my $tree = join('; ', @dependencies);
337 0 return "$sentence\t$tree";
338 }
339 }
340  
341  
342  
343 #------------------------------------------------------------------------------
344 # Says whether this node is member of a fused ("multiword") token.
345 #------------------------------------------------------------------------------
346 sub is_fused
347 0 ▶{
Subroutine is_fused: not called CC=3 SCAR=24.8
Pod undocumented
348 0 my $self = shift;
349 0 ▶ return 1 if($self->fused_with_next());
Branch: 1 branch
BranchTrueFalseTotal
if $self->fused_with_next 0 0 0
350 0 my $prev = $self->get_prev_node();
351 0 ▶ return defined($prev) && $prev->fused_with_next();
Condition0%0/3
defined $prev && $prev->fused_with_next
!ll&&!rl&&r
000
MC/DC0%0/2
defined $prev && $prev->fused_with_next
defined $prev $prev->fused_with_next
Truth table0%0/3
A && B
A= defined $prevB= $prev->fused_with_next
ABresult
0X0
100
111
352 }
353  
354  
355  
356 #------------------------------------------------------------------------------
357 # If this node is fused with one or more preceding nodes, returns the first
358 # node of the fusion. Otherwise returns this node.
359 #------------------------------------------------------------------------------
360 sub get_fusion_start
361 0 ▶{
Subroutine get_fusion_start: not called CC=3 SCAR=24.8
Pod undocumented
362 0 my $self = shift;
363 0 my $prev = $self->get_prev_node();
364 0 ▶ if(defined($prev) && $prev->fused_with_next())
Branch: 1 branch
BranchTrueFalseTotal
if (defined $prev and $prev->fused_with_next) 0 0 0
Condition0%0/3
defined $prev and $prev->fused_with_next
!ll&&!rl&&r
000
MC/DC0%0/2
defined $prev and $prev->fused_with_next
defined $prev $prev->fused_with_next
Truth table0%0/3
A and B
A= defined $prevB= $prev->fused_with_next
ABresult
0X0
100
111
365 {
366 0 return $prev->get_fusion_start();
367 }
368 0 return $self;
369 }
370  
371  
372  
373 #------------------------------------------------------------------------------
374 # If this node is fused with one or more following nodes, returns the last
375 # node of the fusion. Otherwise returns this node.
376 #------------------------------------------------------------------------------
377 sub get_fusion_end
378 0 ▶{
Subroutine get_fusion_end: not called CC=3 SCAR=24.8
Pod undocumented
379 0 my $self = shift;
380 0 ▶ if($self->fused_with_next())
Branch: 1 branch
BranchTrueFalseTotal
if ($self->fused_with_next) 0 0 0
381 {
382 0 my $next = $self->get_next_node();
383 0 ▶ if(defined($next))
Branch: 1 branch
BranchTrueFalseTotal
if (defined $next) 0 0 0
384 {
385 0 return $next->get_fusion_end();
386 }
387 }
388 0 return $self;
389 }
390  
391  
392  
393 #------------------------------------------------------------------------------
394 # Returns list of fused nodes including this node. If the node is not fused
395 # with its neighbors, the list contains only this node.
396 #------------------------------------------------------------------------------
397 sub get_fused_nodes
398 0 ▶{
Subroutine get_fused_nodes: not called CC=5 SCAR=34.0
Pod undocumented
399 0 my $self = shift;
400 0 my @nodes = ($self);
401 0 my $x = $self->get_prev_node();
402 0 ▶ while(defined($x) && $x->fused_with_next())
Branch: 1 branch
BranchTrueFalseTotal
if (defined $x and $x->fused_with_next) 0 0 0
Condition0%0/3
defined $x and $x->fused_with_next
!ll&&!rl&&r
000
MC/DC0%0/2
defined $x and $x->fused_with_next
defined $x $x->fused_with_next
Truth table0%0/3
A and B
A= defined $xB= $x->fused_with_next
ABresult
0X0
100
111
403 {
404 0 unshift(@nodes, $x);
405 0 $x = $x->get_prev_node();
406 }
407 0 $x = $self;
408 0 ▶ while($x->fused_with_next())
Branch: 1 branch
BranchTrueFalseTotal
if ($x->fused_with_next) 0 0 0
409 {
410 0 $x = $x->get_next_node();
411 0 ▶ last if(!defined($x));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $x 0 0 0
412 0 push(@nodes, $x);
413 }
414 0 return @nodes;
415 }
416  
417  
418  
419 #------------------------------------------------------------------------------
420 # Returns the fused form stored in the first node of the fusion (multiword
421 # token). If this node is not part of any fusion, returns the fused_form of
422 # this node, which should be undefined.
423 #------------------------------------------------------------------------------
424 sub get_fusion
425 0 ▶{
Subroutine get_fusion: not called CC=1 SCAR=6.9
Pod undocumented
426 0 my $self = shift;
427 0 return $self->get_fusion_start()->fused_form();
428 }
429  
430  
431  
432 #------------------------------------------------------------------------------
433 # Returns the MISC attributes stored in the first node of the fusion (multiword
434 # token). If this node is not part of any fusion, returns the fused_misc of
435 # this node, which should be undefined.
436 #------------------------------------------------------------------------------
437 sub get_fused_misc
438 0 ▶{
Subroutine get_fused_misc: not called CC=1 SCAR=6.9
Pod undocumented
439 0 my $self = shift;
440 0 return $self->get_fusion_start()->fused_misc();
441 }
442  
443  
444  
445 #------------------------------------------------------------------------------
446 # Returns the sentence text, observing the current setting of no_space_after
447 # and of the fused multi-word tokens. That is, this method does not reach to
448 # the sentence attribute of the zone. Instead, it visits all nodes including
449 # $self, puts together their word forms and spaces. The result can be compared
450 # to the zone's sentence attribute, or even used to update the attribute.
451 #------------------------------------------------------------------------------
452 sub collect_sentence_text
453 0 ▶{
Subroutine collect_sentence_text: not called CC=6 SCAR=37.4
Pod undocumented
454 0 my $self = shift;
455 0 my @nodes = $self->get_root()->get_descendants({'ordered' => 1});
456 0 my $text = '';
457 0 ▶ for(my $i = 0; $i<=$#nodes; $i++)
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#nodes) 0 0 0
458 {
459 0 my $node = $nodes[$i];
460 0 ▶ if($node->is_fused() && $node->get_fusion_start() == $node)
Branch: 1 branch
BranchTrueFalseTotal
if ($node->is_fused and $node->get_fusion_start == $node) { } 0 0 0
Condition0%0/3
$node->is_fused and $node->get_fusion_start == $node
!ll&&!rl&&r
000
MC/DC0%0/2
$node->is_fused and $node->get_fusion_start == $node
$node->is_fused $node->get_fusion_start == $node
Truth table0%0/3
A and B
A= $node->is_fusedB= $node->get_fusion_start == $node
ABresult
0X0
100
111
461 {
462 0 my $last_node = $node->get_fusion_end();
463 0 $text .= $node->get_fusion();
464 0 ▶ $text .= ' ' unless($last_node->no_space_after());
Branch: 1 branch
BranchTrueFalseTotal
unless $last_node->no_space_after 0 0 0
465 0 $i += $last_node->ord() - $node->ord();
466 }
467 else
468 {
469 0 $text .= $node->form();
470 0 ▶ $text .= ' ' unless($node->no_space_after());
Branch: 1 branch
BranchTrueFalseTotal
unless $node->no_space_after 0 0 0
471 }
472 }
473 0 $text =~ s/^\s+//;
474 0 $text =~ s/\s+$//;
475 0 return $text;
476 }
477  
478  
479  
480 #----------- CoNLL attributes -------------
481  
482 3 ▶sub conll_deprel { return $_[0]->get_attr('conll/deprel'); }
Subroutine conll_deprel: called CC=1 SCAR=0.0
Pod undocumented
483 0 ▶sub conll_cpos { return $_[0]->get_attr('conll/cpos'); }
Subroutine conll_cpos: not called CC=1 SCAR=6.9
Pod undocumented
484 0 ▶sub conll_pos { return $_[0]->get_attr('conll/pos'); }
Subroutine conll_pos: not called CC=1 SCAR=6.9
Pod undocumented
485 0 ▶sub conll_feat { return $_[0]->get_attr('conll/feat'); }
Subroutine conll_feat: not called CC=1 SCAR=6.9
Pod undocumented
486  
487 0 ▶sub set_conll_deprel { return $_[0]->set_attr( 'conll/deprel', $_[1] ); }
Subroutine set_conll_deprel: not called CC=1 SCAR=6.9
Pod undocumented
488 0 ▶sub set_conll_cpos { return $_[0]->set_attr( 'conll/cpos', $_[1] ); }
Subroutine set_conll_cpos: not called CC=1 SCAR=6.9
Pod undocumented
489 0 ▶sub set_conll_pos { return $_[0]->set_attr( 'conll/pos', $_[1] ); }
Subroutine set_conll_pos: not called CC=1 SCAR=6.9
Pod undocumented
490 0 ▶sub set_conll_feat { return $_[0]->set_attr( 'conll/feat', $_[1] ); }
Subroutine set_conll_feat: not called CC=1 SCAR=6.9
Pod undocumented
491  
492 #---------- Morphcat -------------
493  
494 0 ▶sub morphcat_pos { return $_[0]->get_attr('morphcat/pos'); }
Subroutine morphcat_pos: not called CC=1 SCAR=6.9
Pod undocumented
495 0 ▶sub morphcat_subpos { return $_[0]->get_attr('morphcat/subpos'); }
Subroutine morphcat_subpos: not called CC=1 SCAR=6.9
Pod undocumented
496 0 ▶sub morphcat_number { return $_[0]->get_attr('morphcat/number'); }
Subroutine morphcat_number: not called CC=1 SCAR=6.9
Pod undocumented
497 0 ▶sub morphcat_gender { return $_[0]->get_attr('morphcat/gender'); }
Subroutine morphcat_gender: not called CC=1 SCAR=6.9
Pod undocumented
498 0 ▶sub morphcat_case { return $_[0]->get_attr('morphcat/case'); }
Subroutine morphcat_case: not called CC=1 SCAR=6.9
Pod undocumented
499 0 ▶sub morphcat_person { return $_[0]->get_attr('morphcat/person'); }
Subroutine morphcat_person: not called CC=1 SCAR=6.9
Pod undocumented
500 0 ▶sub morphcat_tense { return $_[0]->get_attr('morphcat/tense'); }
Subroutine morphcat_tense: not called CC=1 SCAR=6.9
Pod undocumented
501 0 ▶sub morphcat_negation { return $_[0]->get_attr('morphcat/negation'); }
Subroutine morphcat_negation: not called CC=1 SCAR=6.9
Pod undocumented
502 0 ▶sub morphcat_voice { return $_[0]->get_attr('morphcat/voice'); }
Subroutine morphcat_voice: not called CC=1 SCAR=6.9
Pod undocumented
503 0 ▶sub morphcat_grade { return $_[0]->get_attr('morphcat/grade'); }
Subroutine morphcat_grade: not called CC=1 SCAR=6.9
Pod undocumented
504 0 ▶sub morphcat_mood { return $_[0]->get_attr('morphcat/mood'); }
Subroutine morphcat_mood: not called CC=1 SCAR=6.9
Pod undocumented
505 0 ▶sub morphcat_possnumber { return $_[0]->get_attr('morphcat/possnumber'); }
Subroutine morphcat_possnumber: not called CC=1 SCAR=6.9
Pod undocumented
506 0 ▶sub morphcat_possgender { return $_[0]->get_attr('morphcat/possgender'); }
Subroutine morphcat_possgender: not called CC=1 SCAR=6.9
Pod undocumented
507  
508 0 ▶sub set_morphcat_pos { return $_[0]->set_attr( 'morphcat/pos', $_[1] ); }
Subroutine set_morphcat_pos: not called CC=1 SCAR=6.9
Pod undocumented
509 0 ▶sub set_morphcat_subpos { return $_[0]->set_attr( 'morphcat/subpos', $_[1] ); }
Subroutine set_morphcat_subpos: not called CC=1 SCAR=6.9
Pod undocumented
510 0 ▶sub set_morphcat_number { return $_[0]->set_attr( 'morphcat/number', $_[1] ); }
Subroutine set_morphcat_number: not called CC=1 SCAR=6.9
Pod undocumented
511 0 ▶sub set_morphcat_gender { return $_[0]->set_attr( 'morphcat/gender', $_[1] ); }
Subroutine set_morphcat_gender: not called CC=1 SCAR=6.9
Pod undocumented
512 0 ▶sub set_morphcat_case { return $_[0]->set_attr( 'morphcat/case', $_[1] ); }
Subroutine set_morphcat_case: not called CC=1 SCAR=6.9
Pod undocumented
513 0 ▶sub set_morphcat_person { return $_[0]->set_attr( 'morphcat/person', $_[1] ); }
Subroutine set_morphcat_person: not called CC=1 SCAR=6.9
Pod undocumented
514 0 ▶sub set_morphcat_tense { return $_[0]->set_attr( 'morphcat/tense', $_[1] ); }
Subroutine set_morphcat_tense: not called CC=1 SCAR=6.9
Pod undocumented
515 0 ▶sub set_morphcat_negation { return $_[0]->set_attr( 'morphcat/negation', $_[1] ); }
Subroutine set_morphcat_negation: not called CC=1 SCAR=6.9
Pod undocumented
516 0 ▶sub set_morphcat_voice { return $_[0]->set_attr( 'morphcat/voice', $_[1] ); }
Subroutine set_morphcat_voice: not called CC=1 SCAR=6.9
Pod undocumented
517 0 ▶sub set_morphcat_grade { return $_[0]->set_attr( 'morphcat/grade', $_[1] ); }
Subroutine set_morphcat_grade: not called CC=1 SCAR=6.9
Pod undocumented
518 0 ▶sub set_morphcat_mood { return $_[0]->set_attr( 'morphcat/mood', $_[1] ); }
Subroutine set_morphcat_mood: not called CC=1 SCAR=6.9
Pod undocumented
519 0 ▶sub set_morphcat_possnumber { return $_[0]->set_attr( 'morphcat/possnumber', $_[1] ); }
Subroutine set_morphcat_possnumber: not called CC=1 SCAR=6.9
Pod undocumented
520 0 ▶sub set_morphcat_possgender { return $_[0]->set_attr( 'morphcat/possgender', $_[1] ); }
Subroutine set_morphcat_possgender: not called CC=1 SCAR=6.9
Pod undocumented
521  
522 36 1;
523  
524 __END__
« Treex/Core/RememberArgs.pm ↑ Summary Treex/Core/TredView/Vallex.pm »