blib/lib/Lingua/Ogmios/Annotations/SemanticUnit.pm

filter: Statementstmt 4.2% 11 / 258 Branchbran 0.0% 0 / 122 Conditioncond 0.0% 0 / 33 MC/DCmcdc 0.0% 0 / 22 Subroutinesub 7.8% 3 / 38 Podpod 0.0% 0 / 35 totaltotal 2.7% 14 / 508 CC 81 SCAR 37.3
CC
81
Cov
3%
new
156.0
getPreceedingTerm
110.0
preceeds
72.0
CRAP 41.8
« blib/lib/Lingua/Ogmios/Annotations/SyntacticRelation.pm ↑ Summary blib/script/Txt2Ogmios-TabularFiles.pl »
1 package Lingua::Ogmios::Annotations::SemanticUnit;
2  
3 16 ▶use Lingua::Ogmios::Annotations::Element;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 16 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 16 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 16 our @ISA = qw(Lingua::Ogmios::Annotations::Element);
9  
10 # <!-- Named entities and terms -->
11 # <!ELEMENT semantic_unit
12 # (named_entity | term | undefined)+ >
13
14  
15 # <!-- term -->
16 # <!ELEMENT term (id, log_id?, (refid_phrase
17 # | refid_word | list_refid_token),
18 # weights, negation
19 # form?, canonical_form?) >
20  
21 # <!ELEMENT weights ( >
22
23 # <!-- undefined semantic unit -->
24 # <!ELEMENT undefined (id, log_id?, (refid_phrase
25 # | refid_word | list_refid_token),
26 # form?, canonical_form?) >
27  
28 # <!-- named entity -->
29 # <!ELEMENT named_entity (id?, log_id?, (refid_phrase |
30 # refid_word | list_refid_token)? ,
31 # form?, canonical_form?,
32 # named_entity_type) >
33  
34 # at the creation defined a type (named_netity, term, undefined)
35  
36 0 ▶sub new {
Subroutine new: not called CC=12 SCAR=50.5
Pod undocumented
37 0 my ($class, $fields) = @_;
38  
39 0 my @refTypes = ('refid_phrase', 'refid_word', 'list_refid_token');
40  
41 0 ▶ if (!defined $fields->{'id'}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $fields->{"id"}) 0 0 0
42 0 $fields->{'id'} = -1;
43 }
44 0 ▶ if (!defined $fields->{'type'}) { # named_entity, term or undefined
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $fields->{"type"}) 0 0 0
45 0 die("type is not defined");
46 }
47 my $sem_unit = $class->SUPER::new({
48 0 'id' => $fields->{'id'},
49 # 'form' => $fields->{'form'},
50 }
51 );
52  
53 0 my $i = 0;
54 0 my $reference_name;
55 my $ref;
56 0 foreach $ref (@refTypes) {
57 0 ▶ if (defined $fields->{$ref}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $fields->{$ref}) 0 0 0
58 0 $reference_name = $ref;
59 0 last;
60 }
61 0 $i++;
62 }
63 0 ▶ if ($i == scalar(@refTypes)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i == scalar @refTypes) 0 0 0
64 0 die("reference (list) is not defined");
65 }
66  
67 # if ((!defined $fields->{'refid_phrase'}) ||
68 # (!defined $fields->{'refid_word'}) ||
69 # (!defined $fields->{'list_refid_token'}))
70 # {
71 # die("reference (list) is not defined");
72  
73 # }
74  
75 0 bless ($sem_unit,$class);
76  
77 # warn "=>>$reference_name\n";
78  
79 0 $sem_unit->reference($reference_name, $fields->{$reference_name});
80  
81 0 ▶ if (defined $fields->{'form'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $fields->{"form"}) 0 0 0
82 0 $sem_unit->setForm($fields->{'form'});
83 }
84 0 ▶ if (defined $fields->{'weights'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $fields->{"weights"}) 0 0 0
85 0 $sem_unit->weights($fields->{'weights'});
86 }
87  
88 0 ▶ if (defined $fields->{'negation'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $fields->{"negation"}) 0 0 0
89 0 $sem_unit->negation($fields->{'negation'});
90 }
91  
92 0 ▶ if (defined $fields->{'log_id'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $fields->{"log_id"}) 0 0 0
93 0 $sem_unit->setLogId($fields->{'log_id'});
94 }
95  
96 0 $sem_unit->type($fields->{'type'});
97
98 0 ▶ if (defined $fields->{'canonical_form'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $fields->{"canonical_form"}) 0 0 0
99 0 $sem_unit->canonical_form($fields->{'canonical_form'});
100 }
101  
102 0 ▶ if ($sem_unit->isNamedEntity) {
Branch: 1 branch
BranchTrueFalseTotal
if ($sem_unit->isNamedEntity) 0 0 0
103 0 $sem_unit->NEtype($fields->{'named_entity_type'});
104 }
105  
106 0 return($sem_unit);
107 }
108  
109 0 ▶sub negation {
Subroutine negation: not called CC=2 SCAR=17.9
Pod undocumented
110 0 my $self = shift;
111  
112 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
113 0 $self->{'negation'} = shift;
114 }
115 0 return($self->{'negation'});
116 }
117 0 ▶sub printWeights {
Subroutine printWeights: not called CC=4 SCAR=30.0
Pod undocumented
118 0 my ($self, $fh) = @_;
119 0 my $weight_name;
120  
121 0 ▶ if (!defined $fh) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $fh) 0 0 0
122 0 $fh = \*STDERR;
123 }
124  
125 0 ▶ if (defined $self->weights) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->weights) 0 0 0
126 0 foreach $weight_name (keys %{$self->weights}) {
127 0 print $fh "$weight_name : " . $self->weight($weight_name) . "\n";
128 }
129 }
130 }
131  
132 0 ▶sub weights {
Subroutine weights: not called CC=3 SCAR=24.8
Pod undocumented
133 0 my $self = shift;
134
135 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
136 0 my $weights = shift;
137
138 # warn "$weights\n";
139  
140 0 my $weight_name;
141 0 foreach $weight_name (keys %$weights) {
142 # warn "$weight_name\n";
143 0 $self->{'weights'}->{$weight_name} = $weights->{$weight_name};
144 # warn "$weight_name : " . $self->weights->{$weight_name} . "\n";
145 }
146 }
147
148 0 return($self->{'weights'});
149 }
150  
151 0 ▶sub sortedWeightValues {
Subroutine sortedWeightValues: not called CC=2 SCAR=17.9
Pod undocumented
152 0 my $self = shift;
153  
154 0 my @w;
155 my $weight_name;
156  
157 0 foreach $weight_name (sort keys %{$self->weights}) {
158 0 push @w, $self->weight($weight_name);
159 }
160 0 return(@w);
161 }
162  
163 0 ▶sub numberOfWeights {
Subroutine numberOfWeights: not called CC=1 SCAR=6.9
Pod undocumented
164 0 my $self = shift;
165  
166 0 return(scalar(keys %{$self->weights}));
167 }
168  
169 0 ▶sub existsWeight {
Subroutine existsWeight: not called CC=1 SCAR=6.9
Pod undocumented
170 0 my $self = shift;
171 0 my $weight_name = shift;
172  
173 0 return(exists($self->{'weights'}->{$weight_name}));
174 }
175  
176 0 ▶sub incr_weight {
Subroutine incr_weight: not called CC=2 SCAR=17.9
Pod undocumented
177 0 my ($self, $weight_name, $step) = @_;
178  
179 0 ▶ if (!defined($self->weight($weight_name))) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->weight($weight_name)) 0 0 0
180 0 $self->weight($weight_name, 0);
181 }
182 0 $self->weight($weight_name, $self->weight($weight_name) + 1);
183 0 return($self->weight($weight_name));
184 }
185  
186 0 ▶sub weight {
Subroutine weight: not called CC=4 SCAR=30.0
Pod undocumented
187 0 my $self = shift;
188  
189 0 ▶ if (!defined $self->weights) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->weights) 0 0 0
190 0 ▶ if (scalar(@_) > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @_ > 0) { } 0 0 0
191 0 $self->{'weights'} = {};
192 } else {
193 0 return(undef);
194 }
195 }
196 0 my $weight_name = shift;
197
198 # warn "--> " . $weight_name . "\n";
199 # warn "\tOK\n";
200 # warn scalar(@_) . "\n";
201 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
202 # warn "\t In\n";
203 0 $self->{'weights'}->{$weight_name} = shift;
204 }
205 # warn "\t\t" . $self->{'weights'}->{$weight_name} . "\n";
206 0 return($self->{'weights'}->{$weight_name});
207 }
208  
209 0 ▶sub newNamedEntity {
Subroutine newNamedEntity: not called CC=2 SCAR=17.9
Pod undocumented
210 0 my ($class, $fields) = @_;
211  
212 0 ▶ if (!defined $fields->{'named_entity_type'}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $fields->{"named_entity_type"}) 0 0 0
213 0 die("named_entity_type is not defined");
214 }
215  
216 0 $fields->{'type'} = "named_entity";
217  
218 0 return($class->new($fields));
219  
220 }
221  
222 0 ▶sub newTerm {
Subroutine newTerm: not called CC=1 SCAR=6.9
Pod undocumented
223 0 my ($class, $fields) = @_;
224  
225 0 $fields->{'type'} = "term";
226  
227 0 return($class->new($fields));
228 }
229  
230 0 ▶sub newUndefinedSemanticUnit {
Subroutine newUndefinedSemanticUnit: not called CC=1 SCAR=6.9
Pod undocumented
231 0 my ($class, $fields) = @_;
232  
233 0 $fields->{'type'} = "undefined";
234  
235 0 return($class->new($fields));
236 }
237  
238 # type canonical_form reference NEtype isNamedEntoty
239  
240 0 ▶sub canonical_form {
Subroutine canonical_form: not called CC=2 SCAR=17.9
Pod undocumented
241 0 my $self = shift;
242  
243 0 ▶ $self->{'canonical_form'} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
244 0 return $self->{'canonical_form'};
245 }
246  
247 0 ▶sub exists_canonical_form {
Subroutine exists_canonical_form: not called CC=1 SCAR=6.9
Pod undocumented
248 0 my $self = shift;
249  
250 0 return exists($self->{'canonical_form'});
251 }
252  
253 0 ▶sub type {
Subroutine type: not called CC=2 SCAR=17.9
Pod undocumented
254 0 my $self = shift;
255  
256 0 ▶ $self->{'type'} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
257 0 return $self->{'type'};
258 }
259  
260 0 ▶sub reference_name {
Subroutine reference_name: not called CC=2 SCAR=17.9
Pod undocumented
261 0 my $self = shift;
262  
263 0 ▶ $self->{'reference'} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
264 0 return $self->{'reference'};
265  
266 }
267  
268 0 ▶sub reference {
Subroutine reference: not called CC=5 SCAR=34.0
Pod undocumented
269 0 my $self = shift;
270 0 my $ref;
271 my $elt;
272  
273 0 ▶ if ((@_) && (scalar @_ == 2)) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ and scalar @_ == 2) 0 0 0
Condition0%0/3
@_ and scalar @_ == 2
!ll&&!rl&&r
000
MC/DC0%0/2
@_ and scalar @_ == 2
@_ scalar @_ == 2
Truth table0%0/3
A and B
A= @_B= scalar @_ == 2
ABresult
0X0
100
111
274 0 $self->{'reference'} = shift;
275 0 $ref = shift;
276  
277 # warn "term ref: " . ref($ref) . "\n";
278 0 ▶ if (ref($ref) eq "ARRAY") {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $ref eq 'ARRAY') { } 0 0 0
279 0 $self->{$self->{'reference'}} = [];
280 0 foreach $elt (@$ref) {
281 0 push @{$self->{$self->{'reference'}}}, $elt;
282 }
283 } else { # it's a single string
284 # warn $self->{'reference'} . ": $ref\n";
285 0 $self->{$self->{'reference'}} = $ref;
286  
287 }
288 }
289 0 return($self->{$self->{'reference'}});
290 }
291  
292  
293 0 ▶sub getReferenceSize {
Subroutine getReferenceSize: not called CC=4 SCAR=30.0
Pod undocumented
294 0 my $self = shift;
295  
296 0 ▶ if ($self->reference_name eq "list_refid_token") {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->reference_name eq "list_refid_token") 0 0 0
297 0 return(scalar(@{$self->{$self->{'reference'}}}));
298 }
299 0 ▶ if ($self->reference_name eq "refid_word") {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->reference_name eq "refid_word") 0 0 0
300 0 return(1);
301 }
302 0 ▶ if ($self->reference_name eq "refid_phrase") {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->reference_name eq "refid_phrase") 0 0 0
303 0 return(1);
304 }
305 }
306  
307 0 ▶sub getReferenceWordSize {
Subroutine getReferenceWordSize: not called CC=6 SCAR=37.4
Pod undocumented
308 0 my $self = shift;
309  
310 0 my $elmt;
311 0 ▶ if ($self->reference_name eq "list_refid_token") {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->reference_name eq "list_refid_token") 0 0 0
312 0 return(scalar(@{$self->{$self->{'reference'}}}));
313 }
314 0 ▶ if ($self->reference_name eq "refid_word") {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->reference_name eq "refid_word") 0 0 0
315 0 return(1);
316 }
317 0 ▶ if ($self->reference_name eq "refid_phrase") {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->reference_name eq "refid_phrase") 0 0 0
318 0 my $wordCount = 0;
319 0 foreach $elmt ($self->reference->getElementList) {
320 0 ▶ if (ref($elmt) eq "Lingua::Ogmios::Annotations::Word") {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $elmt eq "Lingua::Ogmios::Annotations::Word") 0 0 0
321 0 $wordCount++;
322 }
323 }
324
325 0 return($wordCount);
326 }
327 }
328  
329 0 ▶sub getReferenceTokenSize {
Subroutine getReferenceTokenSize: not called CC=4 SCAR=30.0
Pod undocumented
330 0 my $self = shift;
331  
332 0 ▶ if ($self->reference_name eq "list_refid_token") {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->reference_name eq "list_refid_token") 0 0 0
333 0 return(scalar(@{$self->{$self->{'reference'}}}));
334 }
335 0 ▶ if ($self->reference_name eq "refid_word") {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->reference_name eq "refid_word") 0 0 0
336 0 return($self->reference->getReferenceSize);
337 }
338 0 ▶ if ($self->reference_name eq "refid_phrase") {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->reference_name eq "refid_phrase") 0 0 0
339 0 return($self->reference->getReferenceSize);
340 }
341 }
342  
343 0 ▶sub getReference {
Subroutine getReference: not called CC=1 SCAR=6.9
Pod undocumented
344 0 my $self = shift;
345  
346 0 return($self->{$self->{'reference'}});
347 }
348  
349 # sub equals_ref {
350 # my ($self, $element) = @_;
351  
352 # my $i;
353 # while(($i <scalar($self->getReference)) && ($i <scalar($element->getReference)) &&
354 # ($self->getReference->[$i].equals($element->getReference->[$i]))) {
355 # $i++
356 # };
357 # if ($i < scalar($self->getReference)) {
358 # return(0);
359 # } else {
360 # return(1);
361 # }
362  
363 # }
364  
365 0 ▶sub getElementFormList {
Subroutine getElementFormList: not called CC=3 SCAR=24.8
Pod undocumented
366 0 my ($self) = @_;
367  
368 0 my $element;
369 my @elements;
370
371  
372 # warn ref($self->getReference) . "\n";
373  
374 0 ▶ if (ref($self->getReference) eq "ARRAY") {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $self->getReference eq 'ARRAY') { } 0 0 0
375 0 foreach $element (@{$self->getReference}) {
376 # warn "\t". $element->getElementFormList . "\n";
377 0 push @elements, $element->getElementFormList;
378 }
379 } else {
380 0 push @elements, $self->getReference->getElementFormList;
381 }
382 0 return(@elements);
383 }
384  
385  
386 0 ▶sub NEtype {
Subroutine NEtype: not called CC=2 SCAR=17.9
Pod undocumented
387 0 my $self = shift;
388  
389 0 ▶ $self->{'named_entity_type'} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
390 0 return $self->{'named_entity_type'};
391 }
392  
393 0 ▶sub isNamedEntity {
Subroutine isNamedEntity: not called CC=3 SCAR=24.8
Pod undocumented
394 0 my $self = shift;
395  
396 0 ▶ if ((exists $self->{'type'}) && ($self->{'type'} eq "named_entity")) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{'type'} and $self->{'type'} eq 'named_entity') { } 0 0 0
Condition0%0/3
exists $self->{"type"} and $self->{"type"} eq "named_entity"
!ll&&!rl&&r
000
MC/DC0%0/2
exists $self->{"type"} and $self->{"type"} eq "named_entity"
exists $self->{"type"} $self->{"type"} eq "named_entity"
Truth table0%0/3
A and B
A= exists $self->{"type"}B= $self->{"type"} eq "named_entity"
ABresult
0X0
100
111
397 0 return 1;
398 } else {
399 0 return 0;
400 }
401 }
402  
403 0 ▶sub isTerm {
Subroutine isTerm: not called CC=3 SCAR=24.8
Pod undocumented
404 0 my $self = shift;
405  
406 0 ▶ if ((exists $self->{'type'}) && ($self->{'type'} eq "term")) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{'type'} and $self->{'type'} eq 'term') { } 0 0 0
Condition0%0/3
exists $self->{"type"} and $self->{"type"} eq "term"
!ll&&!rl&&r
000
MC/DC0%0/2
exists $self->{"type"} and $self->{"type"} eq "term"
exists $self->{"type"} $self->{"type"} eq "term"
Truth table0%0/3
A and B
A= exists $self->{"type"}B= $self->{"type"} eq "term"
ABresult
0X0
100
111
407 0 return(1);
408 } else {
409 0 return(0);
410 }
411 }
412  
413 0 ▶sub end_token {
Subroutine end_token: not called CC=4 SCAR=30.0
Pod undocumented
414 0 my $self = shift;
415  
416 # warn $self->reference_name . "\n";
417  
418 0 ▶ if ($self->reference_name eq "list_refid_token") {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->reference_name eq "list_refid_token") 0 0 0
419 0 return($self->reference->[$#{$self->reference}]);
420 }
421 #if list_refid token -> OK
422 # if refid word -> word->start_token
423 # OR
424 # if refid phrase -> phrase->start_token
425 0 ▶ if (($self->reference_name eq "refid_word") ||
Branch: 1 branch
BranchTrueFalseTotal
if ($self->reference_name eq "refid_word" or $self->reference_name eq "refid_phrase") 0 0 0
Condition0%0/3
$self->reference_name eq "refid_word" or $self->reference_name eq "refid_phrase"
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->reference_name eq "refid_word" or $self->reference_name eq "refid_phrase"
$self->reference_name eq "refid_word" $self->reference_name eq "refid_phrase"
Truth table0%0/3
A or B
A= $self->reference_name eq "refid_word"B= $self->reference_name eq "refid_phrase"
ABresult
1X1
011
000
426 ($self->reference_name eq "refid_phrase")){
427 0 return($self->reference->end_token);
428 }
429 0 return(undef);
430 }
431  
432 0 ▶sub start_token {
Subroutine start_token: not called CC=4 SCAR=30.0
Pod undocumented
433 0 my $self = shift;
434  
435  
436 0 ▶ if ($self->reference_name eq "list_refid_token") {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->reference_name eq "list_refid_token") 0 0 0
437 0 return($self->reference->[0]);
438 }
439 #if list_refid token -> OK
440  
441 # if refid word -> word->start_token
442 # OR
443 # if refid phrase -> phrase->start_token
444 0 ▶ if (($self->reference_name eq "refid_word") ||
Branch: 1 branch
BranchTrueFalseTotal
if ($self->reference_name eq "refid_word" or $self->reference_name eq "refid_phrase") 0 0 0
Condition0%0/3
$self->reference_name eq "refid_word" or $self->reference_name eq "refid_phrase"
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->reference_name eq "refid_word" or $self->reference_name eq "refid_phrase"
$self->reference_name eq "refid_word" $self->reference_name eq "refid_phrase"
Truth table0%0/3
A or B
A= $self->reference_name eq "refid_word"B= $self->reference_name eq "refid_phrase"
ABresult
1X1
011
000
445 ($self->reference_name eq "refid_phrase")){
446 0 return($self->reference->start_token);
447 }
448 0 return(undef);
449 }
450  
451 # Not check
452 0 ▶sub preceeds {
Subroutine preceeds: not called CC=8 SCAR=42.8
Pod undocumented
453 0 my ($self, $elt, $wordLimit, $document) = @_;
454  
455 0 my $token = $self->end_token;
456  
457 0 my $wordcount = 0;
458  
459 0 ▶ do {
Branch: 1 branch
BranchTrueFalseTotal
not $token->equals($elt->end_token) and $wordcount < $wordLimit and do { do { do { $token = $token->next } while $token->isSep; if (not $token->equals($elt->end_token) and $wordcount < $wordLimit) { if (scalar @{$document->getAnnotations->getWordLevel->getElementByToken($token);} > 0) { $token = $document->getAnnotations->getWordLevel->getElementByToken($token)->end_token; ++$wordcount; } ; } } } 0 0 0
Condition0%0/3
not $token->equals($elt->end_token) and $wordcount < $wordLimit
!ll&&!rl&&r
000
MC/DC0%0/2
not $token->equals($elt->end_token) and $wordcount < $wordLimit
not $token->equals($elt->end_token) $wordcount < $wordLimit
Truth table0%0/3
not(A) and B
A= not $token->equals($elt->end_token)B= $wordcount < $wordLimit
ABresult
0X0
100
111
460 0 ▶ do {
Branch: 1 branch
BranchTrueFalseTotal
$token->isSep and do { do { $token = $token->next } } 0 0 0
461 0 $token = $token->next;
462 } while($token->isSep);
463  
464 0 ▶ if ((!$token->equals($elt->end_token)) && ($wordcount < $wordLimit)){
Branch: 1 branch
BranchTrueFalseTotal
if (not $token->equals($elt->end_token) and $wordcount < $wordLimit) 0 0 0
Condition0%0/3
not $token->equals($elt->end_token) and $wordcount < $wordLimit
!ll&&!rl&&r
000
MC/DC0%0/2
not $token->equals($elt->end_token) and $wordcount < $wordLimit
not $token->equals($elt->end_token) $wordcount < $wordLimit
Truth table0%0/3
not(A) and B
A= not $token->equals($elt->end_token)B= $wordcount < $wordLimit
ABresult
0X0
100
111
465 0 ▶ if (scalar(@{$document->getAnnotations->getWordLevel->getElementByToken($token)}) > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @{$document->getAnnotations->getWordLevel->getElementByToken($token);} > 0) 0 0 0
466 0 $token = $document->getAnnotations->getWordLevel->getElementByToken($token)->end_token;
467 0 $wordcount++;
468 }
469 }
470 } while((!$token->equals($elt->end_token)) && ($wordcount < $wordLimit));
471  
472 0 ▶ if ($token->equals($elt->end_token)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token->equals($elt->end_token)) { } 0 0 0
473 0 return(1);
474 } else {
475 0 return(0);
476 }
477 }
478  
479  
480 0 ▶sub getPreceedingTerm {
Subroutine getPreceedingTerm: not called CC=10 SCAR=47.0
Pod undocumented
481 0 my ($self, $wordLimit, $document) = @_;
482  
483 0 my $token = $self->start_token;
484  
485 0 my $wordcount = 0;
486  
487 0 my $lastword;
488  
489 # warn "go in ($token)\n";
490 0 ▶ do {
Branch: 1 branch
BranchTrueFalseTotal
$wordcount < $wordLimit and do { do { do { $token = $token->previous } while $token->isSep; if (scalar @{$document->getAnnotations->getSemanticUnitLevel->getElementByToken($token);} > 0) { return $document->getAnnotations->getSemanticUnitLevel->getElementByToken($token)->[0]; } else { while (defined $token->previous and scalar @{$document->getAnnotations->getWordLevel->getElementByToken($token);} == 0) { $token = $token->previous; } ; if (defined $token->previous and scalar @{$document->getAnnotations->getWordLevel->getElementByToken($token);} > 0) { $token = $document->getAnnotations->getWordLevel->getElementByToken($token)->[0]->start_token; $lastword = $document->getAnnotations->getWordLevel->getElementByToken($token)->[0]; if (scalar @{$document->getAnnotations->getSemanticUnitLevel->getElementByToken($token);} > 0) { return $document->getAnnotations->getSemanticUnitLevel->getElementByToken($token)->[0]; } ; ++$wordcount; } else { return $lastword; } ; } } } 0 0 0
491 0 ▶ do {
Branch: 1 branch
BranchTrueFalseTotal
$token->isSep and do { do { $token = $token->previous } } 0 0 0
492 0 $token = $token->previous;
493 } while($token->isSep);
494  
495 # warn "not sep $token\n";
496 0 ▶ if (scalar(@{$document->getAnnotations->getSemanticUnitLevel->getElementByToken($token)}) > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @{$document->getAnnotations->getSemanticUnitLevel->getElementByToken($token);} > 0) { } 0 0 0
497 # warn "go out\n";
498 0 return($document->getAnnotations->getSemanticUnitLevel->getElementByToken($token)->[0]);
499 } else {
500 # warn "Go\n";
501 0 ▶ while((defined $token->previous) && (scalar(@{$document->getAnnotations->getWordLevel->getElementByToken($token)})== 0)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $token->previous and scalar @{$document->getAnnotations->getWordLevel->getElementByToken($token);} == 0) 0 0 0
Condition0%0/3
defined $token->previous and scalar @{$document->getAnnotations->getWordLevel->getElementByToken($token);} == 0
!ll&&!rl&&r
000
MC/DC0%0/2
defined $token->previous and scalar @{$document->getAnnotations->getWordLevel->getElementByToken($token);} == 0
defined $token->previous scalar @{$document->getAnnotations->getWordLevel->getElementByToken($token);} == 0
Truth table0%0/3
A and B
A= defined $token->previousB= scalar @{$document->getAnnotations->getWordLevel->getElementByToken($token);} == 0
ABresult
0X0
100
111
502 # warn "go\n";
503 0 $token = $token->previous;
504 }
505 # warn "GO\n";
506  
507 0 ▶ if ((defined $token->previous) && (scalar(@{$document->getAnnotations->getWordLevel->getElementByToken($token)}) > 0)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $token->previous and scalar @{$document->getAnnotations->getWordLevel->getElementByToken($token);} > 0) { } 0 0 0
Condition0%0/3
defined $token->previous and scalar @{$document->getAnnotations->getWordLevel->getElementByToken($token);} > 0
!ll&&!rl&&r
000
MC/DC0%0/2
defined $token->previous and scalar @{$document->getAnnotations->getWordLevel->getElementByToken($token);} > 0
defined $token->previous scalar @{$document->getAnnotations->getWordLevel->getElementByToken($token);} > 0
Truth table0%0/3
A and B
A= defined $token->previousB= scalar @{$document->getAnnotations->getWordLevel->getElementByToken($token);} > 0
ABresult
0X0
100
111
508 # warn "GO2\n";
509 0 $token = $document->getAnnotations->getWordLevel->getElementByToken($token)->[0]->start_token;
510 0 $lastword = $document->getAnnotations->getWordLevel->getElementByToken($token)->[0];
511 0 ▶ if (scalar(@{$document->getAnnotations->getSemanticUnitLevel->getElementByToken($token)}) > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @{$document->getAnnotations->getSemanticUnitLevel->getElementByToken($token);} > 0) 0 0 0
512 # warn "go out\n";
513 0 return($document->getAnnotations->getSemanticUnitLevel->getElementByToken($token)->[0]);
514 }# warn "go out\n";
515 # warn "GO3\n";
516 0 $wordcount++;
517 } else {
518 # warn "go out\n";
519 0 return($lastword);
520 }
521 # warn "GO4\n";
522  
523 }
524 } while($wordcount < $wordLimit);
525 0 ▶ if (scalar(@{$document->getAnnotations->getSemanticUnitLevel->getElementByToken($token)}) > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @{$document->getAnnotations->getSemanticUnitLevel->getElementByToken($token);} > 0) 0 0 0
526 # warn "go out\n";
527 0 return($document->getAnnotations->getSemanticUnitLevel->getElementByToken($token)->[0]);
528 }# warn "go out\n";
529 0 return($lastword);
530  
531 }
532  
533  
534 0 ▶sub XMLout {
Subroutine XMLout: not called CC=1 SCAR=6.9
Pod undocumented
535 0 my ($self, $order) = @_;
536
537 0 my $str;
538  
539 0 $str = "\t<semantic_unit>\t\n";
540 0 $str .= $self->SUPER::XMLout($self->type, $order);
541 0 $str .= "\t</semantic_unit>\n";
542  
543 0 return($str);
544 }
545  
546  
547 0 ▶sub getSemanticFeatureFC {
Subroutine getSemanticFeatureFC: not called CC=2 SCAR=17.9
Pod undocumented
548 0 my ($self, $document) = @_;
549  
550 0 ▶ if (defined ($document->getAnnotations->getSemanticFeaturesLevel->getElementFromIndex("refid_semantic_unit", $self->getId)->[0])) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $document->getAnnotations->getSemanticFeaturesLevel->getElementFromIndex('refid_semantic_unit', $self->getId)->[0]) { } 0 0 0
551 0 return($document->getAnnotations->getSemanticFeaturesLevel->getElementFromIndex("refid_semantic_unit", $self->getId)->[0]->first_node_first_semantic_category);
552 } else {
553 0 return(undef);
554 }
555 }
556  
557 0 ▶sub getSemanticFeature1 {
Subroutine getSemanticFeature1: not called CC=2 SCAR=17.9
Pod undocumented
558 0 my ($self, $document) = @_;
559  
560 0 ▶ if (defined ($document->getAnnotations->getSemanticFeaturesLevel->getElementFromIndex("refid_semantic_unit", $self->getId)->[0])) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $document->getAnnotations->getSemanticFeaturesLevel->getElementFromIndex('refid_semantic_unit', $self->getId)->[0]) { } 0 0 0
561 0 return($document->getAnnotations->getSemanticFeaturesLevel->getElementFromIndex("refid_semantic_unit", $self->getId)->[0]);
562 } else {
563 0 return(undef);
564 }
565 }
566  
567 0 ▶sub SemanticFeatureFCEquals {
Subroutine SemanticFeatureFCEquals: not called CC=3 SCAR=24.8
Pod undocumented
568 0 my ($self, $document, $semTypeValue) = @_;
569  
570 # warn $self->getForm . "\n";
571 # warn "semTypeValue: $semTypeValue\n";
572 # warn "semTypeValue: " . $self->getSemanticFeatureFC($document) ."\n";
573  
574 0 ▶ if ((defined ($self->getSemanticFeatureFC($document))) &&
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->getSemanticFeatureFC($document) and $self->getSemanticFeatureFC($document) eq $semTypeValue) { } 0 0 0
Condition0%0/3
defined $self->getSemanticFeatureFC($document) and $self->getSemanticFeatureFC($document) eq $semTypeValue
!ll&&!rl&&r
000
MC/DC0%0/2
defined $self->getSemanticFeatureFC($document) and $self->getSemanticFeatureFC($document) eq $semTypeValue
defined $self->getSemanticFeatureFC($document) $self->getSemanticFeatureFC($document) eq $semTypeValue
Truth table0%0/3
A and B
A= defined $self->getSemanticFeatureFC($document)B= $self->getSemanticFeatureFC($document) eq $semTypeValue
ABresult
0X0
100
111
575 ($self->getSemanticFeatureFC($document) eq $semTypeValue)) {
576 # ($document->getAnnotations->getSemanticFeaturesLevel->getElementFromIndex("refid_semantic_unit", $self->getId)->[0]->first_node_first_semantic_category eq $semTypeValue)) {
577 0 return(1);
578 } else {
579 0 return(0);
580 }
581 }
582  
583  
584 0 ▶sub equalsAtTokenLevel {
Subroutine equalsAtTokenLevel: not called CC=3 SCAR=24.8
Pod undocumented
585 0 my ($self, $element) = @_;
586  
587 0 ▶ if (($self->start_token->equals($element->start_token)) &&
Branch: 1 branch
BranchTrueFalseTotal
if ($self->start_token->equals($element->start_token) and $self->end_token->equals($element->end_token)) { } 0 0 0
Condition0%0/3
$self->start_token->equals($element->start_token) and $self->end_token->equals($element->end_token)
!ll&&!rl&&r
000
MC/DC0%0/2
$self->start_token->equals($element->start_token) and $self->end_token->equals($element->end_token)
$self->start_token->equals($element->start_token) $self->end_token->equals($element->end_token)
Truth table0%0/3
A and B
A= $self->start_token->equals($element->start_token)B= $self->end_token->equals($element->end_token)
ABresult
0X0
100
111
588 ($self->end_token->equals($element->end_token)))
589 {
590 0 return(1);
591 } else {
592 0 return(0);
593 }
594 }
595  
596 0 ▶sub getLemmaString {
Subroutine getLemmaString: not called CC=5 SCAR=34.0
Pod undocumented
597 0 my ($self, $document) = @_;
598  
599 0 my $elmt;
600 my $lemma;
601  
602 0 ▶ if ($self->reference_name eq "list_refid_token") {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->reference_name eq "list_refid_token") 0 0 0
603 # warn "TOKEN: " . $self->{'reference'} . "\n";
604 # warn join(':', @{$self->{$self->{'reference'}}}) . "\n";
605 # return(scalar(@{$self->{$self->{'reference'}}}));
606 0 foreach $elmt (@{$self->{$self->{'reference'}}}) {
607 0 $lemma .= $elmt->getContent;
608 }
609 }
610 0 ▶ if ($self->reference_name eq "refid_word") {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->reference_name eq "refid_word") 0 0 0
611 # warn $self->reference . "\n";
612 0 $lemma .= $self->reference->getLemma($document)->canonical_form;
613 }
614 0 ▶ if ($self->reference_name eq "refid_phrase") {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->reference_name eq "refid_phrase") 0 0 0
615 # warn "PHRASE: " . $self->reference . "\n";
616 0 $lemma .= $self->reference->getLemmaString($document);
617 }
618 0 return($lemma);
619 }
620  
621  
622 16 1;
623  
624 __END__
« blib/lib/Lingua/Ogmios/Annotations/SyntacticRelation.pm ↑ Summary blib/script/Txt2Ogmios-TabularFiles.pl »