blib/lib/Lingua/Ogmios/NLPWrappers/Wrapper.pm

filter: Statementstmt 5.4% 167 / 3066 Branchbran 3.1% 39 / 1256 Conditioncond 0.1% 1 / 678 MC/DCmcdc 0.0% 0 / 372 Subroutinesub 21.9% 34 / 155 Podpod 0.0% 0 / 26 totaltotal 4.3% 241 / 5553 CC 957 SCAR 65.5
CC
957
Cov
4%
_mergeTerms
5852.0
getWindowLimits
2256.0
_parseTreeTaggerFormatOutput
1332.0
CRAP 700.6
« blib/lib/Lingua/Ogmios/NLPWrappers/PerlWordSegmentizer.pm ↑ Summary blib/lib/Lingua/Ogmios/NLPWrappers/TreeTagger.pm »
1 package Lingua::Ogmios::NLPWrappers::Wrapper;
2  
3  
4 6 our $VERSION='0.1';
5  
6 6 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 6 ▶use Config::General;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 6 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 6 ▶use Lingua::Ogmios::NLPWrappers::PatternParser;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 6 ▶use Lingua::Ogmios::Annotations::Phrase;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 6 ▶use Lingua::Ogmios::Annotations::SemanticUnit;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 6 ▶use Lingua::Ogmios::Annotations::SemanticFeatures;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 6 ▶use Lingua::Ogmios::Annotations::LogProcessing;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 6 ▶use Lingua::Ogmios::Timer;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 6 ▶use Lingua::Ogmios::LearningDataSet;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 6 ▶use Lingua::Ogmios::LearningDataSet::Attribute;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 6 ▶use Lingua::Ogmios::LearningDataSet::Data;
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
24 6 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
25 24 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
26 24 my ($class, $config, $tmpfile_prefix, $logfile, $position, $no_standard_output, $out_stream) = @_;
27  
28 24 my $wrapper = {
29 "config" => $config,
30 "tmpfile_prefix" => $tmpfile_prefix,
31 "documentSet" => undef,
32 "input_filename" => undef,
33 "tmp_filename" => undef,
34 "output_filename" => undef,
35 "logfile" => $logfile,
36 "position" => $position, # position in the NL line processing
37 "no_standard_output" => $no_standard_output,
38 "timer" => Lingua::Ogmios::Timer->new(),
39 "currentDocument" => undef,
40 "out_stream" => $out_stream,
41 };
42  
43 24 bless $wrapper, $class;
44  
45 24 $wrapper->{"timer"}->start;
46  
47 # die "You call the 'new' method of the wrapper class base\n
48 # You should define a 'new' method for your wrapper\n";
49  
50 24 return($wrapper);
51 }
52  
53 # sub _logfile {
54 # my ($self) = @_;
55  
56 # die "You call the '_logfile' method of the wrapper class base\n
57 # You should define a '_logfile' method for your wrapper\n";
58 # }
59  
60  
61 0 ▶sub run {
Subroutine run: not called CC=1 SCAR=6.9
Pod undocumented
62 0 my ($self, $documentSet) = @_;
63  
64 0 die "You call the 'rum' method of the wrapper class base\n
65 You should define a 'run' method for your wrapper\n";
66 }
67  
68 12 ▶sub _defineCommandLine {
Subroutine _defineCommandLine: called CC=3 SCAR=12.0
69 12 my ($self, $cmd, $input, $output) = @_;
70  
71 12 my $command_line;
72
73 12 $command_line = "(";
74 12 $command_line .= $cmd;
75 12 $command_line .= ") ";
76 12 ▶ if (defined $input) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $input) 0 12 12
77 0 $command_line .= " < ";
78 0 $command_line .= $input;
79 }
80 12 ▶ if (defined $output) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $output) 0 12 12
81 0 $command_line .= " > ";
82 0 $command_line .= $output;
83 }
84 12 $command_line .= " 2>> " . $self->_logfile;
85 12 warn "[LOG] command line : $command_line\n";
86 12 return($command_line);
87 }
88  
89  
90 12 ▶sub _exec_command {
Subroutine _exec_command: called CC=2 SCAR=7.0
91  
92 12 my ($self, $command, $env_vars) = @_;
93 12 my $cmd_withEnvVar = "";
94 12 my $var;
95  
96  
97 12 foreach $var (keys %$env_vars) {
98 0 $cmd_withEnvVar .= "export " . $var . "=" . $env_vars->{$var} . " ; ";
99 }
100 12 $cmd_withEnvVar .= $command;
101 # warn "Running $cmd_withEnvVar\n";
102 12 `$cmd_withEnvVar`;
103  
104 12 return($cmd_withEnvVar);
105 }
106  
107 18 ▶sub _log {
Subroutine _log: called CC=2 SCAR=6.9
108 18 my ($self, $information) = @_;
109  
110 18 my $document;
111 18 foreach $document (@{$self->_documentSet}) {
112 27 $document->getAnnotations->addLogProcessing(Lingua::Ogmios::Annotations::LogProcessing->new($information));
113 }
114 }
115  
116 54 ▶sub _input_filename {
Subroutine _input_filename: called CC=2 SCAR=6.9
117 54 my $self = shift;
118  
119 54 ▶ $self->{"input_filename"} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 14 40 54
120  
121 54 return($self->{"input_filename"});
122  
123 }
124  
125 0 ▶sub _tmp_filename {
Subroutine _tmp_filename: not called CC=2 SCAR=17.9
126 0 my $self = shift;
127  
128 0 ▶ $self->{"input_filename"} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
129  
130 0 return($self->{"input_filename"});
131 }
132  
133 74 ▶sub _output_filename {
Subroutine _output_filename: called CC=2 SCAR=6.9
134 74 my $self = shift;
135  
136 74 ▶ $self->{"output_filename"} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 14 60 74
137  
138 74 return($self->{"output_filename"});
139 }
140  
141 0 ▶sub _out_stream {
Subroutine _out_stream: not called CC=2 SCAR=17.9
142 0 my $self = shift;
143  
144 0 ▶ $self->{"out_stream"} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
145  
146 0 return($self->{"out_stream"});
147 }
148  
149 8454 ▶sub _input_array {
Subroutine _input_array: called CC=2 SCAR=6.9
150 8454 my $self = shift;
151  
152 8454 ▶ $self->{"input_array"} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 6 8448 8454
153  
154 8454 return($self->{"input_array"});
155 }
156  
157 0 ▶sub _output_array {
Subroutine _output_array: not called CC=2 SCAR=17.9
158 0 my $self = shift;
159  
160 0 ▶ $self->{"output_array"} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
161  
162 0 return($self->{"output_array"});
163 }
164  
165 0 ▶sub _addedElements_array {
Subroutine _addedElements_array: not called CC=2 SCAR=17.9
166 0 my $self = shift;
167  
168 0 ▶ $self->{"addedElements_array"} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
169  
170 0 return($self->{"addedElements_array"});
171 }
172  
173 16 ▶sub _input_hash {
Subroutine _input_hash: called CC=2 SCAR=6.9
174 16 my $self = shift;
175  
176 16 ▶ $self->{"input_hash"} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 4 12 16
177  
178 16 return($self->{"input_hash"});
179 }
180  
181 6 ▶sub _output_hash {
Subroutine _output_hash: called CC=2 SCAR=7.1
182 6 my $self = shift;
183  
184 6 ▶ $self->{"output_hash"} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 6 0 6
185  
186 6 return($self->{"output_hash"});
187 }
188  
189 189 ▶sub _config {
Subroutine _config: called CC=2 SCAR=7.1
190 189 my $self = shift;
191  
192 189 ▶ $self->{"config"} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 189 189
193  
194 189 return($self->{"config"});
195  
196 }
197 18 ▶sub _position {
Subroutine _position: called CC=2 SCAR=7.1
198 18 my $self = shift;
199  
200 18 ▶ $self->{"position"} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 18 18
201  
202 18 return($self->{"position"});
203 }
204  
205 0 ▶sub _no_standard_output {
Subroutine _no_standard_output: not called CC=2 SCAR=17.9
206 0 my $self = shift;
207  
208 0 ▶ $self->{"no_standard_output"} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
209  
210 0 return($self->{"no_standard_output"});
211 }
212  
213 0 ▶sub _tmpfile_prefix {
Subroutine _tmpfile_prefix: not called CC=2 SCAR=17.9
214 0 my $self = shift;
215  
216 0 ▶ $self->{"tmpfile_prefix"} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
217  
218 # warn "tmpfile_prefix:" . $self->{"tmpfile_prefix"} . "\n";
219  
220 0 return($self->{"tmpfile_prefix"});
221  
222 }
223  
224 12 ▶sub _logfile {
Subroutine _logfile: called CC=2 SCAR=7.1
225 12 my $self = shift;
226  
227 12 ▶ $self->{"logfile"} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 12 12
228  
229 12 return($self->{"logfile"});
230 }
231  
232 2924 ▶sub _documentSet {
Subroutine _documentSet: called CC=2 SCAR=6.9
233 2924 my $self = shift;
234  
235 2924 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 24 2900 2924
236 24 $self->{'documentSet'} = shift;
237  
238 24 $self->setDocIndex2DocId;
239 24 $self->setDocId2DocIndex;
240 }
241 2924 return($self->{'documentSet'});
242 }
243  
244 24 ▶sub setDocIndex2DocId {
Subroutine setDocIndex2DocId: called CC=2 SCAR=6.9
Pod undocumented
245  
246 24 my ($self) = @_;
247  
248 24 my $i;
249 my @DocIndex2DocId;
250  
251 24 ▶ for($i=0;$i < scalar(@{$self->{'documentSet'}}); $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < scalar @{$self->{"documentSet"};}) 36 24 60
252 36 $DocIndex2DocId[$i] = $self->{'documentSet'}->[$i]->getId;
253 }
254  
255 24 $self->{DocIndex2DocId} = \@DocIndex2DocId;
256 }
257  
258 24 ▶sub setDocId2DocIndex {
Subroutine setDocId2DocIndex: called CC=2 SCAR=6.9
Pod undocumented
259  
260 24 my ($self) = @_;
261  
262 24 my $i;
263 my %DocId2DocIndex;
264  
265 # warn "In setDocId2Index\n";
266  
267 24 ▶ for($i=0;$i < scalar(@{$self->{'documentSet'}}); $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < scalar @{$self->{"documentSet"};}) 36 24 60
268 # warn $self->{'documentSet'}->[$i]->getId . " => $i\n";
269 36 $DocId2DocIndex{$self->{'documentSet'}->[$i]->getId} = $i;
270 }
271  
272 24 $self->{DocId2DocIndex} = \%DocId2DocIndex;
273  
274 }
275  
276 0 ▶sub getDocId2DocIndex {
Subroutine getDocId2DocIndex: not called CC=1 SCAR=6.9
Pod undocumented
277  
278 0 my ($self) = @_;
279  
280 0 return($self->{DocId2DocIndex});
281 }
282  
283 0 ▶sub getDocIndex2DocId {
Subroutine getDocIndex2DocId: not called CC=1 SCAR=6.9
Pod undocumented
284  
285 0 my ($self) = @_;
286  
287 0 return($self->{DocIndex2DocId});
288 }
289  
290 0 ▶sub getDocumentFromDocId {
Subroutine getDocumentFromDocId: not called CC=1 SCAR=6.9
Pod undocumented
291  
292 0 my ($self, $docId) = @_;
293  
294 0 return($self->_documentSet->[$self->getDocId2DocIndex->{$docId}]);
295  
296 }
297  
298 0 ▶sub getDocumentFromRank {
Subroutine getDocumentFromRank: not called CC=1 SCAR=6.9
Pod undocumented
299  
300 0 my ($self, $rank) = @_;
301  
302 0 return($self->_documentSet->[$rank]);
303  
304 }
305  
306 0 ▶sub _getLemmatisedSentence {
Subroutine _getLemmatisedSentence: not called CC=10 SCAR=47.0
307 0 my ($self, $document, $refid_start_token, $refid_end_token) = @_;
308  
309 0 my $word;
310 my $lemma;
311  
312 0 my $sentLemma = "";;
313 0 my $token = $refid_start_token;
314  
315 0 my $token_prec = 0;
316 0 my %offsets;
317  
318 0 ▶ if (defined $token) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $token) 0 0 0
319 0 ▶ do {
Branch: 1 branch
BranchTrueFalseTotal
defined $token and not $token->previous->equals($refid_end_token) and do { do { if ($document->getAnnotations->getWordLevel->existsElementFromIndex("list_refid_token", $token->getId)) { $word = $document->getAnnotations->getWordLevel->getElementFromIndex("list_refid_token", $token->getId)->[0]; $lemma = $document->getAnnotations->getLemmaLevel->getElementFromIndex("refid_word", $word->getId)->[0]; $offsets{length $sentLemma} = $word->reference; if (defined $lemma) { $sentLemma .= $lemma->canonical_form; } else { $sentLemma .= $word->getForm; } ; if (index($word->getForm, "'") == length($word->getForm) - 1) { $sentLemma .= ' '; } ; $token = $word->end_token; $token_prec = 0; } else { $offsets{length $sentLemma} = [$token]; $sentLemma .= $token->getContent; $token_prec = 1; } ; if (defined $token) { $token = $token->next; } } } 0 0 0
Condition0%0/3
defined $token and not $token->previous->equals($refid_end_token)
!ll&&!rl&&r
000
MC/DC0%0/2
defined $token and not $token->previous->equals($refid_end_token)
defined $token not $token->previous->equals($refid_end_token)
Truth table0%0/3
A and not(B)
A= defined $tokenB= not $token->previous->equals($refid_end_token)
ABresult
0X0
100
111
320 # warn $token->getContent . "\n";
321 0 ▶ if ($document->getAnnotations->getWordLevel->existsElementFromIndex("list_refid_token", $token->getId)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($document->getAnnotations->getWordLevel->existsElementFromIndex('list_refid_token', $token->getId)) { } 0 0 0
322 0 $word = $document->getAnnotations->getWordLevel->getElementFromIndex("list_refid_token", $token->getId)->[0];
323 0 $lemma = $document->getAnnotations->getLemmaLevel->getElementFromIndex("refid_word", $word->getId)->[0];
324 # $MS_features = $document->getAnnotations->getMorphosyntacticFeaturesLevel->getElementFromIndex("refid_word", $word->getId)->[0];
325 # warn $word->getFrom . " : " . $lemma->canonical_form . " : " . length($sentLemma) . "($sentLemma)\n";
326 0 $offsets{length($sentLemma)} = $word->reference;
327 0 ▶ if (defined $lemma) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $lemma) { } 0 0 0
328 0 $sentLemma .= $lemma->canonical_form;
329 } else {
330 0 $sentLemma .= $word->getForm;
331 }
332 0 ▶ if (index($word->getForm, "'") == length($word->getForm) - 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (index($word->getForm, "'") == length($word->getForm) - 1) 0 0 0
333 0 $sentLemma .= " ";
334 }
335 0 $token = $word->end_token;
336 0 $token_prec = 0;
337 } else {
338 0 $offsets{length($sentLemma)} = [$token];
339 0 $sentLemma .= $token->getContent;
340 0 $token_prec = 1;
341 }
342 0 ▶ if (defined $token) { # {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $token) 0 0 0
343 0 $token = $token->next;
344 }
345  
346 # warn "=> " . length($sentLemma) . " ($sentLemma)\n";
347 } while((defined $token) && (!($token->previous->equals($refid_end_token))));
348 }
349 # warn (length($sentLemma) - length($token->previous->getContent)) . "\n";
350 # warn scalar(@{$offsets{length($sentLemma) - length($token->previous->getContent)}}) . " -- \n";
351 # warn $offsets{length($sentLemma) - length($token->previous->getContent)}->[0]->getContent . "\n";
352 # warn "-> $token_prec\n";
353 # warn join(";", sort({$a <=> $b} keys %offsets)) . "\n";
354 0 ▶ if (($token_prec == 0) && ($document->getAnnotations->getSectionLevel->existsElementFromIndex("to", $refid_end_token->getId))) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token_prec == 0 and $document->getAnnotations->getSectionLevel->existsElementFromIndex("to", $refid_end_token->getId)) 0 0 0
Condition0%0/3
$token_prec == 0 and $document->getAnnotations->getSectionLevel->existsElementFromIndex("to", $refid_end_token->getId)
!ll&&!rl&&r
000
MC/DC0%0/2
$token_prec == 0 and $document->getAnnotations->getSectionLevel->existsElementFromIndex("to", $refid_end_token->getId)
$token_prec == 0 $document->getAnnotations->getSectionLevel->existsElementFromIndex("to", $refid_end_token->getId)
Truth table0%0/3
A and B
A= $token_prec == 0B= $document->getAnnotations->getSectionLevel->existsElementFromIndex("to", $refid_end_token->getId)
ABresult
0X0
100
111
355 # warn "Add empty\n";
356 0 $offsets{length($sentLemma)} = [];
357 }
358 # warn join(";", sort({$a <=> $b} keys %offsets)) . "\n";
359 # warn join(";", values %offsets) . "\n";
360  
361 # if ((defined $token) && ($token->isSymb)) {
362 # if ($document->getAnnotations->getWordLevel->existsElementFromIndex("list_refid_token", $token->getId)) {
363 # $offsets{length($sentLemma)} = $token;
364 # $sentLemma .= $token->getContent;
365 # }
366 # }
367 # $sentLemma =~ s/ +/ /go;
368 0 return($sentLemma, \%offsets);
369 }
370  
371  
372 2 ▶sub _printTreeTaggerFormatOutput {
Subroutine _printTreeTaggerFormatOutput: called CC=20 SCAR=40.8
373 2 my $self = shift;
374 2 my $filename = shift;
375 2 my $encoding = shift;
376 2 my $printDocId = shift;
377  
378 2 my $fh_out;
379 my $document;
380 2 my $doc_idx;
381 2 my $token;
382 2 my $word;
383 2 my $lemma;
384 2 my $MS_features;
385 2 my @corpus_in_t;
386  
387 2 warn "[LOG] printing TreeTagger Like Output\n";
388  
389 2 my $i = 0;
390 2 foreach $document (@{$self->_documentSet}) {
391 3 warn "$i : " . $document->getId . "\n";
392 3 $i++;
393 3 my @tmp;
394 3 ▶ if ((!defined $printDocId) || ($printDocId)) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $printDocId or $printDocId) 3 0 3
Condition33%1/3
not defined $printDocId or $printDocId
l!l&&r!l&&!r
300
MC/DC0%0/2
not defined $printDocId or $printDocId
not defined $printDocId $printDocId
Truth table33%1/3
not(A) or B
A= not defined $printDocIdB= $printDocId
ABresult
1X1
011
000
395 3 @tmp = ($document->getId, "DOCUMENT", $document->getId);
396 3 push @corpus_in_t, \@tmp;
397 }
398
399 3 ▶ for($doc_idx = 0; $doc_idx < scalar(@{$document->getAnnotations->getTokenLevel->getElements});$doc_idx++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($doc_idx < scalar @{$document->getAnnotations->getTokenLevel->getElements;}) 1717 3 1720
400 # warn "doc_idx: $doc_idx\n";
401 1717 $token = $document->getAnnotations->getTokenLevel->getElements->[$doc_idx];
402 1717 ▶ if ($document->getAnnotations->getWordLevel->existsElementFromIndex("list_refid_token", $token->getId)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($document->getAnnotations->getWordLevel->existsElementFromIndex('list_refid_token', $token->getId)) { } 0 1717 1717
403 0 $word = $document->getAnnotations->getWordLevel->getElementFromIndex("list_refid_token", $token->getId)->[0];
404 0 $lemma = $document->getAnnotations->getLemmaLevel->getElementFromIndex("refid_word", $word->getId)->[0];
405 0 $MS_features = $document->getAnnotations->getMorphosyntacticFeaturesLevel->getElementFromIndex("refid_word", $word->getId)->[0];
406 0 my $wordform = $word->getForm;
407 0 $wordform =~ s/[\t\n]/ /gos;
408 0 $wordform =~ s/ +/ /gos;
409
410 0 my @tmp = ($wordform, $MS_features->syntactic_category, $lemma->canonical_form);
411  
412 0 push @corpus_in_t, \@tmp;
413  
414 0 $doc_idx += $word->getReferenceSize - 1;
415 # warn "doc_idx (new value): $doc_idx\n";
416 0 $token = $document->getAnnotations->getTokenLevel->getElements->[$doc_idx];
417
418 } else {
419 1717 ▶ if (!($token->isSep)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($token->isSep) 937 780 1717
420 937 ▶ if ($token->getContent =~ /[\x{2019}\x{2032}']/go) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token->getContent =~ /[\x{2019}\x{2032}']/go) { } 2 935 937
421 2 $corpus_in_t[$#corpus_in_t]->[0] .= $token->getContent;
422 } else {
423 935 my @tmp = ($token->getContent, $token->getContent, $token->getContent);
424 935 push @corpus_in_t, \@tmp;
425 }
426 }
427 }
428 1717 ▶ if ($document->getAnnotations->getSentenceLevel->existsElementFromIndex("refid_end_token", $token->getId)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($document->getAnnotations->getSentenceLevel->existsElementFromIndex("refid_end_token", $token->getId)) 41 1676 1717
429 41 ▶ if ($token->isSymb) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token->isSymb) { } 38 3 41
430 38 ▶ if (!($document->getAnnotations->getWordLevel->existsElementFromIndex("list_refid_token", $token->getId))) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $document->getAnnotations->getWordLevel->existsElementFromIndex('list_refid_token', $token->getId)) { } 38 0 38
431 38 my @tmp = ($corpus_in_t[$#corpus_in_t]->[0] , "SENT", $corpus_in_t[$#corpus_in_t]->[0]);
432 38 $corpus_in_t[$#corpus_in_t] = \@tmp;
433 } else {
434 0 my @tmp = ($token->getContent, "SENT", $token->getContent);
435 0 push @corpus_in_t, \@tmp;
436 }
437 } else {
438 3 my @tmp = (".", "SENT", ".");
439 3 push @corpus_in_t, \@tmp;
440 }
441 }
442 }
443 }
444  
445 2 warn "\tOpenning " . $filename . "\n";
446 2 ▶ if ($filename ne "stdout") {
Branch: 1 branch
BranchTrueFalseTotal
if ($filename ne 'stdout') { } 2 0 2
447 2 ▶ open $fh_out, ">". $filename or die "can't open " . $filename . "\n";
Branch: 1 branch
BranchTrueFalseTotal
open $fh_out, '>' . $filename or die q[can't open ] . $filename . "\n" 0 2 2
448 } else {
449 0 $fh_out = \*STDOUT;
450 }
451  
452  
453 0 my $word_ref;
454 0 foreach $word_ref (@corpus_in_t) {
455  
456 0 ▶ if ($word_ref->[0] =~ s/ /_/go) {
Branch: 1 branch
BranchTrueFalseTotal
if ($word_ref->[0] =~ s/ /_/go) 0 0 0
457 0 $word_ref->[2] =~ s/ /_/go;
458 }
459  
460 0 ▶ if ($word_ref->[0] =~ s/[\x{2019}\x{2032}]/\'/go) {
Branch: 1 branch
BranchTrueFalseTotal
if ($word_ref->[0] =~ s/[\x{2019}\x{2032}]/'/go) 0 0 0
461 0 $word_ref->[1] =~ s/[\x{2019}\x{2032}]/\'/go;
462 0 $word_ref->[2] =~ s/[\x{2019}\x{2032}]/\'/go;
463 }
464  
465 # Encode::encode("iso-8859-1", join("\n",@corpus_in_t), Encode::FB_DEFAULT);
466 0 ▶ if ((!defined $encoding) || (uc($encoding) eq "UTF-8")) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $encoding or uc $encoding eq 'UTF-8') { } 0 0 0
Condition0%0/3
not defined $encoding or uc $encoding eq "UTF-8"
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $encoding or uc $encoding eq "UTF-8"
not defined $encoding uc $encoding eq "UTF-8"
Truth table0%0/3
not(A) or B
A= not defined $encodingB= uc $encoding eq "UTF-8"
ABresult
1X1
011
000
467 0 print $fh_out Encode::encode("UTF-8", join("\t",@$word_ref)) . "\n";
468 } else {
469 0 ▶ if ((defined $encoding) && (uc($encoding) eq "LATIN1")) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $encoding and uc $encoding eq 'LATIN1') { } 0 0 0
Condition0%0/3
defined $encoding and uc $encoding eq "LATIN1"
!ll&&!rl&&r
000
MC/DC0%0/2
defined $encoding and uc $encoding eq "LATIN1"
defined $encoding uc $encoding eq "LATIN1"
Truth table0%0/3
A and B
A= defined $encodingB= uc $encoding eq "LATIN1"
ABresult
0X0
100
111
470 # print FILE_IN Encode::encode("iso-8859-1", join("\t",@$word_ref), Encode::FB_DEFAULT) . "\n";
471 0 print $fh_out Encode::encode("iso-8859-1", join("\t",@$word_ref)) . "\n";
472 } else {
473 0 warn "[WRAPPER LOG] Unknown enconding charset\n";
474 }
475 }
476 }
477  
478 0 close $fh_out;
479 0 warn "[LOG] done\n";
480 }
481  
482  
483 0 ▶sub _createTermFromStartEndTokens {
Subroutine _createTermFromStartEndTokens: not called CC=3 SCAR=24.8
484 0 my ($self, $document, $token_start, $token_end) = @_;
485  
486 0 my @tokens;
487  
488 0 my $term_content = "";
489  
490 0 my $token = $token_start;
491  
492 # warn "start_token: " . $token->getFrom . " (" . $token->getContent . ")\n";
493 0 $term_content = $token->getContent;
494  
495 0 push @tokens, $token;
496 0 ▶ while((defined $token) && (!$token->equals($token_end))) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $token and not $token->equals($token_end)) 0 0 0
Condition0%0/3
defined $token and not $token->equals($token_end)
!ll&&!rl&&r
000
MC/DC0%0/2
defined $token and not $token->equals($token_end)
defined $token not $token->equals($token_end)
Truth table0%0/3
A and not(B)
A= defined $tokenB= not $token->equals($token_end)
ABresult
0X0
100
111
497 0 $token = $token->next;
498 0 $term_content .= $token->getContent;
499 0 push @tokens, $token;
500 }
501 # warn "term_content: $term_content\n";
502 0 return($self->_createTerm($document, \@tokens, $term_content));
503  
504 }
505  
506 0 ▶sub _changeSemanticFeatures {
Subroutine _changeSemanticFeatures: not called CC=6 SCAR=37.4
507 0 my ($self, $document, $oldTerm1, $oldTerm2, $newTerm) = @_;
508  
509 0 my $semf;
510  
511 0 ▶ if (defined $document->getAnnotations->getSemanticFeaturesLevel->getElementFromIndex("refid_semantic_unit", $oldTerm1->getId)->[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $document->getAnnotations->getSemanticFeaturesLevel->getElementFromIndex('refid_semantic_unit', $oldTerm1->getId)->[0]) { } 0 0 0
512 0 ▶ if ((defined $oldTerm2) && (defined $document->getAnnotations->getSemanticFeaturesLevel->getElementFromIndex("refid_semantic_unit", $oldTerm2->getId)->[0])) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $oldTerm2 and defined $document->getAnnotations->getSemanticFeaturesLevel->getElementFromIndex('refid_semantic_unit', $oldTerm2->getId)->[0]) { } 0 0 0
Condition0%0/3
defined $oldTerm2 and defined $document->getAnnotations->getSemanticFeaturesLevel->getElementFromIndex("refid_semantic_unit", $oldTerm2->getId)->[0]
!ll&&!rl&&r
000
MC/DC0%0/2
defined $oldTerm2 and defined $document->getAnnotations->getSemanticFeaturesLevel->getElementFromIndex("refid_semantic_unit", $oldTerm2->getId)->[0]
defined $oldTerm2 defined $document->getAnnotations->getSemanticFeaturesLevel->getElementFromIndex("refid_semantic_unit", $oldTerm2->getId)->[0]
Truth table0%0/3
A and B
A= defined $oldTerm2B= defined $document->getAnnotations->getSemanticFeaturesLevel->getElementFromIndex("refid_semantic_unit", $oldTerm2->getId)->[0]
ABresult
0X0
100
111
513 0 my $semFeatures = Lingua::Ogmios::Annotations::SemanticFeatures->new(
514 { 'semantic_category' => $document->getAnnotations->getSemanticFeaturesLevel->getElementFromIndex("refid_semantic_unit", $self->_getLargerTerm([$oldTerm1, $oldTerm2])->getId)->[0]->semantic_category,
515 'refid_semantic_unit' => $newTerm->getId,
516 });
517 0 $document->getAnnotations->addSemanticFeatures($semFeatures);
518
519
520 } else {
521 0 my $semFeatures = Lingua::Ogmios::Annotations::SemanticFeatures->new(
522 { 'semantic_category' => $document->getAnnotations->getSemanticFeaturesLevel->getElementFromIndex("refid_semantic_unit", $oldTerm1->getId)->[0]->semantic_category,
523 'refid_semantic_unit' => $newTerm->getId,
524 });
525 0 $document->getAnnotations->addSemanticFeatures($semFeatures);
526 }
527 } else {
528 0 ▶ if ((defined $oldTerm2) && (defined $document->getAnnotations->getSemanticFeaturesLevel->getElementFromIndex("refid_semantic_unit", $oldTerm2->getId)->[0])) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $oldTerm2 and defined $document->getAnnotations->getSemanticFeaturesLevel->getElementFromIndex("refid_semantic_unit", $oldTerm2->getId)->[0]) 0 0 0
Condition0%0/3
defined $oldTerm2 and defined $document->getAnnotations->getSemanticFeaturesLevel->getElementFromIndex("refid_semantic_unit", $oldTerm2->getId)->[0]
!ll&&!rl&&r
000
MC/DC0%0/2
defined $oldTerm2 and defined $document->getAnnotations->getSemanticFeaturesLevel->getElementFromIndex("refid_semantic_unit", $oldTerm2->getId)->[0]
defined $oldTerm2 defined $document->getAnnotations->getSemanticFeaturesLevel->getElementFromIndex("refid_semantic_unit", $oldTerm2->getId)->[0]
Truth table0%0/3
A and B
A= defined $oldTerm2B= defined $document->getAnnotations->getSemanticFeaturesLevel->getElementFromIndex("refid_semantic_unit", $oldTerm2->getId)->[0]
ABresult
0X0
100
111
529 0 my $semFeatures = Lingua::Ogmios::Annotations::SemanticFeatures->new(
530 { 'semantic_category' => $document->getAnnotations->getSemanticFeaturesLevel->getElementFromIndex("refid_semantic_unit", $oldTerm2->getId)->[0]->semantic_category,
531 'refid_semantic_unit' => $newTerm->getId,
532 });
533 0 $document->getAnnotations->addSemanticFeatures($semFeatures);
534 }
535 }
536 }
537  
538 0 ▶sub _getLargerTerm {
Subroutine _getLargerTerm: not called CC=5 SCAR=34.0
539 0 my ($self, $terms) = @_;
540  
541 0 my $largerTerm;
542 my $tmpTerm;
543  
544 0 $largerTerm = $terms->[0];
545  
546 0 foreach $tmpTerm (@$terms) {
547 0 ▶ if (!$tmpTerm->equals($largerTerm)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($tmpTerm->equals($largerTerm)) 0 0 0
548 0 ▶ if (($tmpTerm->start_token->getFrom < $largerTerm->start_token->getFrom ) ||
Branch: 1 branch
BranchTrueFalseTotal
if ($tmpTerm->start_token->getFrom < $largerTerm->start_token->getFrom or $largerTerm->end_token->getTo < $tmpTerm->end_token->getTo) 0 0 0
Condition0%0/3
$tmpTerm->start_token->getFrom < $largerTerm->start_token->getFrom or $largerTerm->end_token->getTo < $tmpTerm->end_token->getTo
l!l&&r!l&&!r
000
MC/DC0%0/2
$tmpTerm->start_token->getFrom < $largerTerm->start_token->getFrom or $largerTerm->end_token->getTo < $tmpTerm->end_token->getTo
$tmpTerm->start_token->getFrom < $largerTerm->start_token->getFrom $largerTerm->end_token->getTo < $tmpTerm->end_token->getTo
Truth table0%0/3
A or B
A= $tmpTerm->start_token->getFrom < $largerTerm->start_token->getFromB= $largerTerm->end_token->getTo < $tmpTerm->end_token->getTo
ABresult
1X1
011
000
549 ($largerTerm->end_token->getTo < $tmpTerm->end_token->getTo)) {
550 0 $largerTerm = $tmpTerm
551 }
552 }
553 }
554 0 return($largerTerm);
555 }
556  
557  
558  
559 0 ▶sub _createTerm {
Subroutine _createTerm: not called CC=20 SCAR=60.4
560 0 my ($self, $document, $termTokens, $term_content, $termType) = @_;
561  
562 0 my $token_offset = $termTokens->[0];
563 0 my @termWords;
564  
565 my $termUnit;
566  
567 0 $termUnit = $document->getAnnotations->getSemanticUnitLevel->getElementByStartEndTokens($termTokens->[0], $termTokens->[scalar(@$termTokens) - 1]);
568  
569 0 ▶ if (!defined $termUnit) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $termUnit) { } 0 0 0
570 0 ▶ do {
Branch: 1 branch
BranchTrueFalseTotal
defined $token_offset and $token_offset->getTo < $$termTokens[$termTokens->$#*]->next->getTo and do { do { if ($document->getAnnotations->getWordLevel->existsElementFromIndex("list_refid_token", $token_offset->getId)) { push @termWords, $document->getAnnotations->getWordLevel->getElementFromIndex("list_refid_token", $token_offset->getId)->[0]; $token_offset = $termWords[$#termWords]->getLastToken; } ; $token_offset = $token_offset->next } } 0 0 0
Condition0%0/3
defined $token_offset and $token_offset->getTo < $$termTokens[$termTokens->$#*]->next->getTo
!ll&&!rl&&r
000
MC/DC0%0/2
defined $token_offset and $token_offset->getTo < $$termTokens[$termTokens->$#*]->next->getTo
defined $token_offset $token_offset->getTo < $$termTokens[$termTokens->$#*]->next->getTo
Truth table0%0/3
A and B
A= defined $token_offsetB= $token_offset->getTo < $$termTokens[$termTokens->$#*]->next->getTo
ABresult
0X0
100
111
571 0 ▶ if ($document->getAnnotations->getWordLevel->existsElementFromIndex("list_refid_token", $token_offset->getId)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($document->getAnnotations->getWordLevel->existsElementFromIndex("list_refid_token", $token_offset->getId)) 0 0 0
572 ## search the last word
573 0 push @termWords, $document->getAnnotations->getWordLevel->getElementFromIndex("list_refid_token", $token_offset->getId)->[0];
574 0 $token_offset = $termWords[$#termWords]->getLastToken;
575 }
576 0 $token_offset = $token_offset->next;
577 } while((defined $token_offset) && ($token_offset->getTo < $termTokens->[$#$termTokens]->next->getTo));
578  
579 0 ▶ if ((scalar @termWords != 0) &&
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @termWords != 0 and $$termTokens[$termTokens->$#*]->getTo != $termWords[$#termWords]->getLastToken->getTo || $termTokens->[0]->getFrom != $termWords[0]->start_token->getFrom) 0 0 0
Condition0%0/6
scalar @termWords != 0 and $$termTokens[$termTokens->$#*]->getTo != $termWords[$#termWords]->getLastToken->getTo || $termTokens->[0]->getFrom != $termWords[0]->start_token->getFrom
!ll&&!rl&&r
000
$$termTokens[$termTokens->$#*]->getTo != $termWords[$#termWords]->getLastToken->getTo or $termTokens->[0]->getFrom != $termWords[0]->start_token->getFrom
l!l&&r!l&&!r
000
MC/DC0%0/3
scalar @termWords != 0 and $$termTokens[$termTokens->$#*]->getTo != $termWords[$#termWords]->getLastToken->getTo || $termTokens->[0]->getFrom != $termWords[0]->start_token->getFrom
scalar @termWords != 0 $$termTokens[$termTokens->$#*]->getTo != $termWords[$#termWords]->getLastToken->getTo $termTokens->[0]->getFrom != $termWords[0]->start_token->getFrom
Truth table0%0/4
A and B or C
A= scalar @termWords != 0B= $$termTokens[$termTokens->$#*]->getTo != $termWords[$#termWords]->getLastToken->getToC= $termTokens->[0]->getFrom != $termWords[0]->start_token->getFrom
ABCresult
0XX0
1000
11X1
1011
580 (($termTokens->[$#$termTokens]->getTo != $termWords[$#termWords]->getLastToken->getTo) ||
581 ($termTokens->[0]->getFrom != $termWords[0]->start_token->getFrom))) {
582 0 @termWords = ();
583 }
584 0 ▶ if (scalar @termWords == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @termWords == 0) 0 0 0
585 # term is a token list
586 0 my @localTermTokens = @$termTokens;
587 0 ▶ if ((!defined($termType)) || ($termType eq "term")) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $termType or $termType eq 'term') { } 0 0 0
Condition0%0/3
not defined $termType or $termType eq "term"
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $termType or $termType eq "term"
not defined $termType $termType eq "term"
Truth table0%0/3
not(A) or B
A= not defined $termTypeB= $termType eq "term"
ABresult
1X1
011
000
588 0 $termUnit = Lingua::Ogmios::Annotations::SemanticUnit->newTerm(
589 {'form' => $term_content,
590 'list_refid_token' => \@localTermTokens,
591 });
592 # warn "create Term (a)\n";
593 } else {
594 0 ▶ if ($termType eq "named_entity") {
Branch: 1 branch
BranchTrueFalseTotal
if ($termType eq "named_entity") 0 0 0
595 0 $termUnit = Lingua::Ogmios::Annotations::SemanticUnit->newNamedEntity(
596 {'form' => $term_content,
597 'list_refid_token' => \@localTermTokens,
598 'named_entity_type' => "",
599 });
600 # warn "create Named Entity (a)\n";
601 }
602 }
603 }
604 0 ▶ if (scalar @termWords == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @termWords == 1) 0 0 0
605 # term is a word
606 0 $term_content = $termWords[0]->getForm;
607 0 ▶ if ((!defined($termType)) || ($termType eq "term")) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $termType or $termType eq 'term') { } 0 0 0
Condition0%0/3
not defined $termType or $termType eq "term"
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $termType or $termType eq "term"
not defined $termType $termType eq "term"
Truth table0%0/3
not(A) or B
A= not defined $termTypeB= $termType eq "term"
ABresult
1X1
011
000
608 0 $termUnit = Lingua::Ogmios::Annotations::SemanticUnit->newTerm(
609 {'form' => $term_content,
610 'refid_word' => $termWords[0],
611 });
612 # warn "create Term (b)\n";
613 } else {
614 0 ▶ if ($termType eq "named_entity") {
Branch: 1 branch
BranchTrueFalseTotal
if ($termType eq "named_entity") 0 0 0
615 0 $termUnit = Lingua::Ogmios::Annotations::SemanticUnit->newNamedEntity(
616 {'form' => $term_content,
617 'refid_word' => $termWords[0],
618 'named_entity_type' => "",
619 });
620 # warn "create Named Entity (b)\n";
621 }
622 }
623 }
624 0 ▶ if (scalar @termWords > 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @termWords > 1) 0 0 0
625 # term is a phrase
626 0 my $phrase = Lingua::Ogmios::Annotations::Phrase->new(
627 { 'refid_word' => \@termWords,
628 'form' => $term_content,
629 }
630 );
631  
632 0 $document->getAnnotations->addPhrase($phrase);
633 0 ▶ if ((!defined($termType)) || ($termType eq "term")) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $termType or $termType eq 'term') { } 0 0 0
Condition0%0/3
not defined $termType or $termType eq "term"
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $termType or $termType eq "term"
not defined $termType $termType eq "term"
Truth table0%0/3
not(A) or B
A= not defined $termTypeB= $termType eq "term"
ABresult
1X1
011
000
634 0 $termUnit = Lingua::Ogmios::Annotations::SemanticUnit->newTerm(
635 {'form' => $term_content,
636 'refid_phrase' => $phrase,
637 });
638 # warn "create Term (c)\n";
639 } else {
640 0 ▶ if ($termType eq "named_entity") {
Branch: 1 branch
BranchTrueFalseTotal
if ($termType eq "named_entity") 0 0 0
641 0 $termUnit = Lingua::Ogmios::Annotations::SemanticUnit->newNamedEntity(
642 {'form' => $term_content,
643 'refid_phrase' => $phrase,
644 'named_entity_type' => "",
645 });
646 # warn "create Named Entity (c)\n";
647 }
648 }
649 }
650 } else {
651 0 warn "$term_content already exists\n";
652
653 }
654 0 return($termUnit);
655 }
656  
657 0 ▶sub HTMLoutput {
Subroutine HTMLoutput: not called CC=14 SCAR=53.5
Pod undocumented
658 0 my $self = shift;
659  
660 0 my $document;
661 my $doc_token_idx;
662 0 my $token;
663 0 my $word;
664 0 my $term;
665 0 my $phrase;
666 0 my $doc_str;
667 0 my $i;
668 0 my $phraseWords;
669 0 my $termToken;
670 0 my %NEtypeColor;
671 0 my $sentId;
672 0 my %colorTypes;
673 # my %TermtypeColor = ("test", "0000FF", "problem", "FF0000", "treatment" , "00FF00") ;
674  
675 0 my $TermtypeColor = $self->_loadColors; # OR ("test", "0000FF", "problem", "FF0000", "treatment" , "00FF00") ;
676
677 # %NEtypeColor = %$TermtypeColor;
678  
679 0 my $semf;
680 my $idColor;
681  
682 0 my $color = "FFCBDB";
683  
684  
685 0 my $headerStart = << 'EOH';
686 <html>
687 <head>
688 <title>Tagged term candidates</title>
689 <link href="i2b2Style.css" rel="stylesheet" type="text/css"/>
690 <SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript" SRC="infobox.js"></SCRIPT>
691 EOH
692  
693 0 my $headerEnd = << 'EOH';
694 </head><body>
695 EOH
696  
697  
698 0 my $footer = << 'EOF';
699 </body></html>
700 EOF
701  
702 0 foreach $document (@{$self->_documentSet}) {
703 0 $doc_str = "";
704 0 ▶ for($doc_token_idx = 0; $doc_token_idx < scalar(@{$document->getAnnotations->getTokenLevel->getElements});$doc_token_idx++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($doc_token_idx < scalar @{$document->getAnnotations->getTokenLevel->getElements;}) 0 0 0
705 0 $token = $document->getAnnotations->getTokenLevel->getElements->[$doc_token_idx];
706  
707 0 ▶ if ($document->getAnnotations->getSentenceLevel->existsElementFromIndex("refid_start_token", $token->getId)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($document->getAnnotations->getSentenceLevel->existsElementFromIndex("refid_start_token", $token->getId)) 0 0 0
708 0 $sentId = $document->getAnnotations->getSentenceLevel->getElementFromIndex("refid_start_token", $token->getId)->[0]->getId;
709 0 $doc_str .= "<div id=\"" . $document->getId . "-$sentId" . "\" style=\"display:block\">\n";
710 }
711 0 $color = "FFCBDB";
712 # warn $token->getContent . "\n";
713 # if ($document->getAnnotations->getSemanticUnitLevel->existsElementFromIndex("list_refid_token", $token->getId)) {
714 0 ▶ if ($document->getAnnotations->getSemanticUnitLevel->existsElementByToken($token)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($document->getAnnotations->getSemanticUnitLevel->existsElementByToken($token)) { } 0 0 0
715 0 $term = $self->_getLargerTerm($document->getAnnotations->getSemanticUnitLevel->getElementByToken($token));
716 # warn "TermForm: " . $term->getForm . "\n";
717 0 ▶ if ($term->isNamedEntity) {
Branch: 1 branch
BranchTrueFalseTotal
if ($term->isNamedEntity) { } 0 0 0
718 0 $idColor = $self->_getIdColor($term->NEtype, \%colorTypes);
719  
720 } else {
721 0 ▶ if ($document->getAnnotations->getSemanticFeaturesLevel->existsElementFromIndex("refid_semantic_unit", $term->getId)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($document->getAnnotations->getSemanticFeaturesLevel->existsElementFromIndex("refid_semantic_unit", $term->getId)) 0 0 0
722 0 $semf = $document->getAnnotations->getSemanticFeaturesLevel->getElementFromIndex("refid_semantic_unit", $term->getId)->[0];
723 0 ▶ if (defined $semf) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $semf) 0 0 0
724 0 $idColor = $self->_getIdColor($semf->first_node_first_semantic_category, \%colorTypes);
725 }
726 }
727 }
728 0 $doc_str .= $self->_genHTMLTagSemUnit_start($idColor);
729 0 $termToken = $term->start_token;
730 0 ▶ while(!$termToken->equals($token)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($termToken->equals($token)) 0 0 0
731 0 $termToken = $termToken->next;
732 }
733 0 ▶ while(!$termToken->equals($term->end_token)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($termToken->equals($term->end_token)) 0 0 0
734 0 $doc_str .= $termToken->getContent;
735 0 $termToken = $termToken->next;
736 }
737 0 ▶ if (defined $termToken) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $termToken) 0 0 0
738 0 $doc_str .= $termToken->getContent;
739 }
740 0 $doc_str .= $self->_genHTMLTagSemUnit_end;
741 # warn "Size: " . $term->getReferenceTokenSize . " $doc_str\n";
742 0 $doc_token_idx += $term->getReferenceTokenSize - 1;
743 # next;
744 # } elsif ($document->getAnnotations->getWordLevel->existsElementFromIndex("list_refid_token", $token->getId)) {
745 # $word = $document->getAnnotations->getWordLevel->getElementFromIndex("list_refid_token", $token->getId)->[0];
746 # warn "passe" . $word->getForm . "\n";
747 # if ($document->getAnnotations->getPhraseLevel->existsElementFromIndex("refid_word", $word->getId)) {
748 # $phrase = $document->getAnnotations->getPhraseLevel->getElementFromIndex("refid_word", $word->getId)->[0];
749 # if ($document->getAnnotations->getSemanticUnitLevel->existsElementFromIndex("refid_phrase", $phrase->getId)) {
750 # $term = $document->getAnnotations->getSemanticUnitLevel->getElementFromIndex("refid_phrase", $phrase->getId)->[0];
751 # if ($term->isNamedEntity) {
752 # $idColor = $self->_getIdColor($term->NEtype, \%colorTypes);
753 # } else {
754 # if ($document->getAnnotations->getSemanticFeaturesLevel->existsElementFromIndex("refid_semantic_unit", $term->getId)) {
755 # $semf = $document->getAnnotations->getSemanticFeaturesLevel->getElementFromIndex("refid_semantic_unit", $term->getId)->[0];
756 # $idColor = $self->_getIdColor($semf->first_node_first_semantic_category, \%colorTypes);
757 # }
758 # }
759 # $doc_str .= $self->_genHTMLTagSemUnit_start($idColor);
760 # $i = 0;
761 # $phraseWords = $phrase->reference;
762 # while(($i < scalar(@$phraseWords)) && (!$word->equals($phraseWords->[$i]))) {
763 # $i++;
764 # }
765 # while($i < scalar(@$phraseWords)) {
766 # $doc_str .= $phraseWords->[$i]->getForm;
767 # $i++;
768 # }
769 # $doc_str .= $self->_genHTMLTagSemUnit_end;
770 # $doc_token_idx += $phrase->getReferenceSize - 1;
771 # # next;
772 # }
773 # } else {
774 # if ($document->getAnnotations->getSemanticUnitLevel->existsElementFromIndex("refid_word", $word->getId)) {
775 # $term = $document->getAnnotations->getSemanticUnitLevel->getElementFromIndex("refid_word", $word->getId)->[0];
776 # if ($term->isNamedEntity) {
777 # $idColor = $self->_getIdColor($term->NEtype, \%colorTypes);
778 # } else {
779 # if ($document->getAnnotations->getSemanticFeaturesLevel->existsElementFromIndex("refid_semantic_unit", $term->getId)) {
780 # $semf = $document->getAnnotations->getSemanticFeaturesLevel->getElementFromIndex("refid_semantic_unit", $term->getId)->[0];
781  
782 # $idColor = $self->_getIdColor($semf->first_node_first_semantic_category, \%colorTypes);
783  
784 # }
785 # }
786 # $doc_str .= $self->_genHTMLTagSemUnit($idColor, $term->getForm);
787 # $doc_token_idx += $word->getReferenceSize - 1;
788 # # next;
789 # }
790 # }
791 } else {
792 0 $doc_str .= $token->getContent;
793 }
794 0 ▶ if ($document->getAnnotations->getSentenceLevel->existsElementFromIndex("refid_end_token", $token->getId)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($document->getAnnotations->getSentenceLevel->existsElementFromIndex("refid_end_token", $token->getId)) 0 0 0
795 0 $doc_str .= "<\/div>\n<p/>\n";
796 }
797 }
798 0 $doc_str =~ s/\n/\n<P>\n/go;
799  
800 0 print "$headerStart\n";
801  
802 0 print "$headerEnd\n";
803 0 print '<DIV ID="infodiv" STYLE="position:absolute; visibility:hidden; z-index:20; top:0px; left:0px;"></DIV>' . "\n";
804 0 print '<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">' . "\n";
805 0 print "maketip('Terms','Semantic type','Untagged Terms');\n";
806  
807 0 foreach my $Termtype (sort {$colorTypes{$b} cmp $colorTypes{$a}} keys %colorTypes) {
808 0 $idColor = $colorTypes{$Termtype};
809 0 print "maketip('" . $idColor . "','Semantic type','" . $Termtype . "');\n";
810 }
811  
812 0 print '</SCRIPT>' . "\n";
813 0 print "<BR><B>document ID: " . $document->getId . "</B><BR>\n";
814 0 print "<HR>\n";
815 0 print "colors: <BR>\n<ul>\n";
816 0 $color = "FFCBDB"; # 0000FF
817 0 print "<li><a class=\"Terms\">Terms</a></li>\n";
818 0 foreach my $Termtype (sort {$colorTypes{$b} cmp $colorTypes{$a}} keys %colorTypes) {
819 0 $idColor = $colorTypes{$Termtype};
820 0 print "<li><a class=\"" . $idColor . "\">$Termtype = $idColor</a></li>\n";
821 }
822
823 0 print "</ul>\n<HR>\n";
824 0 print $doc_str;
825 0 print "\n<HR>\n";
826 }
827 0 print "\n$footer\n"
828 }
829  
830 0 ▶sub HTMLoutputOld {
Subroutine HTMLoutputOld: not called CC=22 SCAR=62.3
Pod undocumented
831 0 my $self = shift;
832  
833 0 my $document;
834 my $doc_token_idx;
835 0 my $token;
836 0 my $word;
837 0 my $term;
838 0 my $phrase;
839 0 my $doc_str;
840 0 my $i;
841 0 my $phraseWords;
842 0 my $termToken;
843 0 my %NEtypeColor;
844  
845 # my %TermtypeColor = ("test", "0000FF", "problem", "FF0000", "treatment" , "00FF00") ;
846  
847 0 my $TermtypeColor = $self->_loadColors; # OR ("test", "0000FF", "problem", "FF0000", "treatment" , "00FF00") ;
848
849 # %NEtypeColor = %$TermtypeColor;
850  
851 0 my $semf;
852 0 my $color = "FFCBDB";
853  
854 0 my $header = << 'EOH';
855 <html>
856 <head>
857 <title>Tagged term candidates</title>
858 </head><body>
859 EOH
860  
861 0 my $footer = << 'EOF';
862 </body></html>
863 EOF
864  
865 0 print "$header\n";
866 0 foreach $document (@{$self->_documentSet}) {
867 0 $doc_str = "";
868 0 ▶ for($doc_token_idx = 0; $doc_token_idx < scalar(@{$document->getAnnotations->getTokenLevel->getElements});$doc_token_idx++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($doc_token_idx < scalar @{$document->getAnnotations->getTokenLevel->getElements;}) 0 0 0
869 0 $token = $document->getAnnotations->getTokenLevel->getElements->[$doc_token_idx];
870 0 $color = "FFCBDB";
871 0 ▶ if ($document->getAnnotations->getSemanticUnitLevel->existsElementFromIndex("list_refid_token", $token->getId)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($document->getAnnotations->getSemanticUnitLevel->existsElementFromIndex("list_refid_token", $token->getId)) 0 0 0
872 0 $term = $document->getAnnotations->getSemanticUnitLevel->getElementFromIndex("list_refid_token", $token->getId)->[0];
873 0 ▶ if ($term->isNamedEntity) {
Branch: 1 branch
BranchTrueFalseTotal
if ($term->isNamedEntity) { } 0 0 0
874 0 $color = $self->_determinedColor($term->NEtype, $TermtypeColor);
875  
876 } else {
877 0 ▶ if ($document->getAnnotations->getSemanticFeaturesLevel->existsElementFromIndex("refid_semantic_unit", $term->getId)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($document->getAnnotations->getSemanticFeaturesLevel->existsElementFromIndex("refid_semantic_unit", $term->getId)) 0 0 0
878 0 $semf = $document->getAnnotations->getSemanticFeaturesLevel->getElementFromIndex("refid_semantic_unit", $term->getId)->[0];
879 0 $color = $self->_determinedColor($semf->first_node_first_semantic_category, $TermtypeColor);
880 }
881 }
882 # $doc_str .= "<B><FONT COLOR =\"$color\">" . $term->getForm . "</FONT></B>";
883 0 $doc_str .= "<B><FONT COLOR =\"$color\">";
884 # $doc_str .= $term->getForm;
885 0 $termToken = $term->start_token;
886 0 ▶ while(!$termToken->equals($token)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($termToken->equals($token)) 0 0 0
887 0 $termToken = $termToken->next;
888 }
889 0 ▶ while(!$termToken->equals($term->end_token)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($termToken->equals($term->end_token)) 0 0 0
890 0 $doc_str .= $termToken->getContent;
891 0 $termToken = $termToken->next;
892 }
893 0 ▶ if (defined $termToken) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $termToken) 0 0 0
894 0 $doc_str .= $termToken->getContent;
895 }
896 0 $doc_str .= "</FONT></B>";
897 0 $doc_token_idx += $term->getReferenceSize - 1;
898 0 next;
899 }
900 0 ▶ if ($document->getAnnotations->getWordLevel->existsElementFromIndex("list_refid_token", $token->getId)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($document->getAnnotations->getWordLevel->existsElementFromIndex("list_refid_token", $token->getId)) 0 0 0
901 0 $word = $document->getAnnotations->getWordLevel->getElementFromIndex("list_refid_token", $token->getId)->[0];
902 0 ▶ if ($document->getAnnotations->getPhraseLevel->existsElementFromIndex("refid_word", $word->getId)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($document->getAnnotations->getPhraseLevel->existsElementFromIndex('refid_word', $word->getId)) { } 0 0 0
903 0 $phrase = $document->getAnnotations->getPhraseLevel->getElementFromIndex("refid_word", $word->getId)->[0];
904 0 ▶ if ($document->getAnnotations->getSemanticUnitLevel->existsElementFromIndex("refid_phrase", $phrase->getId)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($document->getAnnotations->getSemanticUnitLevel->existsElementFromIndex("refid_phrase", $phrase->getId)) 0 0 0
905 0 $term = $document->getAnnotations->getSemanticUnitLevel->getElementFromIndex("refid_phrase", $phrase->getId)->[0];
906 0 ▶ if ($term->isNamedEntity) {
Branch: 1 branch
BranchTrueFalseTotal
if ($term->isNamedEntity) { } 0 0 0
907 0 $color = $self->_determinedColor($term->NEtype, $TermtypeColor);
908 } else {
909 0 ▶ if ($document->getAnnotations->getSemanticFeaturesLevel->existsElementFromIndex("refid_semantic_unit", $term->getId)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($document->getAnnotations->getSemanticFeaturesLevel->existsElementFromIndex("refid_semantic_unit", $term->getId)) 0 0 0
910 0 $semf = $document->getAnnotations->getSemanticFeaturesLevel->getElementFromIndex("refid_semantic_unit", $term->getId)->[0];
911 0 $color = $self->_determinedColor($semf->first_node_first_semantic_category, $TermtypeColor);
912 }
913 }
914 # $doc_str .= "<B><FONT COLOR =\"$color\">" . $term->getForm . "</FONT></B>";
915 0 $doc_str .= "<B><FONT COLOR =\"$color\">";
916 0 $i = 0;
917 0 $phraseWords = $phrase->reference;
918 0 ▶ while(($i < scalar(@$phraseWords)) && (!$word->equals($phraseWords->[$i]))) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < scalar @$phraseWords and not $word->equals($phraseWords->[$i])) 0 0 0
Condition0%0/3
$i < scalar @$phraseWords and not $word->equals($phraseWords->[$i])
!ll&&!rl&&r
000
MC/DC0%0/2
$i < scalar @$phraseWords and not $word->equals($phraseWords->[$i])
$i < scalar @$phraseWords not $word->equals($phraseWords->[$i])
Truth table0%0/3
A and not(B)
A= $i < scalar @$phraseWordsB= not $word->equals($phraseWords->[$i])
ABresult
0X0
100
111
919 0 $i++;
920 }
921 0 ▶ while($i < scalar(@$phraseWords)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < scalar @$phraseWords) 0 0 0
922 0 $doc_str .= $phraseWords->[$i]->getForm;
923 0 $i++;
924 }
925 0 $doc_str .= "</FONT></B>";
926 0 $doc_token_idx += $phrase->getReferenceSize - 1;
927 0 next;
928 }
929 } else {
930 0 ▶ if ($document->getAnnotations->getSemanticUnitLevel->existsElementFromIndex("refid_word", $word->getId)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($document->getAnnotations->getSemanticUnitLevel->existsElementFromIndex("refid_word", $word->getId)) 0 0 0
931 0 $term = $document->getAnnotations->getSemanticUnitLevel->getElementFromIndex("refid_word", $word->getId)->[0];
932 0 ▶ if ($term->isNamedEntity) {
Branch: 1 branch
BranchTrueFalseTotal
if ($term->isNamedEntity) { } 0 0 0
933 0 $color = $self->_determinedColor($term->NEtype, $TermtypeColor);
934 } else {
935 0 ▶ if ($document->getAnnotations->getSemanticFeaturesLevel->existsElementFromIndex("refid_semantic_unit", $term->getId)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($document->getAnnotations->getSemanticFeaturesLevel->existsElementFromIndex("refid_semantic_unit", $term->getId)) 0 0 0
936 0 $semf = $document->getAnnotations->getSemanticFeaturesLevel->getElementFromIndex("refid_semantic_unit", $term->getId)->[0];
937  
938 # $color = $self->_determinedColor("medication", $TermtypeColor);
939 0 $color = $self->_determinedColor($semf->first_node_first_semantic_category, $TermtypeColor);
940  
941 }
942 }
943 0 $doc_str .= "<B><FONT COLOR =\"$color\">" . $term->getForm . "</FONT></B>";
944 0 $doc_token_idx += $word->getReferenceSize - 1;
945 0 next;
946 }
947 }
948 }
949 0 $doc_str .= $token->getContent;
950 0 ▶ if ($document->getAnnotations->getSentenceLevel->existsElementFromIndex("refid_end_token", $token->getId)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($document->getAnnotations->getSentenceLevel->existsElementFromIndex("refid_end_token", $token->getId)) 0 0 0
951 0 $doc_str .= "\n<p/>\n";
952 }
953 }
954 0 $doc_str =~ s/\n/\n<P>\n/go;
955  
956 # warn $document->getId . "\n";
957 0 print "<BR><B>document ID: " . $document->getId . "</B><BR>\n";
958 0 print "<HR>\n";
959 0 print "colors: <BR>\n<ul>\n";
960 # foreach my $NEtype (keys %NEtypeColor) {
961 # $color = $NEtypeColor{$NEtype};
962 # print "<LI><b><FONT COLOR=\"" . $color . "\">$NEtype = $color</FONT></b></LI>\n";
963 # }
964 0 $color = "FFCBDB"; # 0000FF
965 0 print "<LI><b><FONT COLOR=\"" . $color . "\">Terms = $color</FONT></b></LI>\n";
966 0 foreach my $Termtype (sort {$TermtypeColor->{$b} cmp $TermtypeColor->{$a}} keys %$TermtypeColor) {
967 0 $color = $TermtypeColor->{$Termtype};
968 0 print "<LI><b><FONT COLOR=\"" . $color . "\">$Termtype = $color</FONT></b></LI>\n";
969 }
970
971 0 print "</ul>\n<HR>\n";
972 0 print $doc_str;
973 0 print "\n<HR>\n";
974 }
975 0 print "\n$footer\n"
976 }
977  
978 0 ▶sub _loadColors {
Subroutine _loadColors: not called CC=1 SCAR=6.9
979 0 my ($self) = @_;
980  
981 0 my $cg = new Config::General('-ConfigFile' => $self->_config->configuration->{'RESOURCE'}->{"language=EN"}->{'COLORFILE'},
982 '-InterPolateVars' => 1,
983 '-InterPolateEnv' => 1,
984 );
985
986 0 my %colors = $cg->getall;
987
988 0 return(\%colors);
989 }
990  
991  
992 0 ▶sub _genHTMLTagSemUnit_start {
Subroutine _genHTMLTagSemUnit_start: not called CC=1 SCAR=6.9
993 0 my ($self, $idColor) = @_;
994  
995 # onMouseOver="tip('alpha')" onMouseOut="untip()"
996 # <a href="#"style="text-decoration:none" onMouseOver="tip('alpha')" onMouseOut="untip()">
997  
998  
999 0 my $str = "<a class=\"$idColor\" href='#' onMouseOver=\"tip('$idColor')\" onMouseOut=\"untip()\">";
1000 0 return($str);
1001 }
1002  
1003 0 ▶sub _genHTMLTagSemUnit_end {
Subroutine _genHTMLTagSemUnit_end: not called CC=1 SCAR=6.9
1004 0 my ($self) = @_;
1005  
1006 0 my $str = "</a>";
1007 0 return($str);
1008 }
1009  
1010 0 ▶sub _genHTMLTagSemUnit {
Subroutine _genHTMLTagSemUnit: not called CC=1 SCAR=6.9
1011 0 my ($self, $idColor, $term_str) = @_;
1012  
1013 0 my $str;
1014  
1015 0 $str = $self->_genHTMLTagSemUnit_start($idColor);
1016 0 $str .= $term_str;
1017 0 $str .= $self->_genHTMLTagSemUnit_end;
1018
1019 0 return($str);
1020 }
1021  
1022  
1023 0 ▶sub _getIdColor {
Subroutine _getIdColor: not called CC=2 SCAR=17.9
1024 0 my ($self, $type, $typeColor) = @_ ;
1025  
1026 0 my $color;
1027  
1028 # warn "$type\n";
1029 0 ▶ if (!exists $typeColor->{$type}) {
Branch: 1 branch
BranchTrueFalseTotal
if (not exists $typeColor->{$type}) { } 0 0 0
1030 0 $typeColor->{$type} = lc($type);
1031 # $typeColor->{$type} =~ s/\-/_/go;
1032 } else {
1033 # $color = $typeColor->{$type}
1034 }
1035 0 return($typeColor->{$type});
1036  
1037 }
1038  
1039 0 ▶sub _determinedColor {
Subroutine _determinedColor: not called CC=2 SCAR=17.9
1040 0 my ($self, $type, $typeColor) = @_ ;
1041  
1042 0 my $color;
1043  
1044 0 ▶ if (!exists $typeColor->{$type}) {
Branch: 1 branch
BranchTrueFalseTotal
if (not exists $typeColor->{$type}) { } 0 0 0
1045 # $color = "FF" . sprintf("%X", (ord(substr($type, 0, 1)) % 16)) . "0" . sprintf("%X", (ord(substr($type, 1, 1)) % 16)) . "0";
1046 0 $color = "FFCBDB";
1047 0 $typeColor->{$type} = $color;
1048 } else {
1049 0 $color = $typeColor->{$type};
1050 }
1051 0 return($color);
1052 # return("FFCBDB");
1053 }
1054  
1055  
1056 0 ▶sub _getEndForm {
Subroutine _getEndForm: not called CC=8 SCAR=42.8
1057  
1058 0 my ($self, $nextTerm, $document, $end_form, $endTokens) = @_;
1059  
1060 0 my $token;
1061  
1062 0 $token = $nextTerm->end_token;
1063 0 ▶ while ((defined $token->next) &&
Branch: 1 branch
BranchTrueFalseTotal
if (defined $token->next and $token->next->isSep || $token->next->isSymb and not $document->getAnnotations->getSentenceLevel->existsElementFromIndex("refid_end_token", $token->getId)) 0 0 0
Condition0%0/9
defined $token->next and $token->next->isSep || $token->next->isSymb and not $document->getAnnotations->getSentenceLevel->existsElementFromIndex("refid_end_token", $token->getId)
!ll&&!rl&&r
000
defined $token->next and $token->next->isSep || $token->next->isSymb
!ll&&!rl&&r
000
$token->next->isSep or $token->next->isSymb
l!l&&r!l&&!r
000
MC/DC0%0/4
defined $token->next and $token->next->isSep || $token->next->isSymb and not $document->getAnnotations->getSentenceLevel->existsElementFromIndex("refid_end_token", $token->getId)
defined $token->next $token->next->isSep $token->next->isSymb not $document->getAnnotations->getSentenceLevel->existsElementFromIndex("refid_end_token", $token->getId)
Truth table0%0/6
A and B or C and not(D)
A= defined $token->nextB= $token->next->isSepC= $token->next->isSymbD= not $document->getAnnotations->getSentenceLevel->existsElementFromIndex("refid_end_token", $token->getId)
ABCDresult
0XXX0
100X0
11X00
10100
11X11
10111
1064 (($token->next->isSep) || ($token->next->isSymb)) &&
1065 # (index($token->getContent, ")") == -1) &&
1066 (!$document->getAnnotations->getSentenceLevel->existsElementFromIndex("refid_end_token", $token->getId))
1067 ) {
1068 0 $token = $token->next;
1069 0 push @$endTokens, $token;
1070 }
1071  
1072 0 $token = $$endTokens[$#$endTokens];
1073 0 ▶ while((scalar(@$endTokens) > 0) && ($token->isSep)) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @$endTokens > 0 and $token->isSep) 0 0 0
Condition0%0/3
scalar @$endTokens > 0 and $token->isSep
!ll&&!rl&&r
000
MC/DC0%0/2
scalar @$endTokens > 0 and $token->isSep
scalar @$endTokens > 0 $token->isSep
Truth table0%0/3
A and B
A= scalar @$endTokens > 0B= $token->isSep
ABresult
0X0
100
111
1074 0 pop @$endTokens;
1075 0 $token = $$endTokens[$#$endTokens];
1076 }
1077 0 foreach $token (@$endTokens) {
1078 0 $$end_form .= $token->getContent;
1079 }
1080 0 return($$endTokens[$#$endTokens]);
1081 }
1082  
1083  
1084 # Take into account the sem tag
1085 0 ▶sub _semanticUnitMerging {
Subroutine _semanticUnitMerging: not called CC=14 SCAR=53.5
1086 0 my ($self, $document, $firstTerm, $secondTerm, $sepForm, $sepTokens, $endForm, $endTokens) = @_;
1087  
1088 0 my @Term2tokens;
1089 my $token;
1090 0 my $term_form;
1091 0 my $id;
1092 0 my $newTerm;
1093  
1094 # warn "Merging " . $firstTerm->getForm . " : " . $firstTerm->type . "\n";
1095  
1096 # if (defined $secondTerm) {
1097 # warn " with " . $secondTerm->getForm . " : " . $secondTerm->type. "\n";
1098 # }
1099 # if (defined $endForm) {
1100 # warn " with $endForm\n";
1101 # }
1102 # warn "Merging " . $firstTerm->getForm . " and " . $secondTerm->getForm . "\n";
1103  
1104 # Merge Term if same type
1105 # warn "in _semanticUnitMerging\n";
1106  
1107 # warn $firstTerm->reference_name . "\n";
1108 # warn $firstTerm->reference . "\n";
1109  
1110 0 $token = $firstTerm->start_token;
1111 0 push @Term2tokens, $token;
1112 0 ▶ while(!$token->equals($firstTerm->end_token)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($token->equals($firstTerm->end_token)) 0 0 0
1113 0 $token = $token->next;
1114 0 push @Term2tokens, $token;
1115 };
1116 0 $term_form = $firstTerm->getForm;
1117  
1118 0 ▶ if (defined $sepForm) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $sepForm) { } 0 0 0
1119 0 push @Term2tokens, @$sepTokens;
1120 0 $term_form .= $sepForm;
1121 0 $token = $sepTokens->[$#$sepTokens];
1122 } else {
1123 0 $token = $firstTerm->end_token;
1124 }
1125 0 ▶ if (defined $secondTerm) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $secondTerm) 0 0 0
1126 0 ▶ while(!($token->equals($secondTerm->end_token))) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($token->equals($secondTerm->end_token)) 0 0 0
1127 0 $token = $token->next;
1128 0 push @Term2tokens, $token;
1129 0 $term_form .= $token->getContent;
1130 }
1131 }
1132  
1133 0 ▶ if (defined $endForm) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $endForm) 0 0 0
1134 0 push @Term2tokens, @$endTokens;
1135 0 $term_form .= $endForm;
1136 }
1137  
1138 0 $newTerm = $self->_createTerm($document, \@Term2tokens, $term_form, $firstTerm->type);
1139 0 ▶ if ($newTerm->getId == -1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($newTerm->getId == -1) 0 0 0
1140 # Add semantic Modification
1141 0 $id = $document->getAnnotations->addSemanticUnit($newTerm);
1142 # warn "\tnewTerm: " . $newTerm->getForm . " ($id)\n";
1143 0 my $semf;
1144 0 ▶ if ($firstTerm->isTerm) {
Branch: 2 branches
BranchTrueFalseTotal
if ($firstTerm->isTerm) { } 0 0 0
elsif ($firstTerm->isNamedEntity) { } 0 0 0
1145 0 ▶ if (defined $document->getAnnotations->getSemanticFeaturesLevel->getElementFromIndex("refid_semantic_unit", $firstTerm->getId)->[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $document->getAnnotations->getSemanticFeaturesLevel->getElementFromIndex("refid_semantic_unit", $firstTerm->getId)->[0]) 0 0 0
1146 my $semFeatures = Lingua::Ogmios::Annotations::SemanticFeatures->new(
1147 0 { 'semantic_category' => [@{$document->getAnnotations->getSemanticFeaturesLevel->getElementFromIndex("refid_semantic_unit", $firstTerm->getId)->[0]->semantic_category}],
1148 'refid_semantic_unit' => $newTerm->getId,
1149 });
1150 0 $document->getAnnotations->addSemanticFeatures($semFeatures);
1151 }
1152 # if (!$firstTerm->equals($newTerm)) {
1153 # warn "del1a\n";
1154 # $document->getAnnotations->delSemanticUnit($firstTerm);
1155 # }
1156 } elsif ($firstTerm->isNamedEntity) {
1157 # warn $firstTerm->NEtype . "\n";
1158 0 $newTerm->NEtype($firstTerm->NEtype);
1159 # if (!$firstTerm->equals($newTerm)) {
1160 # $document->getAnnotations->delSemanticUnit($firstTerm);
1161 # }
1162 }
1163 }
1164  
1165 0 ▶ if (!$firstTerm->equals($newTerm)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($firstTerm->equals($newTerm)) 0 0 0
1166 # warn "del1b\n";
1167 0 $document->getAnnotations->delSemanticUnit($firstTerm);
1168 }
1169 0 ▶ if ((defined $secondTerm) && ($secondTerm->isTerm)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $secondTerm and $secondTerm->isTerm) 0 0 0
Condition0%0/3
defined $secondTerm and $secondTerm->isTerm
!ll&&!rl&&r
000
MC/DC0%0/2
defined $secondTerm and $secondTerm->isTerm
defined $secondTerm $secondTerm->isTerm
Truth table0%0/3
A and B
A= defined $secondTermB= $secondTerm->isTerm
ABresult
0X0
100
111
1170 0 ▶ if (!$secondTerm->equals($newTerm)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($secondTerm->equals($newTerm)) 0 0 0
1171 # warn "del2\n";
1172 0 $document->getAnnotations->delSemanticUnit($secondTerm);
1173 }
1174 }
1175 0 return($newTerm);
1176  
1177 }
1178  
1179  
1180 0 ▶sub _loadResource {
Subroutine _loadResource: not called CC=1 SCAR=6.9
1181 0 my ($self, $resourceRC, $name) = @_;
1182  
1183 # warn "$resourceRC : $name : " . $resourceRC->{$name} . "\n";
1184  
1185 0 my $cg = new Config::General('-ConfigFile' => $resourceRC->{$name},
1186 '-InterPolateVars' => 1,
1187 '-InterPolateEnv' => 1
1188 );
1189
1190 0 my %resource = $cg->getall;
1191  
1192  
1193  
1194 # foreach my $type (keys %resource) {
1195 # warn "$type : " . $resource{$type} . "\n**\n";
1196 # foreach my $elt (keys %{$resource{$type}}) {
1197 # warn "\t" . $elt . " : " . $resource{$type}->{$elt} . "\n";
1198 # }
1199 # }
1200 0 $self->{$name} = \%resource;
1201 }
1202  
1203 0 ▶sub _loadRCFile {
Subroutine _loadRCFile: not called CC=3 SCAR=24.8
1204 0 my ($self, $file, $fields) = @_;
1205  
1206 0 my $field;
1207 0 my $cg = new Config::General('-ConfigFile' => $file,
1208 '-InterPolateVars' => 1,
1209 '-InterPolateEnv' => 1,
1210 # '-NoEscape' => 1,
1211 # '-BackslashEscape' => 1,
1212 );
1213
1214 0 my %resource = $cg->getall;
1215  
1216 0 foreach $field (@$fields) {
1217  
1218 0 ▶ if (exists $resource{$field}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $resource{$field}) { } 0 0 0
1219 0 $self->{$field} = $resource{$field};
1220 0 $self->{$field} = $resource{$field};
1221 } else {
1222 0 warn "*** $field not found ***\n";
1223 }
1224 }
1225 }
1226  
1227  
1228 0 ▶sub LoadMorphoSemanticMarkResource {
Subroutine LoadMorphoSemanticMarkResource: not called CC=11 SCAR=48.8
Pod undocumented
1229 0 my ($self, $fieldGroup) = @_;
1230  
1231 0 ▶ if (defined $self->_config->configuration->{'RESOURCE'}->{"language=EN"}->{"AFFIXLIST"}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->_config->configuration->{"RESOURCE"}{"language=EN"}{"AFFIXLIST"}) 0 0 0
1232 0 my $filename = $self->_config->configuration->{'RESOURCE'}->{"language=EN"}->{"AFFIXLIST"};
1233  
1234 0 warn "Reading file containing marks $filename\n";
1235  
1236 0 my $affix;
1237 my $type;
1238  
1239 0 my %problems_lexical;
1240 0 my %tests_lexical;
1241 0 my %treatments_lexical;
1242  
1243 0 my %problems_morphologic;
1244 0 my %tests_morphologic;
1245 0 my %treatments_morphologic;
1246  
1247 0 my $line;
1248 0 my $field;
1249  
1250 0 foreach $field (keys %{$self->{$fieldGroup}}) {
1251 0 my %tmp;
1252 0 $self->{"RESOURCES"}->{$field . "_lexical"} = \%tmp;
1253 0 my %tmp2;
1254 0 $self->{"RESOURCES"}->{$field . "_adjectival"} = \%tmp;
1255 0 my %tmp3;
1256 0 $self->{"RESOURCES"}->{$field . "_morphological"} = \%tmp2;
1257 }
1258  
1259 0 ▶ open (AFFIXFILE, $filename) || die "file not found ($filename)\n";
Branch: 1 branch
BranchTrueFalseTotal
open AFFIXFILE, $filename or die "file not found ($filename)\n" 0 0 0
1260  
1261 0 ▶ while ($line = <AFFIXFILE>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($line = readline AFFIXFILE)) 0 0 0
1262 0 chomp $line;
1263 0 ▶ if (($line !~ /\s*#/o) && ($line !~ /^\s*$/o)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($line =~ /\s*#/o or $line =~ /^\s*$/o) 0 0 0
Condition0%0/3
$line =~ /\s*#/o or $line =~ /^\s*$/o
l!l&&r!l&&!r
000
MC/DC0%0/2
$line =~ /\s*#/o or $line =~ /^\s*$/o
$line =~ /\s*#/o $line =~ /^\s*$/o
Truth table0%0/3
A or B
A= $line =~ /\s*#/oB= $line =~ /^\s*$/o
ABresult
1X1
011
000
1264 0 ($affix, $type) = split / : *: /, $line; # /
1265 # warn "affix: $affix ; type: $type\n";
1266 0 ▶ if (exists $self->{$fieldGroup}->{$type}) {
Branch: 3 branches
BranchTrueFalseTotal
if (exists $self->{$fieldGroup}{$type}) { } 0 0 0
elsif ($type =~ s/\-a$// and exists $self->{$fieldGroup}{$type}) { } 0 0 0
elsif ($type =~ /\-(m(-[ps])?)$/) { } 0 0 0
1267 0 $self->{"RESOURCES"}->{$type . "_lexical"}->{$affix} = "l";
1268 ▶ } elsif (($type =~ s/\-a$//) &&(exists $self->{$fieldGroup}->{$type})) {
Condition0%0/3
$type =~ s/\-a$// and exists $self->{$fieldGroup}{$type}
!ll&&!rl&&r
000
MC/DC0%0/2
$type =~ s/\-a$// and exists $self->{$fieldGroup}{$type}
$type =~ s/\-a$// exists $self->{$fieldGroup}{$type}
Truth table0%0/3
A and B
A= $type =~ s/\-a$//B= exists $self->{$fieldGroup}{$type}
ABresult
0X0
100
111
1269 0 $self->{"RESOURCES"}->{$type . "_adjectival"}->{$affix} = "a";
1270 } elsif ($type =~ /\-(m(-[ps])?)$/) {
1271 0 $self->{"RESOURCES"}->{$` . "_morphological"}->{$affix} = "$1";
1272 } else {
1273 0 warn "type not found\n";
1274 }
1275 }
1276 }
1277 }
1278 }
1279  
1280  
1281 0 ▶sub _addSemanticFeature {
Subroutine _addSemanticFeature: not called CC=3 SCAR=24.8
1282 0 my ($self, $termUnit, $semtag, $document) = @_;
1283  
1284 0 my $semFeatures;
1285  
1286 0 ▶ if (defined $semtag) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $semtag) { } 0 0 0
1287 0 my @semtags;
1288 0 ▶ if (ref($semtag) ne "ARRAY") {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $semtag ne 'ARRAY') { } 0 0 0
1289 0 @semtags = split /\//, $semtag;
1290 } else {
1291 0 @semtags = @$semtag;
1292 }
1293 0 my @list_semtags;
1294 0 push @list_semtags, \@semtags;
1295 # TODO Check if the semtag already exists in order to avoid to create one another
1296 0 $semFeatures = Lingua::Ogmios::Annotations::SemanticFeatures->new(
1297 { 'semantic_category' => \@list_semtags,
1298 'refid_semantic_unit' => $termUnit->getId,
1299 });
1300 0 $document->getAnnotations->addSemanticFeatures($semFeatures);
1301 } else {
1302 0 warn "Semtag not defined\n";
1303 }
1304  
1305 }
1306  
1307 0 ▶sub _split_RE {
Subroutine _split_RE: not called CC=9 SCAR=45.0
1308 0 my ($self, $RE) = @_;
1309  
1310 0 my $pos_start = 0;
1311 0 my $pos = 0;
1312 0 my $str;
1313 my $i;
1314 0 my @pattern_tab;
1315  
1316 0 my ($pattern, $rel_type) = split /\|\|/, $RE;
1317
1318 0 push @pattern_tab, $rel_type;
1319 0 ▶ do {
Branch: 1 branch
BranchTrueFalseTotal
$pos > -1 and $pos < length $pattern and do { do { $pos = index($pattern, "\@", $pos_start); if ($pos > -1) { if ($pos != 0) { $str = substr($pattern, $pos_start, $pos - $pos_start); my(%tmp) = ("mark", $str); push @pattern_tab, \%tmp; } ; $str = substr($pattern, $pos + 1, 2); my %tmp; if (exists $self->{"SEMANTICTYPES"}{$str}) { %tmp = ("semtype", $str); } ; unless (exists $self->{"SEMANTICTYPES"}{$str}) { %tmp = ("postag", $str); } ; push @pattern_tab, \%tmp; $pos_start = $pos + 3; } } } 0 0 0
Condition0%0/3
$pos > -1 and $pos < length $pattern
!ll&&!rl&&r
000
MC/DC0%0/2
$pos > -1 and $pos < length $pattern
$pos > -1 $pos < length $pattern
Truth table0%0/3
A and B
A= $pos > -1B= $pos < length $pattern
ABresult
0X0
100
111
1320 0 $pos = index($pattern, '@', $pos_start);
1321 0 ▶ if ($pos > -1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pos > -1) 0 0 0
1322 0 ▶ if ($pos != 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pos != 0) 0 0 0
1323 0 $str = substr($pattern, $pos_start, $pos - $pos_start);
1324 0 my %tmp = ("mark" => $str);
1325 0 push @pattern_tab, \%tmp;
1326 }
1327 0 $str = substr($pattern, $pos+1, 2);
1328  
1329 0 my %tmp;
1330 0 ▶ if (exists $self->{"SEMANTICTYPES"}->{$str}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{"SEMANTICTYPES"}{$str}) 0 0 0
1331 0 %tmp = ("semtype" => $str);
1332 }
1333 0 ▶ if (!exists $self->{"SEMANTICTYPES"}->{$str}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $self->{"SEMANTICTYPES"}{$str}) 0 0 0
1334 0 %tmp = ("postag" => $str);
1335 }
1336 0 push @pattern_tab, \%tmp ;
1337 0 $pos_start = $pos + 3;
1338 }
1339 } while(($pos > -1) && ($pos < length($pattern)));
1340 0 $str = substr($pattern, $pos_start);
1341  
1342 0 ▶ if ($str ne "") {
Branch: 1 branch
BranchTrueFalseTotal
if ($str ne "") 0 0 0
1343 0 my %tmp = ("mark" => $str);
1344 0 push @pattern_tab, \%tmp;
1345 }
1346  
1347 0 ▶ for($i = 1; $i < scalar(@pattern_tab);$i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < scalar @pattern_tab) 0 0 0
1348 0 $pattern = $pattern_tab[$i];
1349 }
1350 0 return(\@pattern_tab);
1351 }
1352  
1353  
1354  
1355 0 ▶sub patternSearch {
Subroutine patternSearch: not called CC=25 SCAR=64.8
Pod undocumented
1356 0 my ($self, $function_pointer, $args) = @_;
1357  
1358 0 my $document;
1359 my $sentence;
1360 0 my $sentenceLemma;
1361 0 my $sentenceLemma2;
1362 # my $sentenceForm;
1363 0 my $REtype;
1364 0 my $RELtype;
1365 0 my $pattern;
1366
1367 0 my $sentence_start_token;
1368 0 my $sentence_end_token;
1369  
1370 0 my $i;
1371 0 my $j;
1372 0 my $regexp;
1373  
1374 0 my $offset_refs;
1375  
1376 0 my $wordLimit = 10;
1377 0 my $POSTAGwordLimit = 10;
1378 0 my $tokenLimit;
1379  
1380 0 my $semfGuessing = 0;
1381  
1382 0 my $word;
1383 my $domainSpecificRelation;
1384
1385 0 my $start_mark_token;
1386 0 my $end_mark_token;
1387  
1388 0 my $found;
1389 0 my @terms;
1390 0 my $term;
1391  
1392 # warn "pattternSearch\n";
1393  
1394 0 foreach $document (@{$self->_documentSet}) {
1395 0 foreach $sentence (@{$document->getAnnotations->getSentenceLevel->getElements}) {
1396 0 $sentence_start_token = $sentence->refid_start_token;
1397 0 $sentence_end_token = $sentence->refid_end_token;
1398  
1399 # warn "==> " . $sentence->getForm . "\n";
1400 0 ($sentenceLemma, $offset_refs) = $self->_getLemmatisedSentence($document, $sentence_start_token, $sentence_end_token);
1401 0 foreach $REtype (keys %{$self->{'Resources'}}) {
1402 # warn "REType: $REtype\n";
1403 0 $RELtype = $self->{'Resources'}->{$REtype}->[2];
1404 0 ▶ for($i=0; $i < scalar(@{$self->{'Resources'}->{$REtype}->[4]});$i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < scalar @{$self->{"Resources"}{$REtype}[4];}) 0 0 0
1405 # warn "==>?PATTERN: " . $self->{'Resources'}->{$REtype}->[1]->[$i] . "\n";
1406 0 $pattern = $self->{'Resources'}->{$REtype}->[4]->[$i];
1407 # foreach $pattern (@{$self->{'Resources'}->{$REtype}->[4]}) {
1408 # warn "$pattern\n";
1409 # warn "relation type: " . $pattern->[0] . "\n";
1410 0 $tokenLimit = $sentence_start_token;
1411 0 $start_mark_token = $sentence_start_token;
1412 0 $end_mark_token = $sentence_end_token;
1413 # warn "+++>" . scalar(@{$pattern}) . "\n";
1414 0 @terms = ();
1415 # $sentenceLemma2 = $sentenceLemma;
1416 # $sentenceLemma =~ /^/go;
1417  
1418 0 $sentenceLemma =~ /^/go;
1419 0 $found = 0;
1420 0 ▶ for($j = 1; $j < scalar(@{$pattern}); $j++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($j < scalar @{$pattern;}) 0 0 0
1421 0 ▶ if (exists $pattern->[$j]->{'mark'}) {
Branch: 3 branches
BranchTrueFalseTotal
if (exists $pattern->[$j]{'mark'}) { } 0 0 0
elsif (exists $pattern->[$j]{'semtype'}) { } 0 0 0
elsif (exists $pattern->[$j]{'postag'}) { } 0 0 0
1422 # warn "mark ($j): " . $pattern->[$j]->{'mark'} . "\n";
1423 0 $regexp = $pattern->[$j]->{'mark'};
1424
1425 # warn "SENTENCE => $sentenceLemma\n";
1426 0 ▶ if ($sentenceLemma =~ /$regexp/gcsi) {
Branch: 1 branch
BranchTrueFalseTotal
if ($sentenceLemma =~ /$regexp/cgis) { } 0 0 0
1427 # warn "=============\n";
1428 # warn "SENTENCE => $sentenceForm\n";
1429 # warn "SENTENCE => $sentenceLemma\n";
1430 # warn "PATTERN: " . $self->{'Resources'}->{$REtype}->[1]->[$i] . "\n";
1431 # warn "\tMATCH $& " . (length($`)) . "\n";
1432 0 $start_mark_token = undef;
1433 0 ▶ if (exists $offset_refs->{length($`)}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $$offset_refs{length $`}) 0 0 0
1434 # warn "$` " . length($`) . " / " . $offset_refs->{length($`)}->getContent . "\n";
1435 0 $start_mark_token = $offset_refs->{length($`)};
1436 }
1437 # warn "$' " . (length($` . $&)) . "\n"; # ' #
1438 0 $end_mark_token = undef;
1439 0 ▶ if (exists $offset_refs->{length($` . $&)}) {
Branch: 2 branches
BranchTrueFalseTotal
if (exists $$offset_refs{length $` . $&}) { } 0 0 0
elsif (exists $$offset_refs{length($` . $&) - 1}) { } 0 0 0
1440 # warn "$' " . (length($` . $&)) . " / " . $offset_refs->{length($` . $&)}->getContent . "\n"; # ' #
1441 0 $end_mark_token = $offset_refs->{length($` . $&)};
1442 0 $end_mark_token = $end_mark_token->previous;
1443 } elsif (exists $offset_refs->{length($` . $&) - 1}) {
1444 # warn ">>>$' " . (length($` . $&) - 1) . " / " . $offset_refs->{length($` . $&) - 1}->getContent . "\n"; # ' #
1445 0 $end_mark_token = $offset_refs->{length($` . $&) - 1};
1446 0 $end_mark_token = $end_mark_token->previous;
1447 }
1448  
1449 # if ((defined $start_mark_token) && ()) {
1450
1451 0 ▶ if ((defined $end_mark_token) && ($j > 1)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $end_mark_token and $j > 1) { } 0 0 0
Condition0%0/3
defined $end_mark_token and $j > 1
!ll&&!rl&&r
000
MC/DC0%0/2
defined $end_mark_token and $j > 1
defined $end_mark_token $j > 1
Truth table0%0/3
A and B
A= defined $end_mark_tokenB= $j > 1
ABresult
0X0
100
111
1452 # if ((defined $start_mark_token) && (defined $end_mark_token) && ($j > 1)) {
1453 0 ▶ if (exists $pattern->[$j - 1]->{'semtype'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $$pattern[$j - 1]{'semtype'}) { } 0 0 0
1454 0 ▶ if ($term = $self->_searchConceptBefore($document, $tokenLimit, $sentence_end_token, $pattern->[$j - 1]->{"semtype"}, $end_mark_token, $wordLimit, $semfGuessing)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($term = $self->_searchConceptBefore($document, $tokenLimit, $sentence_end_token, $$pattern[$j - 1]{'semtype'}, $end_mark_token, $wordLimit, $semfGuessing)) { } 0 0 0
1455 # warn "Found term " . $term->getId . " / " . $term->getForm . " and store it\n";
1456 0 push @terms, $term;
1457 0 $tokenLimit = $end_mark_token;
1458 # $tokenLimit = $start_mark_token;
1459 } else {
1460 # warn "concept not found\n";
1461 # warn "pattern not complete\n";
1462 #$j = scalar(@{$pattern}) + 1 ;
1463 0 last;
1464 }
1465 } else {
1466 # warn "(3) pattern not complete\n";
1467 #$j = scalar(@{$pattern}) + 1 ;
1468 0 last;
1469 }
1470 } else {
1471 # warn "(2) pattern not complete\n";
1472 #$j = scalar(@{$pattern}) + 1 ;
1473 # if ($j > 1) {
1474 0 last;
1475 # }
1476 }
1477 } else {
1478 # warn "(1) pattern not complete\n";
1479 #$j = scalar(@{$pattern}) + 1 ;
1480 0 last;
1481 }
1482 } elsif (exists $pattern->[$j]->{'semtype'}) {
1483 # warn "semtype ($j)\n";
1484 } elsif (exists $pattern->[$j]->{'postag'}) {
1485 # POSTAG
1486 # warn "postag ($j)\n";
1487 0 ▶ if ($word = $self->_searchPOSTagBefore($document, $tokenLimit, $sentence_end_token, $pattern->[$j]->{"postag"}, $end_mark_token, $POSTAGwordLimit)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($word = $self->_searchPOSTagBefore($document, $tokenLimit, $sentence_end_token, $pattern->[$j]{'postag'}, $end_mark_token, $POSTAGwordLimit)) { } 0 0 0
1488 # warn "found postag ($word)\n";
1489 } else {
1490 # warn "postag not found\n";
1491 0 last;
1492 }
1493 }
1494 }
1495 # warn "j = $j\n";
1496 # warn "\t" . scalar(@{$pattern}) . "\n";
1497 0 ▶ if ($j == scalar(@{$pattern})) {
Branch: 1 branch
BranchTrueFalseTotal
if ($j == scalar @{$pattern;}) 0 0 0
1498 0 ▶ if ((defined $end_mark_token) && (exists $pattern->[$j - 1]->{'semtype'})) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $end_mark_token and exists $$pattern[$j - 1]{'semtype'}) { } 0 0 0
elsif (exists $$pattern[$j - 1]{'postag'}) { } 0 0 0
Condition0%0/3
defined $end_mark_token and exists $$pattern[$j - 1]{"semtype"}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $end_mark_token and exists $$pattern[$j - 1]{"semtype"}
defined $end_mark_token exists $$pattern[$j - 1]{"semtype"}
Truth table0%0/3
A and B
A= defined $end_mark_tokenB= exists $$pattern[$j - 1]{"semtype"}
ABresult
0X0
100
111
1499 0 $found = 0;
1500 0 ▶ if ($term = $self->_searchConceptAfter($document, $tokenLimit, $sentence_end_token, $pattern->[$j - 1]->{"semtype"}, $end_mark_token, $wordLimit, $semfGuessing)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($term = $self->_searchConceptAfter($document, $tokenLimit, $sentence_end_token, $$pattern[$j - 1]{"semtype"}, $end_mark_token, $wordLimit, $semfGuessing)) 0 0 0
1501 # warn "Found term " . $term->getId . " / " . $term->getForm . " and store it\n";
1502 0 push @terms, $term;
1503 0 $found = 1;
1504 }
1505 } elsif (exists $pattern->[$j - 1]->{'postag'}) {
1506 # POSTAG
1507 # warn "postag ($j)\n";
1508 0 ▶ if ($word = $self->_searchPOSTagAfter($document, $tokenLimit, $sentence_end_token, $pattern->[$j - 1]->{"postag"}, $end_mark_token, $POSTAGwordLimit)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($word = $self->_searchPOSTagAfter($document, $tokenLimit, $sentence_end_token, $$pattern[$j - 1]{'postag'}, $end_mark_token, $POSTAGwordLimit)) { } 0 0 0
1509 # warn "found postag ($word)\n";
1510 } else {
1511 # warn "postag not found\n";
1512 0 last;
1513 }
1514
1515 }
1516 0 ▶ if ($found == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($found == 1) 0 0 0
1517 # $tokenLimit = $start_mark_token;
1518 # warn "\tFind a relation (" . (scalar(@terms)) . ")\n";
1519 # warn "\tCreation of the relation " . $pattern->[0] . "\n";
1520
1521 # warn "$self\n";
1522 0 &$function_pointer($document, $pattern->[0], \@terms, $args);
1523 # $self->_addRelation($document, $pattern->[0], \@terms);
1524 }
1525 }
1526 }
1527 }
1528 }
1529 }
1530 # warn "Done\n";
1531 }
1532  
1533 0 ▶sub _searchConceptBefore {
Subroutine _searchConceptBefore: not called CC=11 SCAR=48.8
1534 0 my ($self, $document, $sentence_start_token, $sentence_end_token, $semtypeAcr, $start_mark_token, $tokenLimit, $semfGuessing) = @_;
1535  
1536  
1537 0 my $token = $start_mark_token;
1538 0 my $term;
1539  
1540 0 my $windowSize = 0;
1541  
1542 0 my %words;
1543  
1544 0 my $semtype = $self->{"SEMANTICTYPES"}->{$semtypeAcr};
1545  
1546 # warn "in _searchConceptBefore (" . $start_mark_token->getFrom . ") " . $sentence_start_token->getId . " $semtype\n";
1547  
1548 0 ▶ do {
Branch: 1 branch
BranchTrueFalseTotal
$windowSize < $tokenLimit and defined $token and $token->getTo >= $sentence_start_token->getFrom and do { do { my(@words) = @{$document->getAnnotations->getWordLevel->getElementByToken($token);}; if (scalar @words > 0) { ++$words{$words[0]->getId}; $windowSize = scalar keys %words; } ; if (scalar @{$document->getAnnotations->getSemanticUnitLevel->getElementByToken($token);} > 0) { if ($semfGuessing) { if ($term->isTerm and not defined $term->getSemanticFeatureFC($document)) { $self->_addSemanticFeature($term, $semtype, $document); } ; } else { $term = $document->getAnnotations->getSemanticUnitLevel->getElementByToken($token)->[0]; if ($term->isTerm) { if ($term->getSemanticFeatureFC($document) eq $semtype) { return $term; } ; } ; } ; } ; $token = $token->previous } } 0 0 0
Condition0%0/6
$windowSize < $tokenLimit and defined $token and $token->getTo >= $sentence_start_token->getFrom
!ll&&!rl&&r
000
$windowSize < $tokenLimit and defined $token
!ll&&!rl&&r
000
MC/DC0%0/3
$windowSize < $tokenLimit and defined $token and $token->getTo >= $sentence_start_token->getFrom
$windowSize < $tokenLimit defined $token $token->getTo >= $sentence_start_token->getFrom
Truth table0%0/4
A and B and C
A= $windowSize < $tokenLimitB= defined $tokenC= $token->getTo >= $sentence_start_token->getFrom
ABCresult
0XX0
10X0
1100
1111
1549 0 my @words = @{$document->getAnnotations->getWordLevel->getElementByToken($token)};
1550 0 ▶ if (scalar(@words) > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @words > 0) 0 0 0
1551 0 $words{$words[0]->getId}++;
1552 0 $windowSize = scalar(keys %words);
1553 }
1554 # warn "(0) Id: " . $token->getId . " token: " . $token->getContent . " ( $windowSize / $tokenLimit)\n";
1555 # warn "\t" . scalar(@{$document->getAnnotations->getSemanticUnitLevel->getElementByToken($token)}) . "\n";
1556 # foreach $term (@{$document->getAnnotations->getSemanticUnitLevel->getElementByToken($token)}) {
1557 # while((defined $token) && (($token->isSep) && (!$token->equals($sentence_start_token))) ) {
1558 # $token = $token->previous;
1559 # } ;
1560  
1561 # if (defined($token)) {
1562 # warn "(a) Id: " . $token->getId . "token: " . $token->getContent . " ( $tokenLimit / $windowSize)\n";
1563 # warn "\t" . scalar(@{$document->getAnnotations->getSemanticUnitLevel->getElementByToken($token)}) . "\n";
1564 # $windowSize++;
1565  
1566 0 ▶ if (scalar(@{$document->getAnnotations->getSemanticUnitLevel->getElementByToken($token)}) > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @{$document->getAnnotations->getSemanticUnitLevel->getElementByToken($token);} > 0) 0 0 0
1567 # warn "---\n";
1568 0 ▶ if ($semfGuessing) {
Branch: 1 branch
BranchTrueFalseTotal
if ($semfGuessing) { } 0 0 0
1569 # # $term = $document->getAnnotations->getSemanticUnitLevel->getElementByToken($token)->[0];
1570
1571 0 ▶ if (($term->isTerm) && (!defined($term->getSemanticFeatureFC($document)))) {
Branch: 1 branch
BranchTrueFalseTotal
if ($term->isTerm and not defined $term->getSemanticFeatureFC($document)) 0 0 0
Condition0%0/3
$term->isTerm and not defined $term->getSemanticFeatureFC($document)
!ll&&!rl&&r
000
MC/DC0%0/2
$term->isTerm and not defined $term->getSemanticFeatureFC($document)
$term->isTerm not defined $term->getSemanticFeatureFC($document)
Truth table0%0/3
A and not(B)
A= $term->isTermB= not defined $term->getSemanticFeatureFC($document)
ABresult
0X0
100
111
1572 # warn "Guessing $semtype\n";
1573 0 $self->_addSemanticFeature($term, $semtype, $document);
1574 }
1575 } else {
1576 0 $term = $document->getAnnotations->getSemanticUnitLevel->getElementByToken($token)->[0];
1577 0 ▶ if ($term->isTerm) {
Branch: 1 branch
BranchTrueFalseTotal
if ($term->isTerm) 0 0 0
1578 # warn 'Term: ' . $term->getForm . "\n";
1579 # warn "Semf: " . $term->getSemanticFeatureFC($document) . "\n";
1580 0 ▶ if ($term->getSemanticFeatureFC($document) eq $semtype) {
Branch: 1 branch
BranchTrueFalseTotal
if ($term->getSemanticFeatureFC($document) eq $semtype) 0 0 0
1581 # warn "found concept with the right semtype ($semtype)\n";
1582 0 return($term);
1583 }
1584 }
1585 }
1586 }
1587 # if (!$token->equals($sentence_start_token)) {
1588 0 $token = $token->previous;
1589 # }
1590 # warn "(b) Id: " . $token->getId . "token: " . $token->getContent . " ( $tokenLimit / $windowSize)\n";
1591 } while(($windowSize < $tokenLimit) && (defined $token) && ($token->getTo >= $sentence_start_token->getFrom));
1592 # warn "+++\n";
1593 0 return(0);
1594 }
1595  
1596  
1597 0 ▶sub _searchConceptAfter {
Subroutine _searchConceptAfter: not called CC=11 SCAR=48.8
1598 0 my ($self, $document, $sentence_start_token, $sentence_end_token, $semtypeAcr, $start_mark_token, $tokenLimit, $semfGuessing) = @_;
1599  
1600  
1601 0 my $token = $start_mark_token;
1602 0 my $term;
1603  
1604 my $word;
1605  
1606 0 my $windowSize = 0;
1607 0 my $semtype = $self->{"SEMANTICTYPES"}->{$semtypeAcr};
1608 0 my %words;
1609  
1610 # warn "in _searchConceptAfter (" . $start_mark_token->getFrom . ") " . $sentence_start_token->getId . " $semtype\n";
1611 # warn "in _searchConceptAfter (" . $start_mark_token->getFrom . ")\n";
1612  
1613 0 ▶ do {
Branch: 1 branch
BranchTrueFalseTotal
$windowSize < $tokenLimit and defined $token and $token->getFrom <= $sentence_end_token->getTo and do { do { my(@words) = @{$document->getAnnotations->getWordLevel->getElementByToken($token);}; if (scalar @words > 0) { ++$words{$words[0]->getId}; $windowSize = scalar keys %words; } ; foreach $term (@{$document->getAnnotations->getSemanticUnitLevel->getElementByToken($token);}) { if ($semfGuessing) { if ($term->isTerm and not defined $term->getSemanticFeatureFC($document)) { $self->_addSemanticFeature($term, $semtype, $document); } ; } else { if ($term->isTerm) { if ($term->getSemanticFeatureFC($document) eq $semtype) { return $term; } ; } ; } ; } ; $token = $token->next } } 0 0 0
Condition0%0/6
$windowSize < $tokenLimit and defined $token and $token->getFrom <= $sentence_end_token->getTo
!ll&&!rl&&r
000
$windowSize < $tokenLimit and defined $token
!ll&&!rl&&r
000
MC/DC0%0/3
$windowSize < $tokenLimit and defined $token and $token->getFrom <= $sentence_end_token->getTo
$windowSize < $tokenLimit defined $token $token->getFrom <= $sentence_end_token->getTo
Truth table0%0/4
A and B and C
A= $windowSize < $tokenLimitB= defined $tokenC= $token->getFrom <= $sentence_end_token->getTo
ABCresult
0XX0
10X0
1100
1111
1614  
1615 0 my @words = @{$document->getAnnotations->getWordLevel->getElementByToken($token)};
1616 0 ▶ if (scalar(@words) > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @words > 0) 0 0 0
1617 0 $words{$words[0]->getId}++;
1618 0 $windowSize = scalar(keys %words);
1619 }
1620 0 foreach $term (@{$document->getAnnotations->getSemanticUnitLevel->getElementByToken($token)}) {
1621  
1622  
1623 # # while((defined $token) && (($token->isSep) && (!$token->equals($sentence_end_token))) ) {
1624 # # $token = $token->next;
1625 # # } ;
1626 # # if ((defined($token)) && (!$token->equals($sentence_end_token))) {
1627 # # # warn "(a) Id: " . $token->getId . "token: " . $token->getContent . " ( $tokenLimit / $windowSize)\n";
1628 # # $windowSize++;
1629 # # if (scalar(@{$document->getAnnotations->getSemanticUnitLevel->getElementByToken($token)}) > 0) {
1630 # # # warn "---\n";
1631 0 ▶ if ($semfGuessing) {
Branch: 1 branch
BranchTrueFalseTotal
if ($semfGuessing) { } 0 0 0
1632 # # $term = $document->getAnnotations->getSemanticUnitLevel->getElementByToken($token)->[0];
1633 0 ▶ if (($term->isTerm) && (!defined($term->getSemanticFeatureFC($document)))) {
Branch: 1 branch
BranchTrueFalseTotal
if ($term->isTerm and not defined $term->getSemanticFeatureFC($document)) 0 0 0
Condition0%0/3
$term->isTerm and not defined $term->getSemanticFeatureFC($document)
!ll&&!rl&&r
000
MC/DC0%0/2
$term->isTerm and not defined $term->getSemanticFeatureFC($document)
$term->isTerm not defined $term->getSemanticFeatureFC($document)
Truth table0%0/3
A and not(B)
A= $term->isTermB= not defined $term->getSemanticFeatureFC($document)
ABresult
0X0
100
111
1634 # warn "Guessing $semtype\n";
1635 0 $self->_addSemanticFeature($term, $semtype, $document);
1636 }
1637 } else {
1638 # # $term = $document->getAnnotations->getSemanticUnitLevel->getElementByToken($token)->[0];
1639 # warn 'Term: ' . $term->getForm . "\n";
1640 # warn "Semf: " . $term->getSemanticFeatureFC($document) . "\n";
1641 0 ▶ if ($term->isTerm) {
Branch: 1 branch
BranchTrueFalseTotal
if ($term->isTerm) 0 0 0
1642 0 ▶ if ($term->getSemanticFeatureFC($document) eq $semtype) {
Branch: 1 branch
BranchTrueFalseTotal
if ($term->getSemanticFeatureFC($document) eq $semtype) 0 0 0
1643 # warn "found concept with the right semtype ($semtype)\n";
1644 0 return($term);
1645 }
1646 }
1647 }
1648 }
1649 # if (!$token->equals($sentence_end_token)) {
1650 0 $token = $token->next;
1651 # }
1652 # warn "(b) Id: " . $token->getId . "token: " . $token->getContent . " ( $tokenLimit / $windowSize)\n";
1653 } while(($windowSize < $tokenLimit) && (defined $token) && ($token->getFrom <= $sentence_end_token->getTo));
1654  
1655 0 return(0);
1656 }
1657  
1658 ########################################################################
1659  
1660 0 ▶sub _searchPOSTagBefore {
Subroutine _searchPOSTagBefore: not called CC=12 SCAR=50.5
1661 0 my ($self, $document, $sentence_start_token, $sentence_end_token, $POSTagAcr, $start_mark_token, $tokenLimit) = @_;
1662  
1663  
1664 0 my $token = $start_mark_token;
1665 0 my $word;
1666  
1667 0 my $windowSize = 0;
1668  
1669 # warn "in _searchPOSTagBefore (" . $start_mark_token->getFrom . ")\n";
1670  
1671 0 my $POSTag;
1672 0 ▶ if (defined $self->{"POSTAGS"}->{$POSTagAcr}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{'POSTAGS'}{$POSTagAcr}) { } 0 0 0
1673 0 $POSTag = $self->{"POSTAGS"}->{$POSTagAcr};
1674 } else {
1675 0 $POSTag = $POSTagAcr;
1676 }
1677 # my $semtype = $self->{"SEMANTICTYPES"}->{$POSTag};
1678  
1679 0 ▶ do {
Branch: 1 branch
BranchTrueFalseTotal
$windowSize < $tokenLimit and defined $token and not $token->equals($sentence_start_token) and do { do { while (defined $token and ($token->isSep and not $token->equals($sentence_start_token))) { $token = $token->previous; } ; if (defined $token) { ++$windowSize; if (scalar @{$document->getAnnotations->getWordLevel->getElementByToken($token);} > 0) { $word = $document->getAnnotations->getWordLevel->getElementByToken($token)->[0]; if ($word->getMorphoSyntacticFeatures($document)->syntactic_category eq $POSTag) { return $word; } ; } ; unless ($token->equals($sentence_start_token)) { $token = $token->previous; } ; } } } 0 0 0
Condition0%0/6
$windowSize < $tokenLimit and defined $token and not $token->equals($sentence_start_token)
!ll&&!rl&&r
000
$windowSize < $tokenLimit and defined $token
!ll&&!rl&&r
000
MC/DC0%0/3
$windowSize < $tokenLimit and defined $token and not $token->equals($sentence_start_token)
$windowSize < $tokenLimit defined $token not $token->equals($sentence_start_token)
Truth table0%0/4
A and B and not(C)
A= $windowSize < $tokenLimitB= defined $tokenC= not $token->equals($sentence_start_token)
ABCresult
0XX0
10X0
1100
1111
1680 0 ▶ while((defined $token) && (($token->isSep) && (!$token->equals($sentence_start_token))) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $token and ($token->isSep and not $token->equals($sentence_start_token))) 0 0 0
Condition0%0/6
defined $token and ($token->isSep and not $token->equals($sentence_start_token))
!ll&&!rl&&r
000
$token->isSep and not $token->equals($sentence_start_token)
!ll&&!rl&&r
000
MC/DC0%0/3
defined $token and ($token->isSep and not $token->equals($sentence_start_token))
defined $token $token->isSep not $token->equals($sentence_start_token)
Truth table0%0/4
A and B and not(C)
A= defined $tokenB= $token->isSepC= not $token->equals($sentence_start_token)
ABCresult
0XX0
10X0
1100
1111
1681 0 $token = $token->previous;
1682 } ;
1683  
1684 0 ▶ if ((defined($token))# && (!$token->equals($sentence_start_token))
Branch: 1 branch
BranchTrueFalseTotal
if (defined $token) 0 0 0
1685 ) {
1686 # warn "token: " . $token->getContent . "\n";
1687 # warn "\t" . scalar(@{$document->getAnnotations->getWordLevel->getElementByToken($token)}) . "\n";
1688 0 $windowSize++;
1689  
1690 0 ▶ if (scalar(@{$document->getAnnotations->getWordLevel->getElementByToken($token)}) > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @{$document->getAnnotations->getWordLevel->getElementByToken($token);} > 0) 0 0 0
1691 0 $word = $document->getAnnotations->getWordLevel->getElementByToken($token)->[0];
1692 0 ▶ if ($word->getMorphoSyntacticFeatures($document)->syntactic_category eq $POSTag) {
Branch: 1 branch
BranchTrueFalseTotal
if ($word->getMorphoSyntacticFeatures($document)->syntactic_category eq $POSTag) 0 0 0
1693 # warn "found word with rigt POSTAG ($POSTag)\n";
1694 0 return($word);
1695 }
1696 }
1697 0 ▶ if (!$token->equals($sentence_start_token)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($token->equals($sentence_start_token)) 0 0 0
1698 0 $token = $token->previous;
1699 }
1700 # $token = $token->previous;
1701 # warn "token: " . $token->getContent . "\n";
1702 }
1703 } while(($windowSize < $tokenLimit) && (defined $token) && (!$token->equals($sentence_start_token)));
1704
1705 0 return(0);
1706
1707 }
1708  
1709  
1710 0 ▶sub _searchPOSTagAfter {
Subroutine _searchPOSTagAfter: not called CC=13 SCAR=52.0
1711 0 my ($self, $document, $sentence_start_token, $sentence_end_token, $POSTagAcr, $start_mark_token, $tokenLimit) = @_;
1712  
1713  
1714 0 my $token = $start_mark_token;
1715 0 my $word;
1716  
1717 0 my $windowSize = 0;
1718 0 my $POSTag;
1719 0 ▶ if (defined $self->{"POSTAGS"}->{$POSTagAcr}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{'POSTAGS'}{$POSTagAcr}) { } 0 0 0
1720 0 $POSTag = $self->{"POSTAGS"}->{$POSTagAcr};
1721 } else {
1722 0 $POSTag = $POSTagAcr;
1723 }
1724 # my $POSTag = $self->{"POSTAGS"}->{$POSTagAcr};
1725 # my $semtype = $self->{"SEMANTICTYPES"}->{$semtypeAcr};
1726  
1727 # warn "in _searchPOSTagAfter (" . $start_mark_token->getFrom . ")\n";
1728  
1729 0 ▶ do {
Branch: 1 branch
BranchTrueFalseTotal
$windowSize < $tokenLimit and defined $token and not $token->equals($sentence_end_token) and do { do { while (defined $token and ($token->isSep and not $token->equals($sentence_end_token))) { $token = $token->next; } ; if (defined $token and not $token->equals($sentence_end_token)) { ++$windowSize; if (scalar @{$document->getAnnotations->getWordLevel->getElementByToken($token);} > 0) { $word = $document->getAnnotations->getWordLevel->getElementByToken($token)->[0]; if ($word->getMorphoSyntacticFeatures($document)->syntactic_category eq $POSTag) { return $word; } ; } ; unless ($token->equals($sentence_end_token)) { $token = $token->next; } ; } } } 0 0 0
Condition0%0/6
$windowSize < $tokenLimit and defined $token and not $token->equals($sentence_end_token)
!ll&&!rl&&r
000
$windowSize < $tokenLimit and defined $token
!ll&&!rl&&r
000
MC/DC0%0/3
$windowSize < $tokenLimit and defined $token and not $token->equals($sentence_end_token)
$windowSize < $tokenLimit defined $token not $token->equals($sentence_end_token)
Truth table0%0/4
A and B and not(C)
A= $windowSize < $tokenLimitB= defined $tokenC= not $token->equals($sentence_end_token)
ABCresult
0XX0
10X0
1100
1111
1730 0 ▶ while((defined $token) && (($token->isSep) && (!$token->equals($sentence_end_token))) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $token and ($token->isSep and not $token->equals($sentence_end_token))) 0 0 0
Condition0%0/6
defined $token and ($token->isSep and not $token->equals($sentence_end_token))
!ll&&!rl&&r
000
$token->isSep and not $token->equals($sentence_end_token)
!ll&&!rl&&r
000
MC/DC0%0/3
defined $token and ($token->isSep and not $token->equals($sentence_end_token))
defined $token $token->isSep not $token->equals($sentence_end_token)
Truth table0%0/4
A and B and not(C)
A= defined $tokenB= $token->isSepC= not $token->equals($sentence_end_token)
ABCresult
0XX0
10X0
1100
1111
1731 0 $token = $token->next;
1732 } ;
1733 0 ▶ if ((defined($token)) && (!$token->equals($sentence_end_token))) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $token and not $token->equals($sentence_end_token)) 0 0 0
Condition0%0/3
defined $token and not $token->equals($sentence_end_token)
!ll&&!rl&&r
000
MC/DC0%0/2
defined $token and not $token->equals($sentence_end_token)
defined $token not $token->equals($sentence_end_token)
Truth table0%0/3
A and not(B)
A= defined $tokenB= not $token->equals($sentence_end_token)
ABresult
0X0
100
111
1734 0 $windowSize++;
1735 0 ▶ if (scalar(@{$document->getAnnotations->getWordLevel->getElementByToken($token)}) > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @{$document->getAnnotations->getWordLevel->getElementByToken($token);} > 0) 0 0 0
1736 0 $word = $document->getAnnotations->getWordLevel->getElementByToken($token)->[0];
1737 0 ▶ if ($word->getMorphoSyntacticFeatures($document)->syntactic_category eq $POSTag) {
Branch: 1 branch
BranchTrueFalseTotal
if ($word->getMorphoSyntacticFeatures($document)->syntactic_category eq $POSTag) 0 0 0
1738 0 return($word);
1739 }
1740 }
1741 0 ▶ if (!$token->equals($sentence_end_token)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($token->equals($sentence_end_token)) 0 0 0
1742 0 $token = $token->next;
1743 }
1744 }
1745 } while(($windowSize < $tokenLimit) && (defined $token) && (!$token->equals($sentence_end_token)));
1746  
1747 0 return(0);
1748 }
1749  
1750  
1751 ########################################################################
1752 ########################################################################
1753  
1754 0 ▶sub _searchConceptBefore1 {
Subroutine _searchConceptBefore1: not called CC=15 SCAR=54.8
1755 0 my ($self, $document, $sentence_start_token, $sentence_end_token, $semtypeAcr, $start_mark_token, $tokenLimit, $semfGuessing) = @_;
1756  
1757  
1758 0 my $token = $start_mark_token;
1759 0 my $term;
1760  
1761 0 my $windowSize = 0;
1762  
1763 # warn "in _searchConceptBefore (" . $start_mark_token->getFrom . ")\n";
1764  
1765 0 my $semtype = $self->{"SEMANTICTYPES"}->{$semtypeAcr};
1766  
1767 0 ▶ do {
Branch: 1 branch
BranchTrueFalseTotal
$windowSize < $tokenLimit and defined $token and not $token->equals($sentence_start_token) and do { do { while (defined $token and ($token->isSep and not $token->equals($sentence_start_token))) { $token = $token->previous; } ; if (defined $token and not $token->equals($sentence_start_token)) { ++$windowSize; if (scalar @{$document->getAnnotations->getSemanticUnitLevel->getElementByToken($token);} > 0) { if ($semfGuessing) { $term = $document->getAnnotations->getSemanticUnitLevel->getElementByToken($token)->[0]; if ($term->isTerm and not defined $term->getSemanticFeatureFC($document)) { $self->_addSemanticFeature($term, $semtype, $document); } ; } else { $term = $document->getAnnotations->getSemanticUnitLevel->getElementByToken($token)->[0]; if ($term->isTerm) { if ($term->getSemanticFeatureFC($document) eq $semtype) { return $term; } ; } ; } ; } ; $token = $token->previous; } } } 0 0 0
Condition0%0/6
$windowSize < $tokenLimit and defined $token and not $token->equals($sentence_start_token)
!ll&&!rl&&r
000
$windowSize < $tokenLimit and defined $token
!ll&&!rl&&r
000
MC/DC0%0/3
$windowSize < $tokenLimit and defined $token and not $token->equals($sentence_start_token)
$windowSize < $tokenLimit defined $token not $token->equals($sentence_start_token)
Truth table0%0/4
A and B and not(C)
A= $windowSize < $tokenLimitB= defined $tokenC= not $token->equals($sentence_start_token)
ABCresult
0XX0
10X0
1100
1111
1768 0 ▶ while((defined $token) && (($token->isSep) && (!$token->equals($sentence_start_token))) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $token and ($token->isSep and not $token->equals($sentence_start_token))) 0 0 0
Condition0%0/6
defined $token and ($token->isSep and not $token->equals($sentence_start_token))
!ll&&!rl&&r
000
$token->isSep and not $token->equals($sentence_start_token)
!ll&&!rl&&r
000
MC/DC0%0/3
defined $token and ($token->isSep and not $token->equals($sentence_start_token))
defined $token $token->isSep not $token->equals($sentence_start_token)
Truth table0%0/4
A and B and not(C)
A= defined $tokenB= $token->isSepC= not $token->equals($sentence_start_token)
ABCresult
0XX0
10X0
1100
1111
1769 0 $token = $token->previous;
1770 } ;
1771  
1772 0 ▶ if ((defined($token)) && (!$token->equals($sentence_start_token))) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $token and not $token->equals($sentence_start_token)) 0 0 0
Condition0%0/3
defined $token and not $token->equals($sentence_start_token)
!ll&&!rl&&r
000
MC/DC0%0/2
defined $token and not $token->equals($sentence_start_token)
defined $token not $token->equals($sentence_start_token)
Truth table0%0/3
A and not(B)
A= defined $tokenB= not $token->equals($sentence_start_token)
ABresult
0X0
100
111
1773 # warn "token: " . $token->getContent . "\n";
1774 # warn "\t" . scalar(@{$document->getAnnotations->getSemanticUnitLevel->getElementByToken($token)}) . "\n";
1775 0 $windowSize++;
1776  
1777 0 ▶ if (scalar(@{$document->getAnnotations->getSemanticUnitLevel->getElementByToken($token)}) > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @{$document->getAnnotations->getSemanticUnitLevel->getElementByToken($token);} > 0) 0 0 0
1778 0 ▶ if ($semfGuessing) {
Branch: 1 branch
BranchTrueFalseTotal
if ($semfGuessing) { } 0 0 0
1779 0 $term = $document->getAnnotations->getSemanticUnitLevel->getElementByToken($token)->[0];
1780
1781 0 ▶ if (($term->isTerm) && (!defined($term->getSemanticFeatureFC($document)))) {
Branch: 1 branch
BranchTrueFalseTotal
if ($term->isTerm and not defined $term->getSemanticFeatureFC($document)) 0 0 0
Condition0%0/3
$term->isTerm and not defined $term->getSemanticFeatureFC($document)
!ll&&!rl&&r
000
MC/DC0%0/2
$term->isTerm and not defined $term->getSemanticFeatureFC($document)
$term->isTerm not defined $term->getSemanticFeatureFC($document)
Truth table0%0/3
A and not(B)
A= $term->isTermB= not defined $term->getSemanticFeatureFC($document)
ABresult
0X0
100
111
1782 # warn "Guessing $semtype\n";
1783 0 $self->_addSemanticFeature($term, $semtype, $document);
1784 }
1785 } else {
1786 0 $term = $document->getAnnotations->getSemanticUnitLevel->getElementByToken($token)->[0];
1787 0 ▶ if ($term->isTerm) {
Branch: 1 branch
BranchTrueFalseTotal
if ($term->isTerm) 0 0 0
1788 0 ▶ if ($term->getSemanticFeatureFC($document) eq $semtype) {
Branch: 1 branch
BranchTrueFalseTotal
if ($term->getSemanticFeatureFC($document) eq $semtype) 0 0 0
1789 # warn "found concept with the right semtype ($semtype)\n";
1790 0 return($term);
1791 }
1792 }
1793 }
1794 }
1795 0 $token = $token->previous;
1796 # warn "token: " . $token->getContent . "\n";
1797 }
1798 } while(($windowSize < $tokenLimit) && (defined $token) && (!$token->equals($sentence_start_token)));
1799
1800 0 return(0);
1801
1802 }
1803  
1804  
1805 0 ▶sub _searchConceptAfter1 {
Subroutine _searchConceptAfter1: not called CC=15 SCAR=54.8
1806 0 my ($self, $document, $sentence_start_token, $sentence_end_token, $semtypeAcr, $start_mark_token, $tokenLimit, $semfGuessing) = @_;
1807  
1808  
1809 0 my $token = $start_mark_token;
1810 0 my $term;
1811  
1812 0 my $windowSize = 0;
1813 0 my $semtype = $self->{"SEMANTICTYPES"}->{$semtypeAcr};
1814  
1815 # warn "in _searchConceptAfter (" . $start_mark_token->getFrom . ")\n";
1816  
1817 0 ▶ do {
Branch: 1 branch
BranchTrueFalseTotal
$windowSize < $tokenLimit and defined $token and not $token->equals($sentence_end_token) and do { do { while (defined $token and ($token->isSep and not $token->equals($sentence_end_token))) { $token = $token->next; } ; if (defined $token and not $token->equals($sentence_end_token)) { ++$windowSize; if (scalar @{$document->getAnnotations->getSemanticUnitLevel->getElementByToken($token);} > 0) { if ($semfGuessing) { $term = $document->getAnnotations->getSemanticUnitLevel->getElementByToken($token)->[0]; if ($term->isTerm and not defined $term->getSemanticFeatureFC($document)) { $self->_addSemanticFeature($term, $semtype, $document); } ; } else { $term = $document->getAnnotations->getSemanticUnitLevel->getElementByToken($token)->[0]; if ($term->isTerm) { if ($term->getSemanticFeatureFC($document) eq $semtype) { return $term; } ; } ; } ; } ; $token = $token->next; } } } 0 0 0
Condition0%0/6
$windowSize < $tokenLimit and defined $token and not $token->equals($sentence_end_token)
!ll&&!rl&&r
000
$windowSize < $tokenLimit and defined $token
!ll&&!rl&&r
000
MC/DC0%0/3
$windowSize < $tokenLimit and defined $token and not $token->equals($sentence_end_token)
$windowSize < $tokenLimit defined $token not $token->equals($sentence_end_token)
Truth table0%0/4
A and B and not(C)
A= $windowSize < $tokenLimitB= defined $tokenC= not $token->equals($sentence_end_token)
ABCresult
0XX0
10X0
1100
1111
1818 0 ▶ while((defined $token) && (($token->isSep) && (!$token->equals($sentence_end_token))) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $token and ($token->isSep and not $token->equals($sentence_end_token))) 0 0 0
Condition0%0/6
defined $token and ($token->isSep and not $token->equals($sentence_end_token))
!ll&&!rl&&r
000
$token->isSep and not $token->equals($sentence_end_token)
!ll&&!rl&&r
000
MC/DC0%0/3
defined $token and ($token->isSep and not $token->equals($sentence_end_token))
defined $token $token->isSep not $token->equals($sentence_end_token)
Truth table0%0/4
A and B and not(C)
A= defined $tokenB= $token->isSepC= not $token->equals($sentence_end_token)
ABCresult
0XX0
10X0
1100
1111
1819 0 $token = $token->next;
1820 } ;
1821 0 ▶ if ((defined($token)) && (!$token->equals($sentence_end_token))) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $token and not $token->equals($sentence_end_token)) 0 0 0
Condition0%0/3
defined $token and not $token->equals($sentence_end_token)
!ll&&!rl&&r
000
MC/DC0%0/2
defined $token and not $token->equals($sentence_end_token)
defined $token not $token->equals($sentence_end_token)
Truth table0%0/3
A and not(B)
A= defined $tokenB= not $token->equals($sentence_end_token)
ABresult
0X0
100
111
1822 0 $windowSize++;
1823 0 ▶ if (scalar(@{$document->getAnnotations->getSemanticUnitLevel->getElementByToken($token)}) > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @{$document->getAnnotations->getSemanticUnitLevel->getElementByToken($token);} > 0) 0 0 0
1824 0 ▶ if ($semfGuessing) {
Branch: 1 branch
BranchTrueFalseTotal
if ($semfGuessing) { } 0 0 0
1825 0 $term = $document->getAnnotations->getSemanticUnitLevel->getElementByToken($token)->[0];
1826 0 ▶ if (($term->isTerm) && (!defined($term->getSemanticFeatureFC($document)))) {
Branch: 1 branch
BranchTrueFalseTotal
if ($term->isTerm and not defined $term->getSemanticFeatureFC($document)) 0 0 0
Condition0%0/3
$term->isTerm and not defined $term->getSemanticFeatureFC($document)
!ll&&!rl&&r
000
MC/DC0%0/2
$term->isTerm and not defined $term->getSemanticFeatureFC($document)
$term->isTerm not defined $term->getSemanticFeatureFC($document)
Truth table0%0/3
A and not(B)
A= $term->isTermB= not defined $term->getSemanticFeatureFC($document)
ABresult
0X0
100
111
1827 # warn "Guessing $semtype\n";
1828 0 $self->_addSemanticFeature($term, $semtype, $document);
1829 }
1830 } else {
1831 0 $term = $document->getAnnotations->getSemanticUnitLevel->getElementByToken($token)->[0];
1832 0 ▶ if ($term->isTerm) {
Branch: 1 branch
BranchTrueFalseTotal
if ($term->isTerm) 0 0 0
1833 0 ▶ if ($term->getSemanticFeatureFC($document) eq $semtype) {
Branch: 1 branch
BranchTrueFalseTotal
if ($term->getSemanticFeatureFC($document) eq $semtype) 0 0 0
1834 0 return($term);
1835 }
1836 }
1837 }
1838 }
1839 0 $token = $token->next;
1840 }
1841 } while(($windowSize < $tokenLimit) && (defined $token) && (!$token->equals($sentence_end_token)));
1842  
1843 0 return(0);
1844 }
1845  
1846 ########################################################################
1847  
1848 0 ▶sub _searchPOSTagBefore1 {
Subroutine _searchPOSTagBefore1: not called CC=12 SCAR=50.5
1849 0 my ($self, $document, $sentence_start_token, $sentence_end_token, $POSTagAcr, $start_mark_token, $tokenLimit) = @_;
1850  
1851  
1852 0 my $token = $start_mark_token;
1853 0 my $word;
1854  
1855 0 my $windowSize = 0;
1856  
1857 # warn "in _searchPOSTagBefore (" . $start_mark_token->getFrom . ")\n";
1858  
1859 0 my $POSTag;
1860 0 ▶ if (defined $self->{"POSTAGS"}->{$POSTagAcr}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{'POSTAGS'}{$POSTagAcr}) { } 0 0 0
1861 0 $POSTag = $self->{"POSTAGS"}->{$POSTagAcr};
1862 } else {
1863 0 $POSTag = $POSTagAcr;
1864 }
1865 # my $semtype = $self->{"SEMANTICTYPES"}->{$POSTag};
1866  
1867 0 ▶ do {
Branch: 1 branch
BranchTrueFalseTotal
$windowSize < $tokenLimit and defined $token and not $token->equals($sentence_start_token) and do { do { while (defined $token and ($token->isSep and not $token->equals($sentence_start_token))) { $token = $token->previous; } ; if (defined $token and not $token->equals($sentence_start_token)) { ++$windowSize; if (scalar @{$document->getAnnotations->getWordLevel->getElementByToken($token);} > 0) { $word = $document->getAnnotations->getWordLevel->getElementByToken($token)->[0]; if ($word->getMorphoSyntacticFeatures($document) eq $POSTag) { return $word; } ; } ; $token = $token->previous; } } } 0 0 0
Condition0%0/6
$windowSize < $tokenLimit and defined $token and not $token->equals($sentence_start_token)
!ll&&!rl&&r
000
$windowSize < $tokenLimit and defined $token
!ll&&!rl&&r
000
MC/DC0%0/3
$windowSize < $tokenLimit and defined $token and not $token->equals($sentence_start_token)
$windowSize < $tokenLimit defined $token not $token->equals($sentence_start_token)
Truth table0%0/4
A and B and not(C)
A= $windowSize < $tokenLimitB= defined $tokenC= not $token->equals($sentence_start_token)
ABCresult
0XX0
10X0
1100
1111
1868 0 ▶ while((defined $token) && (($token->isSep) && (!$token->equals($sentence_start_token))) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $token and ($token->isSep and not $token->equals($sentence_start_token))) 0 0 0
Condition0%0/6
defined $token and ($token->isSep and not $token->equals($sentence_start_token))
!ll&&!rl&&r
000
$token->isSep and not $token->equals($sentence_start_token)
!ll&&!rl&&r
000
MC/DC0%0/3
defined $token and ($token->isSep and not $token->equals($sentence_start_token))
defined $token $token->isSep not $token->equals($sentence_start_token)
Truth table0%0/4
A and B and not(C)
A= defined $tokenB= $token->isSepC= not $token->equals($sentence_start_token)
ABCresult
0XX0
10X0
1100
1111
1869 0 $token = $token->previous;
1870 } ;
1871  
1872 0 ▶ if ((defined($token)) && (!$token->equals($sentence_start_token))) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $token and not $token->equals($sentence_start_token)) 0 0 0
Condition0%0/3
defined $token and not $token->equals($sentence_start_token)
!ll&&!rl&&r
000
MC/DC0%0/2
defined $token and not $token->equals($sentence_start_token)
defined $token not $token->equals($sentence_start_token)
Truth table0%0/3
A and not(B)
A= defined $tokenB= not $token->equals($sentence_start_token)
ABresult
0X0
100
111
1873 # warn "token: " . $token->getContent . "\n";
1874 # warn "\t" . scalar(@{$document->getAnnotations->getWordLevel->getElementByToken($token)}) . "\n";
1875 0 $windowSize++;
1876  
1877 0 ▶ if (scalar(@{$document->getAnnotations->getWordLevel->getElementByToken($token)}) > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @{$document->getAnnotations->getWordLevel->getElementByToken($token);} > 0) 0 0 0
1878 0 $word = $document->getAnnotations->getWordLevel->getElementByToken($token)->[0];
1879 0 ▶ if ($word->getMorphoSyntacticFeatures($document) eq $POSTag) {
Branch: 1 branch
BranchTrueFalseTotal
if ($word->getMorphoSyntacticFeatures($document) eq $POSTag) 0 0 0
1880 # warn "found word with rigt POSTAG ($POSTag)\n";
1881 0 return($word);
1882 }
1883 }
1884 0 $token = $token->previous;
1885 # warn "token: " . $token->getContent . "\n";
1886 }
1887 } while(($windowSize < $tokenLimit) && (defined $token) && (!$token->equals($sentence_start_token)));
1888
1889 0 return(0);
1890
1891 }
1892  
1893  
1894 0 ▶sub _searchPOSTagAfter1 {
Subroutine _searchPOSTagAfter1: not called CC=12 SCAR=50.5
1895 0 my ($self, $document, $sentence_start_token, $sentence_end_token, $POSTagAcr, $start_mark_token, $tokenLimit) = @_;
1896  
1897  
1898 0 my $token = $start_mark_token;
1899 0 my $word;
1900  
1901 0 my $windowSize = 0;
1902 0 my $POSTag;
1903 0 ▶ if (defined $self->{"POSTAGS"}->{$POSTagAcr}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{'POSTAGS'}{$POSTagAcr}) { } 0 0 0
1904 0 $POSTag = $self->{"POSTAGS"}->{$POSTagAcr};
1905 } else {
1906 0 $POSTag = $POSTagAcr;
1907 }
1908 0 ▶ do {
Branch: 1 branch
BranchTrueFalseTotal
$windowSize < $tokenLimit and defined $token and not $token->equals($sentence_end_token) and do { do { while (defined $token and ($token->isSep and not $token->equals($sentence_end_token))) { $token = $token->next; } ; if (defined $token and not $token->equals($sentence_end_token)) { ++$windowSize; if (scalar @{$document->getAnnotations->getWordLevel->getElementByToken($token);} > 0) { $word = $document->getAnnotations->getWordLevel->getElementByToken($token)->[0]; if ($word->getMorphoSyntacticFeatures($document) eq $POSTag) { return $word; } ; } ; $token = $token->next; } } } 0 0 0
Condition0%0/6
$windowSize < $tokenLimit and defined $token and not $token->equals($sentence_end_token)
!ll&&!rl&&r
000
$windowSize < $tokenLimit and defined $token
!ll&&!rl&&r
000
MC/DC0%0/3
$windowSize < $tokenLimit and defined $token and not $token->equals($sentence_end_token)
$windowSize < $tokenLimit defined $token not $token->equals($sentence_end_token)
Truth table0%0/4
A and B and not(C)
A= $windowSize < $tokenLimitB= defined $tokenC= not $token->equals($sentence_end_token)
ABCresult
0XX0
10X0
1100
1111
1909 0 ▶ while((defined $token) && (($token->isSep) && (!$token->equals($sentence_end_token))) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $token and ($token->isSep and not $token->equals($sentence_end_token))) 0 0 0
Condition0%0/6
defined $token and ($token->isSep and not $token->equals($sentence_end_token))
!ll&&!rl&&r
000
$token->isSep and not $token->equals($sentence_end_token)
!ll&&!rl&&r
000
MC/DC0%0/3
defined $token and ($token->isSep and not $token->equals($sentence_end_token))
defined $token $token->isSep not $token->equals($sentence_end_token)
Truth table0%0/4
A and B and not(C)
A= defined $tokenB= $token->isSepC= not $token->equals($sentence_end_token)
ABCresult
0XX0
10X0
1100
1111
1910 0 $token = $token->next;
1911 } ;
1912 0 ▶ if ((defined($token)) && (!$token->equals($sentence_end_token))) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $token and not $token->equals($sentence_end_token)) 0 0 0
Condition0%0/3
defined $token and not $token->equals($sentence_end_token)
!ll&&!rl&&r
000
MC/DC0%0/2
defined $token and not $token->equals($sentence_end_token)
defined $token not $token->equals($sentence_end_token)
Truth table0%0/3
A and not(B)
A= defined $tokenB= not $token->equals($sentence_end_token)
ABresult
0X0
100
111
1913 0 $windowSize++;
1914 0 ▶ if (scalar(@{$document->getAnnotations->getWordLevel->getElementByToken($token)}) > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @{$document->getAnnotations->getWordLevel->getElementByToken($token);} > 0) 0 0 0
1915 0 $word = $document->getAnnotations->getWordLevel->getElementByToken($token)->[0];
1916 0 ▶ if ($word->getMorphoSyntacticFeatures($document) eq $POSTag) {
Branch: 1 branch
BranchTrueFalseTotal
if ($word->getMorphoSyntacticFeatures($document) eq $POSTag) 0 0 0
1917 0 return($word);
1918 }
1919 }
1920 0 $token = $token->next;
1921 }
1922 } while(($windowSize < $tokenLimit) && (defined $token) && (!$token->equals($sentence_end_token)));
1923  
1924 0 return(0);
1925 }
1926  
1927 sub loadSynPatterns
1928 0 ▶{
Subroutine loadSynPatterns: not called CC=3 SCAR=24.8
Pod undocumented
1929 0 my ($self) = @_;
1930  
1931 # $self->_documentSet->[0]->getAnnotations->getLanguage;
1932  
1933 0 ▶ if (defined $self->_config->configuration->{'RESOURCE'}->{"language=EN"}->{"PATTERNSSYN"}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->_config->configuration->{'RESOURCE'}{'language=EN'}{'PATTERNSSYN'}) { } 0 0 0
1934 # warn "**** FILE value to CHANGE *****";
1935 # open FILE, "/home/thierry/Recherche/Challenges/I2B2-2010/Resources/structure_syntaxique-nf.txt" or die "No such file\n";
1936 # open FILE, "/export/home/limbio/hamon/Research/Challenges/I2B2-2010/Resources/structure_syntaxique-test.txt";
1937  
1938 0 ▶ if (!open FILE, $self->_config->configuration->{'RESOURCE'}->{"language=EN"}->{"PATTERNSSYN"}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (open FILE, $self->_config->configuration->{"RESOURCE"}{"language=EN"}{"PATTERNSSYN"}) 0 0 0
1939 0 warn "No such file" . $self->_config->configuration->{'RESOURCE'}->{"language=EN"}->{"PATTERNSSYN"} ."\n";
1940 0 return(0);
1941 }
1942 } else {
1943 0 warn "No Pattern FileName specified\n";
1944 0 return(0);
1945 }
1946  
1947 0 my $parser = Lingua::Ogmios::NLPWrappers::PatternParser->new();
1948  
1949 0 $parser->YYData->{PPRS} = $self;
1950 0 $parser->YYData->{FH} = \*FILE;
1951
1952 0 $parser->YYParse(yylex => \&Lingua::Ogmios::NLPWrappers::PatternParser::_Lexer, yyerror => \&Lingua::Ogmios::NLPWrappers::PatternParser::_Error);
1953  
1954 0 close FILE;
1955 }
1956  
1957 0 ▶sub addSynPattern {
Subroutine addSynPattern: not called CC=1 SCAR=6.9
Pod undocumented
1958 0 my ($self, $node_set, $action, $distance) = @_;
1959  
1960 0 my @nodes = @{$node_set};
1961 0 push @{$self->{'SYN_PATTERNS'}}, {'pattern' => \@nodes,
1962 'action' => $action,
1963 'distance' => $distance};
1964 }
1965  
1966 0 ▶sub getSynPatterns {
Subroutine getSynPatterns: not called CC=1 SCAR=6.9
Pod undocumented
1967 0 my ($self) = @_;
1968  
1969 0 return $self->{SYN_PATTERNS};
1970 }
1971  
1972 0 ▶sub synPatternSearch {
Subroutine synPatternSearch: not called CC=7 SCAR=40.3
Pod undocumented
1973 0 my ($self, $function_pointer, $args) = @_;
1974  
1975 0 warn "start synPatternSearch\n";
1976  
1977 0 $self->{"SYN_PATTERNS"} = [];
1978  
1979 0 ▶ if ($self->loadSynPatterns() == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->loadSynPatterns == 0) 0 0 0
1980 0 return(0);
1981 }
1982  
1983 0 my $document;
1984 my $sentence;
1985  
1986 0 my $sentence_start_token;
1987 0 my $sentence_end_token;
1988  
1989 0 my $pattern;
1990 0 my $synPattern;
1991  
1992 0 my $term;
1993 0 my $word;
1994  
1995 0 my $sentenceLemma;
1996 0 my $sentenceLemma2;
1997  
1998 0 my $REtype;
1999 0 my $RELtype;
2000  
2001 0 my $i;
2002  
2003 0 my $semfGuessing = 0;
2004 0 my $wordSize = 5;
2005  
2006 0 my $j;
2007 my $regexp;
2008  
2009 0 my $offset_refs;
2010  
2011 0 my $POSTAGwordLimit = 10;
2012 0 my $tokenLimit;
2013  
2014 my $domainSpecificRelation;
2015
2016 0 my $start_token;
2017 0 my $start_token_origin;
2018 0 my $end_mark_token;
2019  
2020 0 my $found;
2021 0 my @terms;
2022  
2023 0 my $word_re_start_token;
2024 0 my $word_re_end_token;
2025  
2026 0 my $element;
2027 0 my $selectedSentences;
2028  
2029 # print Dumper($self->{SYN_PATTERNS});
2030  
2031 # warn "start Search\n";
2032  
2033 0 foreach $document (@{$self->_documentSet}) {
2034 0 foreach $synPattern (@{$self->getSynPatterns}) {
2035 # $pattern = $synPattern->{'pattern'};
2036 0 foreach $sentence (@{$document->getAnnotations->getSentenceLevel->getElements}) {
2037 0 $selectedSentences->{$sentence->refid_start_token} = {'sentence' => $sentence,
2038 'first_item' => []
2039 };
2040 }
2041 # print STDERR "Select sentences\n";
2042 # print STDERR Dumper $synPattern->{'pattern'};
2043 0 $selectedSentences = $self->_selectSentencesFromPattern($synPattern->{'pattern'}, $selectedSentences, $document, 0);
2044  
2045 # print STDERR "================\n";
2046 0 foreach $sentence (values %$selectedSentences) {
2047 # print "sentenceID: " . $sentence->{'sentence'}->getId . "\n";
2048 # print STDERR "Scanning sentence " . $sentence->{'sentence'}->getId . "\n";
2049 0 foreach $element (@{$sentence->{'first_item'}}) {
2050 # print STDERR '>>>' . $element->getForm . "\n";
2051  
2052 0 $start_token = $element->start_token;
2053 # if ($synPattern->{'pattern'}->[0]->{'type'} eq "word_re") {
2054 # $start_token = $sentence->{'sentence'}->refid_start_token;
2055 # }
2056 0 $sentence_end_token = $sentence->{'sentence'}->refid_end_token;
2057 0 $wordSize = $synPattern->{'distance'};
2058  
2059 0 my @terms;
2060 0 $self->_searchPattern($document, \$start_token, $sentence_end_token, $synPattern, $wordSize, $semfGuessing, 0, \@terms, $function_pointer, $args);
2061  
2062 }
2063 # print STDERR "-----\n";
2064 }
2065 # print STDERR "************************\n";
2066 }
2067 }
2068 # warn "end Search\n";
2069 0 return (0);
2070 }
2071  
2072 0 ▶sub _searchPattern {
Subroutine _searchPattern: not called CC=24 SCAR=64.0
2073 0 my ($self, $document, $start_token, $sentence_end_token, $synPattern, $wordSize, $semfGuessing, $level, $terms, $function_pointer, $args) = @_;
2074  
2075 0 my $word;
2076 my $term;
2077 0 my $word_re_start_token;
2078 0 my $word_re_end_token;
2079 0 my $found = 0;
2080 0 my $i;
2081  
2082 0 my $pattern = $synPattern->{"pattern"};
2083  
2084 0 my $syndep_start_token = $$start_token;
2085  
2086 # my @terms;
2087  
2088 # my $start_token_orig = $$start_token;
2089  
2090 0 my @patternElements;
2091  
2092 # print STDERR "level = $level\n";
2093  
2094 # print STDERR Dumper $pattern;
2095  
2096  
2097 # if ((scalar(@$pattern) == 1) && ($pattern->[0]->{'type'} eq "chunk")) {
2098 # $level = -1;
2099 # }
2100  
2101 0 ▶ for($i = 0; $i < scalar(@$pattern); $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < scalar @$pattern) 0 0 0
2102 # print "i = $i (" . $pattern->[$i]->{'type'} . ")\n";
2103 # print "$$start_token\n";
2104 # print $$start_token->getId . " : " . $$start_token->getFrom . "\n";
2105 0 ▶ if (!defined $$start_token) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $$start_token) 0 0 0
2106 0 $found = 0;
2107 0 last;
2108 }
2109 0 ▶ if ($pattern->[$i]->{'type'} eq "semtype") {
Branch: 1 branch
BranchTrueFalseTotal
if ($pattern->[$i]{"type"} eq "semtype") 0 0 0
2110 # print "i = $i (" . $pattern->[$i]->{'type'} . ")\n";
2111 0 ▶ if ($term = $self->_searchSemType($document, $$start_token, $sentence_end_token, $pattern->[$i]->{"semtype"}, $wordSize, $semfGuessing)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($term = $self->_searchSemType($document, $$start_token, $sentence_end_token, $pattern->[$i]{'semtype'}, $wordSize, $semfGuessing)) { } 0 0 0
2112 # print STDERR "found " . $term->getForm . " : " . $term->end_token->getId . "(SEMTYPE)\n";
2113 0 push @patternElements, $term;
2114 # temporary
2115 0 ▶ if ($level == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($level == 0) 0 0 0
2116 0 push @$terms, $term;
2117 }
2118 0 $$start_token = $term->end_token->next;
2119 0 $found = 1;
2120 # next;
2121 } else {
2122 # print "term not found\n";
2123 0 $found = 0;
2124 0 last;
2125 }
2126 }
2127 0 ▶ if ($pattern->[$i]->{'type'} eq "postag") {
Branch: 1 branch
BranchTrueFalseTotal
if ($pattern->[$i]{"type"} eq "postag") 0 0 0
2128 # print "i = $i (" . $pattern->[$i]->{'type'} . ")\n";
2129 0 ▶ if ($word = $self->_searchPOSTAG($document, $$start_token, $sentence_end_token, $pattern->[$i]->{"postag"}, $wordSize)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($word = $self->_searchPOSTAG($document, $$start_token, $sentence_end_token, $pattern->[$i]{'postag'}, $wordSize)) { } 0 0 0
2130 # print STDERR "found " . $word->getForm . "(POSTAG)\n";
2131 0 push @patternElements, $word;
2132 0 $$start_token = $word->end_token->next;
2133 0 $found = 1;
2134 # next;
2135 } else {
2136 # print "postag not found\n";
2137 0 $found = 0;
2138 0 last;
2139 }
2140 }
2141 0 ▶ if ($pattern->[$i]->{'type'} eq "word") {
Branch: 1 branch
BranchTrueFalseTotal
if ($pattern->[$i]{"type"} eq "word") 0 0 0
2142 0 ▶ if ($word = $self->_searchWord($document, $$start_token, $sentence_end_token, $pattern->[$i]->{"word"}, $wordSize)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($word = $self->_searchWord($document, $$start_token, $sentence_end_token, $pattern->[$i]{'word'}, $wordSize)) { } 0 0 0
2143 # print STDERR "found " . $word->getForm . " " . $word->start_token->getFrom . " (WORD)\n";
2144 0 push @patternElements, $word;
2145 0 $$start_token = $word->end_token->next;
2146 0 $found = 1;
2147 # next;
2148 } else {
2149 # print "word not found\n";
2150 0 $found = 0;
2151 0 last;
2152 }
2153 }
2154 0 ▶ if ($pattern->[$i]->{'type'} eq "word_re") {
Branch: 1 branch
BranchTrueFalseTotal
if ($pattern->[$i]{"type"} eq "word_re") 0 0 0
2155 # $$start_token = $start_token_orig;
2156 0 ($word_re_start_token, $word_re_end_token) = $self->_searchWordRE($document, $$start_token, $sentence_end_token, $pattern->[$i]->{"word_re"}, $wordSize);
2157 0 ▶ if ((defined $word_re_start_token) && (defined $word_re_end_token)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $word_re_start_token and defined $word_re_end_token) { } 0 0 0
Condition0%0/3
defined $word_re_start_token and defined $word_re_end_token
!ll&&!rl&&r
000
MC/DC0%0/2
defined $word_re_start_token and defined $word_re_end_token
defined $word_re_start_token defined $word_re_end_token
Truth table0%0/3
A and B
A= defined $word_re_start_tokenB= defined $word_re_end_token
ABresult
0X0
100
111
2158 # print STDERR "found " . $word_re_end_token->getContent . "(WORDRE)\n";
2159 ## push @patternElements, $term;
2160 0 $$start_token = $word_re_end_token->next;
2161 0 $found = 1;
2162 # next;
2163 } else {
2164 # print "word not found\n";
2165 0 $found = 0;
2166 0 last;
2167 }
2168 }
2169 0 ▶ if ($pattern->[$i]->{'type'} eq "term") {
Branch: 1 branch
BranchTrueFalseTotal
if ($pattern->[$i]{"type"} eq "term") 0 0 0
2170 0 ▶ if ($term = $self->_searchTerm($document, $$start_token, $sentence_end_token, $wordSize)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($term = $self->_searchTerm($document, $$start_token, $sentence_end_token, $wordSize)) { } 0 0 0
2171 # print STDERR "found " . $word->getForm . "(TERM)\n";
2172 0 push @patternElements, $term;
2173 0 $$start_token = $term->end_token->next;
2174 0 $found = 1;
2175 # next;
2176 } else {
2177 # print "word not found\n";
2178 0 $found = 0;
2179 0 last;
2180 }
2181 }
2182 0 ▶ if ($pattern->[$i]->{'type'} eq "termContent") {
Branch: 1 branch
BranchTrueFalseTotal
if ($pattern->[$i]{"type"} eq "termContent") 0 0 0
2183 0 ▶ if ($term = $self->_searchTermContent($document, $$start_token, $sentence_end_token, $pattern->[$i]->{"termContent"}, $wordSize)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($term = $self->_searchTermContent($document, $$start_token, $sentence_end_token, $pattern->[$i]{'termContent'}, $wordSize)) { } 0 0 0
2184 # print STDERR "found " . $word->getForm . "(TERMCONTENT)\n";
2185 0 push @patternElements, $term;
2186 0 $$start_token = $term->end_token->next;
2187 0 $found = 1;
2188 # next;
2189 } else {
2190 # print "word not found\n";
2191 0 $found = 0;
2192 0 last;
2193 }
2194 }
2195 0 ▶ if ($pattern->[$i]->{'type'} eq "chunk") {
Branch: 1 branch
BranchTrueFalseTotal
if ($pattern->[$i]{"type"} eq "chunk") 0 0 0
2196 # print "i = $i (" . $pattern->[$i]->{'type'} . ")\n";
2197 0 ▶ if ($found = $self->_searchPattern($document, $start_token, $sentence_end_token, {'pattern' => $pattern->[$i]->{"chunk"}}, $wordSize, $semfGuessing, $level + 1, $terms, $function_pointer, $args)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($found = $self->_searchPattern($document, $start_token, $sentence_end_token, {'pattern', $pattern->[$i]{'chunk'}}, $wordSize, $semfGuessing, $level + 1, $terms, $function_pointer, $args)) { } 0 0 0
2198 ## push @patternElements, $term;
2199 0 $found = 1;
2200 # print STDERR "chunk found $found\n";
2201 } else {
2202 # print "chunk not found\n";
2203 0 $found = 0;
2204 0 last;
2205 }
2206 }
2207 0 ▶ if ($pattern->[$i]->{'type'} eq "syndep") {
Branch: 1 branch
BranchTrueFalseTotal
if ($pattern->[$i]{"type"} eq "syndep") 0 0 0
2208 0 ▶ if (scalar (@patternElements) > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @patternElements > 0) 0 0 0
2209 0 $syndep_start_token = $patternElements[0]->start_token;
2210 }
2211  
2212 0 ▶ if ($self->_searchSynDep($document, $syndep_start_token, $sentence_end_token, $pattern->[$i]->{'syndep'}, $wordSize, \@patternElements, $terms)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_searchSynDep($document, $syndep_start_token, $sentence_end_token, $pattern->[$i]{'syndep'}, $wordSize, \@patternElements, $terms)) { } 0 0 0
2213 # print STDERR "syndep found\n";
2214 0 $found = 1;
2215 } else {
2216 # print "i = $i (" . $pattern->[$i]->{'type'} . ")\n";
2217 0 $found = 0;
2218 0 last;
2219 }
2220 }
2221 }
2222 # print STDERR "($level - $found)\n";
2223 0 ▶ if (($level == 0) && ($found == 1)) { # ($i == scalar(@$pattern)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($level == 0 and $found == 1) 0 0 0
Condition0%0/3
$level == 0 and $found == 1
!ll&&!rl&&r
000
MC/DC0%0/2
$level == 0 and $found == 1
$level == 0 $found == 1
Truth table0%0/3
A and B
A= $level == 0B= $found == 1
ABresult
0X0
100
111
2224 # if ($found == 1) { # ($i == scalar(@$pattern)) {
2225 # print STDERR "PATTERN FOUND ($level - $found) - " . $synPattern->{"action"} . "\n";
2226 # my @tmp = split m!/!, $synPattern->{"action"};
2227 0 &$function_pointer($document, $synPattern->{"action"}, $terms, $args);
2228 # &$function_pointer($document, $synPattern->{"action"}, \@terms, $args);
2229 }
2230 0 return($found);
2231 }
2232  
2233 0 ▶sub _searchSynDep {
Subroutine _searchSynDep: not called CC=9 SCAR=45.0
2234 0 my ($self, $document, $start_token, $end_token, $syndep, $WindowSize, $patternElements, $terms) = @_;
2235  
2236 0 my $token = $start_token;
2237 0 my $synrel;
2238 0 my $currentWindowSize = 0;
2239 0 my $phrase;
2240  
2241 0 ▶ if (scalar(@$terms) == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @$terms == 0) 0 0 0
2242 0 return(0);
2243 }
2244  
2245 0 my $term_start_token = $terms->[0]->start_token;
2246 0 my $term_end_token = $terms->[0]->end_token;
2247  
2248 0 my %postags = ("DT" => 1, "IN" => 1);
2249  
2250 # warn "====> " . $terms->[0]->getForm . "\n";
2251  
2252 0 ▶ if (ref($terms->[0]) eq "Lingua::Ogmios::Annotations::SemanticUnit") {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $terms->[0] eq "Lingua::Ogmios::Annotations::SemanticUnit") 0 0 0
2253 0 ▶ if (($terms->[0]->reference_name eq "refid_word") ||
Branch: 2 branches
BranchTrueFalseTotal
if ($terms->[0]->reference_name eq 'refid_word' or $terms->[0]->reference_name eq 'refid_phrase') { } 0 0 0
elsif ($document->getAnnotations->getWordLevel->existsElementFromIndex('list_refid_token', $terms->[0]->start_token->getId)) { } 0 0 0
Condition0%0/3
$terms->[0]->reference_name eq "refid_word" or $terms->[0]->reference_name eq "refid_phrase"
l!l&&r!l&&!r
000
MC/DC0%0/2
$terms->[0]->reference_name eq "refid_word" or $terms->[0]->reference_name eq "refid_phrase"
$terms->[0]->reference_name eq "refid_word" $terms->[0]->reference_name eq "refid_phrase"
Truth table0%0/3
A or B
A= $terms->[0]->reference_name eq "refid_word"B= $terms->[0]->reference_name eq "refid_phrase"
ABresult
1X1
011
000
2254 ($terms->[0]->reference_name eq "refid_phrase")) {
2255 0 $phrase = $terms->[0]->reference;
2256 } elsif ($document->getAnnotations->getWordLevel->existsElementFromIndex("list_refid_token", $terms->[0]->start_token->getId)) {
2257 0 $phrase = $document->getAnnotations->getWordLevel->getElementFromIndex("list_refid_token", $terms->[0]->start_token->getId)->[0];
2258 }
2259 }
2260  
2261 # warn "phrase: " . $phrase->getForm . "\n";
2262  
2263 0 foreach $synrel (@{$document->getAnnotations->getSyntacticRelationLevel->getElementFromIndex('syntactic_relation_type', $syndep)}) {
2264 # foreach $synrel (@{$document->getAnnotations->getSyntacticRelationLevel->getElementFromIndex2('refid_head', $phrase)}) {
2265 # foreach $synrel (@{$document->getAnnotations->getSyntacticRelationLevel->getElements}) {
2266 # if ($synrel->syntactic_relation_type eq $syndep) {
2267 # print $start_token->getFrom . " <= " . $synrel->refid_modifier->[0]->start_token->getFrom . "\n";
2268 # print $synrel->refid_modifier->[0]->end_token->getTo . " <= " . $end_token->getTo . "\n";
2269  
2270 # print STDERR "syndep\n";
2271  
2272 # my %tmp = (ref($synrel->refid_head->[0]) . $synrel->refid_head->[0]->getId => $synrel->refid_head->[0]);
2273 # my @elementChunk = $self->_getChunkFromElement($document, $synrel->refid_modifier->[0], $synrel->refid_head->[0], \%tmp);
2274 # my $elt;
2275 # warn "===\n";
2276 # foreach $elt (keys %tmp) {
2277 # print STDERR "\t$elt : " . $tmp{$elt}->getForm . "\n";
2278 # }
2279  
2280 # ? check if the head of syndep is in the found elements at the level n-1
2281 # my $i = -1;
2282 # my $refPatElmt;
2283 # for($i = 0; $i < scalar(@$patternelments); $i++) {
2284 # if ((($refPatElmt eq "Lingua::Ogmios::Annotations::Word" ) ||
2285 # ($refPatElmt eq "Lingua::Ogmios::Annotations::Phrase" )) &&
2286 # (!exists $tmp{$refPatElmt . $patternelments->[$i]->getId})) {
2287 # return(0);
2288 # }
2289 # }
2290 # return(1);
2291  
2292 # do {
2293 # $i++;
2294 # if ($i < scalar(@$patternElements)) {
2295 # $refPatElmt = ref($patternElements->[$i]);
2296 # print STDERR "($i)" . $refPatElmt . $patternElements->[$i]->getId . "\n";
2297 # if ($refPatElmt eq "Lingua::Ogmios::Annotations::Word" ) {
2298 # print STDERR "\t" . $patternElements->[$i]->getMorphoSyntacticFeatures($document)->syntactic_category . "\n";
2299 # }
2300 # }
2301 # } while(($i < scalar(@$patternElements)) &&
2302 # (($refPatElmt eq "Lingua::Ogmios::Annotations::Word" ) ||
2303 # ($refPatElmt eq "Lingua::Ogmios::Annotations::Phrase" )) &&
2304 # ((($refPatElmt eq "Lingua::Ogmios::Annotations::Word" ) &&
2305 # (exists $postags{$patternElements->[$i]->getMorphoSyntacticFeatures($document)->syntactic_category})) ||
2306 # (exists $tmp{$refPatElmt . $patternElements->[$i]->getId})));
2307 # warn "i = $i\n";
2308 # if ($i == scalar(@$patternElements)) {
2309 # print STDERR "==>FOUND (" . $terms->[0]->getForm . ")\n";
2310 # print "==>FOUND (" . $terms->[0]->getForm . ")\n";
2311 # return(1);
2312 # }
2313  
2314 # search in syndep is in the found elements
2315 0 ▶ if (($start_token->getFrom <= $synrel->refid_modifier->[0]->start_token->getFrom) &&
Branch: 1 branch
BranchTrueFalseTotal
if ($start_token->getFrom <= $synrel->refid_modifier->[0]->start_token->getFrom and $synrel->refid_modifier->[0]->end_token->getTo <= $end_token->getTo) 0 0 0
Condition0%0/3
$start_token->getFrom <= $synrel->refid_modifier->[0]->start_token->getFrom and $synrel->refid_modifier->[0]->end_token->getTo <= $end_token->getTo
!ll&&!rl&&r
000
MC/DC0%0/2
$start_token->getFrom <= $synrel->refid_modifier->[0]->start_token->getFrom and $synrel->refid_modifier->[0]->end_token->getTo <= $end_token->getTo
$start_token->getFrom <= $synrel->refid_modifier->[0]->start_token->getFrom $synrel->refid_modifier->[0]->end_token->getTo <= $end_token->getTo
Truth table0%0/3
A and B
A= $start_token->getFrom <= $synrel->refid_modifier->[0]->start_token->getFromB= $synrel->refid_modifier->[0]->end_token->getTo <= $end_token->getTo
ABresult
0X0
100
111
2316 ($synrel->refid_modifier->[0]->end_token->getTo <= $end_token->getTo)) {
2317  
2318 # # if ((($start_token->getFrom <= $synrel->refid_modifier->[0]->start_token->getFrom) &&
2319 # # ($synrel->refid_modifier->[0]->end_token->getTo <= $end_token->getTo)) &&
2320 # # (($term_start_token->getFrom <= $synrel->refid_head->[0]->start_token->getFrom) &&
2321 # # ($synrel->refid_head->[0]->end_token->getTo <= $term_end_token->getTo))) {
2322  
2323 # print STDERR "==>FOUND (" . $terms->[0]->getForm . ")\n";
2324 # print "==>FOUND (" . $terms->[0]->getForm . ")\n";
2325 0 return(1);
2326  
2327 # check if all the the elements are in the chunk
2328  
2329 }
2330 }
2331 # warn "syndep not found\n";
2332 # print "search Concept\n";
2333  
2334 # do {
2335 # my @words = @{$document->getAnnotations->getWordLevel->getElementByToken($token)};
2336 # if (scalar(@words) > 0) {
2337 # $words{$words[0]->getId}++;
2338 # $currentWindowSize = scalar(keys %words);
2339 # }
2340 # foreach $term (@{$document->getAnnotations->getSemanticUnitLevel->getElementByToken($token)}) {
2341 # if ($semfGuessing) {
2342 # if (($term->isTerm) && (!defined($term->getSemanticFeatureFC($document)))) {
2343 # $self->_addSemanticFeature($term, $semtype, $document);
2344 # }
2345 # } else {
2346 # if ($term->isTerm) {
2347 # if ($term->getSemanticFeatureFC($document) eq $semtype) {
2348 # return($term);
2349 # }
2350 # }
2351 # }
2352 # }
2353 # $token = $token->next;
2354 # } while(($currentWindowSize < $WindowSize) && (defined $token) && ($token->getFrom <= $end_token->getTo));
2355  
2356 0 return(0);
2357 }
2358  
2359 0 ▶sub _searchSynDep2 {
Subroutine _searchSynDep2: not called CC=16 SCAR=56.1
2360 0 my ($self, $document, $start_token, $end_token, $syndep, $WindowSize, $patternElements, $terms) = @_;
2361  
2362 0 my $token = $start_token;
2363 0 my $synrel;
2364 0 my $currentWindowSize = 0;
2365 0 my $phrase;
2366  
2367 0 my $term_start_token = $terms->[0]->start_token;
2368 0 my $term_end_token = $terms->[0]->end_token;
2369  
2370 0 my %postags = ("DT" => 1, "IN" => 1);
2371  
2372 # warn "====> " . $terms->[0]->getForm . "\n";
2373  
2374 0 ▶ if (ref($terms->[0]) eq "Lingua::Ogmios::Annotations::SemanticUnit") {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $terms->[0] eq "Lingua::Ogmios::Annotations::SemanticUnit") 0 0 0
2375 0 ▶ if (($terms->[0]->reference_name eq "refid_word") ||
Branch: 2 branches
BranchTrueFalseTotal
if ($terms->[0]->reference_name eq 'refid_word' or $terms->[0]->reference_name eq 'refid_phrase') { } 0 0 0
elsif ($document->getAnnotations->getWordLevel->existsElementFromIndex('list_refid_token', $terms->[0]->start_token->getId)) { } 0 0 0
Condition0%0/3
$terms->[0]->reference_name eq "refid_word" or $terms->[0]->reference_name eq "refid_phrase"
l!l&&r!l&&!r
000
MC/DC0%0/2
$terms->[0]->reference_name eq "refid_word" or $terms->[0]->reference_name eq "refid_phrase"
$terms->[0]->reference_name eq "refid_word" $terms->[0]->reference_name eq "refid_phrase"
Truth table0%0/3
A or B
A= $terms->[0]->reference_name eq "refid_word"B= $terms->[0]->reference_name eq "refid_phrase"
ABresult
1X1
011
000
2376 ($terms->[0]->reference_name eq "refid_phrase")) {
2377 0 $phrase = $terms->[0]->reference;
2378 } elsif ($document->getAnnotations->getWordLevel->existsElementFromIndex("list_refid_token", $terms->[0]->start_token->getId)) {
2379 0 $phrase = $document->getAnnotations->getWordLevel->getElementFromIndex("list_refid_token", $terms->[0]->start_token->getId)->[0];
2380 }
2381 }
2382  
2383 0 warn "phrase: " . $phrase->getForm . "\n";
2384  
2385 # foreach $synrel (@{$document->getAnnotations->getSyntacticRelationLevel->getElementFromIndex('syntactic_relation_type', $syndep)}) {
2386 0 foreach $synrel (@{$document->getAnnotations->getSyntacticRelationLevel->getElementFromIndex2('refid_head', $phrase)}) {
2387 # foreach $synrel (@{$document->getAnnotations->getSyntacticRelationLevel->getElements}) {
2388 # if ($synrel->syntactic_relation_type eq $syndep) {
2389 # print $start_token->getFrom . " <= " . $synrel->refid_modifier->[0]->start_token->getFrom . "\n";
2390 # print $synrel->refid_modifier->[0]->end_token->getTo . " <= " . $end_token->getTo . "\n";
2391  
2392 0 print STDERR "syndep\n";
2393  
2394 0 my %tmp = (ref($synrel->refid_head->[0]) . $synrel->refid_head->[0]->getId => $synrel->refid_head->[0]);
2395 0 my @elementChunk = $self->_getChunkFromElement($document, $synrel->refid_modifier->[0], $synrel->refid_head->[0], \%tmp);
2396 0 my $elt;
2397 0 warn "===\n";
2398 0 foreach $elt (keys %tmp) {
2399 0 print STDERR "\t$elt : " . $tmp{$elt}->getForm . "\n";
2400 }
2401  
2402 # ? check if the head of syndep is in the found elements at the level n-1
2403 0 my $i = -1;
2404 0 my $refPatElmt;
2405 # for($i = 0; $i < scalar(@$patternelments); $i++) {
2406 # if ((($refPatElmt eq "Lingua::Ogmios::Annotations::Word" ) ||
2407 # ($refPatElmt eq "Lingua::Ogmios::Annotations::Phrase" )) &&
2408 # (!exists $tmp{$refPatElmt . $patternelments->[$i]->getId})) {
2409 # return(0);
2410 # }
2411 # }
2412 # return(1);
2413 do {
2414 0 $i++;
2415 0 ▶ if ($i < scalar(@$patternElements)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < scalar @$patternElements) 0 0 0
2416 0 $refPatElmt = ref($patternElements->[$i]);
2417 0 print STDERR "($i)" . $refPatElmt . $patternElements->[$i]->getId . "\n";
2418 0 ▶ if ($refPatElmt eq "Lingua::Ogmios::Annotations::Word" ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($refPatElmt eq "Lingua::Ogmios::Annotations::Word") 0 0 0
2419 0 print STDERR "\t" . $patternElements->[$i]->getMorphoSyntacticFeatures($document)->syntactic_category . "\n";
2420 }
2421 }
2422 } while(($i < scalar(@$patternElements)) &&
2423 (($refPatElmt eq "Lingua::Ogmios::Annotations::Word" ) ||
2424 ($refPatElmt eq "Lingua::Ogmios::Annotations::Phrase" )) &&
2425 ((($refPatElmt eq "Lingua::Ogmios::Annotations::Word" ) &&
2426 (exists $postags{$patternElements->[$i]->getMorphoSyntacticFeatures($document)->syntactic_category})) ||
2427 0 ▶ (exists $tmp{$refPatElmt . $patternElements->[$i]->getId})));
Branch: 1 branch
BranchTrueFalseTotal
$i < scalar @$patternElements and $refPatElmt eq "Lingua::Ogmios::Annotations::Word" || $refPatElmt eq "Lingua::Ogmios::Annotations::Phrase" and $refPatElmt eq "Lingua::Ogmios::Annotations::Word" && exists $postags{$patternElements->[$i]->getMorphoSyntacticFeatures($document)->syntactic_category} || exists $tmp{$refPatElmt . $patternElements->[$i]->getId} and do { do { ++$i; if ($i < scalar @$patternElements) { $refPatElmt = ref $patternElements->[$i]; print STDERR "($i)" . $refPatElmt . $patternElements->[$i]->getId . "\n"; if ($refPatElmt eq "Lingua::Ogmios::Annotations::Word") { print STDERR "\t" . $patternElements->[$i]->getMorphoSyntacticFeatures($document)->syntactic_category . "\n"; } ; } } } 0 0 0
Condition0%0/15
$i < scalar @$patternElements and $refPatElmt eq "Lingua::Ogmios::Annotations::Word" || $refPatElmt eq "Lingua::Ogmios::Annotations::Phrase" and $refPatElmt eq "Lingua::Ogmios::Annotations::Word" && exists $postags{$patternElements->[$i]->getMorphoSyntacticFeatures($document)->syntactic_category} || exists $tmp{$refPatElmt . $patternElements->[$i]->getId}
!ll&&!rl&&r
000
$i < scalar @$patternElements and $refPatElmt eq "Lingua::Ogmios::Annotations::Word" || $refPatElmt eq "Lingua::Ogmios::Annotations::Phrase"
!ll&&!rl&&r
000
$refPatElmt eq "Lingua::Ogmios::Annotations::Word" or $refPatElmt eq "Lingua::Ogmios::Annotations::Phrase"
l!l&&r!l&&!r
000
$refPatElmt eq "Lingua::Ogmios::Annotations::Word" and exists $postags{$patternElements->[$i]->getMorphoSyntacticFeatures($document)->syntactic_category} or exists $tmp{$refPatElmt . $patternElements->[$i]->getId}
l!l&&r!l&&!r
000
$refPatElmt eq "Lingua::Ogmios::Annotations::Word" and exists $postags{$patternElements->[$i]->getMorphoSyntacticFeatures($document)->syntactic_category}
!ll&&!rl&&r
000
MC/DC0%0/6
$i < scalar @$patternElements and $refPatElmt eq "Lingua::Ogmios::Annotations::Word" || $refPatElmt eq "Lingua::Ogmios::Annotations::Phrase" and $refPatElmt eq "Lingua::Ogmios::Annotations::Word" && exists $postags{$patternElements->[$i]->getMorphoSyntacticFeatures($document)->syntactic_category} || exists $tmp{$refPatElmt . $patternElements->[$i]->getId}
$i < scalar @$patternElements $refPatElmt eq "Lingua::Ogmios::Annotations::Word" $refPatElmt eq "Lingua::Ogmios::Annotations::Phrase" $refPatElmt eq "Lingua::Ogmios::Annotations::Word" exists $postags{$patternElements->[$i]->getMorphoSyntacticFeatures($document)->syntactic_category} exists $tmp{$refPatElmt . $patternElements->[$i]->getId}
Truth table0%0/12
A and B or C and D and E or F
A= $i < scalar @$patternElementsB= $refPatElmt eq "Lingua::Ogmios::Annotations::Word"C= $refPatElmt eq "Lingua::Ogmios::Annotations::Phrase"D= $refPatElmt eq "Lingua::Ogmios::Annotations::Word"E= exists $postags{$patternElements->[$i]->getMorphoSyntacticFeatures($document)->syntactic_category}F= exists $tmp{$refPatElmt . $patternElements->[$i]->getId}
ABCDEFresult
0XXXXX0
100XXX0
11X0X00
11X1000
1010X00
1011000
11X11X1
11X0X11
11X1011
10111X1
1010X11
1011011
2428 0 warn "i = $i\n";
2429 0 ▶ if ($i == scalar(@$patternElements)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i == scalar @$patternElements) 0 0 0
2430 0 print STDERR "==>FOUND (" . $terms->[0]->getForm . ")\n";
2431 0 print "==>FOUND (" . $terms->[0]->getForm . ")\n";
2432 0 return(1);
2433 }
2434  
2435 # search in syndep is in the found elements
2436 # if (($start_token->getFrom <= $synrel->refid_modifier->[0]->start_token->getFrom) &&
2437 # ($synrel->refid_modifier->[0]->end_token->getTo <= $end_token->getTo)) {
2438  
2439 # # if ((($start_token->getFrom <= $synrel->refid_modifier->[0]->start_token->getFrom) &&
2440 # # ($synrel->refid_modifier->[0]->end_token->getTo <= $end_token->getTo)) &&
2441 # # (($term_start_token->getFrom <= $synrel->refid_head->[0]->start_token->getFrom) &&
2442 # # ($synrel->refid_head->[0]->end_token->getTo <= $term_end_token->getTo))) {
2443  
2444 # print STDERR "==>FOUND (" . $terms->[0]->getForm . ")\n";
2445 # print "==>FOUND (" . $terms->[0]->getForm . ")\n";
2446 # return(1);
2447  
2448 # # check if all the the elements are in the chunk
2449  
2450 # }
2451 }
2452 0 warn "syndep not found\n";
2453 # print "search Concept\n";
2454  
2455 # do {
2456 # my @words = @{$document->getAnnotations->getWordLevel->getElementByToken($token)};
2457 # if (scalar(@words) > 0) {
2458 # $words{$words[0]->getId}++;
2459 # $currentWindowSize = scalar(keys %words);
2460 # }
2461 # foreach $term (@{$document->getAnnotations->getSemanticUnitLevel->getElementByToken($token)}) {
2462 # if ($semfGuessing) {
2463 # if (($term->isTerm) && (!defined($term->getSemanticFeatureFC($document)))) {
2464 # $self->_addSemanticFeature($term, $semtype, $document);
2465 # }
2466 # } else {
2467 # if ($term->isTerm) {
2468 # if ($term->getSemanticFeatureFC($document) eq $semtype) {
2469 # return($term);
2470 # }
2471 # }
2472 # }
2473 # }
2474 # $token = $token->next;
2475 # } while(($currentWindowSize < $WindowSize) && (defined $token) && ($token->getFrom <= $end_token->getTo));
2476  
2477 0 return(0);
2478 }
2479  
2480 0 ▶sub _searchSemType {
Subroutine _searchSemType: not called CC=11 SCAR=48.8
2481 0 my ($self, $document, $start_token, $end_token, $semtypeAcr, $WindowSize, $semfGuessing) = @_;
2482  
2483 0 my $token = $start_token;
2484 0 my $term;
2485 my $word;
2486 0 my $currentWindowSize = 0;
2487 0 my $semtype = $self->{"SEMANTICTYPES"}->{$semtypeAcr};
2488 0 my %words;
2489  
2490 # print STDERR "search SemType\n";
2491  
2492 0 ▶ do {
Branch: 1 branch
BranchTrueFalseTotal
$currentWindowSize < $WindowSize and defined $token and $token->getFrom <= $end_token->getTo and do { do { my(@words) = @{$document->getAnnotations->getWordLevel->getElementByToken($token);}; if (scalar @words > 0) { ++$words{$words[0]->getId}; $currentWindowSize = scalar keys %words; } ; foreach $term (@{$document->getAnnotations->getSemanticUnitLevel->getElementByToken($token);}) { if ($semfGuessing) { if ($term->isTerm and not defined $term->getSemanticFeatureFC($document)) { $self->_addSemanticFeature($term, $semtype, $document); } ; } else { if ($term->isTerm) { if ($term->getSemanticFeatureFC($document) eq $semtype) { return $term; } ; } ; } ; } ; $token = $token->next } } 0 0 0
Condition0%0/6
$currentWindowSize < $WindowSize and defined $token and $token->getFrom <= $end_token->getTo
!ll&&!rl&&r
000
$currentWindowSize < $WindowSize and defined $token
!ll&&!rl&&r
000
MC/DC0%0/3
$currentWindowSize < $WindowSize and defined $token and $token->getFrom <= $end_token->getTo
$currentWindowSize < $WindowSize defined $token $token->getFrom <= $end_token->getTo
Truth table0%0/4
A and B and C
A= $currentWindowSize < $WindowSizeB= defined $tokenC= $token->getFrom <= $end_token->getTo
ABCresult
0XX0
10X0
1100
1111
2493 0 my @words = @{$document->getAnnotations->getWordLevel->getElementByToken($token)};
2494 0 ▶ if (scalar(@words) > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @words > 0) 0 0 0
2495 0 $words{$words[0]->getId}++;
2496 0 $currentWindowSize = scalar(keys %words);
2497 }
2498 0 foreach $term (@{$document->getAnnotations->getSemanticUnitLevel->getElementByToken($token)}) {
2499 0 ▶ if ($semfGuessing) {
Branch: 1 branch
BranchTrueFalseTotal
if ($semfGuessing) { } 0 0 0
2500 0 ▶ if (($term->isTerm) && (!defined($term->getSemanticFeatureFC($document)))) {
Branch: 1 branch
BranchTrueFalseTotal
if ($term->isTerm and not defined $term->getSemanticFeatureFC($document)) 0 0 0
Condition0%0/3
$term->isTerm and not defined $term->getSemanticFeatureFC($document)
!ll&&!rl&&r
000
MC/DC0%0/2
$term->isTerm and not defined $term->getSemanticFeatureFC($document)
$term->isTerm not defined $term->getSemanticFeatureFC($document)
Truth table0%0/3
A and not(B)
A= $term->isTermB= not defined $term->getSemanticFeatureFC($document)
ABresult
0X0
100
111
2501 0 $self->_addSemanticFeature($term, $semtype, $document);
2502 }
2503 } else {
2504 0 ▶ if ($term->isTerm) {
Branch: 1 branch
BranchTrueFalseTotal
if ($term->isTerm) 0 0 0
2505 0 ▶ if ($term->getSemanticFeatureFC($document) eq $semtype) {
Branch: 1 branch
BranchTrueFalseTotal
if ($term->getSemanticFeatureFC($document) eq $semtype) 0 0 0
2506 0 return($term);
2507 }
2508 }
2509 }
2510 }
2511 0 $token = $token->next;
2512 } while(($currentWindowSize < $WindowSize) && (defined $token) && ($token->getFrom <= $end_token->getTo));
2513  
2514 0 return(0);
2515 }
2516  
2517 0 ▶sub _searchTermContent {
Subroutine _searchTermContent: not called CC=8 SCAR=42.8
2518 0 my ($self, $document, $start_token, $end_token, $termcontent, $WindowSize) = @_;
2519  
2520 0 my $token = $start_token;
2521 0 my $term;
2522 my $word;
2523 0 my $currentWindowSize = 0;
2524 0 my %words;
2525  
2526 # print STDERR "search term content\n";
2527  
2528 0 ▶ do {
Branch: 1 branch
BranchTrueFalseTotal
$currentWindowSize < $WindowSize and defined $token and $token->getFrom <= $end_token->getTo and do { do { my(@words) = @{$document->getAnnotations->getWordLevel->getElementByToken($token);}; if (scalar @words > 0) { ++$words{$words[0]->getId}; $currentWindowSize = scalar keys %words; } ; foreach $term (@{$document->getAnnotations->getSemanticUnitLevel->getElementByToken($token);}) { if ($term->isTerm) { if ($term->getForm eq $termcontent) { return $term; } ; } ; } ; $token = $token->next } } 0 0 0
Condition0%0/6
$currentWindowSize < $WindowSize and defined $token and $token->getFrom <= $end_token->getTo
!ll&&!rl&&r
000
$currentWindowSize < $WindowSize and defined $token
!ll&&!rl&&r
000
MC/DC0%0/3
$currentWindowSize < $WindowSize and defined $token and $token->getFrom <= $end_token->getTo
$currentWindowSize < $WindowSize defined $token $token->getFrom <= $end_token->getTo
Truth table0%0/4
A and B and C
A= $currentWindowSize < $WindowSizeB= defined $tokenC= $token->getFrom <= $end_token->getTo
ABCresult
0XX0
10X0
1100
1111
2529 0 my @words = @{$document->getAnnotations->getWordLevel->getElementByToken($token)};
2530 0 ▶ if (scalar(@words) > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @words > 0) 0 0 0
2531 0 $words{$words[0]->getId}++;
2532 0 $currentWindowSize = scalar(keys %words);
2533 }
2534 0 foreach $term (@{$document->getAnnotations->getSemanticUnitLevel->getElementByToken($token)}) {
2535 0 ▶ if ($term->isTerm) {
Branch: 1 branch
BranchTrueFalseTotal
if ($term->isTerm) 0 0 0
2536 0 ▶ if ($term->getForm eq $termcontent) {
Branch: 1 branch
BranchTrueFalseTotal
if ($term->getForm eq $termcontent) 0 0 0
2537 0 return($term);
2538 }
2539 }
2540 }
2541 0 $token = $token->next;
2542 } while(($currentWindowSize < $WindowSize) && (defined $token) && ($token->getFrom <= $end_token->getTo));
2543  
2544 0 return(0);
2545 }
2546  
2547 0 ▶sub _searchTerm {
Subroutine _searchTerm: not called CC=7 SCAR=40.3
2548 0 my ($self, $document, $start_token, $end_token, $WindowSize) = @_;
2549  
2550 0 my $token = $start_token;
2551 0 my $term;
2552 my $word;
2553 0 my $currentWindowSize = 0;
2554 0 my %words;
2555  
2556 # print STDERR "search Term\n";
2557  
2558 0 ▶ do {
Branch: 1 branch
BranchTrueFalseTotal
$currentWindowSize < $WindowSize and defined $token and $token->getFrom <= $end_token->getTo and do { do { my(@words) = @{$document->getAnnotations->getWordLevel->getElementByToken($token);}; if (scalar @words > 0) { ++$words{$words[0]->getId}; $currentWindowSize = scalar keys %words; } ; foreach $term (@{$document->getAnnotations->getSemanticUnitLevel->getElementByToken($token);}) { if ($term->isTerm) { return $term; } ; } ; $token = $token->next } } 0 0 0
Condition0%0/6
$currentWindowSize < $WindowSize and defined $token and $token->getFrom <= $end_token->getTo
!ll&&!rl&&r
000
$currentWindowSize < $WindowSize and defined $token
!ll&&!rl&&r
000
MC/DC0%0/3
$currentWindowSize < $WindowSize and defined $token and $token->getFrom <= $end_token->getTo
$currentWindowSize < $WindowSize defined $token $token->getFrom <= $end_token->getTo
Truth table0%0/4
A and B and C
A= $currentWindowSize < $WindowSizeB= defined $tokenC= $token->getFrom <= $end_token->getTo
ABCresult
0XX0
10X0
1100
1111
2559 0 my @words = @{$document->getAnnotations->getWordLevel->getElementByToken($token)};
2560 0 ▶ if (scalar(@words) > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @words > 0) 0 0 0
2561 0 $words{$words[0]->getId}++;
2562 0 $currentWindowSize = scalar(keys %words);
2563 }
2564 0 foreach $term (@{$document->getAnnotations->getSemanticUnitLevel->getElementByToken($token)}) {
2565 0 ▶ if ($term->isTerm) {
Branch: 1 branch
BranchTrueFalseTotal
if ($term->isTerm) 0 0 0
2566 0 return($term);
2567 }
2568 }
2569 0 $token = $token->next;
2570 } while(($currentWindowSize < $WindowSize) && (defined $token) && ($token->getFrom <= $end_token->getTo));
2571  
2572 0 return(0);
2573 }
2574  
2575 0 ▶sub _searchPOSTAG {
Subroutine _searchPOSTAG: not called CC=6 SCAR=37.4
2576 0 my ($self, $document, $start_token, $end_token, $POSTAG, $WindowSize) = @_;
2577  
2578 0 my $token = $start_token;
2579 0 my $currentWindowSize = 0;
2580 0 my %words;
2581  
2582 # print STDERR "search POSTAG ($POSTAG - $WindowSize)\n";
2583 0 ▶ do {
Branch: 1 branch
BranchTrueFalseTotal
$currentWindowSize < $WindowSize and defined $token and $token->getFrom <= $end_token->getTo and do { do { my(@words) = @{$document->getAnnotations->getWordLevel->getElementByToken($token);}; if (scalar @words > 0) { ++$words{$words[0]->getId}; $currentWindowSize = scalar keys %words; if ($words[0]->getMorphoSyntacticFeatures($document)->syntactic_category eq $POSTAG) { return $words[0]; } ; } ; $token = $token->next } } 0 0 0
Condition0%0/6
$currentWindowSize < $WindowSize and defined $token and $token->getFrom <= $end_token->getTo
!ll&&!rl&&r
000
$currentWindowSize < $WindowSize and defined $token
!ll&&!rl&&r
000
MC/DC0%0/3
$currentWindowSize < $WindowSize and defined $token and $token->getFrom <= $end_token->getTo
$currentWindowSize < $WindowSize defined $token $token->getFrom <= $end_token->getTo
Truth table0%0/4
A and B and C
A= $currentWindowSize < $WindowSizeB= defined $tokenC= $token->getFrom <= $end_token->getTo
ABCresult
0XX0
10X0
1100
1111
2584 # print $token->getContent . "\n";
2585 0 my @words = @{$document->getAnnotations->getWordLevel->getElementByToken($token)};
2586 0 ▶ if (scalar(@words) > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @words > 0) 0 0 0
2587 0 $words{$words[0]->getId}++;
2588 0 $currentWindowSize = scalar(keys %words);
2589 # print STDERR "word : " . $words[0]->getMorphoSyntacticFeatures($document) . "\n";
2590 # print STDERR "word : " . $words[0]->getMorphoSyntacticFeatures($document)->syntactic_category . "\n";
2591  
2592 0 ▶ if ($words[0]->getMorphoSyntacticFeatures($document)->syntactic_category eq $POSTAG) {
Branch: 1 branch
BranchTrueFalseTotal
if ($words[0]->getMorphoSyntacticFeatures($document)->syntactic_category eq $POSTAG) 0 0 0
2593 0 return($words[0]);
2594 }
2595 }
2596 0 $token = $token->next;
2597 } while(($currentWindowSize < $WindowSize) && (defined $token) && ($token->getFrom <= $end_token->getTo));
2598  
2599 0 return(0);
2600 }
2601  
2602 0 ▶sub _searchWordRE {
Subroutine _searchWordRE: not called CC=10 SCAR=47.0
2603 0 my ($self, $document, $start_token, $end_token, $wordRegExp, $WindowSize) = @_;
2604  
2605 0 my $sentenceLemma;
2606 my $offset_refs;
2607 # print STDERR "in wordRE: $wordRegExp (" . $start_token->getContent . ")\n";
2608  
2609 0 my $word_re_start_token = undef;
2610 0 my $word_re_end_token = undef;
2611 0 my $currentWindowSize = 0;
2612 0 my %words;
2613 0 my $token = $start_token;
2614  
2615 0 ▶ do {
Branch: 1 branch
BranchTrueFalseTotal
$currentWindowSize < $WindowSize and defined $token and $token->getFrom <= $end_token->getTo and do { do { my(@words) = @{$document->getAnnotations->getWordLevel->getElementByToken($token);}; if (scalar @words > 0) { ++$words{$words[0]->getId}; $currentWindowSize = scalar keys %words; } ; $token = $token->next } } 0 0 0
Condition0%0/6
$currentWindowSize < $WindowSize and defined $token and $token->getFrom <= $end_token->getTo
!ll&&!rl&&r
000
$currentWindowSize < $WindowSize and defined $token
!ll&&!rl&&r
000
MC/DC0%0/3
$currentWindowSize < $WindowSize and defined $token and $token->getFrom <= $end_token->getTo
$currentWindowSize < $WindowSize defined $token $token->getFrom <= $end_token->getTo
Truth table0%0/4
A and B and C
A= $currentWindowSize < $WindowSizeB= defined $tokenC= $token->getFrom <= $end_token->getTo
ABCresult
0XX0
10X0
1100
1111
2616 0 my @words = @{$document->getAnnotations->getWordLevel->getElementByToken($token)};
2617 0 ▶ if (scalar(@words) > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @words > 0) 0 0 0
2618 0 $words{$words[0]->getId}++;
2619 0 $currentWindowSize = scalar(keys %words);
2620 }
2621 0 $token = $token->next;
2622 } while(($currentWindowSize < $WindowSize) && (defined $token) && ($token->getFrom <= $end_token->getTo));
2623  
2624  
2625 0 ($sentenceLemma, $offset_refs) = $self->_getLemmatisedSentence($document, $start_token, $token->previous);
2626  
2627 # print STDERR $sentenceLemma . ";\n";
2628  
2629 0 ▶ while(($sentenceLemma =~ /$wordRegExp/gcsi) && (!defined $word_re_end_token)){
Branch: 1 branch
BranchTrueFalseTotal
if ($sentenceLemma =~ /$wordRegExp/cgis and not defined $word_re_end_token) 0 0 0
Condition0%0/3
$sentenceLemma =~ /$wordRegExp/cgis and not defined $word_re_end_token
!ll&&!rl&&r
000
MC/DC0%0/2
$sentenceLemma =~ /$wordRegExp/cgis and not defined $word_re_end_token
$sentenceLemma =~ /$wordRegExp/cgis not defined $word_re_end_token
Truth table0%0/3
A and not(B)
A= $sentenceLemma =~ /$wordRegExp/cgisB= not defined $word_re_end_token
ABresult
0X0
100
111
2630 # print STDERR "match\n";
2631 0 $word_re_start_token = undef;
2632 0 ▶ if (exists $offset_refs->{length($`)}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $$offset_refs{length $`}) 0 0 0
2633 0 $word_re_start_token = $offset_refs->{length($`)};
2634 }
2635 0 $word_re_end_token = undef;
2636 0 ▶ if (exists $offset_refs->{length($` . $&)}) {
Branch: 2 branches
BranchTrueFalseTotal
if (exists $$offset_refs{length $` . $&}) { } 0 0 0
elsif (exists $$offset_refs{length($` . $&) - 1}) { } 0 0 0
2637 0 $word_re_end_token = $offset_refs->{length($` . $&)};
2638 0 $word_re_end_token = $word_re_end_token->previous;
2639 } elsif (exists $offset_refs->{length($` . $&) - 1}) {
2640 0 $word_re_end_token = $offset_refs->{length($` . $&) - 1};
2641 0 $word_re_end_token = $word_re_end_token->previous;
2642 }
2643
2644 }
2645  
2646 0 return($word_re_start_token, $word_re_end_token);
2647 }
2648 0 ▶sub _searchWord {
Subroutine _searchWord: not called CC=7 SCAR=40.3
2649 0 my ($self, $document, $start_token, $end_token, $wordForm, $WindowSize) = @_;
2650  
2651 0 my $token = $start_token;
2652 0 my $currentWindowSize = 0;
2653 0 my %words;
2654  
2655 # print STDERR "search Word\n";
2656  
2657 0 ▶ do {
Branch: 1 branch
BranchTrueFalseTotal
$currentWindowSize < $WindowSize and defined $token and $token->getFrom <= $end_token->getTo and do { do { my(@words) = @{$document->getAnnotations->getWordLevel->getElementByToken($token);}; if (scalar @words > 0) { ++$words{$words[0]->getId}; $currentWindowSize = scalar keys %words; if (lc $words[0]->getForm eq lc $wordForm or lc $words[0]->getLemma($document)->canonical_form eq lc $wordForm) { return $words[0]; } ; } ; $token = $token->next } } 0 0 0
Condition0%0/6
$currentWindowSize < $WindowSize and defined $token and $token->getFrom <= $end_token->getTo
!ll&&!rl&&r
000
$currentWindowSize < $WindowSize and defined $token
!ll&&!rl&&r
000
MC/DC0%0/3
$currentWindowSize < $WindowSize and defined $token and $token->getFrom <= $end_token->getTo
$currentWindowSize < $WindowSize defined $token $token->getFrom <= $end_token->getTo
Truth table0%0/4
A and B and C
A= $currentWindowSize < $WindowSizeB= defined $tokenC= $token->getFrom <= $end_token->getTo
ABCresult
0XX0
10X0
1100
1111
2658 # print $token->getContent . "\n";
2659 0 my @words = @{$document->getAnnotations->getWordLevel->getElementByToken($token)};
2660 0 ▶ if (scalar(@words) > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @words > 0) 0 0 0
2661 0 $words{$words[0]->getId}++;
2662 0 $currentWindowSize = scalar(keys %words);
2663 0 ▶ if ((lc($words[0]->getForm) eq lc($wordForm)) || (lc($words[0]->getLemma($document)->canonical_form) eq lc($wordForm))) {
Branch: 1 branch
BranchTrueFalseTotal
if (lc $words[0]->getForm eq lc $wordForm or lc $words[0]->getLemma($document)->canonical_form eq lc $wordForm) 0 0 0
Condition0%0/3
lc $words[0]->getForm eq lc $wordForm or lc $words[0]->getLemma($document)->canonical_form eq lc $wordForm
l!l&&r!l&&!r
000
MC/DC0%0/2
lc $words[0]->getForm eq lc $wordForm or lc $words[0]->getLemma($document)->canonical_form eq lc $wordForm
lc $words[0]->getForm eq lc $wordForm lc $words[0]->getLemma($document)->canonical_form eq lc $wordForm
Truth table0%0/3
A or B
A= lc $words[0]->getForm eq lc $wordFormB= lc $words[0]->getLemma($document)->canonical_form eq lc $wordForm
ABresult
1X1
011
000
2664 0 return($words[0]);
2665 }
2666 }
2667 0 $token = $token->next;
2668 } while(($currentWindowSize < $WindowSize) && (defined $token) && ($token->getFrom <= $end_token->getTo));
2669  
2670 0 return(0);
2671 }
2672  
2673 0 ▶sub _selectSentencesFromPattern {
Subroutine _selectSentencesFromPattern: not called CC=10 SCAR=47.0
2674 0 my ($self, $pattern, $selectedSentences, $document, $level) = @_;
2675  
2676 # print STDERR "===\n";
2677 # my $pattern = $synPattern->{"pattern"};
2678 0 my $i;
2679 my $sentence;
2680 0 ▶ for($i = 0; $i < scalar(@$pattern); $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < scalar @$pattern) 0 0 0
2681 # print STDERR "i: $i " . $pattern->[$i]->{'type'} . "\n";
2682 # foreach $sentence (values %$selectedSentences) {
2683 # print STDERR "sentenceID: " . $sentence->{'sentence'}->getId . "\n";
2684 # }
2685 # selection of the sentence containing $pattern->[$i] (Semtype) according to %selectedSentences
2686 0 ▶ if ($pattern->[$i]->{'type'} eq "semtype") {
Branch: 1 branch
BranchTrueFalseTotal
if ($pattern->[$i]{"type"} eq "semtype") 0 0 0
2687 0 $selectedSentences = $self->_selectSentencesFromSemType($pattern->[$i]->{'semtype'}, $selectedSentences, $i + $level, $document);
2688 }
2689 # selection of the sentence containing $pattern->[$i] (termcontent) according to %selectedSentences
2690 0 ▶ if ($pattern->[$i]->{'type'} eq "termcontent") {
Branch: 1 branch
BranchTrueFalseTotal
if ($pattern->[$i]{"type"} eq "termcontent") 0 0 0
2691 0 $selectedSentences = $self->_selectSentencesFromTermContent($pattern->[$i]->{'termcontent'}, $selectedSentences, $i + $level, $document);
2692 }
2693 # selection of the sentence containing $pattern->[$i] (term) according to %selectedSentences
2694 0 ▶ if ($pattern->[$i]->{'type'} eq "term") {
Branch: 1 branch
BranchTrueFalseTotal
if ($pattern->[$i]{"type"} eq "term") 0 0 0
2695 0 $selectedSentences = $self->_selectSentencesFromTerm($selectedSentences, $i + $level, $document);
2696 }
2697 # selection of the sentence containing $pattern->[$i] (postag) according to %selectedSentences
2698 0 ▶ if ($pattern->[$i]->{'type'} eq "postag") {
Branch: 1 branch
BranchTrueFalseTotal
if ($pattern->[$i]{"type"} eq "postag") 0 0 0
2699 0 $selectedSentences = $self->_selectSentencesFromPOSTAG($pattern->[$i]->{'postag'}, $selectedSentences, $i + $level, $document);
2700 }
2701 # selection of the sentence containing $pattern->[$i] (word) according to %selectedSentences
2702 0 ▶ if ($pattern->[$i]->{'type'} eq "word") {
Branch: 1 branch
BranchTrueFalseTotal
if ($pattern->[$i]{"type"} eq "word") 0 0 0
2703 0 $selectedSentences = $self->_selectSentencesFromWord($pattern->[$i]->{'word'}, $selectedSentences, $i + $level, $document);
2704 }
2705
2706 # selection of the sentence containing $pattern->[$i] (word_re) according to %selectedSentences
2707 0 ▶ if ($pattern->[$i]->{'type'} eq "word_re") {
Branch: 1 branch
BranchTrueFalseTotal
if ($pattern->[$i]{"type"} eq "word_re") 0 0 0
2708 0 $selectedSentences = $self->_selectSentencesFromWordRE($pattern->[$i]->{'word_re'}, $selectedSentences, $i + $level, $document);
2709 }
2710  
2711 # selection of the sentence containing $pattern->[$i] (syndep) according to %selectedSentences
2712 0 ▶ if ($pattern->[$i]->{'type'} eq "syndep") {
Branch: 1 branch
BranchTrueFalseTotal
if ($pattern->[$i]{"type"} eq "syndep") 0 0 0
2713 0 $selectedSentences = $self->_selectSentencesFromSynDep($pattern->[$i]->{'syndep'}, $selectedSentences, $i + $level, $document);
2714 }
2715 # if chunk, go inside the chunk
2716 0 ▶ if ($pattern->[$i]->{'type'} eq "chunk") {
Branch: 1 branch
BranchTrueFalseTotal
if ($pattern->[$i]{"type"} eq "chunk") 0 0 0
2717 0 $selectedSentences = $self->_selectSentencesFromPattern($pattern->[$i]->{'chunk'}, $selectedSentences, $document, $level + 1);
2718 }
2719 # foreach $sentence (values %$selectedSentences) {
2720 # print STDERR "sentenceID: " . $sentence->{'sentence'}->getId . "\n";
2721 # # print STDERR Dumper($sentence->{'first_item'});
2722 # }
2723 }
2724 # print STDERR "----\n";
2725 0 return($selectedSentences);
2726 }
2727  
2728 # selection of the sentence containing $pattern->[$i] (Semtype) according to %selectedSentences
2729  
2730 0 ▶sub _selectSentencesFromSemType {
Subroutine _selectSentencesFromSemType: not called CC=10 SCAR=47.0
2731 0 my ($self, $semtypeAcr, $selectedSentences, $i, $document) = @_;
2732  
2733 0 my %newSelectedSentences;
2734 my $term;
2735 0 my $sentence;
2736 0 my $semtype = $self->{"SEMANTICTYPES"}->{$semtypeAcr};
2737  
2738 # print STDERR "select semtype: $semtype\n";
2739 0 foreach $term (@{$document->getAnnotations->getSemanticUnitLevel->getElements}) {
2740 # if ($term->isTerm) {
2741 # print STDERR " " . $term->getForm . "\n";
2742 # print STDERR "FC: " . $term->getSemanticFeatureFC($document) . "\n";
2743 # }
2744 0 ▶ if (($term->isTerm) && ((defined($term->getSemanticFeatureFC($document))) && ($term->getSemanticFeatureFC($document) eq $semtype))) {
Branch: 1 branch
BranchTrueFalseTotal
if ($term->isTerm and (defined $term->getSemanticFeatureFC($document) and $term->getSemanticFeatureFC($document) eq $semtype)) 0 0 0
Condition0%0/6
$term->isTerm and (defined $term->getSemanticFeatureFC($document) and $term->getSemanticFeatureFC($document) eq $semtype)
!ll&&!rl&&r
000
defined $term->getSemanticFeatureFC($document) and $term->getSemanticFeatureFC($document) eq $semtype
!ll&&!rl&&r
000
MC/DC0%0/3
$term->isTerm and (defined $term->getSemanticFeatureFC($document) and $term->getSemanticFeatureFC($document) eq $semtype)
$term->isTerm defined $term->getSemanticFeatureFC($document) $term->getSemanticFeatureFC($document) eq $semtype
Truth table0%0/4
A and B and C
A= $term->isTermB= defined $term->getSemanticFeatureFC($document)C= $term->getSemanticFeatureFC($document) eq $semtype
ABCresult
0XX0
10X0
1100
1111
2745 0 foreach $sentence (values %$selectedSentences) {
2746 0 ▶ if (($sentence->{'sentence'}->refid_start_token->getFrom <= $term->start_token->getFrom) &&
Branch: 1 branch
BranchTrueFalseTotal
if ($sentence->{"sentence"}->refid_start_token->getFrom <= $term->start_token->getFrom and $term->end_token->getTo <= $sentence->{"sentence"}->refid_end_token->getTo) 0 0 0
Condition0%0/3
$sentence->{"sentence"}->refid_start_token->getFrom <= $term->start_token->getFrom and $term->end_token->getTo <= $sentence->{"sentence"}->refid_end_token->getTo
!ll&&!rl&&r
000
MC/DC0%0/2
$sentence->{"sentence"}->refid_start_token->getFrom <= $term->start_token->getFrom and $term->end_token->getTo <= $sentence->{"sentence"}->refid_end_token->getTo
$sentence->{"sentence"}->refid_start_token->getFrom <= $term->start_token->getFrom $term->end_token->getTo <= $sentence->{"sentence"}->refid_end_token->getTo
Truth table0%0/3
A and B
A= $sentence->{"sentence"}->refid_start_token->getFrom <= $term->start_token->getFromB= $term->end_token->getTo <= $sentence->{"sentence"}->refid_end_token->getTo
ABresult
0X0
100
111
2747 ($term->end_token->getTo <= $sentence->{'sentence'}->refid_end_token->getTo)) {
2748 # print STDERR "==>sentenceID: " . $sentence->{'sentence'}->getId . "$term (" . $term->getForm . ")\n";
2749 0 ▶ if (($i == 0) || (scalar(@{$sentence->{'first_item'}}) == 0)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i == 0 or scalar @{$sentence->{'first_item'};} == 0) { } 0 0 0
Condition0%0/3
$i == 0 or scalar @{$sentence->{"first_item"};} == 0
l!l&&r!l&&!r
000
MC/DC0%0/2
$i == 0 or scalar @{$sentence->{"first_item"};} == 0
$i == 0 scalar @{$sentence->{"first_item"};} == 0
Truth table0%0/3
A or B
A= $i == 0B= scalar @{$sentence->{"first_item"};} == 0
ABresult
1X1
011
000
2750 # if ($i == 0) {
2751 0 $newSelectedSentences{$sentence->{'sentence'}->refid_start_token}->{'sentence'} = $sentence->{'sentence'};
2752 0 push @{$newSelectedSentences{$sentence->{'sentence'}->refid_start_token}->{'first_item'}}, $term;
2753 } else {
2754 0 $newSelectedSentences{$sentence->{'sentence'}->refid_start_token} = $sentence;
2755 }
2756 }
2757 }
2758 }
2759 }
2760 0 $selectedSentences = \%newSelectedSentences;
2761 0 return(\%newSelectedSentences);
2762 }
2763  
2764 # selection of the sentence containing $pattern->[$i] (termcontent) according to %selectedSentences
2765  
2766 0 ▶sub _selectSentencesFromTermContent {
Subroutine _selectSentencesFromTermContent: not called CC=9 SCAR=45.0
2767 0 my ($self, $termcontent, $selectedSentences, $i, $document) = @_;
2768  
2769 0 my %newSelectedSentences;
2770 my $term;
2771 0 my $sentence;
2772  
2773  
2774 # print STDERR "select termcontent: $termcontent\n";
2775 0 foreach $term (@{$document->getAnnotations->getSemanticUnitLevel->getElements}) {
2776 # if ($term->isTerm) {
2777 # print "FC: " . $term->getSemanticFeatureFC($document) . "\n";
2778 # }
2779 0 ▶ if (($term->isTerm) && ($term->getForm eq $termcontent)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($term->isTerm and $term->getForm eq $termcontent) 0 0 0
Condition0%0/3
$term->isTerm and $term->getForm eq $termcontent
!ll&&!rl&&r
000
MC/DC0%0/2
$term->isTerm and $term->getForm eq $termcontent
$term->isTerm $term->getForm eq $termcontent
Truth table0%0/3
A and B
A= $term->isTermB= $term->getForm eq $termcontent
ABresult
0X0
100
111
2780 0 foreach $sentence (values %$selectedSentences) {
2781 0 ▶ if (($sentence->{'sentence'}->refid_start_token->getFrom <= $term->start_token->getFrom) &&
Branch: 1 branch
BranchTrueFalseTotal
if ($sentence->{"sentence"}->refid_start_token->getFrom <= $term->start_token->getFrom and $term->end_token->getTo <= $sentence->{"sentence"}->refid_end_token->getTo) 0 0 0
Condition0%0/3
$sentence->{"sentence"}->refid_start_token->getFrom <= $term->start_token->getFrom and $term->end_token->getTo <= $sentence->{"sentence"}->refid_end_token->getTo
!ll&&!rl&&r
000
MC/DC0%0/2
$sentence->{"sentence"}->refid_start_token->getFrom <= $term->start_token->getFrom and $term->end_token->getTo <= $sentence->{"sentence"}->refid_end_token->getTo
$sentence->{"sentence"}->refid_start_token->getFrom <= $term->start_token->getFrom $term->end_token->getTo <= $sentence->{"sentence"}->refid_end_token->getTo
Truth table0%0/3
A and B
A= $sentence->{"sentence"}->refid_start_token->getFrom <= $term->start_token->getFromB= $term->end_token->getTo <= $sentence->{"sentence"}->refid_end_token->getTo
ABresult
0X0
100
111
2782 ($term->end_token->getTo <= $sentence->{'sentence'}->refid_end_token->getTo)) {
2783 # print "==>sentenceID: " . $sentence->{'sentence'}->getId . "\n";
2784 0 ▶ if (($i == 0) || (scalar(@{$sentence->{'first_item'}}) == 0)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i == 0 or scalar @{$sentence->{'first_item'};} == 0) { } 0 0 0
Condition0%0/3
$i == 0 or scalar @{$sentence->{"first_item"};} == 0
l!l&&r!l&&!r
000
MC/DC0%0/2
$i == 0 or scalar @{$sentence->{"first_item"};} == 0
$i == 0 scalar @{$sentence->{"first_item"};} == 0
Truth table0%0/3
A or B
A= $i == 0B= scalar @{$sentence->{"first_item"};} == 0
ABresult
1X1
011
000
2785 # if ($i == 0) {
2786 0 $newSelectedSentences{$sentence->{'sentence'}->refid_start_token}->{'sentence'} = $sentence->{'sentence'};
2787 0 push @{$newSelectedSentences{$sentence->{'sentence'}->refid_start_token}->{'first_item'}}, $term;
2788 } else {
2789 0 $newSelectedSentences{$sentence->{'sentence'}->refid_start_token} = $sentence;
2790 }
2791 }
2792 }
2793 }
2794 }
2795 0 $selectedSentences = \%newSelectedSentences;
2796 0 return(\%newSelectedSentences);
2797 }
2798  
2799 # selection of the sentence containing $pattern->[$i] (term) according to %selectedSentences
2800  
2801 0 ▶sub _selectSentencesFromTerm {
Subroutine _selectSentencesFromTerm: not called CC=8 SCAR=42.8
2802 0 my ($self, $selectedSentences, $i, $document) = @_;
2803  
2804 0 my %newSelectedSentences;
2805 my $term;
2806 0 my $sentence;
2807  
2808 # print STDERR "select term exists ?\n";
2809 0 foreach $term (@{$document->getAnnotations->getSemanticUnitLevel->getElements}) {
2810 # if ($term->isTerm) {
2811 # print "FC: " . $term->getSemanticFeatureFC($document) . "\n";
2812 # }
2813 0 ▶ if ($term->isTerm) {
Branch: 1 branch
BranchTrueFalseTotal
if ($term->isTerm) 0 0 0
2814 0 foreach $sentence (values %$selectedSentences) {
2815 0 ▶ if (($sentence->{'sentence'}->refid_start_token->getFrom <= $term->start_token->getFrom) &&
Branch: 1 branch
BranchTrueFalseTotal
if ($sentence->{"sentence"}->refid_start_token->getFrom <= $term->start_token->getFrom and $term->end_token->getTo <= $sentence->{"sentence"}->refid_end_token->getTo) 0 0 0
Condition0%0/3
$sentence->{"sentence"}->refid_start_token->getFrom <= $term->start_token->getFrom and $term->end_token->getTo <= $sentence->{"sentence"}->refid_end_token->getTo
!ll&&!rl&&r
000
MC/DC0%0/2
$sentence->{"sentence"}->refid_start_token->getFrom <= $term->start_token->getFrom and $term->end_token->getTo <= $sentence->{"sentence"}->refid_end_token->getTo
$sentence->{"sentence"}->refid_start_token->getFrom <= $term->start_token->getFrom $term->end_token->getTo <= $sentence->{"sentence"}->refid_end_token->getTo
Truth table0%0/3
A and B
A= $sentence->{"sentence"}->refid_start_token->getFrom <= $term->start_token->getFromB= $term->end_token->getTo <= $sentence->{"sentence"}->refid_end_token->getTo
ABresult
0X0
100
111
2816 ($term->end_token->getTo <= $sentence->{'sentence'}->refid_end_token->getTo)) {
2817 # print "==>sentenceID: " . $sentence->{'sentence'}->getId . "\n";
2818 0 ▶ if (($i == 0) || (scalar(@{$sentence->{'first_item'}}) == 0)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i == 0 or scalar @{$sentence->{'first_item'};} == 0) { } 0 0 0
Condition0%0/3
$i == 0 or scalar @{$sentence->{"first_item"};} == 0
l!l&&r!l&&!r
000
MC/DC0%0/2
$i == 0 or scalar @{$sentence->{"first_item"};} == 0
$i == 0 scalar @{$sentence->{"first_item"};} == 0
Truth table0%0/3
A or B
A= $i == 0B= scalar @{$sentence->{"first_item"};} == 0
ABresult
1X1
011
000
2819 # if ($i == 0) {
2820 0 $newSelectedSentences{$sentence->{'sentence'}->refid_start_token}->{'sentence'} = $sentence->{'sentence'};
2821 0 push @{$newSelectedSentences{$sentence->{'sentence'}->refid_start_token}->{'first_item'}}, $term;
2822 } else {
2823 0 $newSelectedSentences{$sentence->{'sentence'}->refid_start_token} = $sentence;
2824 }
2825 }
2826 }
2827 }
2828 }
2829 0 $selectedSentences = \%newSelectedSentences;
2830 0 return(\%newSelectedSentences);
2831 }
2832  
2833 # selection of the sentence containing $pattern->[$i] (postag) according to %selectedSentences
2834  
2835 0 ▶sub _selectSentencesFromPOSTAG {
Subroutine _selectSentencesFromPOSTAG: not called CC=8 SCAR=42.8
2836 0 my ($self, $postag, $selectedSentences, $i, $document) = @_;
2837  
2838 0 my %newSelectedSentences;
2839 my $word;
2840 0 my $sentence;
2841  
2842 # print STDERR "select postag; $postag\n";
2843  
2844 0 foreach $word (@{$document->getAnnotations->getWordLevel->getElements}) {
2845 0 ▶ if ($word->getMorphoSyntacticFeatures($document)->syntactic_category eq $postag) {
Branch: 1 branch
BranchTrueFalseTotal
if ($word->getMorphoSyntacticFeatures($document)->syntactic_category eq $postag) 0 0 0
2846 0 foreach $sentence (values %$selectedSentences) {
2847 0 ▶ if (($sentence->{'sentence'}->refid_start_token->getFrom <= $word->start_token->getFrom) &&
Branch: 1 branch
BranchTrueFalseTotal
if ($sentence->{"sentence"}->refid_start_token->getFrom <= $word->start_token->getFrom and $word->end_token->getTo <= $sentence->{"sentence"}->refid_end_token->getTo) 0 0 0
Condition0%0/3
$sentence->{"sentence"}->refid_start_token->getFrom <= $word->start_token->getFrom and $word->end_token->getTo <= $sentence->{"sentence"}->refid_end_token->getTo
!ll&&!rl&&r
000
MC/DC0%0/2
$sentence->{"sentence"}->refid_start_token->getFrom <= $word->start_token->getFrom and $word->end_token->getTo <= $sentence->{"sentence"}->refid_end_token->getTo
$sentence->{"sentence"}->refid_start_token->getFrom <= $word->start_token->getFrom $word->end_token->getTo <= $sentence->{"sentence"}->refid_end_token->getTo
Truth table0%0/3
A and B
A= $sentence->{"sentence"}->refid_start_token->getFrom <= $word->start_token->getFromB= $word->end_token->getTo <= $sentence->{"sentence"}->refid_end_token->getTo
ABresult
0X0
100
111
2848 ($word->end_token->getTo <= $sentence->{'sentence'}->refid_end_token->getTo)) {
2849 0 ▶ if (($i == 0) || (scalar(@{$sentence->{'first_item'}}) == 0)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i == 0 or scalar @{$sentence->{'first_item'};} == 0) { } 0 0 0
Condition0%0/3
$i == 0 or scalar @{$sentence->{"first_item"};} == 0
l!l&&r!l&&!r
000
MC/DC0%0/2
$i == 0 or scalar @{$sentence->{"first_item"};} == 0
$i == 0 scalar @{$sentence->{"first_item"};} == 0
Truth table0%0/3
A or B
A= $i == 0B= scalar @{$sentence->{"first_item"};} == 0
ABresult
1X1
011
000
2850 # if ($i == 0) {
2851 0 $newSelectedSentences{$sentence->{'sentence'}->refid_start_token}->{'sentence'} = $sentence->{'sentence'};
2852 0 push @{$newSelectedSentences{$sentence->{'sentence'}->refid_start_token}->{'first_item'}}, $word;
2853 } else {
2854 0 $newSelectedSentences{$sentence->{'sentence'}->refid_start_token} = $sentence;
2855 }
2856 }
2857 }
2858 }
2859 }
2860 0 $selectedSentences = \%newSelectedSentences;
2861 0 return(\%newSelectedSentences);
2862 }
2863  
2864 # selection of the sentence containing $pattern->[$i] (word) according to %selectedSentences
2865  
2866 0 ▶sub _selectSentencesFromWord {
Subroutine _selectSentencesFromWord: not called CC=9 SCAR=45.0
2867 0 my ($self, $wordForm, $selectedSentences, $i, $document) = @_;
2868  
2869 0 my %newSelectedSentences;
2870 my $word;
2871 0 my $sentence;
2872  
2873 # print STDERR "select word: $wordForm\n";
2874  
2875 0 foreach $word (@{$document->getAnnotations->getWordLevel->getElements}) {
2876 0 ▶ if ((lc($word->getForm) eq lc($wordForm)) || (lc($word->getLemma($document)->canonical_form) eq lc($wordForm))) {
Branch: 1 branch
BranchTrueFalseTotal
if (lc $word->getForm eq lc $wordForm or lc $word->getLemma($document)->canonical_form eq lc $wordForm) 0 0 0
Condition0%0/3
lc $word->getForm eq lc $wordForm or lc $word->getLemma($document)->canonical_form eq lc $wordForm
l!l&&r!l&&!r
000
MC/DC0%0/2
lc $word->getForm eq lc $wordForm or lc $word->getLemma($document)->canonical_form eq lc $wordForm
lc $word->getForm eq lc $wordForm lc $word->getLemma($document)->canonical_form eq lc $wordForm
Truth table0%0/3
A or B
A= lc $word->getForm eq lc $wordFormB= lc $word->getLemma($document)->canonical_form eq lc $wordForm
ABresult
1X1
011
000
2877 # warn "\t> " . $word->getForm . "\n";
2878 0 foreach $sentence (values %$selectedSentences) {
2879 # print STDERR "\tsentenceID: " . $sentence->{'sentence'}->getId . "\n";
2880 0 ▶ if (($sentence->{'sentence'}->refid_start_token->getFrom <= $word->start_token->getFrom) &&
Branch: 1 branch
BranchTrueFalseTotal
if ($sentence->{"sentence"}->refid_start_token->getFrom <= $word->start_token->getFrom and $word->end_token->getTo <= $sentence->{"sentence"}->refid_end_token->getTo) 0 0 0
Condition0%0/3
$sentence->{"sentence"}->refid_start_token->getFrom <= $word->start_token->getFrom and $word->end_token->getTo <= $sentence->{"sentence"}->refid_end_token->getTo
!ll&&!rl&&r
000
MC/DC0%0/2
$sentence->{"sentence"}->refid_start_token->getFrom <= $word->start_token->getFrom and $word->end_token->getTo <= $sentence->{"sentence"}->refid_end_token->getTo
$sentence->{"sentence"}->refid_start_token->getFrom <= $word->start_token->getFrom $word->end_token->getTo <= $sentence->{"sentence"}->refid_end_token->getTo
Truth table0%0/3
A and B
A= $sentence->{"sentence"}->refid_start_token->getFrom <= $word->start_token->getFromB= $word->end_token->getTo <= $sentence->{"sentence"}->refid_end_token->getTo
ABresult
0X0
100
111
2881 ($word->end_token->getTo <= $sentence->{'sentence'}->refid_end_token->getTo)) {
2882 0 ▶ if (($i == 0) || (scalar(@{$sentence->{'first_item'}}) == 0)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i == 0 or scalar @{$sentence->{'first_item'};} == 0) { } 0 0 0
Condition0%0/3
$i == 0 or scalar @{$sentence->{"first_item"};} == 0
l!l&&r!l&&!r
000
MC/DC0%0/2
$i == 0 or scalar @{$sentence->{"first_item"};} == 0
$i == 0 scalar @{$sentence->{"first_item"};} == 0
Truth table0%0/3
A or B
A= $i == 0B= scalar @{$sentence->{"first_item"};} == 0
ABresult
1X1
011
000
2883 # if ($i == 0) {
2884 # warn "go there (1)\n";
2885 0 $newSelectedSentences{$sentence->{'sentence'}->refid_start_token}->{'sentence'} = $sentence->{'sentence'};
2886 0 push @{$newSelectedSentences{$sentence->{'sentence'}->refid_start_token}->{'first_item'}}, $word;
2887 } else {
2888 # warn "go there (2)\n";
2889 0 $newSelectedSentences{$sentence->{'sentence'}->refid_start_token} = $sentence;
2890 }
2891 }
2892 }
2893 }
2894 }
2895 0 $selectedSentences = \%newSelectedSentences;
2896 0 return(\%newSelectedSentences);
2897 }
2898  
2899  
2900 # selection of the sentence containing $pattern->[$i] (word_re) according to %selectedSentences
2901  
2902 0 ▶sub _selectSentencesFromWordRE {
Subroutine _selectSentencesFromWordRE: not called CC=7 SCAR=40.3
2903 0 my ($self, $wordRegExp, $selectedSentences, $i, $document) = @_;
2904  
2905 0 my %newSelectedSentences;
2906 my $word;
2907 0 my $sentence;
2908 0 my $sentenceLemma;
2909 0 my $offset_refs;
2910 0 my $word_re_start_token;
2911  
2912 # print STDERR "select word_re: $wordRegExp\n";
2913  
2914 0 foreach $sentence (values %$selectedSentences) {
2915 # print STDERR "\tsentenceID: " . $sentence->{'sentence'}->getId . "\n";
2916 0 ($sentenceLemma, $offset_refs) = $self->_getLemmatisedSentence($document, $sentence->{'sentence'}->refid_start_token, $sentence->{'sentence'}->refid_end_token);
2917  
2918 # print STDERR "\t$sentenceLemma\n";
2919  
2920 0 $word_re_start_token = undef;
2921 0 ▶ while($sentenceLemma =~ /$wordRegExp/gcsi){
Branch: 1 branch
BranchTrueFalseTotal
if ($sentenceLemma =~ /$wordRegExp/cgis) 0 0 0
2922 # print STDERR "MATCH\n";
2923 0 $word_re_start_token = undef;
2924 0 ▶ if (exists $offset_refs->{length($`)}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $$offset_refs{length $`}) 0 0 0
2925 0 $word_re_start_token = $offset_refs->{length($`)};
2926 }
2927
2928 }
2929 0 ▶ if (defined $word_re_start_token) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $word_re_start_token) 0 0 0
2930 0 $word = $document->getAnnotations->getWordLevel->getElementByToken($word_re_start_token)->[0];
2931
2932 # if (($sentence->{'sentence'}->refid_start_token->getFrom <= $word->start_token->getFrom) &&
2933 # ($word->end_token->getTo <= $sentence->{'sentence'}->refid_end_token->getTo)) {
2934 0 ▶ if (($i == 0) || (scalar(@{$sentence->{'first_item'}}) == 0)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i == 0 or scalar @{$sentence->{'first_item'};} == 0) { } 0 0 0
Condition0%0/3
$i == 0 or scalar @{$sentence->{"first_item"};} == 0
l!l&&r!l&&!r
000
MC/DC0%0/2
$i == 0 or scalar @{$sentence->{"first_item"};} == 0
$i == 0 scalar @{$sentence->{"first_item"};} == 0
Truth table0%0/3
A or B
A= $i == 0B= scalar @{$sentence->{"first_item"};} == 0
ABresult
1X1
011
000
2935 # if ($i == 0) {
2936 # warn "go there (1)\n";
2937 0 $newSelectedSentences{$sentence->{'sentence'}->refid_start_token}->{'sentence'} = $sentence->{'sentence'};
2938 0 push @{$newSelectedSentences{$sentence->{'sentence'}->refid_start_token}->{'first_item'}}, $word;
2939 } else {
2940 # warn "go there (2)\n";
2941 0 $newSelectedSentences{$sentence->{'sentence'}->refid_start_token} = $sentence;
2942 }
2943 # }
2944 }
2945 }
2946 0 $selectedSentences = \%newSelectedSentences;
2947 0 return(\%newSelectedSentences);
2948 }
2949  
2950  
2951  
2952 # selection of the sentence containing $pattern->[$i] (syndep) according to %selectedSentences
2953  
2954 0 ▶sub _selectSentencesFromSynDep {
Subroutine _selectSentencesFromSynDep: not called CC=8 SCAR=42.8
2955 0 my ($self, $syndep, $selectedSentences, $i, $document) = @_;
2956  
2957 0 my %newSelectedSentences;
2958 my $synrel;
2959 0 my $sentence;
2960  
2961 # print STDERR "select syndep: $syndep\n";
2962  
2963 0 foreach $synrel (@{$document->getAnnotations->getSyntacticRelationLevel->getElementFromIndex('syntactic_relation_type', $syndep)}) {
2964 # foreach $synrel (@{$document->getAnnotations->getSyntacticRelationLevel->getElements}) {
2965 # if ($synrel->syntactic_relation_type eq $syndep) {
2966 0 foreach $sentence (values %$selectedSentences) {
2967 0 ▶ if (($sentence->{'sentence'}->refid_start_token->getFrom <= $synrel->refid_head->[0]->start_token->getFrom) &&
Branch: 1 branch
BranchTrueFalseTotal
if ($sentence->{"sentence"}->refid_start_token->getFrom <= $synrel->refid_head->[0]->start_token->getFrom and $synrel->refid_head->[0]->end_token->getTo <= $sentence->{"sentence"}->refid_end_token->getTo) 0 0 0
Condition0%0/3
$sentence->{"sentence"}->refid_start_token->getFrom <= $synrel->refid_head->[0]->start_token->getFrom and $synrel->refid_head->[0]->end_token->getTo <= $sentence->{"sentence"}->refid_end_token->getTo
!ll&&!rl&&r
000
MC/DC0%0/2
$sentence->{"sentence"}->refid_start_token->getFrom <= $synrel->refid_head->[0]->start_token->getFrom and $synrel->refid_head->[0]->end_token->getTo <= $sentence->{"sentence"}->refid_end_token->getTo
$sentence->{"sentence"}->refid_start_token->getFrom <= $synrel->refid_head->[0]->start_token->getFrom $synrel->refid_head->[0]->end_token->getTo <= $sentence->{"sentence"}->refid_end_token->getTo
Truth table0%0/3
A and B
A= $sentence->{"sentence"}->refid_start_token->getFrom <= $synrel->refid_head->[0]->start_token->getFromB= $synrel->refid_head->[0]->end_token->getTo <= $sentence->{"sentence"}->refid_end_token->getTo
ABresult
0X0
100
111
2968 ($synrel->refid_head->[0]->end_token->getTo <= $sentence->{'sentence'}->refid_end_token->getTo)) {
2969 0 ▶ if (($i == 0) || (scalar(@{$sentence->{'first_item'}}) == 0)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i == 0 or scalar @{$sentence->{'first_item'};} == 0) { } 0 0 0
Condition0%0/3
$i == 0 or scalar @{$sentence->{"first_item"};} == 0
l!l&&r!l&&!r
000
MC/DC0%0/2
$i == 0 or scalar @{$sentence->{"first_item"};} == 0
$i == 0 scalar @{$sentence->{"first_item"};} == 0
Truth table0%0/3
A or B
A= $i == 0B= scalar @{$sentence->{"first_item"};} == 0
ABresult
1X1
011
000
2970 # if ($i == 0) {
2971 0 $newSelectedSentences{$sentence->{'sentence'}->refid_start_token}->{'sentence'} = $sentence->{'sentence'};
2972 0 ▶ if ($synrel->refid_head->[0]->start_token->getFrom < $synrel->refid_modifier->[0]->start_token->getFrom) {
Branch: 1 branch
BranchTrueFalseTotal
if ($synrel->refid_head->[0]->start_token->getFrom < $synrel->refid_modifier->[0]->start_token->getFrom) { } 0 0 0
2973 0 push @{$newSelectedSentences{$sentence->{'sentence'}->refid_start_token}->{'first_item'}}, $synrel->refid_head->[0];
2974 } else {
2975 0 push @{$newSelectedSentences{$sentence->{'sentence'}->refid_start_token}->{'first_item'}}, $synrel->refid_modifier->[0];
2976 }
2977 } else {
2978 0 $newSelectedSentences{$sentence->{'sentence'}->refid_start_token} = $sentence;
2979 }
2980 }
2981 }
2982 # }
2983 }
2984 0 $selectedSentences = \%newSelectedSentences;
2985 0 return(\%newSelectedSentences);
2986 }
2987  
2988  
2989 0 ▶sub _parseTreeTaggerFormatOutput {
Subroutine _parseTreeTaggerFormatOutput: not called CC=36 SCAR=71.9
2990 0 my ($self, $output_filename, $replace) = @_;
2991 # ($self->_output_filename);
2992  
2993 0 my $line;
2994 my @TreeTaggerOutput;
2995  
2996 0 my $doc_idx;
2997 0 my $word_idx;
2998 0 my $document;
2999  
3000 0 my $word;
3001 0 my $token;
3002  
3003 0 my $posInWord;
3004 0 my $posInLemma;
3005  
3006 0 my $substringBefore;
3007 0 my $substringAfter;
3008  
3009 0 my $MSFeatures;
3010 0 my $Lemma;
3011  
3012 0 warn "[LOG] . Parsing " . $self->_output_filename . "\n";
3013  
3014 0 ▶ open FILE_OUT, $output_filename or warn "Can't open the file " . $output_filename;;
Branch: 1 branch
BranchTrueFalseTotal
open FILE_OUT, $output_filename or warn q[Can't open the file ] . $output_filename 0 0 0
3015 # binmode(FILE_OUT, ":utf8");
3016  
3017 0 ▶ while($line = <FILE_OUT>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($line = readline FILE_OUT)) 0 0 0
3018 0 chomp $line;
3019 # if ($line ne "") {
3020 # my @tmp = split /[\t\|]/, $line;
3021 0 my @tmp = split /\t| ?\| ?/, $line; #/
3022 # warn "$line : " . join(':', @tmp) . "\n";
3023 0 ▶ if (scalar(@tmp) >= 3) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @tmp >= 3) { } 0 0 0
3024 0 ▶ if ($tmp[1] ne "DOCUMENT") {
Branch: 1 branch
BranchTrueFalseTotal
if ($tmp[1] ne "DOCUMENT") 0 0 0
3025 # work around some strange tagging
3026 0 ▶ if (!defined $tmp[1]) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $tmp[1]) 0 0 0
3027 0 $tmp[1] = "SYM";
3028 }
3029 0 ▶ if (!defined $tmp[2]) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $tmp[2]) 0 0 0
3030 0 $tmp[2] = $tmp[0];
3031 }
3032 0 push @TreeTaggerOutput, \@tmp;
3033 }
3034 } else {
3035 # if (scalar(@tmp) != 0) {
3036 0 push @TreeTaggerOutput, \@tmp;
3037 # }
3038 }
3039 # }
3040  
3041 }
3042 0 close FILE_OUT;
3043  
3044 # warn "TT output size: " . scalar(@TreeTaggerOutput) . "\n";
3045  
3046 # warn "\n\n";
3047 0 my $TreeTaggerOutput_idx = 0;
3048  
3049 0 foreach $document (@{$self->_documentSet}) {
3050 # warn $document->getId . "\n";
3051 0 ▶ for($doc_idx = 0; $doc_idx < scalar(@{$document->getAnnotations->getTokenLevel->getElements});$doc_idx++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($doc_idx < scalar @{$document->getAnnotations->getTokenLevel->getElements;}) 0 0 0
3052 # if ((!defined $TreeTaggerOutput[$TreeTaggerOutput_idx]) || (scalar(@{$TreeTaggerOutput[$TreeTaggerOutput_idx]}) == 0)) {
3053 # $TreeTaggerOutput_idx++;
3054 # }
3055 0 $token = $document->getAnnotations->getTokenLevel->getElements->[$doc_idx];
3056 0 ▶ if ($document->getAnnotations->getWordLevel->existsElementFromIndex("list_refid_token", $token->getId)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($document->getAnnotations->getWordLevel->existsElementFromIndex('list_refid_token', $token->getId)) { } 0 0 0
3057 0 $word = $document->getAnnotations->getWordLevel->getElementFromIndex("list_refid_token", $token->getId)->[0];
3058  
3059 # warn $word->getForm . " (" . $word->getId . ") " . $TreeTaggerOutput[$TreeTaggerOutput_idx]->[0] . " : " . $TreeTaggerOutput[$TreeTaggerOutput_idx]->[1] . " : " . $TreeTaggerOutput[$TreeTaggerOutput_idx]->[2] . "\n";
3060  
3061 # Correct POSTag if it's named entity
3062  
3063 0 ▶ if ($word->isNE) {
Branch: 1 branch
BranchTrueFalseTotal
if ($word->isNE) 0 0 0
3064 0 $TreeTaggerOutput[$TreeTaggerOutput_idx]->[1] = "NP";
3065 # warn "Remove _ if it's a complex word i.e. a named entity\n";
3066  
3067 # Remove _ if it's a complex word i.e. a named entity
3068  
3069 0 $posInLemma = 0;
3070 0 ▶ do {
Branch: 1 branch
BranchTrueFalseTotal
$posInLemma != -1 and $posInLemma != $posInWord and $posInLemma < length $TreeTaggerOutput[$TreeTaggerOutput_idx][2] and do { do { if (($posInLemma = index($TreeTaggerOutput[$TreeTaggerOutput_idx][2], "_"), $posInLemma) != -1 and ($posInWord = index($TreeTaggerOutput[$TreeTaggerOutput_idx][0], "_", $posInLemma)) == -1 || $posInLemma != $posInWord) { $substringBefore = substr($TreeTaggerOutput[$TreeTaggerOutput_idx][2], 0, $posInLemma); $substringAfter = substr($TreeTaggerOutput[$TreeTaggerOutput_idx][2], $posInLemma + 1); $TreeTaggerOutput[$TreeTaggerOutput_idx][2] = "$substringBefore $substringAfter"; ++$posInLemma; } } } 0 0 0
Condition0%0/6
$posInLemma != -1 and $posInLemma != $posInWord and $posInLemma < length $TreeTaggerOutput[$TreeTaggerOutput_idx][2]
!ll&&!rl&&r
000
$posInLemma != -1 and $posInLemma != $posInWord
!ll&&!rl&&r
000
MC/DC0%0/3
$posInLemma != -1 and $posInLemma != $posInWord and $posInLemma < length $TreeTaggerOutput[$TreeTaggerOutput_idx][2]
$posInLemma != -1 $posInLemma != $posInWord $posInLemma < length $TreeTaggerOutput[$TreeTaggerOutput_idx][2]
Truth table0%0/4
A and B and C
A= $posInLemma != -1B= $posInLemma != $posInWordC= $posInLemma < length $TreeTaggerOutput[$TreeTaggerOutput_idx][2]
ABCresult
0XX0
10X0
1100
1111
3071 0 ▶ if ((($posInLemma = index($TreeTaggerOutput[$TreeTaggerOutput_idx]->[2], "_"), $posInLemma) != -1) &&
Branch: 1 branch
BranchTrueFalseTotal
if (($posInLemma = index($TreeTaggerOutput[$TreeTaggerOutput_idx][2], "_"), $posInLemma) != -1 and ($posInWord = index($TreeTaggerOutput[$TreeTaggerOutput_idx][0], "_", $posInLemma)) == -1 || $posInLemma != $posInWord) 0 0 0
Condition0%0/6
($posInLemma = index($TreeTaggerOutput[$TreeTaggerOutput_idx][2], "_"), $posInLemma) != -1 and ($posInWord = index($TreeTaggerOutput[$TreeTaggerOutput_idx][0], "_", $posInLemma)) == -1 || $posInLemma != $posInWord
!ll&&!rl&&r
000
($posInWord = index($TreeTaggerOutput[$TreeTaggerOutput_idx][0], "_", $posInLemma)) == -1 or $posInLemma != $posInWord
l!l&&r!l&&!r
000
MC/DC0%0/3
($posInLemma = index($TreeTaggerOutput[$TreeTaggerOutput_idx][2], "_"), $posInLemma) != -1 and ($posInWord = index($TreeTaggerOutput[$TreeTaggerOutput_idx][0], "_", $posInLemma)) == -1 || $posInLemma != $posInWord
($posInLemma = index($TreeTaggerOutput[$TreeTaggerOutput_idx][2], "_"), $posInLemma) != -1 ($posInWord = index($TreeTaggerOutput[$TreeTaggerOutput_idx][0], "_", $posInLemma)) == -1 $posInLemma != $posInWord
Truth table0%0/4
A and B or C
A= ($posInLemma = index($TreeTaggerOutput[$TreeTaggerOutput_idx][2], "_"), $posInLemma) != -1B= ($posInWord = index($TreeTaggerOutput[$TreeTaggerOutput_idx][0], "_", $posInLemma)) == -1C= $posInLemma != $posInWord
ABCresult
0XX0
1000
11X1
1011
3072 ((($posInWord = index($TreeTaggerOutput[$TreeTaggerOutput_idx]->[0], "_", $posInLemma)) == -1) ||
3073 ($posInLemma != $posInWord))) {
3074 # warn "lemma to correct : " . $TreeTaggerOutput[$TreeTaggerOutput_idx]->[2] . "\n";
3075 0 $substringBefore = substr($TreeTaggerOutput[$TreeTaggerOutput_idx]->[2], 0, $posInLemma);
3076 0 $substringAfter = substr($TreeTaggerOutput[$TreeTaggerOutput_idx]->[2], $posInLemma + 1);
3077
3078 # warn "New lemma : $substringBefore $substringAfter ($posInLemma)\n";
3079 0 $TreeTaggerOutput[$TreeTaggerOutput_idx]->[2] = "$substringBefore $substringAfter";
3080 0 $posInLemma++;
3081 }
3082 } while (($posInLemma != -1) && ($posInLemma != $posInWord) && ($posInLemma < length($TreeTaggerOutput[$TreeTaggerOutput_idx]->[2])));
3083 }
3084  
3085 # work around some strange tagging
3086 # warn "TreeTaggerOutput_idx: $TreeTaggerOutput_idx\n";
3087 0 ▶ if ((defined $TreeTaggerOutput[$TreeTaggerOutput_idx]->[1]) && ($TreeTaggerOutput[$TreeTaggerOutput_idx]->[1] eq "SENT")) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $TreeTaggerOutput[$TreeTaggerOutput_idx][1] and $TreeTaggerOutput[$TreeTaggerOutput_idx][1] eq "SENT") 0 0 0
Condition0%0/3
defined $TreeTaggerOutput[$TreeTaggerOutput_idx][1] and $TreeTaggerOutput[$TreeTaggerOutput_idx][1] eq "SENT"
!ll&&!rl&&r
000
MC/DC0%0/2
defined $TreeTaggerOutput[$TreeTaggerOutput_idx][1] and $TreeTaggerOutput[$TreeTaggerOutput_idx][1] eq "SENT"
defined $TreeTaggerOutput[$TreeTaggerOutput_idx][1] $TreeTaggerOutput[$TreeTaggerOutput_idx][1] eq "SENT"
Truth table0%0/3
A and B
A= defined $TreeTaggerOutput[$TreeTaggerOutput_idx][1]B= $TreeTaggerOutput[$TreeTaggerOutput_idx][1] eq "SENT"
ABresult
0X0
100
111
3088 0 $TreeTaggerOutput[$TreeTaggerOutput_idx]->[1] = "NP";
3089 }
3090  
3091 # if (scalar(@{$TreeTaggerOutput[$TreeTaggerOutput_idx]}) >= 0) {
3092 0 ▶ if ($replace == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($replace == 1) { } 0 0 0
3093 # Correction bug
3094 0 my $ttg_syntactic_category = $word->getMorphoSyntacticFeatures($document)->syntactic_category;
3095 0 my $ttg_lemma = $word->getLemma($document)->canonical_form;
3096  
3097 # if (! defined $TreeTaggerOutput[$TreeTaggerOutput_idx]->[0]) {
3098 # warn "(0) " . join(';', @{$TreeTaggerOutput[$TreeTaggerOutput_idx]}) . " $ttg_lemma\n";
3099 # }
3100 # if (scalar(@{$TreeTaggerOutput[$TreeTaggerOutput_idx]}) == 0) {
3101 # @{$TreeTaggerOutput[$TreeTaggerOutput_idx]} = ($ttg_lemma, $ttg_syntactic_category, $ttg_lemma);
3102 # }
3103
3104  
3105 0 ▶ if ((defined $ttg_syntactic_category) && (defined $ttg_lemma) &&
Branch: 1 branch
BranchTrueFalseTotal
if (defined $ttg_syntactic_category and defined $ttg_lemma and defined $TreeTaggerOutput[$TreeTaggerOutput_idx][0] and $TreeTaggerOutput[$TreeTaggerOutput_idx][0] =~ /^:Vm\-\-/o) 0 0 0
Condition0%0/9
defined $ttg_syntactic_category and defined $ttg_lemma and defined $TreeTaggerOutput[$TreeTaggerOutput_idx][0] and $TreeTaggerOutput[$TreeTaggerOutput_idx][0] =~ /^:Vm\-\-/o
!ll&&!rl&&r
000
defined $ttg_syntactic_category and defined $ttg_lemma and defined $TreeTaggerOutput[$TreeTaggerOutput_idx][0]
!ll&&!rl&&r
000
defined $ttg_syntactic_category and defined $ttg_lemma
!ll&&!rl&&r
000
MC/DC0%0/4
defined $ttg_syntactic_category and defined $ttg_lemma and defined $TreeTaggerOutput[$TreeTaggerOutput_idx][0] and $TreeTaggerOutput[$TreeTaggerOutput_idx][0] =~ /^:Vm\-\-/o
defined $ttg_syntactic_category defined $ttg_lemma defined $TreeTaggerOutput[$TreeTaggerOutput_idx][0] $TreeTaggerOutput[$TreeTaggerOutput_idx][0] =~ /^:Vm\-\-/o
Truth table0%0/5
A and B and C and D
A= defined $ttg_syntactic_categoryB= defined $ttg_lemmaC= defined $TreeTaggerOutput[$TreeTaggerOutput_idx][0]D= $TreeTaggerOutput[$TreeTaggerOutput_idx][0] =~ /^:Vm\-\-/o
ABCDresult
0XXX0
10XX0
110X0
11100
11111
3106 (defined ($TreeTaggerOutput[$TreeTaggerOutput_idx]->[0])) &&
3107 ($TreeTaggerOutput[$TreeTaggerOutput_idx]->[0] =~ /^:Vm\-\-/o)) {
3108 # warn "Passe ici\n";
3109 0 ▶ if ($ttg_syntactic_category eq "ADJ") {
Branch: 1 branch
BranchTrueFalseTotal
if ($ttg_syntactic_category eq 'ADJ') { } 0 0 0
3110 0 $TreeTaggerOutput[$TreeTaggerOutput_idx]->[1] = "ADJ:A---s--";
3111 0 $TreeTaggerOutput[$TreeTaggerOutput_idx]->[2] = $ttg_lemma;
3112 } else {
3113 # warn "et ici\n";
3114 0 $TreeTaggerOutput[$TreeTaggerOutput_idx]->[1] = "NOM:Nc-s--";
3115 0 $TreeTaggerOutput[$TreeTaggerOutput_idx]->[2] = $ttg_lemma;
3116 }
3117 }
3118 0 ▶ if ((defined $ttg_syntactic_category) && (defined $ttg_lemma)){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $ttg_syntactic_category and defined $ttg_lemma) 0 0 0
Condition0%0/3
defined $ttg_syntactic_category and defined $ttg_lemma
!ll&&!rl&&r
000
MC/DC0%0/2
defined $ttg_syntactic_category and defined $ttg_lemma
defined $ttg_syntactic_category defined $ttg_lemma
Truth table0%0/3
A and B
A= defined $ttg_syntactic_categoryB= defined $ttg_lemma
ABresult
0X0
100
111
3119
3120 # if (! defined $TreeTaggerOutput[$TreeTaggerOutput_idx]->[1]) {
3121 # warn "(1) " . join(';', @{$TreeTaggerOutput[$TreeTaggerOutput_idx]}) . " $ttg_lemma\n";
3122 # }
3123 #(scalar(@{$TreeTaggerOutput[$TreeTaggerOutput_idx]}) == 0) ||
3124
3125 0 ▶ if ((!defined $TreeTaggerOutput[$TreeTaggerOutput_idx]->[1]) ||
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $TreeTaggerOutput[$TreeTaggerOutput_idx][1] or $TreeTaggerOutput[$TreeTaggerOutput_idx][1] eq "") 0 0 0
Condition0%0/3
not defined $TreeTaggerOutput[$TreeTaggerOutput_idx][1] or $TreeTaggerOutput[$TreeTaggerOutput_idx][1] eq ""
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $TreeTaggerOutput[$TreeTaggerOutput_idx][1] or $TreeTaggerOutput[$TreeTaggerOutput_idx][1] eq ""
not defined $TreeTaggerOutput[$TreeTaggerOutput_idx][1] $TreeTaggerOutput[$TreeTaggerOutput_idx][1] eq ""
Truth table0%0/3
not(A) or B
A= not defined $TreeTaggerOutput[$TreeTaggerOutput_idx][1]B= $TreeTaggerOutput[$TreeTaggerOutput_idx][1] eq ""
ABresult
1X1
011
000
3126 ($TreeTaggerOutput[$TreeTaggerOutput_idx]->[1] eq "")) {
3127 0 $TreeTaggerOutput[$TreeTaggerOutput_idx]->[1] = $ttg_syntactic_category;
3128 # $TreeTaggerOutput[$TreeTaggerOutput_idx]->[0] = $FF;
3129 0 $TreeTaggerOutput[$TreeTaggerOutput_idx]->[2] = $ttg_lemma;
3130 }
3131 # if (! defined $TreeTaggerOutput[$TreeTaggerOutput_idx]->[2]) {
3132 # warn "(2) " . join(';', @{$TreeTaggerOutput[$TreeTaggerOutput_idx]}) . " $ttg_lemma\n";
3133 # }
3134 0 ▶ if ((!defined $TreeTaggerOutput[$TreeTaggerOutput_idx]->[2]) || ($TreeTaggerOutput[$TreeTaggerOutput_idx]->[2] eq "\n")) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $TreeTaggerOutput[$TreeTaggerOutput_idx][2] or $TreeTaggerOutput[$TreeTaggerOutput_idx][2] eq "\n") 0 0 0
Condition0%0/3
not defined $TreeTaggerOutput[$TreeTaggerOutput_idx][2] or $TreeTaggerOutput[$TreeTaggerOutput_idx][2] eq "\n"
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $TreeTaggerOutput[$TreeTaggerOutput_idx][2] or $TreeTaggerOutput[$TreeTaggerOutput_idx][2] eq "\n"
not defined $TreeTaggerOutput[$TreeTaggerOutput_idx][2] $TreeTaggerOutput[$TreeTaggerOutput_idx][2] eq "\n"
Truth table0%0/3
not(A) or B
A= not defined $TreeTaggerOutput[$TreeTaggerOutput_idx][2]B= $TreeTaggerOutput[$TreeTaggerOutput_idx][2] eq "\n"
ABresult
1X1
011
000
3135 0 $TreeTaggerOutput[$TreeTaggerOutput_idx]->[2] = $ttg_lemma;
3136 }
3137 }
3138 0 $word->getMorphoSyntacticFeatures($document)->syntactic_category($TreeTaggerOutput[$TreeTaggerOutput_idx]->[1]);
3139  
3140 0 $word->getLemma($document)->canonical_form($TreeTaggerOutput[$TreeTaggerOutput_idx]->[2]);
3141  
3142 } else {
3143  
3144 0 $MSFeatures = Lingua::Ogmios::Annotations::MorphosyntacticFeatures->new(
3145 {'refid_word' => $word,
3146 'syntactic_category' => $TreeTaggerOutput[$TreeTaggerOutput_idx]->[1],
3147 });
3148 0 $document->getAnnotations->addMorphosyntacticFeatures($MSFeatures);
3149
3150 0 $Lemma = Lingua::Ogmios::Annotations::Lemma->new(
3151 {'refid_word' => $word,
3152 'canonical_form' => $TreeTaggerOutput[$TreeTaggerOutput_idx]->[2],
3153 });
3154 0 $document->getAnnotations->addLemma($Lemma);
3155 }
3156 0 $doc_idx += $word->getReferenceSize - 1;
3157 0 $token = $document->getAnnotations->getTokenLevel->getElements->[$doc_idx];
3158 # }
3159 0 $TreeTaggerOutput_idx++;
3160  
3161 } else {
3162 0 ▶ if ((!($token->isSep)) && ($token->getContent !~ /[\x{2019}\x{2032}']/go)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($token->isSep or $token->getContent =~ /[\x{2019}\x{2032}']/go) 0 0 0
Condition0%0/3
$token->isSep or $token->getContent =~ /[\x{2019}\x{2032}']/go
l!l&&r!l&&!r
000
MC/DC0%0/2
$token->isSep or $token->getContent =~ /[\x{2019}\x{2032}']/go
$token->isSep $token->getContent =~ /[\x{2019}\x{2032}']/go
Truth table0%0/3
A or B
A= $token->isSepB= $token->getContent =~ /[\x{2019}\x{2032}']/go
ABresult
1X1
011
000
3163 # if (!($token->isSep)) {
3164 0 $TreeTaggerOutput_idx++;
3165 # warn $token->getContent . " (" . $token->getId . ") " . $TreeTaggerOutput[$TreeTaggerOutput_idx]->[0] . "\n";
3166 }
3167 }
3168 0 ▶ if ($document->getAnnotations->getSentenceLevel->existsElementFromIndex("refid_end_token", $token->getId)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($document->getAnnotations->getSentenceLevel->existsElementFromIndex("refid_end_token", $token->getId)) 0 0 0
3169 0 ▶ if ($token->isSymb) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token->isSymb) { } 0 0 0
3170 0 ▶ if ($document->getAnnotations->getWordLevel->existsElementFromIndex("list_refid_token", $token->getId)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($document->getAnnotations->getWordLevel->existsElementFromIndex("list_refid_token", $token->getId)) 0 0 0
3171
3172 # } else {
3173 0 $TreeTaggerOutput_idx++;
3174 # warn $token->getContent . " (" . $token->getId . ") " . $TreeTaggerOutput[$TreeTaggerOutput_idx]->[0] . " 0 \n";
3175 }
3176 } else {
3177 0 $TreeTaggerOutput_idx++;
3178 # warn ". ( 000 ) " . $TreeTaggerOutput[$TreeTaggerOutput_idx++]->[0] . "\n";
3179 }
3180 }
3181 # if (scalar(@{$TreeTaggerOutput[$TreeTaggerOutput_idx]}) == 0) {
3182 # $TreeTaggerOutput_idx++;
3183 # }
3184  
3185 }
3186 }
3187  
3188 }
3189  
3190 0 ▶sub propagateSemanticFeatures {
Subroutine propagateSemanticFeatures: not called CC=6 SCAR=37.4
Pod undocumented
3191 0 my ($self) = @_;
3192  
3193 0 my $document;
3194 my $syntactic_relation;
3195 0 my $head_term;
3196 0 my $term;
3197  
3198 0 warn "[LOG] propagateSemanticFeatures\n";
3199  
3200 0 foreach $document (@{$self->_documentSet}) {
3201 0 foreach $syntactic_relation (@{$document->getAnnotations->getSyntacticRelationLevel->getElements}) {
3202 # warn $syntactic_relation->getId . "\n";
3203 # warn $syntactic_relation->syntactic_relation_type . "\n";
3204 0 ▶ if ($syntactic_relation->syntactic_relation_type eq "Head_of") {
Branch: 1 branch
BranchTrueFalseTotal
if ($syntactic_relation->syntactic_relation_type eq "Head_of") 0 0 0
3205 # warn "\t" . $syntactic_relation->refid_head->[0] . "\n";
3206 # warn "\t" . $syntactic_relation->reference_name_head . "\n";
3207 0 $head_term = $document->getAnnotations->getSemanticUnitLevel->getElementFromIndex($syntactic_relation->reference_name_head, $syntactic_relation->refid_head->[0]->getId)->[0];
3208 # warn "===\n";
3209 # warn "\t" . $syntactic_relation->refid_modifier->[0] . "\n";
3210 # warn "\t" . $syntactic_relation->reference_name_modifier . "\n";
3211 0 $term = $document->getAnnotations->getSemanticUnitLevel->getElementFromIndex($syntactic_relation->reference_name_modifier, $syntactic_relation->refid_modifier->[0]->getId)->[0];
3212 # warn "===\n";
3213  
3214 # warn "head = " . $head_term->getForm . "\n";
3215 # warn "head = " . $head_term->getId . "\n";
3216 # warn "term = " . $term->getForm . "\n";
3217 # warn "term = " . $term->getId . "\n";
3218 0 ▶ if (($document->getAnnotations->getSemanticFeaturesLevel->existsElementFromIndex("refid_semantic_unit", $head_term->getId)) &&
Branch: 1 branch
BranchTrueFalseTotal
if ($document->getAnnotations->getSemanticFeaturesLevel->existsElementFromIndex("refid_semantic_unit", $head_term->getId) and not $document->getAnnotations->getSemanticFeaturesLevel->existsElementFromIndex("refid_semantic_unit", $term->getId)) 0 0 0
Condition0%0/3
$document->getAnnotations->getSemanticFeaturesLevel->existsElementFromIndex("refid_semantic_unit", $head_term->getId) and not $document->getAnnotations->getSemanticFeaturesLevel->existsElementFromIndex("refid_semantic_unit", $term->getId)
!ll&&!rl&&r
000
MC/DC0%0/2
$document->getAnnotations->getSemanticFeaturesLevel->existsElementFromIndex("refid_semantic_unit", $head_term->getId) and not $document->getAnnotations->getSemanticFeaturesLevel->existsElementFromIndex("refid_semantic_unit", $term->getId)
$document->getAnnotations->getSemanticFeaturesLevel->existsElementFromIndex("refid_semantic_unit", $head_term->getId) not $document->getAnnotations->getSemanticFeaturesLevel->existsElementFromIndex("refid_semantic_unit", $term->getId)
Truth table0%0/3
A and not(B)
A= $document->getAnnotations->getSemanticFeaturesLevel->existsElementFromIndex("refid_semantic_unit", $head_term->getId)B= not $document->getAnnotations->getSemanticFeaturesLevel->existsElementFromIndex("refid_semantic_unit", $term->getId)
ABresult
0X0
100
111
3219 (!($document->getAnnotations->getSemanticFeaturesLevel->existsElementFromIndex("refid_semantic_unit", $term->getId)))) {
3220 # $document->getAnnotations->getSemanticFeaturesLevel->addSemanticFeature
3221 # warn "head = " . $head_term->getId . "\n";
3222 # warn "term = " . $term->getId . "\n";
3223 # warn "semf = " . $document->getAnnotations->getSemanticFeaturesLevel->getElementFromIndex("refid_semantic_unit", $head_term->getId)->[0]->getId . "\n";
3224 # warn "add a semantic Feature to the term " . $term->getId . "(" . $term->getForm . ")\n";
3225 0 $self->_addSemanticFeature($term, $document->getAnnotations->getSemanticFeaturesLevel->getElementFromIndex("refid_semantic_unit", $head_term->getId)->[0]->semantic_category, $document);
3226 # _addSemanticFeature {
3227 # my ($self, $termUnit, $semtag, $document) = @_;
3228 }
3229 }
3230 }
3231 }
3232  
3233 0 warn "done\n";
3234 }
3235  
3236 0 ▶sub _addRelation {
Subroutine _addRelation: not called CC=9 SCAR=45.0
3237 # my $self;
3238  
3239 # warn join(" : ", (caller(1))) . "\n";
3240  
3241 # warn $_[0] . " : " . __PACKAGE__ . " : " . ref($_[0]) . "\n";
3242  
3243 # if (index($_[0], __PACKAGE__) == 0){
3244 # $self = shift;
3245 # }
3246 0 my ($self, $document, $reltype, $list_refid) = @_;
3247  
3248 0 my $domainSpecificRelation;
3249 my @tmpTerms;
3250 0 my $i;
3251 0 my $rel;
3252 0 my $rel1;
3253 0 my $rel2;
3254 0 my %hrel1;
3255  
3256 0 push @tmpTerms, @$list_refid;
3257  
3258 # warn $tmpTerms[0]->getForm . "\n";
3259 # warn $tmpTerms[1]->getForm . "\n";
3260  
3261 0 $i = 0;
3262 0 ▶ if (!$tmpTerms[0]->equals($tmpTerms[1])) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $tmpTerms[0]->equals($tmpTerms[1])) { } 0 0 0
3263 0 ▶ if ((defined $document->getAnnotations->getDomainSpecificRelationLevel->getElementFromIndex("list_refid_semantic_unit", $tmpTerms[0]->getId)) &&
Branch: 1 branch
BranchTrueFalseTotal
if (defined $document->getAnnotations->getDomainSpecificRelationLevel->getElementFromIndex("list_refid_semantic_unit", $tmpTerms[0]->getId) and defined $document->getAnnotations->getDomainSpecificRelationLevel->getElementFromIndex("list_refid_semantic_unit", $tmpTerms[1]->getId)) 0 0 0
Condition0%0/3
defined $document->getAnnotations->getDomainSpecificRelationLevel->getElementFromIndex("list_refid_semantic_unit", $tmpTerms[0]->getId) and defined $document->getAnnotations->getDomainSpecificRelationLevel->getElementFromIndex("list_refid_semantic_unit", $tmpTerms[1]->getId)
!ll&&!rl&&r
000
MC/DC0%0/2
defined $document->getAnnotations->getDomainSpecificRelationLevel->getElementFromIndex("list_refid_semantic_unit", $tmpTerms[0]->getId) and defined $document->getAnnotations->getDomainSpecificRelationLevel->getElementFromIndex("list_refid_semantic_unit", $tmpTerms[1]->getId)
defined $document->getAnnotations->getDomainSpecificRelationLevel->getElementFromIndex("list_refid_semantic_unit", $tmpTerms[0]->getId) defined $document->getAnnotations->getDomainSpecificRelationLevel->getElementFromIndex("list_refid_semantic_unit", $tmpTerms[1]->getId)
Truth table0%0/3
A and B
A= defined $document->getAnnotations->getDomainSpecificRelationLevel->getElementFromIndex("list_refid_semantic_unit", $tmpTerms[0]->getId)B= defined $document->getAnnotations->getDomainSpecificRelationLevel->getElementFromIndex("list_refid_semantic_unit", $tmpTerms[1]->getId)
ABresult
0X0
100
111
3264 (defined $document->getAnnotations->getDomainSpecificRelationLevel->getElementFromIndex("list_refid_semantic_unit", $tmpTerms[1]->getId))){
3265 0 $rel1 = $document->getAnnotations->getDomainSpecificRelationLevel->getElementFromIndex("list_refid_semantic_unit", $tmpTerms[0]->getId);
3266 0 $rel2 = $document->getAnnotations->getDomainSpecificRelationLevel->getElementFromIndex("list_refid_semantic_unit", $tmpTerms[1]->getId);
3267  
3268 0 foreach $rel (@$rel1) {
3269 0 $hrel1{$rel} = 0;
3270 }
3271 0 $i = 0;
3272 0 ▶ while(($i < scalar(@$rel2)) && (!exists($hrel1{$rel2->[$i]}))) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < scalar @$rel2 and not exists $hrel1{$rel2->[$i]}) 0 0 0
Condition0%0/3
$i < scalar @$rel2 and not exists $hrel1{$rel2->[$i]}
!ll&&!rl&&r
000
MC/DC0%0/2
$i < scalar @$rel2 and not exists $hrel1{$rel2->[$i]}
$i < scalar @$rel2 not exists $hrel1{$rel2->[$i]}
Truth table0%0/3
A and not(B)
A= $i < scalar @$rel2B= not exists $hrel1{$rel2->[$i]}
ABresult
0X0
100
111
3273 0 $i++;
3274 }
3275 }
3276 0 ▶ if (((!defined $rel2) || ($i == scalar(@$rel2))) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $rel2 or $i == scalar @$rel2) { } 0 0 0
Condition0%0/3
not defined $rel2 or $i == scalar @$rel2
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $rel2 or $i == scalar @$rel2
not defined $rel2 $i == scalar @$rel2
Truth table0%0/3
not(A) or B
A= not defined $rel2B= $i == scalar @$rel2
ABresult
1X1
011
000
3277 # warn "add a relation\n";
3278 0 $domainSpecificRelation = Lingua::Ogmios::Annotations::DomainSpecificRelation->new(
3279 {'domain_specific_relation_type' => $reltype,
3280 'list_refid_semantic_unit' => \@tmpTerms,
3281 });
3282 0 $document->getAnnotations->addDomainSpecificRelation($domainSpecificRelation);
3283 0 return($domainSpecificRelation);
3284 } else {
3285 0 warn "Relationalready exists\n";
3286 0 return(undef);
3287 }
3288 } else {
3289 0 warn "term1 == term2\n";
3290 0 return(undef);
3291 }
3292 }
3293  
3294 15 ▶sub getTimer {
Subroutine getTimer: called CC=1 SCAR=0.0
Pod undocumented
3295 15 my ($self) = @_;
3296  
3297 15 return($self->{'timer'});
3298 }
3299  
3300 114 ▶sub currentDocument {
Subroutine currentDocument: called CC=2 SCAR=6.9
Pod undocumented
3301 114 my $self = shift;
3302  
3303 114 ▶ $self->{'currentDocument'} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 9 105 114
3304 114 return $self->{'currentDocument'};
3305  
3306 }
3307  
3308 0 ▶sub _loadStopWords {
Subroutine _loadStopWords: not called CC=6 SCAR=37.4
3309 0 my ($self, $filename, $lang, $name) = @_;
3310 0 my %resource;
3311  
3312 0 ▶ if (defined $self->{$name}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{$name}) 0 0 0
3313 0 %resource = %{$self->{$name}->{$lang}};
3314 }
3315
3316 0 my $line;
3317 0 ▶ if (!(open FILE, $filename)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (open FILE, $filename) 0 0 0
3318 0 warn "No such file " . $filename . "\n";
3319 0 return(-1);
3320 }
3321 0 ▶ while ($line = <FILE>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($line = readline FILE)) 0 0 0
3322 0 chomp $line;
3323 0 ▶ if (($line !~ /^\s*$/o) && ($line !~ /^\s*\#$/o)){
Branch: 1 branch
BranchTrueFalseTotal
unless ($line =~ /^\s*$/o or $line =~ /^\s*\#$/o) 0 0 0
Condition0%0/3
$line =~ /^\s*$/o or $line =~ /^\s*\#$/o
l!l&&r!l&&!r
000
MC/DC0%0/2
$line =~ /^\s*$/o or $line =~ /^\s*\#$/o
$line =~ /^\s*$/o $line =~ /^\s*\#$/o
Truth table0%0/3
A or B
A= $line =~ /^\s*$/oB= $line =~ /^\s*\#$/o
ABresult
1X1
011
000
3324 0 $resource{$line} = 0;
3325 }
3326  
3327 }
3328 0 close FILE;
3329  
3330 0 $self->{$name}->{$lang} = \%resource;
3331 }
3332  
3333 0 ▶sub _loadList {
Subroutine _loadList: not called CC=6 SCAR=37.4
3334 0 my ($self, $filename, $lang, $name) = @_;
3335 0 my @resource;
3336  
3337 0 ▶ if (defined $self->{$name}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{$name}) 0 0 0
3338 0 @resource = @{$self->{$name}->{$lang}};
3339 }
3340
3341 0 my $line;
3342 0 ▶ if (!(open FILE, $filename)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (open FILE, $filename) 0 0 0
3343 0 warn "No such file " . $filename . "\n";
3344 0 return(-1);
3345 }
3346 0 ▶ while ($line = <FILE>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($line = readline FILE)) 0 0 0
3347 0 chomp $line;
3348 0 ▶ if (($line !~ /^\s*$/o) && ($line !~ /^\s*\#$/o)){
Branch: 1 branch
BranchTrueFalseTotal
unless ($line =~ /^\s*$/o or $line =~ /^\s*\#$/o) 0 0 0
Condition0%0/3
$line =~ /^\s*$/o or $line =~ /^\s*\#$/o
l!l&&r!l&&!r
000
MC/DC0%0/2
$line =~ /^\s*$/o or $line =~ /^\s*\#$/o
$line =~ /^\s*$/o $line =~ /^\s*\#$/o
Truth table0%0/3
A or B
A= $line =~ /^\s*$/oB= $line =~ /^\s*\#$/o
ABresult
1X1
011
000
3349 0 push @resource, $line;
3350 }
3351  
3352 }
3353 0 close FILE;
3354  
3355 0 $self->{$name}->{$lang} = \@resource;
3356 }
3357  
3358  
3359 94 ▶sub _setOption {
Subroutine _setOption: called CC=8 SCAR=36.9
3360 94 my ($self, $lang2, $optionRC, $option, $defaultValue, $defaultType) = @_;
3361 94 my $item;
3362  
3363 # warn "==> $lang2\n";
3364 94 my $lang = "language=" . uc($lang2);
3365  
3366
3367 94 ▶ if (defined $self->_config->configuration->{'CONFIG'}->{$lang}->{$optionRC}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->_config->configuration->{'CONFIG'}{$lang}{$optionRC}) { } 0 94 94
3368  
3369 # warn $self->_config->configuration->{'CONFIG'}->{$lang}->{$optionRC} . "\n";
3370 0 ▶ if (ref($self->_config->configuration->{'CONFIG'}->{$lang}->{$optionRC}) eq "ARRAY") {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $self->_config->configuration->{'CONFIG'}{$lang}{$optionRC} eq 'ARRAY') { } 0 0 0
3371 0 $self->{$option}->{$lang2} = {};
3372 0 foreach $item (@{$self->_config->configuration->{'CONFIG'}->{$lang}->{$optionRC}}) {
3373 0 $self->{$option}->{$lang2}->{$item}++;
3374 }
3375 } else {
3376 0 ▶ if ((defined $defaultType) && ($defaultType eq "HASH")) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $defaultType and $defaultType eq 'HASH') { } 0 0 0
Condition0%0/3
defined $defaultType and $defaultType eq "HASH"
!ll&&!rl&&r
000
MC/DC0%0/2
defined $defaultType and $defaultType eq "HASH"
defined $defaultType $defaultType eq "HASH"
Truth table0%0/3
A and B
A= defined $defaultTypeB= $defaultType eq "HASH"
ABresult
0X0
100
111
3377 0 $self->{$option}->{$lang2}->{$self->_config->configuration->{'CONFIG'}->{$lang}->{$optionRC}}++;
3378 } else {
3379 # warn "ok ($optionRC)\n";
3380 0 ▶ if ($self->_config->configuration->{'CONFIG'}->{$lang}->{$optionRC} eq '\n') {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->_config->configuration->{'CONFIG'}{$lang}{$optionRC} eq '\\n') { } 0 0 0
elsif ($self->_config->configuration->{'CONFIG'}{$lang}{$optionRC} eq '\\t') { } 0 0 0
3381 0 $self->_config->configuration->{'CONFIG'}->{$lang}->{$optionRC} = "\n";
3382 } elsif ($self->_config->configuration->{'CONFIG'}->{$lang}->{$optionRC} eq '\t') {
3383 0 $self->_config->configuration->{'CONFIG'}->{$lang}->{$optionRC} = "\t";
3384 }
3385 0 $self->{$option}->{$lang2} = $self->_config->configuration->{'CONFIG'}->{$lang}->{$optionRC};
3386 }
3387 }
3388 } else {
3389 94 $self->{$option}->{$lang2} = $defaultValue;
3390 }
3391 }
3392  
3393 4 ▶sub _setGeneralOption {
Subroutine _setGeneralOption: called CC=6 SCAR=30.9
3394 4 my ($self, $optionRC, $option, $defaultValue, $defaultType) = @_;
3395 4 my $item;
3396  
3397 # warn "==> $lang2\n";
3398  
3399
3400 4 ▶ if (defined $self->_config->configuration->{'CONFIG'}->{$optionRC}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->_config->configuration->{'CONFIG'}{$optionRC}) { } 0 4 4
3401  
3402 # warn $self->_config->configuration->{'CONFIG'}->{$lang}->{$optionRC} . "\n";
3403 0 ▶ if (ref($self->_config->configuration->{'CONFIG'}->{$optionRC}) eq "ARRAY") {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $self->_config->configuration->{'CONFIG'}{$optionRC} eq 'ARRAY') { } 0 0 0
3404 0 $self->{$option} = {};
3405 0 foreach $item (@{$self->_config->configuration->{'CONFIG'}->{$optionRC}}) {
3406 0 $self->{$option}->{$item}++;
3407 }
3408 } else {
3409 0 ▶ if ((defined $defaultType) && ($defaultType eq "HASH")) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $defaultType and $defaultType eq 'HASH') { } 0 0 0
Condition0%0/3
defined $defaultType and $defaultType eq "HASH"
!ll&&!rl&&r
000
MC/DC0%0/2
defined $defaultType and $defaultType eq "HASH"
defined $defaultType $defaultType eq "HASH"
Truth table0%0/3
A and B
A= defined $defaultTypeB= $defaultType eq "HASH"
ABresult
0X0
100
111
3410 0 $self->{$option}->{$self->_config->configuration->{'CONFIG'}->{$optionRC}}++;
3411 } else {
3412 # warn "ok ($optionRC)\n";
3413 0 $self->{$option} = $self->_config->configuration->{'CONFIG'}->{$optionRC};
3414 }
3415 }
3416 } else {
3417 4 $self->{$option} = $defaultValue;
3418 }
3419 }
3420  
3421 0 ▶sub _getCanonicalForm {
Subroutine _getCanonicalForm: not called CC=7 SCAR=40.3
3422 0 my ($self, $term, $document) = @_;
3423  
3424 0 my $canForm;
3425 my $elmt;
3426  
3427 # warn ">> " . $term->getForm . "\n";
3428 0 ▶ if (!defined $term->canonical_form) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $term->canonical_form) { } 0 0 0
3429 0 ▶ if ($term->reference_name eq "refid_word") {
Branch: 2 branches
BranchTrueFalseTotal
if ($term->reference_name eq 'refid_word') { } 0 0 0
elsif ($term->reference_name eq 'refid_phrase') { } 0 0 0
3430 0 $canForm = $term->reference->getLemma($document)->canonical_form;
3431 } elsif ($term->reference_name eq "refid_phrase") {
3432 0 $canForm = "";
3433 0 foreach $elmt ($term->reference->getElementList) {
3434 # warn "$elmt\n";
3435 0 ▶ if (ref($elmt) eq "Lingua::Ogmios::Annotations::Word") {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $elmt eq 'Lingua::Ogmios::Annotations::Word') { } 0 0 0
3436 0 $canForm .= $elmt->getLemma($document)->canonical_form . " ";
3437 } else {
3438 0 $canForm .= $elmt->getContent;
3439 }
3440 }
3441 0 $canForm =~ s/ +$//go;
3442 } else {
3443 0 foreach $elmt (@{$term->reference}) {
3444 0 $canForm .= $elmt->getContent;
3445 }
3446 }
3447 } else {
3448 0 $canForm = $term->canonical_form;
3449 # warn "===> $canForm\n";
3450 }
3451 # warn ">> " . $term->getForm . ": $canForm\n";
3452 0 return($canForm);
3453 }
3454  
3455 0 ▶sub _getSyntacticCategory {
Subroutine _getSyntacticCategory: not called CC=6 SCAR=37.4
3456 0 my ($self, $term, $document) = @_;
3457  
3458 0 my $syntCat;
3459 my $elmt;
3460  
3461 0 ▶ if ($term->reference_name eq "refid_word") {
Branch: 2 branches
BranchTrueFalseTotal
if ($term->reference_name eq 'refid_word') { } 0 0 0
elsif ($term->reference_name eq 'refid_phrase') { } 0 0 0
3462 0 $syntCat = $term->reference->getMorphoSyntacticFeatures($document)->syntactic_category;
3463 } elsif ($term->reference_name eq "refid_phrase") {
3464 0 $syntCat = "";
3465 0 foreach $elmt ($term->reference->getElementList) {
3466 0 ▶ if (ref($elmt) eq "Lingua::Ogmios::Annotations::Word") {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $elmt eq 'Lingua::Ogmios::Annotations::Word') { } 0 0 0
3467 0 $syntCat .= $elmt->getMorphoSyntacticFeatures($document)->syntactic_category . " ";
3468 } else {
3469 0 $syntCat .= $elmt->getContent;
3470 }
3471 }
3472 0 $syntCat =~ s/ +$//go;
3473 } else {
3474 0 foreach $elmt (@{$term->reference}) {
3475 0 $syntCat .= $elmt->getContent;
3476 }
3477 }
3478 0 return($syntCat);
3479 }
3480  
3481 0 ▶sub _printCRFInput {
Subroutine _printCRFInput: not called CC=1 SCAR=6.9
3482 0 my ($self, $fh, $fields) = @_;
3483  
3484 0 $self->_makeTaggedSentencesCRF("", $fh, "\t", "\n", $fields);
3485 }
3486  
3487 0 ▶sub _getValidation {
Subroutine _getValidation: not called CC=1 SCAR=6.9
3488 0 my ($self, $SemUnit) = @_;
3489  
3490 0 return('-');
3491  
3492 }
3493 0 ▶sub _makeTaggedSentencesCRF {
Subroutine _makeTaggedSentencesCRF: not called CC=26 SCAR=65.5
3494 0 my ($self, $sentences, $fh, $sepInfo, $sepUnit, $fields) = @_;
3495  
3496 0 ▶ if (!defined $fh) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $fh) 0 0 0
3497 0 $fh = *STDOUT;
3498 }
3499  
3500 0 my $document;
3501 my $doc_idx;
3502 0 my $token;
3503 0 my $word;
3504 0 my $lemma;
3505 0 my $MS_features;
3506 0 my $SemUnit;
3507 0 my @corpus_in_t;
3508 0 my $canonical_form;
3509 0 my $taggedSentence;
3510 0 my $i;
3511 0 my $semf;
3512 0 my $wordform;
3513 0 my $lang;
3514 0 my $lineNb;
3515 # my $validatedTerms;
3516 0 my $terms;
3517 0 my $numberOfWeights;
3518 0 my $validation = 0;
3519 0 my @weights;
3520 my @emptyWeights;
3521 0 my $sortedFields = [sort {$fields->{$a}->{'ORDER'} <=> $fields->{$b}->{'ORDER'}} keys(%$fields)];
3522 0 my $weight;
3523  
3524 0 ▶ if (exists $fields->{'WEIGHTS'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $fields->{"WEIGHTS"}) 0 0 0
3525 # Get number of weigts
3526 # my @terms = @{$self->_documentSet->[0]->getAnnotations->getSemanticUnitLevel->getElements};
3527 # $i = 0;
3528 # while(($i < scalar(@terms)) && (!$terms[$i]->isTerm)) { $i++; };
3529 # if ($i < scalar(@terms)) {
3530 # $numberOfWeights = $terms[$i]->numberOfWeights;
3531 # } else {
3532 # $numberOfWeights = 0;
3533 # }
3534 0 $numberOfWeights = scalar(@{$fields->{'WEIGHTS'}->{'LIST'}});
3535 0 warn "Number of weights: $numberOfWeights\n";
3536 # warn " List of weights: " . join(':', keys(%{$terms[$i]->weights})) . "\n";
3537 0 ▶ for($i=0;$i < $numberOfWeights; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $numberOfWeights) 0 0 0
3538 0 $emptyWeights[$i] = -1;
3539 }
3540 }
3541  
3542 0 $self->getTimer->startsLap("making tagged sentences");
3543 0 warn "[LOG] printing Tagged Sentences\n";
3544  
3545 # warn "open " . $self->_input_filename . "(1)\n";
3546  
3547 # open FILEINPUT, ">:utf8", $self->_input_filename or die "No such file " . $self->_input_filename;
3548  
3549 0 ▶ for ($i = 0; $i < scalar(@{$self->_documentSet}); $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < scalar @{$self->_documentSet;}) 0 0 0
3550 0 $self->getTimer->startsLapByCategory('document');
3551  
3552 0 $document = $self->_documentSet->[$i];
3553 0 $lang = $document->getAnnotations->getLanguage;
3554  
3555 # if ((exists $fields->{"VALIDATION"}) && (defined $keywordProperty)) {
3556 # # if (!defined $validatedTerms) {
3557 # $keywords = $self->_getCorrectKeywords($document, $keywordProperty);
3558 # # }
3559 # }
3560 # warn "$keywordProperty: " . join(":", %$validatedTerms) . "\n";
3561  
3562 # if (defined $termField) {
3563
3564 # }
3565  
3566 0 $self->getTimer->startsLapByCategory('token');
3567  
3568 0 $token = $document->getAnnotations->getTokenLevel->getElements->[0];
3569  
3570 0 $self->getTimer->endsLapByCategory('token');
3571 0 ▶ while(defined ($token)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $token) 0 0 0
3572 0 $self->getTimer->startsLapByCategory('token2');
3573 0 $terms = $document->getAnnotations->getSemanticUnitLevel->getElementByToken($token);
3574  
3575 0 ▶ if (scalar(@$terms) > 0) {
Branch: 2 branches
BranchTrueFalseTotal
if (scalar @$terms > 0) { } 0 0 0
elsif ($document->getAnnotations->getWordLevel->existsElementFromIndex('list_refid_token', $token->getId)) { } 0 0 0
3576 0 $self->getTimer->startsLapByCategory('semUnit');
3577  
3578 0 $self->getTimer->startsLapByCategory('LargerSemUnit');
3579 0 $SemUnit = $self->_getLargerTerm($terms);
3580 0 $self->getTimer->endsLapByCategory('LargerSemUnit');
3581  
3582 # warn "OK\n";
3583 0 ▶ if ($SemUnit->isNamedEntity) {
Branch: 2 branches
BranchTrueFalseTotal
if ($SemUnit->isNamedEntity) { } 0 0 0
elsif ($SemUnit->isTerm) { } 0 0 0
3584 0 $canonical_form = $self->_getCanonicalForm($SemUnit, $document);
3585 # if (!defined $SemUnit->canonical_form) {
3586 # $canonical_form = "";
3587 # } else {
3588 # $canonical_form = $SemUnit->canonical_form;
3589 # }
3590 0 @weights = ();
3591 0 foreach $weight (@{$fields->{'WEIGHTS'}->{'LIST'}}) {
3592 0 ▶ if ($weight eq "position") {
Branch: 2 branches
BranchTrueFalseTotal
if ($weight eq 'position') { } 0 0 0
elsif ($weight eq 'wordLength') { } 0 0 0
3593 0 push @weights, $SemUnit->start_token->getFrom;
3594 } elsif ($weight eq "wordLength") {
3595 0 push @weights, $SemUnit->getReferenceWordSize;
3596 } else {
3597 0 push @weights, -1;
3598 }
3599 }
3600  
3601 0 $self->_addInfosUnit($lang, \$lineNb, \@corpus_in_t, {"IF" => $SemUnit->getForm,
3602 "ID" => $SemUnit->getId,
3603 "POSTAG" => "named_entity",
3604 "LM" => $canonical_form,
3605 "SEMTAG" => $SemUnit->NEtype,
3606 "DOCID" => $document->getId,
3607 "WEIGHTS" => [@weights],
3608 "VALIDATION" => "-",
3609 }, $sortedFields);
3610
3611 } elsif ($SemUnit->isTerm) {
3612 0 $semf = $document->getAnnotations->getSemanticFeaturesLevel->getElementFromIndex("refid_semantic_unit", $SemUnit->getId)->[0];
3613 # warn "OK2";
3614 0 ▶ if (defined $semf) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $semf) { } 0 0 0
3615 # warn "OK2b";
3616 0 $canonical_form = $self->_getCanonicalForm($SemUnit, $document);
3617 # if (!defined $SemUnit->canonical_form) {
3618 # $canonical_form = "";
3619 # } else {
3620 # $canonical_form = $SemUnit->canonical_form;
3621 # }
3622 0 $validation = $self->_getValidation($SemUnit, $document);
3623 0 my $weight;
3624 0 @weights = ();
3625 0 foreach $weight (@{$fields->{'WEIGHTS'}->{'LIST'}}) {
3626 # warn $weight . "\n";
3627 0 ▶ if ($SemUnit->existsWeight($weight)) {
Branch: 3 branches
BranchTrueFalseTotal
if ($SemUnit->existsWeight($weight)) { } 0 0 0
elsif ($weight eq 'position') { } 0 0 0
elsif ($weight eq 'wordLength') { } 0 0 0
3628 0 push @weights, $SemUnit->weight($weight);
3629 } elsif ($weight eq "position") {
3630 0 push @weights, $SemUnit->start_token->getFrom;
3631 } elsif ($weight eq "wordLength") {
3632 0 push @weights, $SemUnit->getReferenceWordSize;
3633 } else {
3634 0 push @weights, 0;
3635 }
3636  
3637 }
3638  
3639 0 $self->_addInfosUnit($lang, \$lineNb, \@corpus_in_t, {"IF" => $SemUnit->getForm,
3640 "ID" => $SemUnit->getId,
3641 "POSTAG" => "term",
3642 "LM" => $canonical_form,
3643 "SEMTAG" => $semf->first_node_first_semantic_category,
3644 "DOCID" => $document->getId,
3645 "WEIGHTS" => [@weights],
3646 "VALIDATION" => $validation,
3647 }, $sortedFields);
3648 0 $self->{'ML_termlist'}->{$lineNb} = [$i, $SemUnit];
3649 # warn "$lineNb: " . $SemUnit->getForm . "\n";
3650 } else {
3651 # warn "OK2c";
3652 0 $canonical_form = $self->_getCanonicalForm($SemUnit, $document);
3653 # if (!defined $SemUnit->canonical_form) {
3654 # $canonical_form = "";
3655 # } else {
3656 # $canonical_form = $SemUnit->canonical_form;
3657 # }
3658 # warn "OK\n";
3659 0 $self->_addInfosUnit($lang, \$lineNb, \@corpus_in_t, {"IF" => $SemUnit->getForm,
3660 "ID" => $SemUnit->getId,
3661 "POSTAG" => "term",
3662 "LM" => $canonical_form,
3663 "SEMTAG" => "NOSEMTAG",
3664 "DOCID" => $document->getId,
3665 "WEIGHTS" => [@emptyWeights],
3666 "VALIDATION" => "-",
3667 }, $sortedFields);
3668 }
3669 }
3670 0 $token = $SemUnit->end_token;
3671 0 $self->getTimer->endsLapByCategory('semUnit');
3672 } elsif ($document->getAnnotations->getWordLevel->existsElementFromIndex("list_refid_token", $token->getId)) {
3673 0 $self->getTimer->startsLapByCategory('word');
3674 0 $word = $document->getAnnotations->getWordLevel->getElementFromIndex("list_refid_token", $token->getId)->[0];
3675 0 $lemma = $document->getAnnotations->getLemmaLevel->getElementFromIndex("refid_word", $word->getId)->[0];
3676 0 $MS_features = $document->getAnnotations->getMorphosyntacticFeaturesLevel->getElementFromIndex("refid_word", $word->getId)->[0];
3677 0 $wordform = $word->getForm;
3678 0 $wordform =~ s/[\t\n]/ /gos;
3679 0 $wordform =~ s/ +/ /gos;
3680  
3681 0 @weights = ();
3682 0 foreach $weight (@{$fields->{'WEIGHTS'}->{'LIST'}}) {
3683 0 ▶ if ($weight eq "position") {
Branch: 2 branches
BranchTrueFalseTotal
if ($weight eq 'position') { } 0 0 0
elsif ($weight eq 'wordLength') { } 0 0 0
3684 0 push @weights, $word->start_token->getFrom;
3685 } elsif ($weight eq "wordLength") {
3686 0 push @weights, $word->getReferenceSize;
3687 } else {
3688 0 push @weights, -1;
3689 }
3690 }
3691
3692 0 $self->_addInfosUnit($lang, \$lineNb, \@corpus_in_t, {"IF" => $wordform,
3693 "ID" => $word->getId,
3694 "POSTAG" => $MS_features->syntactic_category,
3695 "LM" => $lemma->canonical_form,
3696 "SEMTAG" => "NOSEMTAG",
3697 "DOCID" => $document->getId,
3698 "WEIGHTS" => [@weights],
3699 "VALIDATION" => "-",
3700 }, $sortedFields);
3701  
3702 0 $token = $word->end_token;
3703
3704 0 $self->getTimer->endsLapByCategory('word');
3705 } else {
3706 0 $self->getTimer->startsLapByCategory('separator');
3707 0 ▶ if ((!($token->isSep)) && (!($document->getAnnotations->getSentenceLevel->existsElementFromIndex("refid_end_token", $token->getId)))){
Branch: 1 branch
BranchTrueFalseTotal
unless ($token->isSep or $document->getAnnotations->getSentenceLevel->existsElementFromIndex("refid_end_token", $token->getId)) 0 0 0
Condition0%0/3
$token->isSep or $document->getAnnotations->getSentenceLevel->existsElementFromIndex("refid_end_token", $token->getId)
l!l&&r!l&&!r
000
MC/DC0%0/2
$token->isSep or $document->getAnnotations->getSentenceLevel->existsElementFromIndex("refid_end_token", $token->getId)
$token->isSep $document->getAnnotations->getSentenceLevel->existsElementFromIndex("refid_end_token", $token->getId)
Truth table0%0/3
A or B
A= $token->isSepB= $document->getAnnotations->getSentenceLevel->existsElementFromIndex("refid_end_token", $token->getId)
ABresult
1X1
011
000
3708 0 $self->_addInfosUnit($lang, \$lineNb, \@corpus_in_t, {"IF" => $token->getContent,
3709 "ID" => $token->getId,
3710 "POSTAG" => $token->getContent,
3711 "LM" => $token->getContent,
3712 "SEMTAG" => "NOSEMTAG",
3713 "DOCID" => $document->getId,
3714 "WEIGHTS" => [@emptyWeights],
3715 "VALIDATION" => "-",
3716 }, $sortedFields);
3717 }
3718 0 $self->getTimer->endsLapByCategory('separator');
3719 }
3720 0 $self->getTimer->startsLapByCategory('end sentence');
3721 0 ▶ if ($document->getAnnotations->getSentenceLevel->existsElementFromIndex("refid_end_token", $token->getId)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($document->getAnnotations->getSentenceLevel->existsElementFromIndex("refid_end_token", $token->getId)) 0 0 0
3722 0 ▶ if ($token->isSymb) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token->isSymb) { } 0 0 0
3723 0 ▶ if (!($document->getAnnotations->getWordLevel->existsElementFromIndex("list_refid_token", $token->getId))) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $document->getAnnotations->getWordLevel->existsElementFromIndex('list_refid_token', $token->getId)) { } 0 0 0
3724 0 $self->_addInfosUnit($lang, \$lineNb, \@corpus_in_t, {"IF" => $token->getContent,
3725 "ID" => $token->getId,
3726 "POSTAG" => "SENT",
3727 "LM" => $token->getContent,
3728 "SEMTAG" => "NOSEMTAG",
3729 "DOCID" => $document->getId,
3730 "WEIGHTS" => [@emptyWeights],
3731 "VALIDATION" => "-",
3732 }, $sortedFields);
3733 0 $self->_printTaggedSentence($fh, \@corpus_in_t, $sepInfo, $sepUnit);
3734 0 @corpus_in_t = ();
3735 } else {
3736 0 $self->_addInfosUnit($lang, \$lineNb, \@corpus_in_t, {"IF" => $token->getContent,
3737 "ID" => $token->getId,
3738 "POSTAG" => "SENT",
3739 "LM" => $token->getContent,
3740 "SEMTAG" => "NOSEMTAG",
3741 "DOCID" => $document->getId,
3742 "WEIGHTS" => [@emptyWeights],
3743 "VALIDATION" => "-",
3744 }, $sortedFields);
3745 0 $self->_printTaggedSentence($fh, \@corpus_in_t, $sepInfo, $sepUnit);
3746 0 @corpus_in_t = ();
3747 }
3748 } else {
3749 # my @tmp = (".", $token->getId, "SENT", ".");
3750 # push @corpus_in_t, \@tmp;
3751 0 $self->_addInfosUnit($lang, \$lineNb, \@corpus_in_t, {"IF" => ".",
3752 "ID" => $token->getId,
3753 "POSTAG" => "SENT",
3754 "LM" => ".",
3755 "SEMTAG" => "NOSEMTAG",
3756 "DOCID" => $document->getId,
3757 "WEIGHTS" => [@emptyWeights],
3758 "VALIDATION" => "-",
3759 }, $sortedFields);
3760 0 $self->_printTaggedSentence($fh, \@corpus_in_t, $sepInfo, $sepUnit);
3761 0 @corpus_in_t = ();
3762 }
3763 0 $self->getTimer->endsLapByCategory('end sentence');
3764 }
3765 0 $token = $token->next;
3766 0 $self->getTimer->endsLapByCategory('token2');
3767 }
3768 0 $self->getTimer->endsLapByCategory('token');
3769  
3770 0 $self->getTimer->endsLapByCategory('document');
3771 }
3772 # close FILEINPUT;
3773 0 $self->getTimer->_printTimeByCategory(0);
3774 0 $self->getTimer->_printTimesBySteps;
3775 0 warn "[LOG] done\n";
3776 }
3777  
3778 0 ▶sub _QALDoutput {
Subroutine _QALDoutput: not called CC=8 SCAR=42.8
3779 0 my ($self, $fh) = @_;
3780  
3781 0 my $document;
3782 my $i;
3783 0 my $lang;
3784 0 my $sentence;
3785 0 my $SemUnit;
3786 0 my $semf;
3787 0 my $semfString;
3788 0 my %fields = ("IF" => 1,
3789 "POSTAG" => 2,
3790 "LM" => 3,
3791 # "ID" => 4,
3792 # "DOCID" => 5,
3793 # "SEMTAG" => 6,
3794 "OFFSET" => 4
3795 );
3796  
3797 0 ▶ if (!defined $fh) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $fh) 0 0 0
3798 0 $fh = $self->_out_stream;
3799 0 ▶ if (!defined $fh) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $fh) 0 0 0
3800 0 $fh = \*STDOUT;
3801 }
3802 }
3803  
3804 0 ▶ for ($i = 0; $i < scalar(@{$self->_documentSet}); $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < scalar @{$self->_documentSet;}) 0 0 0
3805 0 $self->getTimer->startsLapByCategory('document');
3806  
3807 0 $document = $self->_documentSet->[$i];
3808 0 $lang = $document->getAnnotations->getLanguage;
3809 0 print $fh "DOC: " . $document->getId . "\n";
3810 0 print $fh "language: $lang\n\n";
3811 0 print $fh "sentence: \n";
3812 0 print $fh "# sentence form (ended by _END_SENT_)\n";
3813 0 foreach $sentence (@{$document->getAnnotations->getSentenceLevel->getElements}) {
3814 0 print $fh XML::Entities::decode('all', $sentence->getForm) . "\n_END_SENT_\n";
3815 }
3816 0 print $fh "\n";
3817 0 print $fh "word information:\n";
3818 0 print $fh "# Inflected form<tab>POSTAG<tab>Lemma<tab>offset (ended by _END_POSTAG_)\n";
3819 0 $self->_makeOneTaggedSentence($document, \*STDOUT, "\t", "\n", "\n", "", " ", \%fields);
3820 0 print $fh "_END_POSTAG_\n";
3821 0 print $fh "\n";
3822 0 print $fh "semantic units:\n";
3823 0 print $fh "# term form<tab>term canonical form<tab>semantic features<tab>offset start<tab>offset end<tab>negation indication (ended by _END_SEM_UNIT_)\n";
3824 0 foreach $SemUnit (@{$document->getAnnotations->getSemanticUnitLevel->getElements}) {
3825 # warn "==> " . $SemUnit->getForm . "\n";
3826 0 print $fh $SemUnit->getForm . "\t" . $self->_getCanonicalForm($SemUnit, $document) . "\t";
3827 0 $semfString = "";
3828 0 foreach $semf (@{$document->getAnnotations->getSemanticFeaturesLevel->getElementFromIndex("refid_semantic_unit", $SemUnit->getId)}) {
3829 0 $semfString .= $semf->toString . ":";
3830 }
3831 0 chop($semfString);
3832 0 print $fh $semfString . "\t" . $SemUnit->start_token->getFrom . "\t" . $SemUnit->end_token->getTo . "\t";
3833 0 ▶ if (defined $SemUnit->negation) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $SemUnit->negation) 0 0 0
3834 0 print $fh $SemUnit->negation;
3835 }
3836 0 print $fh "\n";
3837 }
3838 0 print $fh "_END_SEM_UNIT_\n";
3839 0 print $fh "\n_END_DOC_\n\n";
3840 }
3841 }
3842  
3843 0 ▶sub _makeOneTaggedSentence {
Subroutine _makeOneTaggedSentence: not called CC=23 SCAR=63.1
3844 0 my ($self, $document, $fh, $sepInfo, $sepUnit, $sepSent, $sepSect, $sepTermComp, $fields) = @_;
3845  
3846 # warn "in _makeOneTaggedSentence $sepInfo, $sepUnit\n";
3847  
3848 0 ▶ if (!defined $fh) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $fh) 0 0 0
3849 0 $fh = *STDOUT;
3850 }
3851 0 ▶ if (!defined $fields) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $fields) 0 0 0
3852 0 $fields = {"IF" => 1,
3853 "POSTAG" => 2,
3854 "LM" => 3,
3855 "ID" => 4,
3856 "DOCID" => 5,
3857 "SEMTAG" => 6,
3858 "OFFSET" => 7,
3859 };
3860 }
3861 0 my $doc_idx;
3862 my $token;
3863 0 my $word;
3864 0 my $lemma;
3865 0 my $MS_features;
3866 0 my $SemUnit;
3867 0 my $semForm;
3868 0 my @corpus_in_t;
3869 0 my $canonical_form;
3870 0 my $taggedSentence;
3871 0 my $id;
3872 0 my $lineNb = 0;
3873 0 my $semf;
3874 my $wordform;
3875 0 my $lang;
3876 0 my $terms = [];
3877 0 my $inSentence = 0;
3878  
3879 0 ▶ if (!defined $sepSect) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $sepSect) 0 0 0
3880 0 $sepSect = "";
3881 }
3882  
3883 0 $self->getTimer->startsLap("making tagged sentences");
3884 0 warn "[LOG] printing Tagged Sentences\n";
3885  
3886 0 $self->getTimer->startsLapByCategory('document');
3887 0 $id = $document->getId;
3888 0 $lang = $document->getAnnotations->getLanguage;
3889  
3890 0 $self->getTimer->startsLapByCategory('token');
3891  
3892 0 $token = $document->getAnnotations->getTokenLevel->getElements->[0];
3893  
3894 0 $self->getTimer->endsLapByCategory('token');
3895 0 ▶ while(defined ($token)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $token) 0 0 0
3896 0 $self->getTimer->startsLapByCategory('token2');
3897 0 ▶ if ($document->getAnnotations->getSentenceLevel->existsElementFromIndex("refid_start_token", $token->getId)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($document->getAnnotations->getSentenceLevel->existsElementFromIndex("refid_start_token", $token->getId)) 0 0 0
3898 0 $inSentence = 1;
3899 }
3900 # if ((exists $fields->{"SEMTAG"}) && ($fields->{"SEMTAG"} > 0)) {
3901 0 $terms = $document->getAnnotations->getSemanticUnitLevel->getElementByToken($token);
3902 # } else {
3903 # $terms = [];
3904 # }
3905  
3906  
3907 0 ▶ if (scalar(@$terms) > 0) {
Branch: 2 branches
BranchTrueFalseTotal
if (scalar @$terms > 0) { } 0 0 0
elsif ($document->getAnnotations->getWordLevel->existsElementFromIndex('list_refid_token', $token->getId)) { } 0 0 0
3908 0 $self->getTimer->startsLapByCategory('semUnit');
3909  
3910 0 $self->getTimer->startsLapByCategory('LargerSemUnit');
3911 0 $SemUnit = $self->_getLargerTerm($terms);
3912 0 $self->getTimer->endsLapByCategory('LargerSemUnit');
3913  
3914 0 ▶ if ($SemUnit->isNamedEntity) {
Branch: 2 branches
BranchTrueFalseTotal
if ($SemUnit->isNamedEntity) { } 0 0 0
elsif ($SemUnit->isTerm) { } 0 0 0
3915 0 $semForm = $SemUnit->getForm;
3916 0 $canonical_form = $self->_getCanonicalForm($SemUnit, $document);
3917 0 ▶ if ($sepTermComp ne "") {
Branch: 1 branch
BranchTrueFalseTotal
if ($sepTermComp ne "") 0 0 0
3918 0 $semForm =~ s/ /$sepTermComp/g;
3919 0 $canonical_form =~ s/ /$sepTermComp/g;
3920 }
3921 0 $self->_addInfosUnit($lang, \$lineNb, \@corpus_in_t, {"IF" => $semForm,
3922 "ID" => "S". $SemUnit->getId,
3923 "POSTAG" => "named_entity",
3924 "LM" => $canonical_form,
3925 "SEMTAG" => $SemUnit->NEtype,
3926 "DOCID" => $id,
3927 "OFFSET" => $SemUnit->start_token->getFrom,
3928 }, $fields);
3929
3930 } elsif ($SemUnit->isTerm) {
3931 0 $semf = $document->getAnnotations->getSemanticFeaturesLevel->getElementFromIndex("refid_semantic_unit", $SemUnit->getId)->[0];
3932 0 ▶ if (defined $semf) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $semf) { } 0 0 0
3933 0 $semForm = $SemUnit->getForm;
3934 0 $canonical_form = $self->_getCanonicalForm($SemUnit, $document);
3935 0 ▶ if ($sepTermComp ne "") {
Branch: 1 branch
BranchTrueFalseTotal
if ($sepTermComp ne "") 0 0 0
3936 0 $semForm =~ s/ /$sepTermComp/g;
3937 0 $canonical_form =~ s/ /$sepTermComp/g;
3938 }
3939 0 $self->_addInfosUnit($lang, \$lineNb, \@corpus_in_t, {"IF" => $semForm,
3940 "ID" => "S". $SemUnit->getId,
3941 "POSTAG" => "term",
3942 "LM" => $canonical_form,
3943 "SEMTAG" => $semf->first_node_first_semantic_category,
3944 "DOCID" => $id,
3945 "OFFSET" => $SemUnit->start_token->getFrom,
3946 }, $fields);
3947 } else {
3948 0 $semForm = $SemUnit->getForm;
3949 0 $canonical_form = $self->_getCanonicalForm($SemUnit, $document);
3950 0 ▶ if ($sepTermComp ne "") {
Branch: 1 branch
BranchTrueFalseTotal
if ($sepTermComp ne "") 0 0 0
3951 0 $semForm =~ s/ /$sepTermComp/g;
3952 0 $canonical_form =~ s/ /$sepTermComp/g;
3953 }
3954 0 $self->_addInfosUnit($lang, \$lineNb, \@corpus_in_t, {"IF" => $semForm,
3955 "ID" => "S". $SemUnit->getId,
3956 "POSTAG" => "term",
3957 "LM" => $canonical_form,
3958 "SEMTAG" => "",
3959 "DOCID" => $id,
3960 "OFFSET" => $SemUnit->start_token->getFrom,
3961 }, $fields);
3962 }
3963 }
3964 0 $token = $SemUnit->end_token;
3965 0 $self->getTimer->endsLapByCategory('semUnit');
3966 } elsif ($document->getAnnotations->getWordLevel->existsElementFromIndex("list_refid_token", $token->getId)) {
3967 0 $self->getTimer->startsLapByCategory('word');
3968 0 $word = $document->getAnnotations->getWordLevel->getElementFromIndex("list_refid_token", $token->getId)->[0];
3969 0 $lemma = $document->getAnnotations->getLemmaLevel->getElementFromIndex("refid_word", $word->getId)->[0];
3970 0 $MS_features = $document->getAnnotations->getMorphosyntacticFeaturesLevel->getElementFromIndex("refid_word", $word->getId)->[0];
3971 0 $wordform = $word->getForm;
3972 0 $wordform =~ s/[\t\n]/ /gos;
3973 0 $wordform =~ s/ +/ /gos;
3974
3975 0 $self->_addInfosUnit($lang, \$lineNb, \@corpus_in_t, {"IF" => $wordform,
3976 "ID" => "W". $word->getId,
3977 "POSTAG" => $MS_features->syntactic_category,
3978 "LM" => $lemma->canonical_form,
3979 "SEMTAG" => "",
3980 "DOCID" => $id,
3981 "OFFSET" => $word->start_token->getFrom,
3982 }, $fields);
3983  
3984 0 $token = $word->end_token;
3985
3986 0 $self->getTimer->endsLapByCategory('word');
3987 } else {
3988 0 $self->getTimer->startsLapByCategory('separator');
3989 0 ▶ if ((!($token->isSep)) && (!($document->getAnnotations->getSentenceLevel->existsElementFromIndex("refid_end_token", $token->getId)))){
Branch: 2 branches
BranchTrueFalseTotal
if (not $token->isSep || $document->getAnnotations->getSentenceLevel->existsElementFromIndex('refid_end_token', $token->getId)) { } 0 0 0
elsif ($token->isSep and $inSentence and $sepUnit eq '') { } 0 0 0
Condition0%0/3
$token->isSep || $document->getAnnotations->getSentenceLevel->existsElementFromIndex('refid_end_token', $token->getId)
l!l&&r!l&&!r
000
MC/DC0%0/2
$token->isSep || $document->getAnnotations->getSentenceLevel->existsElementFromIndex('refid_end_token', $token->getId)
$token->isSep $document->getAnnotations->getSentenceLevel->existsElementFromIndex('refid_end_token', $token->getId)
Truth table0%0/3
A || B
A= $token->isSepB= $document->getAnnotations->getSentenceLevel->existsElementFromIndex('refid_end_token', $token->getId)
ABresult
1X1
011
000
3990 0 $self->_addInfosUnit($lang, \$lineNb, \@corpus_in_t, {"IF" => $token->getContent,
3991 "ID" => "T". $token->getId,
3992 "POSTAG" => $token->getContent,
3993 "LM" => $token->getContent,
3994 "SEMTAG" => "",
3995 "DOCID" => $id,
3996 "OFFSET" => $token->getFrom,
3997 }, $fields);
3998 ▶ } elsif (($token->isSep) && ($inSentence) && ($sepUnit eq "")) {
Condition0%0/6
$token->isSep and $inSentence and $sepUnit eq ""
!ll&&!rl&&r
000
$token->isSep and $inSentence
!ll&&!rl&&r
000
MC/DC0%0/3
$token->isSep and $inSentence and $sepUnit eq ""
$token->isSep $inSentence $sepUnit eq ""
Truth table0%0/4
A and B and C
A= $token->isSepB= $inSentenceC= $sepUnit eq ""
ABCresult
0XX0
10X0
1100
1111
3999 0 $self->_addInfosUnit($lang, \$lineNb, \@corpus_in_t, {"TYPE" => "SEP",
4000 "CONTENT" => $token->getContent,
4001 }, $fields);
4002 }
4003 0 $self->getTimer->endsLapByCategory('separator');
4004 }
4005 0 $self->getTimer->startsLapByCategory('end sentence');
4006 0 ▶ if ($document->getAnnotations->getSentenceLevel->existsElementFromIndex("refid_end_token", $token->getId)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($document->getAnnotations->getSentenceLevel->existsElementFromIndex("refid_end_token", $token->getId)) 0 0 0
4007 0 ▶ if ($token->isSymb) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token->isSymb) { } 0 0 0
4008 0 ▶ if (!($document->getAnnotations->getWordLevel->existsElementFromIndex("list_refid_token", $token->getId))) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $document->getAnnotations->getWordLevel->existsElementFromIndex('list_refid_token', $token->getId)) { } 0 0 0
4009 0 $self->_addInfosUnit($lang, \$lineNb, \@corpus_in_t, {"IF" => $token->getContent,
4010 "ID" => "T" . $token->getId,
4011 "POSTAG" => "SENT",
4012 "LM" => $token->getContent,
4013 "SEMTAG" => "",
4014 "DOCID" => $id,
4015 "OFFSET" => $token->getFrom,
4016 }, $fields);
4017 0 $self->_printTaggedSentence($fh, \@corpus_in_t, $sepInfo, $sepUnit, $sepSent, $fields);
4018 0 @corpus_in_t = ();
4019 } else {
4020 0 $self->_addInfosUnit($lang, \$lineNb, \@corpus_in_t, {"IF" => $token->getContent,
4021 "ID" => "T" . $token->getId,
4022 "POSTAG" => "SENT",
4023 "LM" => $token->getContent,
4024 "SEMTAG" => "",
4025 "DOCID" => $id,
4026 "OFFSET" => $token->getFrom,
4027 }, $fields);
4028 0 $self->_printTaggedSentence($fh, \@corpus_in_t, $sepInfo, $sepUnit, $sepSent, $fields);
4029 0 @corpus_in_t = ();
4030 }
4031 } else {
4032 0 $self->_addInfosUnit($lang, \$lineNb, \@corpus_in_t, {"IF" => ".",
4033 "ID" => "T" . $token->getId,
4034 "POSTAG" => "SENT",
4035 "LM" => ".",
4036 "SEMTAG" => "",
4037 "DOCID" => $id,
4038 "OFFSET" => $token->getFrom,
4039 }, $fields);
4040 0 $self->_printTaggedSentence($fh, \@corpus_in_t, $sepInfo, $sepUnit, $sepSent, $fields);
4041 0 @corpus_in_t = ();
4042 }
4043 0 $self->getTimer->endsLapByCategory('end sentence');
4044 0 $inSentence = 0;
4045 }
4046 0 ▶ if ($document->getAnnotations->getSectionLevel->existsElementFromIndex("to", $token->getId)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($document->getAnnotations->getSectionLevel->existsElementFromIndex("to", $token->getId)) 0 0 0
4047 0 print $fh $sepSect;
4048 }
4049 0 $token = $token->next;
4050 0 $self->getTimer->endsLapByCategory('token2');
4051 }
4052 0 $self->getTimer->endsLapByCategory('token');
4053  
4054 0 $self->getTimer->endsLapByCategory('document');
4055 0 $self->getTimer->_printTimeByCategory(0);
4056 0 $self->getTimer->_printTimesBySteps;
4057 0 warn "[LOG] done\n";
4058 }
4059  
4060 0 ▶sub _makeTaggedSentences {
Subroutine _makeTaggedSentences: not called CC=4 SCAR=30.0
4061 0 my ($self, $sentences, $fh, $sepInfo, $sepUnit, $sepSent, $sepSect, $sepTermComp, $fields) = @_;
4062  
4063 0 ▶ if (!defined $fh) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $fh) 0 0 0
4064 0 $fh = *STDOUT;
4065 }
4066 # my $printDocId = shift;
4067 0 ▶ if (!defined $fields) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $fields) 0 0 0
4068 0 $fields = {"IF" => 1,
4069 "POSTAG" => 2,
4070 "LM" => 3,
4071 "ID" => 4,
4072 "DOCID" => 5,
4073 "SEMTAG" => 6,
4074 # "OFFSET" => 7,
4075 };
4076 }
4077 0 my $document;
4078 my $doc_idx;
4079 0 my $token;
4080 0 my $word;
4081 0 my $lemma;
4082 0 my $MS_features;
4083 0 my $SemUnit;
4084 0 my @corpus_in_t;
4085 0 my $canonical_form;
4086 0 my $taggedSentence;
4087 0 my $i;
4088 0 my $lineNb = 0;
4089 0 my $semf;
4090 my $wordform;
4091 0 my $lang;
4092 0 my $terms = [];
4093  
4094 0 $self->getTimer->startsLap("making tagged sentences");
4095 0 warn "[LOG] printing Tagged Sentences\n";
4096  
4097 # warn "open " . $self->_input_filename . "(1)\n";
4098  
4099 # open FILEINPUT, ">:utf8", $self->_input_filename or die "No such file " . $self->_input_filename;
4100  
4101 # warn join('//', keys(%$fields)) . "\n";
4102  
4103 0 ▶ for ($i = 0; $i < scalar(@{$self->_documentSet}); $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < scalar @{$self->_documentSet;}) 0 0 0
4104 0 $self->getTimer->startsLapByCategory('document0');
4105 0 $document = $self->_documentSet->[$i];
4106  
4107 0 $self->_makeOneTaggedSentence($document, $fh, $sepInfo, $sepUnit, $sepSent, $sepSect, $sepTermComp, $fields);
4108
4109  
4110 0 $self->getTimer->endsLapByCategory('document0');
4111 }
4112 # close FILEINPUT;
4113 0 $self->getTimer->_printTimeByCategory(0);
4114 0 $self->getTimer->_printTimesBySteps;
4115 0 warn "[LOG] done\n";
4116 }
4117  
4118 0 ▶sub _makeTaggedSentencesRec {
Subroutine _makeTaggedSentencesRec: not called CC=4 SCAR=30.0
4119 0 my ($self, $sentences, $fh, $sepInfo, $sepUnit, $sepSent, $sepSect, $sepTermComp, $fields) = @_;
4120  
4121 0 ▶ if (!defined $fh) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $fh) 0 0 0
4122 0 $fh = *STDOUT;
4123 }
4124 # my $printDocId = shift;
4125 0 ▶ if (!defined $fields) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $fields) 0 0 0
4126 0 $fields = {"IF" => 1,
4127 "POSTAG" => 2,
4128 "LM" => 3,
4129 "ID" => 4,
4130 "DOCID" => 5,
4131 "SEMTAG" => 6,
4132 # "OFFSET" => 7,
4133 };
4134 }
4135 0 my $document;
4136 my $doc_idx;
4137 0 my $token;
4138 0 my $word;
4139 0 my $lemma;
4140 0 my $MS_features;
4141 0 my $SemUnit;
4142 0 my @corpus_in_t;
4143 0 my $canonical_form;
4144 0 my $taggedSentence;
4145 0 my $i;
4146 0 my $lineNb = 0;
4147 0 my $semf;
4148 my $wordform;
4149 0 my $lang;
4150 0 my $terms = [];
4151  
4152 0 $self->getTimer->startsLap("making tagged sentences");
4153 0 warn "[LOG] printing Tagged Sentences\n";
4154  
4155 # warn "open " . $self->_input_filename . "(1)\n";
4156  
4157 # open FILEINPUT, ">:utf8", $self->_input_filename or die "No such file " . $self->_input_filename;
4158  
4159 # warn join('//', keys(%$fields)) . "\n";
4160  
4161 0 ▶ for ($i = 0; $i < scalar(@{$self->_documentSet}); $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < scalar @{$self->_documentSet;}) 0 0 0
4162 0 $self->getTimer->startsLapByCategory('document0');
4163 0 $document = $self->_documentSet->[$i];
4164  
4165 0 $self->_makeOneTaggedSentenceRec($document, $fh, $sepInfo, $sepUnit, $sepSent, $sepSect, $sepTermComp, $fields);
4166
4167  
4168 0 $self->getTimer->endsLapByCategory('document0');
4169 }
4170 # close FILEINPUT;
4171 0 $self->getTimer->_printTimeByCategory(0);
4172 0 $self->getTimer->_printTimesBySteps;
4173 0 warn "[LOG] done\n";
4174 }
4175  
4176 0 ▶sub _makeOneTaggedSentenceRec {
Subroutine _makeOneTaggedSentenceRec: not called CC=8 SCAR=42.8
4177 0 my ($self, $document, $fh, $sepInfo, $sepUnit, $sepSent, $sepSect, $sepTermComp, $fields) = @_;
4178  
4179 # warn "in _makeOneTaggedSentence $sepInfo, $sepUnit\n";
4180  
4181 0 ▶ if (!defined $fh) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $fh) 0 0 0
4182 0 $fh = *STDOUT;
4183 }
4184 0 ▶ if (!defined $fields) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $fields) 0 0 0
4185 0 $fields = {"IF" => 1,
4186 "POSTAG" => 2,
4187 "LM" => 3,
4188 "ID" => 4,
4189 "DOCID" => 5,
4190 "SEMTAG" => 6,
4191 "OFFSET" => 7,
4192 };
4193 }
4194 0 my $doc_idx;
4195 my $token;
4196 0 my $word;
4197 0 my $lemma;
4198 0 my $MS_features;
4199 0 my $SemUnit;
4200 0 my $semForm;
4201 0 my @corpus_in_t;
4202 0 my $canonical_form;
4203 0 my $taggedSentence;
4204 0 my $id;
4205 0 my $lineNb = 0;
4206 0 my $semf;
4207 my $wordform;
4208 0 my $lang;
4209 0 my $terms = [];
4210 0 my $inSentence = 0;
4211 0 my $endSentToken;
4212  
4213 0 ▶ if (!defined $sepSect) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $sepSect) 0 0 0
4214 0 $sepSect = "";
4215 }
4216  
4217 0 $self->getTimer->startsLap("making tagged sentences");
4218 0 warn "[LOG] printing Tagged Sentences\n";
4219  
4220 0 $self->getTimer->startsLapByCategory('document');
4221 0 $id = $document->getId;
4222 0 $lang = $document->getAnnotations->getLanguage;
4223  
4224 0 $self->getTimer->startsLapByCategory('token');
4225  
4226 0 $token = $document->getAnnotations->getTokenLevel->getElements->[0];
4227  
4228 0 $self->getTimer->endsLapByCategory('token');
4229 0 ▶ while(defined $token) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $token) 0 0 0
4230 0 $self->getTimer->startsLapByCategory('token2');
4231 0 warn "\n";
4232 # warn "token: " . $token->getContent . " (" . $token->getId . ")\n";
4233 0 ▶ if ($document->getAnnotations->getSentenceLevel->existsElementFromIndex("refid_start_token", $token->getId)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($document->getAnnotations->getSentenceLevel->existsElementFromIndex("refid_start_token", $token->getId)) 0 0 0
4234 0 $inSentence = 1;
4235 # warn $document->getAnnotations->getSentenceLevel->getElementFromIndex("refid_start_token", $token->getId) . "\n";
4236 0 $endSentToken = $document->getAnnotations->getSentenceLevel->getElementFromIndex("refid_start_token", $token->getId)->[0]->end_token;
4237 0 @corpus_in_t = ();
4238 }
4239 0 $self->_makeTaggedTokenRec($document, $fh, $token, $inSentence, \@corpus_in_t, \$lineNb, $sepInfo, $sepUnit, $sepSent, $sepSect, $sepTermComp, $fields);
4240 # # to check $inSentence, @corpus_in_t, $lineNb
4241 # # to modify
4242 0 ▶ if ($inSentence) {
Branch: 1 branch
BranchTrueFalseTotal
if ($inSentence) 0 0 0
4243 0 $token = $endSentToken;
4244 0 $inSentence = 0;
4245 }
4246 0 ▶ if ($document->getAnnotations->getSectionLevel->existsElementFromIndex("to", $token->getId)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($document->getAnnotations->getSectionLevel->existsElementFromIndex("to", $token->getId)) 0 0 0
4247 0 print $fh $sepSect;
4248 }
4249 0 $token = $token->next;
4250 0 $self->getTimer->endsLapByCategory('token2');
4251 0 warn "-----\n";
4252 }
4253 0 $self->getTimer->endsLapByCategory('token');
4254  
4255 0 $self->getTimer->endsLapByCategory('document');
4256 0 $self->getTimer->_printTimeByCategory(0);
4257 0 $self->getTimer->_printTimesBySteps;
4258 0 warn "[LOG] done\n";
4259 }
4260  
4261 0 ▶sub _makeTaggedTokenRec {
Subroutine _makeTaggedTokenRec: not called CC=16 SCAR=56.1
4262 0 my ($self, $document, $fh, $curToken, $inSentence, $corpusInT, $lineNb, $sepInfo, $sepUnit, $sepSent, $sepSect, $sepTermComp, $fields) = @_;
4263 0 my $terms = [];
4264 0 my $token = $curToken;
4265 0 my $semForm;
4266 my $wordform;
4267 0 my @corpus_in_t; # = @$corpusInT;
4268 0 my $id;
4269 0 my $lang;
4270 # my $lineNb = $$lineNbRec;
4271 0 my $word;
4272 0 my $lemma;
4273 0 my $SemUnit;
4274 0 my $MS_features;
4275 0 my $canonical_form;
4276 0 my $semf;
4277
4278 0 $id = $document->getId;
4279 0 $lang = $document->getAnnotations->getLanguage;
4280 0 ▶ if (!defined $token) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $token) 0 0 0
4281 0 return;
4282 }
4283 # warn "token => " . $token->getContent . " ($inSentence)\n";
4284  
4285 # $terms = $document->getAnnotations->getSemanticUnitLevel->getElementByToken($token);
4286 0 $terms = $document->getAnnotations->getSemanticUnitLevel->getElementsByStartToken($token);
4287 0 ▶ if (scalar(@$terms) > 0) {
Branch: 2 branches
BranchTrueFalseTotal
if (scalar @$terms > 0) { } 0 0 0
elsif ($document->getAnnotations->getWordLevel->existsElementFromIndex('list_refid_token', $token->getId)) { } 0 0 0
4288 0 $self->getTimer->startsLapByCategory('semUnit');
4289  
4290 # $self->getTimer->startsLapByCategory('LargerSemUnit');
4291 # $SemUnit = $self->_getLargerTerm($terms);
4292 # $self->getTimer->endsLapByCategory('LargerSemUnit');
4293  
4294 0 foreach $SemUnit (@$terms) {
4295 # warn "SemUnit form: " . $SemUnit->getForm . "\n";
4296 0 @corpus_in_t = @$corpusInT;
4297  
4298 0 ▶ if ($SemUnit->isNamedEntity) {
Branch: 2 branches
BranchTrueFalseTotal
if ($SemUnit->isNamedEntity) { } 0 0 0
elsif ($SemUnit->isTerm) { } 0 0 0
4299 0 $semForm = $SemUnit->getForm;
4300 0 $canonical_form = $self->_getCanonicalForm($SemUnit, $document);
4301 0 ▶ if ($sepTermComp ne "") {
Branch: 1 branch
BranchTrueFalseTotal
if ($sepTermComp ne "") 0 0 0
4302 0 $semForm =~ s/ /$sepTermComp/g;
4303 0 $canonical_form =~ s/ /$sepTermComp/g;
4304 }
4305 0 $self->_addInfosUnit($lang, $lineNb, \@corpus_in_t, {"IF" => $semForm,
4306 "ID" => "S". $SemUnit->getId,
4307 "POSTAG" => "named_entity",
4308 "LM" => $canonical_form,
4309 "SEMTAG" => $SemUnit->NEtype,
4310 "DOCID" => $id,
4311 "OFFSET" => $SemUnit->start_token->getFrom,
4312 }, $fields);
4313 } elsif ($SemUnit->isTerm) {
4314 0 $semf = $document->getAnnotations->getSemanticFeaturesLevel->getElementFromIndex("refid_semantic_unit", $SemUnit->getId)->[0];
4315 0 ▶ if (defined $semf) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $semf) { } 0 0 0
4316 0 $semForm = $SemUnit->getForm;
4317 0 $canonical_form = $self->_getCanonicalForm($SemUnit, $document);
4318 0 ▶ if ($sepTermComp ne "") {
Branch: 1 branch
BranchTrueFalseTotal
if ($sepTermComp ne "") 0 0 0
4319 0 $semForm =~ s/ /$sepTermComp/g;
4320 0 $canonical_form =~ s/ /$sepTermComp/g;
4321 }
4322 0 $self->_addInfosUnit($lang, $lineNb, \@corpus_in_t, {"IF" => $semForm,
4323 "ID" => "S". $SemUnit->getId,
4324 "POSTAG" => "term",
4325 "LM" => $canonical_form,
4326 "SEMTAG" => $semf->first_node_first_semantic_category,
4327 "DOCID" => $id,
4328 "OFFSET" => $SemUnit->start_token->getFrom,
4329 }, $fields);
4330 } else {
4331 0 $semForm = $SemUnit->getForm;
4332 0 $canonical_form = $self->_getCanonicalForm($SemUnit, $document);
4333 0 ▶ if ($sepTermComp ne "") {
Branch: 1 branch
BranchTrueFalseTotal
if ($sepTermComp ne "") 0 0 0
4334 0 $semForm =~ s/ /$sepTermComp/g;
4335 0 $canonical_form =~ s/ /$sepTermComp/g;
4336 }
4337 0 $self->_addInfosUnit($lang, $lineNb, \@corpus_in_t, {"IF" => $semForm,
4338 "ID" => "S". $SemUnit->getId,
4339 "POSTAG" => "term",
4340 "LM" => $canonical_form,
4341 "SEMTAG" => "",
4342 "DOCID" => $id,
4343 "OFFSET" => $SemUnit->start_token->getFrom,
4344 }, $fields);
4345 }
4346 }
4347 0 $token = $SemUnit->end_token;
4348 0 $self->_endOfTaggedSentenceRec($document, $fh, $token, $inSentence, \@corpus_in_t, $lineNb, $sepInfo, $sepUnit, $sepSent, $sepSect, $sepTermComp, $fields);
4349 }
4350 0 $self->getTimer->endsLapByCategory('semUnit');
4351 } elsif ($document->getAnnotations->getWordLevel->existsElementFromIndex("list_refid_token", $token->getId)) {
4352 0 $self->getTimer->startsLapByCategory('word');
4353 0 @corpus_in_t = @$corpusInT;
4354 0 $word = $document->getAnnotations->getWordLevel->getElementFromIndex("list_refid_token", $token->getId)->[0];
4355 0 $lemma = $document->getAnnotations->getLemmaLevel->getElementFromIndex("refid_word", $word->getId)->[0];
4356 0 $MS_features = $document->getAnnotations->getMorphosyntacticFeaturesLevel->getElementFromIndex("refid_word", $word->getId)->[0];
4357 0 $wordform = $word->getForm;
4358 0 $wordform =~ s/[\t\n]/ /gos;
4359 0 $wordform =~ s/ +/ /gos;
4360  
4361 0 $self->_addInfosUnit($lang, $lineNb, \@corpus_in_t, {"IF" => $wordform,
4362 "ID" => "W". $word->getId,
4363 "POSTAG" => $MS_features->syntactic_category,
4364 "LM" => $lemma->canonical_form,
4365 "SEMTAG" => "",
4366 "DOCID" => $id,
4367 "OFFSET" => $word->start_token->getFrom,
4368 }, $fields);
4369  
4370 0 $token = $word->end_token;
4371 0 $self->getTimer->endsLapByCategory('word');
4372 0 $self->_endOfTaggedSentenceRec($document, $fh, $token, $inSentence, \@corpus_in_t, $lineNb, $sepInfo, $sepUnit, $sepSent, $sepSect, $sepTermComp, $fields);
4373 } else {
4374 0 $self->getTimer->startsLapByCategory('separator');
4375 0 @corpus_in_t = @$corpusInT;
4376 0 ▶ if ((!($token->isSep)) && (!($document->getAnnotations->getSentenceLevel->existsElementFromIndex("refid_end_token", $token->getId)))){
Branch: 2 branches
BranchTrueFalseTotal
if (not $token->isSep || $document->getAnnotations->getSentenceLevel->existsElementFromIndex('refid_end_token', $token->getId)) { } 0 0 0
elsif ($token->isSep and $inSentence and $sepUnit eq '') { } 0 0 0
Condition0%0/3
$token->isSep || $document->getAnnotations->getSentenceLevel->existsElementFromIndex('refid_end_token', $token->getId)
l!l&&r!l&&!r
000
MC/DC0%0/2
$token->isSep || $document->getAnnotations->getSentenceLevel->existsElementFromIndex('refid_end_token', $token->getId)
$token->isSep $document->getAnnotations->getSentenceLevel->existsElementFromIndex('refid_end_token', $token->getId)
Truth table0%0/3
A || B
A= $token->isSepB= $document->getAnnotations->getSentenceLevel->existsElementFromIndex('refid_end_token', $token->getId)
ABresult
1X1
011
000
4377 0 $self->_addInfosUnit($lang, $lineNb, \@corpus_in_t, {"IF" => $token->getContent,
4378 "ID" => "T". $token->getId,
4379 "POSTAG" => $token->getContent,
4380 "LM" => $token->getContent,
4381 "SEMTAG" => "",
4382 "DOCID" => $id,
4383 "OFFSET" => $token->getFrom,
4384 }, $fields);
4385 ▶ } elsif (($token->isSep) && ($inSentence) && ($sepUnit eq "")) {
Condition0%0/6
$token->isSep and $inSentence and $sepUnit eq ""
!ll&&!rl&&r
000
$token->isSep and $inSentence
!ll&&!rl&&r
000
MC/DC0%0/3
$token->isSep and $inSentence and $sepUnit eq ""
$token->isSep $inSentence $sepUnit eq ""
Truth table0%0/4
A and B and C
A= $token->isSepB= $inSentenceC= $sepUnit eq ""
ABCresult
0XX0
10X0
1100
1111
4386 0 $self->_addInfosUnit($lang, $lineNb, \@corpus_in_t, {"TYPE" => "SEP",
4387 "CONTENT" => $token->getContent,
4388 }, $fields);
4389 }
4390 0 $self->getTimer->endsLapByCategory('separator');
4391 0 $self->_endOfTaggedSentenceRec($document, $fh, $token, $inSentence, \@corpus_in_t, $lineNb, $sepInfo, $sepUnit, $sepSent, $sepSect, $sepTermComp, $fields);
4392 }
4393  
4394 }
4395  
4396  
4397 0 ▶sub _endOfTaggedSentenceRec {
Subroutine _endOfTaggedSentenceRec: not called CC=7 SCAR=40.3
4398 0 my ($self, $document, $fh, $curToken, $inSentence, $corpusInT, $lineNb, $sepInfo, $sepUnit, $sepSent, $sepSect, $sepTermComp, $fields) = @_;
4399  
4400 0 my $token = $curToken;
4401 0 my $semForm;
4402 my $wordform;
4403 0 my @corpus_in_t = @$corpusInT;
4404 0 my $id;
4405 my $lang;
4406 # my $lineNb = $$lineNbRec;
4407 0 my $word;
4408 0 my $lemma;
4409 0 my $SemUnit;
4410 0 my $MS_features;
4411 0 my $canonical_form;
4412 0 my $semf;
4413
4414 0 $id = $document->getId;
4415 0 $lang = $document->getAnnotations->getLanguage;
4416 0 ▶ if (!defined $token) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $token) 0 0 0
4417 0 return;
4418 }
4419 # warn "token => " . $token->getContent . " ($inSentence - end)\n";
4420  
4421 0 $self->getTimer->startsLapByCategory('end sentence');
4422 0 ▶ if ($document->getAnnotations->getSentenceLevel->existsElementFromIndex("refid_end_token", $token->getId)) {
Branch: 2 branches
BranchTrueFalseTotal
if ($document->getAnnotations->getSentenceLevel->existsElementFromIndex('refid_end_token', $token->getId)) { } 0 0 0
elsif ($inSentence) { } 0 0 0
4423 0 ▶ if ($token->isSymb) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token->isSymb) { } 0 0 0
4424 0 ▶ if (!($document->getAnnotations->getWordLevel->existsElementFromIndex("list_refid_token", $token->getId))) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $document->getAnnotations->getWordLevel->existsElementFromIndex('list_refid_token', $token->getId)) { } 0 0 0
4425 0 $self->_addInfosUnit($lang, $lineNb, \@corpus_in_t, {"IF" => $token->getContent,
4426 "ID" => "T" . $token->getId,
4427 "POSTAG" => "SENT",
4428 "LM" => $token->getContent,
4429 "SEMTAG" => "",
4430 "DOCID" => $id,
4431 "OFFSET" => $token->getFrom,
4432 }, $fields);
4433 # $self->_printTaggedSentence($fh, \@corpus_in_t, $sepInfo, $sepUnit, $sepSent, $fields);
4434 } else {
4435 0 $self->_addInfosUnit($lang, $lineNb, \@corpus_in_t, {"IF" => $token->getContent,
4436 "ID" => "T" . $token->getId,
4437 "POSTAG" => "SENT",
4438 "LM" => $token->getContent,
4439 "SEMTAG" => "",
4440 "DOCID" => $id,
4441 "OFFSET" => $token->getFrom,
4442 }, $fields);
4443 # $self->_printTaggedSentence($fh, \@corpus_in_t, $sepInfo, $sepUnit, $sepSent, $fields);
4444 }
4445 } else {
4446 0 $self->_addInfosUnit($lang, $lineNb, \@corpus_in_t, {"IF" => ".",
4447 "ID" => "T" . $token->getId,
4448 "POSTAG" => "SENT",
4449 "LM" => ".",
4450 "SEMTAG" => "",
4451 "DOCID" => $id,
4452 "OFFSET" => $token->getFrom,
4453 }, $fields);
4454 # $self->_printTaggedSentence($fh, \@corpus_in_t, $sepInfo, $sepUnit, $sepSent, $fields);
4455 }
4456 0 $self->_printTaggedSentence($fh, \@corpus_in_t, $sepInfo, $sepUnit, $sepSent, $fields);
4457 0 ▶ if ($document->getAnnotations->getSectionLevel->existsElementFromIndex("to", $token->getId)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($document->getAnnotations->getSectionLevel->existsElementFromIndex("to", $token->getId)) 0 0 0
4458 0 print $fh $sepSect;
4459 }
4460 0 @corpus_in_t = ();
4461 0 $inSentence = 0;
4462 0 $self->getTimer->endsLapByCategory('end sentence');
4463 } elsif ($inSentence) {
4464 0 $self->_makeTaggedTokenRec($document, $fh, $token->next, $inSentence, \@corpus_in_t, $lineNb, $sepInfo, $sepUnit, $sepSent, $sepSect, $sepTermComp, $fields);
4465 }
4466  
4467 }
4468  
4469 0 ▶sub _makeTaggedSentences2 {
Subroutine _makeTaggedSentences2: not called CC=17 SCAR=57.2
4470 0 my ($self, $sentences, $fh, $sepInfo, $sepUnit, $fields) = @_;
4471  
4472 0 ▶ if (!defined $fh) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $fh) 0 0 0
4473 0 $fh = *STDOUT;
4474 }
4475 # my $printDocId = shift;
4476 0 ▶ if (!defined $fields) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $fields) 0 0 0
4477 0 $fields = {"IF" => 1,
4478 "POSTAG" => 2,
4479 "LM" => 3,
4480 "ID" => 4,
4481 "DOCID" => 5,
4482 "SEMTAG" => 6,
4483 "OFFSET" => 7,
4484 };
4485 }
4486 0 my $document;
4487 my $doc_idx;
4488 0 my $token;
4489 0 my $word;
4490 0 my $lemma;
4491 0 my $MS_features;
4492 0 my $SemUnit;
4493 0 my @corpus_in_t;
4494 0 my $canonical_form;
4495 0 my $taggedSentence;
4496 0 my $i;
4497 0 my $lineNb = 0;
4498 0 my $semf;
4499 my $wordform;
4500 0 my $lang;
4501 0 my $terms = [];
4502  
4503 0 $self->getTimer->startsLap("making tagged sentences");
4504 0 warn "[LOG] printing Tagged Sentences\n";
4505  
4506 # warn "open " . $self->_input_filename . "(1)\n";
4507  
4508 # open FILEINPUT, ">:utf8", $self->_input_filename or die "No such file " . $self->_input_filename;
4509  
4510 0 ▶ for ($i = 0; $i < scalar(@{$self->_documentSet}); $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < scalar @{$self->_documentSet;}) 0 0 0
4511 0 $self->getTimer->startsLapByCategory('document');
4512  
4513 0 $document = $self->_documentSet->[$i];
4514 0 $lang = $document->getAnnotations->getLanguage;
4515  
4516 0 $self->getTimer->startsLapByCategory('token');
4517  
4518 0 $token = $document->getAnnotations->getTokenLevel->getElements->[0];
4519  
4520 0 $self->getTimer->endsLapByCategory('token');
4521 0 ▶ while(defined ($token)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $token) 0 0 0
4522 0 $self->getTimer->startsLapByCategory('token2');
4523 0 ▶ if ((exists $fields->{"SEMTAG"}) && ($fields->{"SEMTAG"} > 0)) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $fields->{'SEMTAG'} and $fields->{'SEMTAG'} > 0) { } 0 0 0
Condition0%0/3
exists $fields->{"SEMTAG"} and $fields->{"SEMTAG"} > 0
!ll&&!rl&&r
000
MC/DC0%0/2
exists $fields->{"SEMTAG"} and $fields->{"SEMTAG"} > 0
exists $fields->{"SEMTAG"} $fields->{"SEMTAG"} > 0
Truth table0%0/3
A and B
A= exists $fields->{"SEMTAG"}B= $fields->{"SEMTAG"} > 0
ABresult
0X0
100
111
4524 0 $terms = $document->getAnnotations->getSemanticUnitLevel->getElementByToken($token);
4525 } else {
4526 0 $terms = [];
4527 }
4528  
4529 0 ▶ if (scalar(@$terms) > 0) {
Branch: 2 branches
BranchTrueFalseTotal
if (scalar @$terms > 0) { } 0 0 0
elsif ($document->getAnnotations->getWordLevel->existsElementFromIndex('list_refid_token', $token->getId)) { } 0 0 0
4530 0 $self->getTimer->startsLapByCategory('semUnit');
4531  
4532 0 $self->getTimer->startsLapByCategory('LargerSemUnit');
4533 0 $SemUnit = $self->_getLargerTerm($terms);
4534 0 $self->getTimer->endsLapByCategory('LargerSemUnit');
4535  
4536 # warn "OK\n";
4537 0 ▶ if ($SemUnit->isNamedEntity) {
Branch: 2 branches
BranchTrueFalseTotal
if ($SemUnit->isNamedEntity) { } 0 0 0
elsif ($SemUnit->isTerm) { } 0 0 0
4538 0 $canonical_form = $self->_getCanonicalForm($SemUnit, $document);
4539 # if (!defined $SemUnit->canonical_form) {
4540 # $canonical_form = "";
4541 # } else {
4542 # $canonical_form = $SemUnit->canonical_form;
4543 # }
4544 # warn "OK1";
4545 0 $self->_addInfosUnit($lang, \$lineNb, \@corpus_in_t, {"IF" => $SemUnit->getForm,
4546 "ID" => $SemUnit->getId,
4547 "POSTAG" => "named_entity",
4548 "LM" => $canonical_form,
4549 "SEMTAG" => $SemUnit->NEtype,
4550 "DOCID" => $i,
4551 "OFFSET" => $SemUnit->start_token->getFrom,
4552 }, $fields);
4553
4554 } elsif ($SemUnit->isTerm) {
4555 0 $semf = $document->getAnnotations->getSemanticFeaturesLevel->getElementFromIndex("refid_semantic_unit", $SemUnit->getId)->[0];
4556 # warn "OK2";
4557 0 ▶ if (defined $semf) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $semf) { } 0 0 0
4558 # warn "OK2b";
4559 0 $canonical_form = $self->_getCanonicalForm($SemUnit, $document);
4560 # if (!defined $SemUnit->canonical_form) {
4561 # $canonical_form = "";
4562 # } else {
4563 # $canonical_form = $SemUnit->canonical_form;
4564 # }
4565 0 $self->_addInfosUnit($lang, \$lineNb, \@corpus_in_t, {"IF" => $SemUnit->getForm,
4566 "ID" => $SemUnit->getId,
4567 "POSTAG" => "term",
4568 "LM" => $canonical_form,
4569 "SEMTAG" => $semf->first_node_first_semantic_category,
4570 "DOCID" => $i,
4571 "OFFSET" => $SemUnit->start_token->getFrom,
4572 }, $fields);
4573 } else {
4574 # warn "OK2c";
4575 0 $canonical_form = $self->_getCanonicalForm($SemUnit, $document);
4576 # if (!defined $SemUnit->canonical_form) {
4577 # $canonical_form = "";
4578 # } else {
4579 # $canonical_form = $SemUnit->canonical_form;
4580 # }
4581 # warn "OK\n";
4582 0 $self->_addInfosUnit($lang, \$lineNb, \@corpus_in_t, {"IF" => $SemUnit->getForm,
4583 "ID" => $SemUnit->getId,
4584 "POSTAG" => "term",
4585 "LM" => $canonical_form,
4586 "SEMTAG" => "",
4587 "DOCID" => $i,
4588 "OFFSET" => $SemUnit->start_token->getFrom,
4589 }, $fields);
4590 }
4591 }
4592 0 $token = $SemUnit->end_token;
4593 0 $self->getTimer->endsLapByCategory('semUnit');
4594 } elsif ($document->getAnnotations->getWordLevel->existsElementFromIndex("list_refid_token", $token->getId)) {
4595 0 $self->getTimer->startsLapByCategory('word');
4596 0 $word = $document->getAnnotations->getWordLevel->getElementFromIndex("list_refid_token", $token->getId)->[0];
4597 0 $lemma = $document->getAnnotations->getLemmaLevel->getElementFromIndex("refid_word", $word->getId)->[0];
4598 0 $MS_features = $document->getAnnotations->getMorphosyntacticFeaturesLevel->getElementFromIndex("refid_word", $word->getId)->[0];
4599 0 $wordform = $word->getForm;
4600 0 $wordform =~ s/[\t\n]/ /gos;
4601 0 $wordform =~ s/ +/ /gos;
4602
4603 0 $self->_addInfosUnit($lang, \$lineNb, \@corpus_in_t, {"IF" => $wordform,
4604 "ID" => $word->getId,
4605 "POSTAG" => $MS_features->syntactic_category,
4606 "LM" => $lemma->canonical_form,
4607 "SEMTAG" => "",
4608 "DOCID" => $i,
4609 "OFFSET" => $word->start_token->getFrom,
4610 }, $fields);
4611  
4612 0 $token = $word->end_token;
4613
4614 0 $self->getTimer->endsLapByCategory('word');
4615 } else {
4616 0 $self->getTimer->startsLapByCategory('separator');
4617 0 ▶ if ((!($token->isSep)) && (!($document->getAnnotations->getSentenceLevel->existsElementFromIndex("refid_end_token", $token->getId)))){
Branch: 1 branch
BranchTrueFalseTotal
unless ($token->isSep or $document->getAnnotations->getSentenceLevel->existsElementFromIndex("refid_end_token", $token->getId)) 0 0 0
Condition0%0/3
$token->isSep or $document->getAnnotations->getSentenceLevel->existsElementFromIndex("refid_end_token", $token->getId)
l!l&&r!l&&!r
000
MC/DC0%0/2
$token->isSep or $document->getAnnotations->getSentenceLevel->existsElementFromIndex("refid_end_token", $token->getId)
$token->isSep $document->getAnnotations->getSentenceLevel->existsElementFromIndex("refid_end_token", $token->getId)
Truth table0%0/3
A or B
A= $token->isSepB= $document->getAnnotations->getSentenceLevel->existsElementFromIndex("refid_end_token", $token->getId)
ABresult
1X1
011
000
4618 0 $self->_addInfosUnit($lang, \$lineNb, \@corpus_in_t, {"IF" => $token->getContent,
4619 "ID" => $token->getId,
4620 "POSTAG" => $token->getContent,
4621 "LM" => $token->getContent,
4622 "SEMTAG" => "",
4623 "DOCID" => $i,
4624 "OFFSET" => $token->getFrom,
4625 }, $fields);
4626 }
4627 0 $self->getTimer->endsLapByCategory('separator');
4628 }
4629 0 $self->getTimer->startsLapByCategory('end sentence');
4630 0 ▶ if ($document->getAnnotations->getSentenceLevel->existsElementFromIndex("refid_end_token", $token->getId)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($document->getAnnotations->getSentenceLevel->existsElementFromIndex("refid_end_token", $token->getId)) 0 0 0
4631 0 ▶ if ($token->isSymb) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token->isSymb) { } 0 0 0
4632 0 ▶ if (!($document->getAnnotations->getWordLevel->existsElementFromIndex("list_refid_token", $token->getId))) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $document->getAnnotations->getWordLevel->existsElementFromIndex('list_refid_token', $token->getId)) { } 0 0 0
4633 0 $self->_addInfosUnit($lang, \$lineNb, \@corpus_in_t, {"IF" => $token->getContent,
4634 "ID" => $token->getId,
4635 "POSTAG" => "SENT",
4636 "LM" => $token->getContent,
4637 "SEMTAG" => "",
4638 "DOCID" => $i,
4639 "OFFSET" => $token->getFrom,
4640 }, $fields);
4641 0 $self->_printTaggedSentence($fh, \@corpus_in_t, $sepInfo, $sepUnit);
4642 0 @corpus_in_t = ();
4643 } else {
4644 0 $self->_addInfosUnit($lang, \$lineNb, \@corpus_in_t, {"IF" => $token->getContent,
4645 "ID" => $token->getId,
4646 "POSTAG" => "SENT",
4647 "LM" => $token->getContent,
4648 "SEMTAG" => "",
4649 "DOCID" => $i,
4650 "OFFSET" => $token->getFrom,
4651 }, $fields);
4652 0 $self->_printTaggedSentence($fh, \@corpus_in_t, $sepInfo, $sepUnit);
4653 0 @corpus_in_t = ();
4654 }
4655 } else {
4656 # my @tmp = (".", $token->getId, "SENT", ".");
4657 # push @corpus_in_t, \@tmp;
4658 0 $self->_addInfosUnit($lang, \$lineNb, \@corpus_in_t, {"IF" => ".",
4659 "ID" => $token->getId,
4660 "POSTAG" => "SENT",
4661 "LM" => ".",
4662 "SEMTAG" => "",
4663 "DOCID" => $i,
4664 "OFFSET" => $token->getFrom,
4665 }, $fields);
4666 0 $self->_printTaggedSentence($fh, \@corpus_in_t, $sepInfo, $sepUnit);
4667 0 @corpus_in_t = ();
4668 }
4669 0 $self->getTimer->endsLapByCategory('end sentence');
4670 }
4671 0 $token = $token->next;
4672 0 $self->getTimer->endsLapByCategory('token2');
4673 }
4674 0 $self->getTimer->endsLapByCategory('token');
4675  
4676 0 $self->getTimer->endsLapByCategory('document');
4677 }
4678 # close FILEINPUT;
4679 0 $self->getTimer->_printTimeByCategory(0);
4680 0 $self->getTimer->_printTimesBySteps;
4681 0 warn "[LOG] done\n";
4682 }
4683  
4684  
4685  
4686 0 ▶sub _addInfosUnit {
Subroutine _addInfosUnit: not called CC=8 SCAR=42.8
4687 0 my ($self, $lang, $lineNb, $corpus, $infoUnit, $fields) = @_;
4688  
4689 0 $self->getTimer->startsLapByCategory('infoUnit');
4690 0 my $field;
4691 my @tabinfos;
4692  
4693 # warn join('//', keys(%$fields)) . "\n";
4694  
4695 0 $$lineNb++;
4696  
4697 0 ▶ if (exists $infoUnit->{'TYPE'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $infoUnit->{'TYPE'}) { } 0 0 0
4698 0 push @tabinfos, $infoUnit->{'CONTENT'}
4699 } else {
4700 0 foreach $field (sort {$fields->{$a} <=> $fields->{$b}} keys %$fields) {
4701 # warn ">>$field\n";
4702 0 ▶ if (($fields->{$field} > 0) && (exists $infoUnit->{$field})) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fields->{$field} > 0 and exists $infoUnit->{$field}) 0 0 0
Condition0%0/3
$fields->{$field} > 0 and exists $infoUnit->{$field}
!ll&&!rl&&r
000
MC/DC0%0/2
$fields->{$field} > 0 and exists $infoUnit->{$field}
$fields->{$field} > 0 exists $infoUnit->{$field}
Truth table0%0/3
A and B
A= $fields->{$field} > 0B= exists $infoUnit->{$field}
ABresult
0X0
100
111
4703 0 ▶ if (ref($infoUnit->{$field}) eq "ARRAY") {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $infoUnit->{$field} eq 'ARRAY') { } 0 0 0
4704 0 push @tabinfos, @{$infoUnit->{$field}};
4705 } else {
4706 # $self->_deft2arff($self->_arff2deft(
4707 0 ▶ if ((defined $self->{"JoinComplexTerm"}->{$lang}) && ($self->{"JoinComplexTerm"}->{$lang} == 1)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{'JoinComplexTerm'}{$lang} and $self->{'JoinComplexTerm'}{$lang} == 1) { } 0 0 0
Condition0%0/3
defined $self->{"JoinComplexTerm"}{$lang} and $self->{"JoinComplexTerm"}{$lang} == 1
!ll&&!rl&&r
000
MC/DC0%0/2
defined $self->{"JoinComplexTerm"}{$lang} and $self->{"JoinComplexTerm"}{$lang} == 1
defined $self->{"JoinComplexTerm"}{$lang} $self->{"JoinComplexTerm"}{$lang} == 1
Truth table0%0/3
A and B
A= defined $self->{"JoinComplexTerm"}{$lang}B= $self->{"JoinComplexTerm"}{$lang} == 1
ABresult
0X0
100
111
4708 0 push @tabinfos, $self->_deft2arff($infoUnit->{$field});
4709 } else {
4710 # warn "\t>> " . $infoUnit->{$field} . "\n";
4711 0 push @tabinfos, $infoUnit->{$field};
4712 }
4713 }
4714 }
4715 }
4716 }
4717 0 push @{$corpus}, \@tabinfos;
4718  
4719 0 $self->getTimer->endsLapByCategory('infoUnit');
4720 }
4721  
4722  
4723 0 ▶sub _printTaggedSentence {
Subroutine _printTaggedSentence: not called CC=11 SCAR=48.8
4724 0 my ($self, $fh, $corpus_in_t, $sepInfo, $sepUnit, $sepSent, $fields) = @_;
4725 0 my $encoding = "no";
4726 0 my $print = 0;
4727 # warn "in _printTaggedSentence $sepInfo, $sepUnit\n";
4728  
4729 0 ▶ if (!defined $sepSent) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $sepSent) 0 0 0
4730 0 $sepSent = "\n";
4731 }
4732  
4733 0 $self->getTimer->startsLapByCategory('print Tagged Sentence');
4734 0 my $taggedSentence = "";
4735 0 my $word_ref;
4736 0 foreach $word_ref (@$corpus_in_t) {
4737
4738 0 ▶ if ((!defined $encoding) || (uc($encoding) eq "UTF-8")) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $encoding or uc $encoding eq 'UTF-8') { } 0 0 0
Condition0%0/3
not defined $encoding or uc $encoding eq "UTF-8"
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $encoding or uc $encoding eq "UTF-8"
not defined $encoding uc $encoding eq "UTF-8"
Truth table0%0/3
not(A) or B
A= not defined $encodingB= uc $encoding eq "UTF-8"
ABresult
1X1
011
000
4739 0 $print = 0;
4740 0 $taggedSentence .= Encode::encode("UTF-8", join($sepInfo, @$word_ref)); # . "\n";
4741 } else {
4742 0 $print = 0;
4743 0 ▶ if ((defined $encoding) && (uc($encoding) eq "LATIN1")) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $encoding and uc $encoding eq 'LATIN1') { } 0 0 0
Condition0%0/3
defined $encoding and uc $encoding eq "LATIN1"
!ll&&!rl&&r
000
MC/DC0%0/2
defined $encoding and uc $encoding eq "LATIN1"
defined $encoding uc $encoding eq "LATIN1"
Truth table0%0/3
A and B
A= defined $encodingB= uc $encoding eq "LATIN1"
ABresult
0X0
100
111
4744 0 $taggedSentence .= Encode::encode("iso-8859-1", join($sepInfo, @$word_ref)); # . "\n";
4745 } else {
4746 # warn "[WRAPPER LOG] Unknown enconding charset\n";
4747 0 $taggedSentence .= join($sepInfo, @$word_ref); # . "\n";
4748 }
4749 }
4750 0 ▶ if (scalar(keys %$fields) > 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar keys %$fields > 1) 0 0 0
4751 0 $taggedSentence .= $sepInfo;
4752 }
4753 0 ▶ if ((defined $word_ref->[1]) && ($word_ref->[1] eq "SENT")) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $word_ref->[1] and $word_ref->[1] eq 'SENT') { } 0 0 0
Condition0%0/3
defined $word_ref->[1] and $word_ref->[1] eq "SENT"
!ll&&!rl&&r
000
MC/DC0%0/2
defined $word_ref->[1] and $word_ref->[1] eq "SENT"
defined $word_ref->[1] $word_ref->[1] eq "SENT"
Truth table0%0/3
A and B
A= defined $word_ref->[1]B= $word_ref->[1] eq "SENT"
ABresult
0X0
100
111
4754 0 print $fh "$taggedSentence$sepUnit$sepSent";
4755 0 $print = 1;
4756 0 $taggedSentence = "";
4757 } else {
4758 0 $taggedSentence .= $sepUnit;
4759 }
4760 }
4761 0 ▶ if (!$print) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($print) 0 0 0
4762 0 print $fh "$taggedSentence$sepUnit";
4763 }
4764 0 $self->getTimer->endsLapByCategory('print Tagged Sentence');
4765 }
4766  
4767 0 ▶sub addResourceSemRel {
Subroutine addResourceSemRel: not called CC=18 SCAR=58.3
Pod undocumented
4768 0 my ($self, $lang, $lang2, $type) = @_;
4769  
4770 0 my $terminologyFilename;
4771 my $DistribThesaurusFilename;
4772 0 my $exceptionFilename;
4773  
4774 0 $self->{"Resources"}->{$lang2}->{$type} = [];
4775  
4776 # warn "==> $self / $lang / type\n";
4777 # warn $self->_config->configuration->{'RESOURCE'}->{$lang}->{$type} . "\n";
4778 0 ▶ if ($type eq "DISTRIBTHESAURUS") {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "DISTRIBTHESAURUS") 0 0 0
4779 0 ▶ if (ref($self->_config->configuration->{'RESOURCE'}->{$lang}->{$type}) eq "ARRAY") {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $self->_config->configuration->{'RESOURCE'}{$lang}{$type} eq 'ARRAY') { } 0 0 0
4780 0 foreach $DistribThesaurusFilename (@{$self->_config->configuration->{'RESOURCE'}->{$lang}->{$type}}) {
4781 0 warn "Adding (1) " . $DistribThesaurusFilename . "\n";
4782 0 my %DistThesaurus;
4783 my %DistThesaurusIdx;
4784 0 push @{$self->{"Resources"}->{$lang2}->{$type}}, {'filename' => $DistribThesaurusFilename,
4785 'type' => $type,
4786 'thesaurus' => \%DistThesaurus,
4787 'thesaurusIdx' => \%DistThesaurusIdx,
4788 };
4789 0 $self->_loadThesaurus($DistribThesaurusFilename, \%DistThesaurus, \%DistThesaurusIdx);
4790 }
4791 } else {
4792 0 $DistribThesaurusFilename = $self->_config->configuration->{'RESOURCE'}->{$lang}->{$type};
4793 0 warn "Adding (2) " . $DistribThesaurusFilename . "\n";
4794 0 my %DistThesaurus;
4795 my %DistThesaurusIdx;
4796 0 push @{$self->{"Resources"}->{$lang2}->{$type}}, {'filename' => $DistribThesaurusFilename,
4797 'type' => $type,
4798 'thesaurus' => \%DistThesaurus,
4799 'thesaurusIdx' => \%DistThesaurusIdx,
4800 };
4801 0 $self->_loadThesaurus($DistribThesaurusFilename, \%DistThesaurus, \%DistThesaurusIdx);
4802 }
4803 # $self->loadResource($lang, $name, $type);
4804 }
4805  
4806 0 ▶ if ($type eq "EXCEPTIONLIST") {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "EXCEPTIONLIST") 0 0 0
4807 0 ▶ if (ref($self->_config->configuration->{'RESOURCE'}->{$lang}->{$type}) eq "ARRAY") {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $self->_config->configuration->{'RESOURCE'}{$lang}{$type} eq 'ARRAY') { } 0 0 0
4808 0 foreach $exceptionFilename (@{$self->_config->configuration->{'RESOURCE'}->{$lang}->{$type}}) {
4809 0 $self->_loadException($exceptionFilename, $lang2, 'exceptions');
4810 }
4811 } else {
4812 0 $self->_loadException($self->_config->configuration->{'RESOURCE'}->{$lang}->{$type}, $lang2, 'exceptions');
4813 }
4814 }
4815  
4816 0 ▶ if ($type eq "TERMINOLOGY") {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "TERMINOLOGY") 0 0 0
4817 0 ▶ if (ref($self->_config->configuration->{'RESOURCE'}->{$lang}->{$type}) eq "ARRAY") {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $self->_config->configuration->{'RESOURCE'}{$lang}{$type} eq 'ARRAY') { } 0 0 0
4818 0 foreach $terminologyFilename (@{$self->_config->configuration->{'RESOURCE'}->{$lang}->{$type}}) {
4819 0 warn "Adding (1) " . $terminologyFilename . "\n";
4820 0 my %Terminology;
4821 my %TerminologyIdx;
4822 0 push @{$self->{"Resources"}->{$lang2}->{$type}}, {'filename' => $terminologyFilename,
4823 'type' => $type,
4824 'terminology' => \%Terminology,
4825 'terminologyIdx' => \%TerminologyIdx,
4826 };
4827 0 $self->_loadTerminology($terminologyFilename, \%Terminology, \%TerminologyIdx);
4828 }
4829 } else {
4830 0 $terminologyFilename = $self->_config->configuration->{'RESOURCE'}->{$lang}->{$type};
4831 0 warn "Adding (2) " . $terminologyFilename . "\n";
4832 0 my %Terminology;
4833 my %TerminologyIdx;
4834 0 push @{$self->{"Resources"}->{$lang2}->{$type}}, {'filename' => $terminologyFilename,
4835 'type' => $type,
4836 'terminology' => \%Terminology,
4837 'terminologyIdx' => \%TerminologyIdx,
4838 };
4839 0 $self->_loadTerminology($terminologyFilename, \%Terminology, \%TerminologyIdx);
4840 }
4841 }
4842  
4843 0 ▶ if ($type eq "SYNONYMY") {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "SYNONYMY") 0 0 0
4844 0 ▶ if (ref($self->_config->configuration->{'RESOURCE'}->{$lang}->{$type}) eq "ARRAY") {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $self->_config->configuration->{'RESOURCE'}{$lang}{$type} eq 'ARRAY') { } 0 0 0
4845 0 foreach $terminologyFilename (@{$self->_config->configuration->{'RESOURCE'}->{$lang}->{$type}}) {
4846 0 warn "Adding (1) " . $terminologyFilename . "\n";
4847 0 my %Terminology;
4848 0 push @{$self->{"Resources"}->{$lang2}->{$type}}, {'filename' => $terminologyFilename,
4849 'type' => $type,
4850 'synonymy' => \%Terminology,
4851 # 'synonymyIdx' => \%TerminologyIdx,
4852 };
4853 0 $self->_loadSynonymy($terminologyFilename, \%Terminology);
4854 }
4855 } else {
4856 0 $terminologyFilename = $self->_config->configuration->{'RESOURCE'}->{$lang}->{$type};
4857 0 warn "Adding (2) " . $terminologyFilename . "\n";
4858 0 my %Terminology;
4859 0 push @{$self->{"Resources"}->{$lang2}->{$type}}, {'filename' => $terminologyFilename,
4860 'type' => $type,
4861 'synonymy' => \%Terminology,
4862 # 'synonymyIdx' => \%TerminologyIdx,
4863 };
4864 0 $self->_loadSynonymy($terminologyFilename, \%Terminology);
4865 }
4866  
4867 }
4868 0 ▶ if ($type eq "VDLMDIR") {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "VDLMDIR") 0 0 0
4869 0 my $vdlmDir = $self->_config->configuration->{'RESOURCE'}->{$lang}->{$type};
4870 0 warn "Adding (2) " . $vdlmDir . "\n";
4871 0 my %DistThesaurus;
4872 my %DistThesaurusIdx;
4873 0 push @{$self->{"Resources"}->{$lang2}->{$type}}, {'filename' => $vdlmDir,
4874 'type' => $type,
4875 'thesaurus' => \%DistThesaurus,
4876 'thesaurusIdx' => \%DistThesaurusIdx,
4877 };
4878 0 $self->_loadVDLM($vdlmDir, \%DistThesaurus, \%DistThesaurusIdx);
4879 }
4880 0 ▶ if ($type eq "VDWDIR") {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "VDWDIR") 0 0 0
4881 0 my $vdwDir = $self->_config->configuration->{'RESOURCE'}->{$lang}->{$type};
4882 0 warn "Adding (2) " . $vdwDir . "\n";
4883 0 my %DistThesaurus;
4884 my %DistThesaurusIdx;
4885 0 push @{$self->{"Resources"}->{$lang2}->{$type}}, {'filename' => $vdwDir,
4886 'type' => $type,
4887 'thesaurus' => \%DistThesaurus,
4888 'thesaurusIdx' => \%DistThesaurusIdx,
4889 };
4890 0 $self->_loadVDLM($vdwDir, \%DistThesaurus, \%DistThesaurusIdx);
4891 }
4892 0 ▶ if ($type eq "SEMANTIC_RELATIONS_WITH_TYPE") {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "SEMANTIC_RELATIONS_WITH_TYPE") 0 0 0
4893 0 ▶ if (ref($self->_config->configuration->{'RESOURCE'}->{$lang}->{$type}) eq "ARRAY") {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $self->_config->configuration->{'RESOURCE'}{$lang}{$type} eq 'ARRAY') { } 0 0 0
4894 0 foreach $terminologyFilename (@{$self->_config->configuration->{'RESOURCE'}->{$lang}->{$type}}) {
4895 0 warn "Adding (1) " . $terminologyFilename . "\n";
4896 0 my %Terminology;
4897 my %TerminologyIdx;
4898 0 push @{$self->{"Resources"}->{$lang2}->{$type}}, {'filename' => $terminologyFilename,
4899 'type' => $type,
4900 'thesaurus' => \%Terminology,
4901 'thesaurusIdx' => \%TerminologyIdx,
4902 };
4903 0 $self->_loadSemanticRelationsWithType($terminologyFilename, \%Terminology, \%TerminologyIdx);
4904 }
4905 } else {
4906 0 $terminologyFilename = $self->_config->configuration->{'RESOURCE'}->{$lang}->{$type};
4907 0 warn "Adding (2) " . $terminologyFilename . "\n";
4908 0 my %Terminology;
4909 my %TerminologyIdx;
4910 0 push @{$self->{"Resources"}->{$lang2}->{$type}}, {'filename' => $terminologyFilename,
4911 'type' => $type,
4912 'thesaurus' => \%Terminology,
4913 'thesaurusIdx' => \%TerminologyIdx,
4914 };
4915 0 $self->_loadSemanticRelationsWithType($terminologyFilename, \%Terminology, \%TerminologyIdx);
4916 }
4917 }
4918 0 warn "Done\n";
4919 }
4920  
4921  
4922  
4923 0 ▶sub _loadVDLM {
Subroutine _loadVDLM: not called CC=5 SCAR=34.0
4924 0 my ($self, $vdlmDir, $DistThesaurus, $DistThesaurusIdx) = @_;
4925  
4926 0 my @wordsInfos;
4927 my $wordInfo;
4928 0 my $word;
4929 0 my $dist;
4930 0 my $wordDist;
4931  
4932 0 my $line;
4933 0 my %lemmaSet;
4934  
4935 0 my $postag;
4936 0 my $id;
4937 0 my $lemma;
4938 0 my $rel;
4939 0 my $n;
4940 0 my $freq;
4941 0 my $nbNeighbour;
4942 0 my $nbcl;
4943 0 my $lid1;
4944 0 my $lid2;
4945 0 my $n1;
4946 0 my $n2;
4947 0 my $jacc;
4948 0 my $lin;
4949 0 my $j1;
4950 0 my $j2;
4951  
4952 0 warn "Load lemma ($vdlmDir/upery-lemme.txt)\n";
4953 0 ▶ open LEMMA, $vdlmDir . "/upery-lemme.txt" or die "no such file $vdlmDir/upery-lemme.txt\n";
Branch: 1 branch
BranchTrueFalseTotal
open LEMMA, $vdlmDir . '/upery-lemme.txt' or die "no such file $vdlmDir/upery-lemme.txt\n" 0 0 0
4954 0 $line = <LEMMA>;
4955 0 ▶ while($line = <LEMMA>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($line = readline LEMMA)) 0 0 0
4956 0 chomp $line;
4957 0 ($id, $postag, $lemma, $rel, $n, $freq, $nbNeighbour, $nbcl) = split /\t/, $line;
4958  
4959 0 $lemmaSet{$id} = {'lemma' => $lemma,
4960 'postag' => $postag,
4961 'freq' => $freq,
4962 };
4963 }
4964 0 close LEMMA;
4965  
4966 0 warn "load Prox ($vdlmDir/upery-prox.txt)\n";
4967  
4968 0 ▶ open PROX, $vdlmDir . "/upery-prox.txt" or die "no such file $vdlmDir/upery-prox.txt\n";
Branch: 1 branch
BranchTrueFalseTotal
open PROX, $vdlmDir . '/upery-prox.txt' or die "no such file $vdlmDir/upery-prox.txt\n" 0 0 0
4969 0 $line = <PROX>;
4970 0 ▶ while($line = <PROX>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($line = readline PROX)) 0 0 0
4971 0 chomp $line;
4972  
4973 0 ($lid1, $lid2, $n1, $n2, $a, $jacc, $lin, $j1, $j2) = split /\t/, $line;
4974  
4975 0 $dist = $jacc;
4976 0 @wordsInfos = ();
4977 0 push @wordsInfos, [$lemmaSet{$lid2}->{'lemma'}, $lemmaSet{$lid2}->{'postag'}, $dist];
4978  
4979 0 $self->_addWord2Thesaurus($lemmaSet{$lid1}->{'lemma'}, $lemmaSet{$lid1}->{'postag'}, $lemmaSet{$lid1}->{'postag'} . "|" . $lemmaSet{$lid1}->{'lemma'}, $DistThesaurus, $DistThesaurusIdx, \@wordsInfos);
4980  
4981 }
4982 0 close PROX;
4983 }
4984  
4985 0 ▶sub _addWord2Thesaurus {
Subroutine _addWord2Thesaurus: not called CC=4 SCAR=30.0
4986 0 my ($self, $word, $postag, $wordInfo, $DistThesaurus, $DistThesaurusIdx, $wordsInfos) = @_;
4987  
4988 0 my $wordInfoElt;
4989  
4990 # warn "add $wordInfo ($word)\n";
4991  
4992 0 ▶ if (!exists $DistThesaurusIdx->{$word}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $DistThesaurusIdx->{$word}) 0 0 0
4993 0 $DistThesaurusIdx->{$word} = [];
4994 }
4995 0 push @{$DistThesaurusIdx->{$word}}, $wordInfo;
4996  
4997 0 ▶ if (!exists $DistThesaurus->{$wordInfo}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $DistThesaurus->{$wordInfo}) 0 0 0
4998 0 $DistThesaurus->{$wordInfo} = { 'word' => $word,
4999 'postag' => $postag,
5000 'neighbour' => [],
5001 };
5002 }
5003
5004 0 foreach $wordInfoElt (@$wordsInfos) {
5005 0 push @{$DistThesaurus->{$wordInfo}->{'neighbour'}}, {'word' => $wordInfoElt->[0],
5006 'postag' => $wordInfoElt->[1],
5007 'dist' => $wordInfoElt->[2],
5008 'type' => $wordInfoElt->[3],
5009 'measure_name' => $wordInfoElt->[4],
5010 }
5011 }
5012 }
5013  
5014 0 ▶sub _loadSemanticRelationsWithType {
Subroutine _loadSemanticRelationsWithType: not called CC=10 SCAR=47.0
5015 0 my ($self, $semanticRelationsFilename, $semanticRelations, $semanticRelationsIdx) = @_;
5016  
5017 0 my $line;
5018 my $T1IF;
5019 0 my $T2IF;
5020 0 my $T1LM;
5021 0 my $T2LM;
5022 0 my $postag;
5023 0 my $postag2;
5024 0 my $type;
5025 0 my $weight;
5026 0 my $measure_name;
5027 0 my @infos;
5028 0 my @wordsInfos2;
5029 0 my $i;
5030 0 my $j;
5031  
5032 # warn "open $semanticRelationsFilename\n";
5033 0 ▶ open SEMREL, "<:utf8", $semanticRelationsFilename or die "no such file $semanticRelationsFilename\n";
Branch: 1 branch
BranchTrueFalseTotal
open SEMREL, "<:utf8", $semanticRelationsFilename or die "no such file $semanticRelationsFilename\n" 0 0 0
5034  
5035 0 ▶ while($line = <SEMREL>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($line = readline SEMREL)) 0 0 0
5036 0 chomp $line;
5037 0 ▶ if (($line !~ /^\s*#/) && ($line !~ /^\s*$/) && ($line !~ /^\s*\-/)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($line =~ /^\s*#/ or $line =~ /^\s*$/ or $line =~ /^\s*\-/) 0 0 0
Condition0%0/6
$line =~ /^\s*#/ or $line =~ /^\s*$/ or $line =~ /^\s*\-/
l!l&&r!l&&!r
000
$line =~ /^\s*#/ or $line =~ /^\s*$/
l!l&&r!l&&!r
000
MC/DC0%0/3
$line =~ /^\s*#/ or $line =~ /^\s*$/ or $line =~ /^\s*\-/
$line =~ /^\s*#/ $line =~ /^\s*$/ $line =~ /^\s*\-/
Truth table0%0/4
A or B or C
A= $line =~ /^\s*#/B= $line =~ /^\s*$/C= $line =~ /^\s*\-/
ABCresult
1XX1
01X1
0011
0000
5038 # warn "$line\n";
5039 # ($T1IF, $T1LM, $T2IF, $T2LM, $type, $weight, $measure_name) = split / *[\|:] */, $line;
5040 0 @infos = split / *[\|:] */, $line;
5041 0 $postag = substr($infos[1], 0, 1);
5042 0 $postag2 = substr($infos[4], 0, 1);
5043 0 $type = $infos[6];
5044 0 $measure_name = $infos[8];
5045 0 $weight = $infos[7];
5046  
5047 0 ▶ for($i=0;$i < 3; $i+=2) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < 3) 0 0 0
5048 0 ▶ if ($infos[$i] !~ /^\s*$/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($infos[$i] =~ /^\s*$/) 0 0 0
5049 0 ▶ for($j=3;$j < 6; $j+=2) {
Branch: 1 branch
BranchTrueFalseTotal
if ($j < 6) 0 0 0
5050 0 ▶ if ($infos[$j] !~ /^\s*$/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($infos[$j] =~ /^\s*$/) 0 0 0
5051 0 @wordsInfos2 = ();
5052 0 push @wordsInfos2, [$infos[$j], $postag2, $weight, $type, $measure_name];
5053
5054 0 $self->_addWord2Thesaurus($infos[$i], $postag, "$postag|". $infos[$i], $semanticRelations, $semanticRelationsIdx, \@wordsInfos2);
5055  
5056 0 push @wordsInfos2, [$infos[$i], $postag, $weight, $type, $measure_name];
5057
5058 0 $self->_addWord2Thesaurus($infos[$j], $postag2, "$postag2|". $infos[$j], $semanticRelations, $semanticRelationsIdx, \@wordsInfos2);
5059 # if (!exists $semanticRelations->{$infos[$i]}) {
5060 # $semanticRelations->{$infos[$i]} = [];
5061 # }
5062 # push @{$semanticRelations->{$infos[$i]}}, {'term' => $infos[$j], 'type' => $type,
5063 # 'weight'=> $weight, 'measure' => $measure_name};
5064 # if (!exists $semanticRelations->{$infos[$j]}) {
5065 # $semanticRelations->{$infos[$j]} = [];
5066 # }
5067 # push @{$semanticRelations->{$infos[$j]}}, {'term' => $infos[$i], 'type' => $type . "_inv",
5068 # 'weight'=> $weight, 'measure' => $measure_name};
5069 }
5070 }
5071 }
5072 }
5073 }
5074 }
5075 0 close SEMREL
5076 }
5077  
5078  
5079 0 ▶sub _loadSemanticRelationsWithType2 {
Subroutine _loadSemanticRelationsWithType2: not called CC=12 SCAR=50.5
5080 0 my ($self, $semanticRelationsFilename, $semanticRelations) = @_;
5081  
5082 0 my $line;
5083 my $T1IF;
5084 0 my $T2IF;
5085 0 my $T1LM;
5086 0 my $T2LM;
5087 0 my $type;
5088 0 my $weight;
5089 0 my $measure_name;
5090 0 my @infos;
5091 0 my $i;
5092 0 my $j;
5093  
5094 # warn "open $semanticRelationsFilename\n";
5095 0 ▶ open SEMREL, "<:utf8", $semanticRelationsFilename or die "no such file $semanticRelationsFilename\n";
Branch: 1 branch
BranchTrueFalseTotal
open SEMREL, "<:utf8", $semanticRelationsFilename or die "no such file $semanticRelationsFilename\n" 0 0 0
5096  
5097 0 ▶ while($line = <SEMREL>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($line = readline SEMREL)) 0 0 0
5098 0 chomp $line;
5099 0 ▶ if (($line !~ /^\s*#/) && ($line !~ /^\s*$/) && ($line !~ /^\s*\-/)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($line =~ /^\s*#/ or $line =~ /^\s*$/ or $line =~ /^\s*\-/) 0 0 0
Condition0%0/6
$line =~ /^\s*#/ or $line =~ /^\s*$/ or $line =~ /^\s*\-/
l!l&&r!l&&!r
000
$line =~ /^\s*#/ or $line =~ /^\s*$/
l!l&&r!l&&!r
000
MC/DC0%0/3
$line =~ /^\s*#/ or $line =~ /^\s*$/ or $line =~ /^\s*\-/
$line =~ /^\s*#/ $line =~ /^\s*$/ $line =~ /^\s*\-/
Truth table0%0/4
A or B or C
A= $line =~ /^\s*#/B= $line =~ /^\s*$/C= $line =~ /^\s*\-/
ABCresult
1XX1
01X1
0011
0000
5100 # warn "$line\n";
5101 # ($T1IF, $T1LM, $T2IF, $T2LM, $type, $weight, $measure_name) = split / *[\|:] */, $line;
5102 0 @infos = split / *[\|:] */, $line;
5103  
5104 0 ▶ for($i=0;$i < 2; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < 2) 0 0 0
5105 0 ▶ if ($infos[$i] !~ /^\s*$/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($infos[$i] =~ /^\s*$/) 0 0 0
5106 0 ▶ for($j=2;$j < 4; $j++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($j < 4) 0 0 0
5107 0 ▶ if ($infos[$j] !~ /^\s*$/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($infos[$j] =~ /^\s*$/) 0 0 0
5108 0 ▶ if (!exists $semanticRelations->{$infos[$i]}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $$semanticRelations{$infos[$i]}) 0 0 0
5109 0 $semanticRelations->{$infos[$i]} = [];
5110 }
5111 0 push @{$semanticRelations->{$infos[$i]}}, {'term' => $infos[$j], 'type' => $type,
5112 'weight'=> $weight, 'measure' => $measure_name};
5113 0 ▶ if (!exists $semanticRelations->{$infos[$j]}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $$semanticRelations{$infos[$j]}) 0 0 0
5114 0 $semanticRelations->{$infos[$j]} = [];
5115 }
5116 0 push @{$semanticRelations->{$infos[$j]}}, {'term' => $infos[$i], 'type' => $type . "_inv",
5117 'weight'=> $weight, 'measure' => $measure_name};
5118 }
5119 }
5120 }
5121 }
5122 }
5123 }
5124 0 close SEMREL
5125 }
5126  
5127  
5128  
5129 0 ▶sub _loadSynonymy {
Subroutine _loadSynonymy: not called CC=8 SCAR=42.8
5130 0 my ($self, $synonymyFilename, $synonymy) = @_;
5131  
5132 0 my $line;
5133 my $T1;
5134 0 my $T2;
5135  
5136 # warn "open $synonymyFilename\n";
5137 0 ▶ open SYNO, "<:utf8", $synonymyFilename or die "no such file $synonymyFilename\n";
Branch: 1 branch
BranchTrueFalseTotal
open SYNO, "<:utf8", $synonymyFilename or die "no such file $synonymyFilename\n" 0 0 0
5138  
5139 0 ▶ while($line = <SYNO>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($line = readline SYNO)) 0 0 0
5140 0 chomp $line;
5141 0 ▶ if (($line !~ /^\s*#/) && ($line !~ /^\s*$/) && ($line !~ /^\s*\-/)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($line =~ /^\s*#/ or $line =~ /^\s*$/ or $line =~ /^\s*\-/) 0 0 0
Condition0%0/6
$line =~ /^\s*#/ or $line =~ /^\s*$/ or $line =~ /^\s*\-/
l!l&&r!l&&!r
000
$line =~ /^\s*#/ or $line =~ /^\s*$/
l!l&&r!l&&!r
000
MC/DC0%0/3
$line =~ /^\s*#/ or $line =~ /^\s*$/ or $line =~ /^\s*\-/
$line =~ /^\s*#/ $line =~ /^\s*$/ $line =~ /^\s*\-/
Truth table0%0/4
A or B or C
A= $line =~ /^\s*#/B= $line =~ /^\s*$/C= $line =~ /^\s*\-/
ABCresult
1XX1
01X1
0011
0000
5142 # warn "$line\n";
5143 0 $line =~ s/__...=?//go;
5144 0 ($T1, $T2) = split / *[\|:] */, $line;
5145 0 ▶ if (!exists $synonymy->{$T1}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $synonymy->{$T1}) 0 0 0
5146 0 $synonymy->{$T1} = [];
5147 }
5148 0 push @{$synonymy->{$T1}}, $T2;
5149 0 ▶ if (!exists $synonymy->{$T2}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $synonymy->{$T2}) 0 0 0
5150 0 $synonymy->{$T2} = [];
5151 }
5152 0 push @{$synonymy->{$T2}}, $T1;
5153 }
5154 }
5155 0 close SYNO
5156 }
5157  
5158 0 ▶sub _loadException {
Subroutine _loadException: not called CC=1 SCAR=6.9
5159 0 my ($self, $resource, $lang, $type) = @_;
5160  
5161 0 return($self->_loadWordList($resource, $lang, $type));
5162 }
5163  
5164 0 ▶sub _loadWordList {
Subroutine _loadWordList: not called CC=12 SCAR=50.5
5165 0 my ($self, $resource, $lang, $type) = @_;
5166 0 my $line;
5167 my $filename;
5168  
5169 0 ▶ if (defined $resource) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $resource) 0 0 0
5170 0 $self->{$type}->{$lang} = {};
5171 0 ▶ if (ref($resource) eq "ARRAY") {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $resource eq 'ARRAY') { } 0 0 0
5172 0 foreach $filename (@$resource) {
5173 0 ▶ open EXCEPTION, "<:utf8", $filename or die "no such file $filename\n";
Branch: 1 branch
BranchTrueFalseTotal
open EXCEPTION, "<:utf8", $filename or die "no such file $filename\n" 0 0 0
5174 0 warn "read $filename\n";
5175 0 ▶ while($line = <EXCEPTION>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($line = readline EXCEPTION)) 0 0 0
5176 0 chomp $line;
5177 0 ▶ if (($line !~ /^\s*$/o) && ($line !~ /^\s*\#$/o)){
Branch: 1 branch
BranchTrueFalseTotal
unless ($line =~ /^\s*$/o or $line =~ /^\s*\#$/o) 0 0 0
Condition0%0/3
$line =~ /^\s*$/o or $line =~ /^\s*\#$/o
l!l&&r!l&&!r
000
MC/DC0%0/2
$line =~ /^\s*$/o or $line =~ /^\s*\#$/o
$line =~ /^\s*$/o $line =~ /^\s*\#$/o
Truth table0%0/3
A or B
A= $line =~ /^\s*$/oB= $line =~ /^\s*\#$/o
ABresult
1X1
011
000
5178 0 $self->{$type}->{$lang}->{$line}++;
5179 }
5180 }
5181 0 close EXCEPTION;
5182 }
5183 } else {
5184 0 $filename = $resource;
5185 0 ▶ open EXCEPTION, "<:utf8", $filename or die "no such file $filename\n";
Branch: 1 branch
BranchTrueFalseTotal
open EXCEPTION, "<:utf8", $filename or die "no such file $filename\n" 0 0 0
5186 0 warn "read $filename\n";
5187 0 ▶ while($line = <EXCEPTION>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($line = readline EXCEPTION)) 0 0 0
5188 0 chomp $line;
5189 0 ▶ if (($line !~ /^\s*$/o) && ($line !~ /^\s*\#$/o)){
Branch: 1 branch
BranchTrueFalseTotal
unless ($line =~ /^\s*$/o or $line =~ /^\s*\#$/o) 0 0 0
Condition0%0/3
$line =~ /^\s*$/o or $line =~ /^\s*\#$/o
l!l&&r!l&&!r
000
MC/DC0%0/2
$line =~ /^\s*$/o or $line =~ /^\s*\#$/o
$line =~ /^\s*$/o $line =~ /^\s*\#$/o
Truth table0%0/3
A or B
A= $line =~ /^\s*$/oB= $line =~ /^\s*\#$/o
ABresult
1X1
011
000
5190 0 $self->{$type}->{$lang}->{$line}++;
5191 }
5192 }
5193 0 close EXCEPTION;
5194 }
5195 }
5196 }
5197  
5198 0 ▶sub _loadCorrespondanceList {
Subroutine _loadCorrespondanceList: not called CC=12 SCAR=50.5
5199 0 my ($self, $resource, $lang, $type) = @_;
5200 0 my $line;
5201 my $filename;
5202 0 my $val1;
5203 0 my $val2;
5204  
5205 0 ▶ if (defined $resource) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $resource) 0 0 0
5206 0 $self->{$type}->{$lang} = {};
5207 0 ▶ if (ref($resource) eq "ARRAY") {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $resource eq 'ARRAY') { } 0 0 0
5208 0 foreach $filename (@$resource) {
5209 0 ▶ open EXCEPTION, "<:utf8", $filename or die "no such file $filename\n";
Branch: 1 branch
BranchTrueFalseTotal
open EXCEPTION, "<:utf8", $filename or die "no such file $filename\n" 0 0 0
5210 0 ▶ while($line = <EXCEPTION>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($line = readline EXCEPTION)) 0 0 0
5211 0 chomp $line;
5212 0 ▶ if (($line !~ /^\s*$/o) && ($line !~ /^\s*\#$/o)){
Branch: 1 branch
BranchTrueFalseTotal
unless ($line =~ /^\s*$/o or $line =~ /^\s*\#$/o) 0 0 0
Condition0%0/3
$line =~ /^\s*$/o or $line =~ /^\s*\#$/o
l!l&&r!l&&!r
000
MC/DC0%0/2
$line =~ /^\s*$/o or $line =~ /^\s*\#$/o
$line =~ /^\s*$/o $line =~ /^\s*\#$/o
Truth table0%0/3
A or B
A= $line =~ /^\s*$/oB= $line =~ /^\s*\#$/o
ABresult
1X1
011
000
5213 0 ($val1, $val2) = split /\s*:\s*/, $line;
5214 0 $self->{$type}->{$lang}->{$val1} = $val2;
5215 }
5216 }
5217 0 close EXCEPTION;
5218 }
5219 } else {
5220 0 $filename = $resource;
5221 0 ▶ open EXCEPTION, "<:utf8", $filename or die "no such file $filename\n";
Branch: 1 branch
BranchTrueFalseTotal
open EXCEPTION, "<:utf8", $filename or die "no such file $filename\n" 0 0 0
5222 0 ▶ while($line = <EXCEPTION>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($line = readline EXCEPTION)) 0 0 0
5223 0 chomp $line;
5224 0 ▶ if (($line !~ /^\s*$/o) && ($line !~ /^\s*\#$/o)){
Branch: 1 branch
BranchTrueFalseTotal
unless ($line =~ /^\s*$/o or $line =~ /^\s*\#$/o) 0 0 0
Condition0%0/3
$line =~ /^\s*$/o or $line =~ /^\s*\#$/o
l!l&&r!l&&!r
000
MC/DC0%0/2
$line =~ /^\s*$/o or $line =~ /^\s*\#$/o
$line =~ /^\s*$/o $line =~ /^\s*\#$/o
Truth table0%0/3
A or B
A= $line =~ /^\s*$/oB= $line =~ /^\s*\#$/o
ABresult
1X1
011
000
5225 0 ($val1, $val2) = split /\s*:\s*/, $line;
5226 0 warn "$val1\n";
5227 0 $self->{$type}->{$lang}->{$val1} = $val2;
5228 }
5229 }
5230 0 close EXCEPTION;
5231 }
5232 }
5233 }
5234  
5235 0 ▶sub _loadTerminology {
Subroutine _loadTerminology: not called CC=8 SCAR=42.8
5236 0 my ($self, $terminologyFilename, $terminology, $terminologyIdx) = @_;
5237 0 my $line;
5238 my @termInfos;
5239 0 my @semCats;
5240 0 my $semCat;
5241  
5242
5243 0 ▶ open TERMINO, "<:utf8", $terminologyFilename or die "no such file $terminologyFilename\n";
Branch: 1 branch
BranchTrueFalseTotal
open TERMINO, "<:utf8", $terminologyFilename or die "no such file $terminologyFilename\n" 0 0 0
5244 0 ▶ while($line = <TERMINO>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($line = readline TERMINO)) 0 0 0
5245 0 chomp $line;
5246 0 ▶ if (($line !~ /^\s*#/) && ($line !~ /^\s*$/)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($line =~ /^\s*#/ or $line =~ /^\s*$/) 0 0 0
Condition0%0/3
$line =~ /^\s*#/ or $line =~ /^\s*$/
l!l&&r!l&&!r
000
MC/DC0%0/2
$line =~ /^\s*#/ or $line =~ /^\s*$/
$line =~ /^\s*#/ $line =~ /^\s*$/
Truth table0%0/3
A or B
A= $line =~ /^\s*#/B= $line =~ /^\s*$/
ABresult
1X1
011
000
5247 0 @termInfos = split / ?[:|] ?/, $line;
5248  
5249 0 ▶ if ((defined $termInfos[2]) && ($termInfos[2] ne "")) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $termInfos[2] and $termInfos[2] ne '') { } 0 0 0
Condition0%0/3
defined $termInfos[2] and $termInfos[2] ne ""
!ll&&!rl&&r
000
MC/DC0%0/2
defined $termInfos[2] and $termInfos[2] ne ""
defined $termInfos[2] $termInfos[2] ne ""
Truth table0%0/3
A and B
A= defined $termInfos[2]B= $termInfos[2] ne ""
ABresult
0X0
100
111
5250 0 @semCats = split /\//, $termInfos[2];
5251 # if ($terminologyIdx->{$termInfos[0]}) {
5252 # $terminologyIdx->{$termInfos[0]} = [];
5253 # }
5254 # push @{$terminologyIdx->{$termInfos[0]}}, $termInfos[2];
5255 0 $terminologyIdx->{$termInfos[0]}->{lc($termInfos[2])}++;
5256 0 $terminology->{lc($termInfos[2])}->{$termInfos[0]}++;
5257  
5258 0 for $semCat (@semCats) {
5259 0 $terminologyIdx->{$termInfos[0]}->{lc($semCat)}++;
5260 0 $terminology->{lc($semCat)}->{$termInfos[0]}++;
5261 }
5262 } else {
5263 0 warn "Empty semantic category\n";
5264 }
5265 }
5266 }
5267 0 close TERMINO;
5268 }
5269  
5270 0 ▶sub _selectTermInfos {
Subroutine _selectTermInfos: not called CC=3 SCAR=24.8
5271 0 my ($self, $termToSelect, $terminology, $terminologyIdx, $selectedTermsInTerminology) = @_;
5272  
5273 0 my $semCat;
5274  
5275 0 %$selectedTermsInTerminology = ();
5276 0 ▶ if (exists $terminologyIdx->{$termToSelect}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $terminologyIdx->{$termToSelect}) 0 0 0
5277 0 foreach $semCat (keys %{$terminologyIdx->{$termToSelect}}) {
5278 0 $selectedTermsInTerminology->{$semCat} = $terminology->{$semCat};
5279 }
5280 }
5281 }
5282  
5283 0 ▶sub _selectSynonyms {
Subroutine _selectSynonyms: not called CC=2 SCAR=17.9
5284 0 my ($self, $termToSelect, $synonymy, $selectedSynonyms) = @_;
5285  
5286 0 my $synonym;
5287  
5288 0 @$selectedSynonyms = ();
5289 0 ▶ if (exists $synonymy->{$termToSelect}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $synonymy->{$termToSelect}) 0 0 0
5290 # warn ".. found\n";
5291 # foreach $synonym (@{$synonymy->{$termToSelect}}) {
5292 0 push @$selectedSynonyms, @{$synonymy->{$termToSelect}};
5293 # }
5294 }
5295 }
5296  
5297  
5298  
5299 0 ▶sub _loadThesaurus {
Subroutine _loadThesaurus: not called CC=4 SCAR=30.0
5300 0 my ($self, $freDistThesaurusFilename, $freDistThesaurus, $freDistThesaurusIdx) = @_;
5301  
5302 0 my @wordsInfos;
5303 my @wordsInfos2;
5304 0 my $wordInfo;
5305 0 my $wordInfoElt;
5306 0 my $postag;
5307 0 my $word;
5308 0 my $dist;
5309 0 my $postag2;
5310 0 my $word2;
5311 0 my $dist2;
5312 0 my $wordDist;
5313 0 my $line;
5314  
5315 0 ▶ open THESAURUS, '<:utf8', $freDistThesaurusFilename or die "no such file $freDistThesaurusFilename\n";
Branch: 1 branch
BranchTrueFalseTotal
open THESAURUS, "<:utf8", $freDistThesaurusFilename or die "no such file $freDistThesaurusFilename\n" 0 0 0
5316  
5317 0 ▶ while($line = <THESAURUS>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($line = readline THESAURUS)) 0 0 0
5318 0 chomp $line;
5319  
5320 0 @wordsInfos = split /\t/, $line;
5321  
5322 0 $wordInfo = shift @wordsInfos;
5323 0 ($postag, $word) = split /\|/, $wordInfo;
5324  
5325 0 @wordsInfos2 = ();
5326 0 foreach $wordInfoElt (@wordsInfos) {
5327 0 ($postag2, $wordDist) = split /\|/, $wordInfoElt;
5328 0 ($word2, $dist2) = split /:/, $wordDist; # /
5329 # push @{$freDistThesaurus->{$wordInfo}->{'neighbour'}}, {'word' => $word,
5330 # 'postag' => $postag,
5331 # 'dist' => $dist,
5332 # }
5333 0 push @wordsInfos2, [$word2, $postag2, $dist2];
5334 }
5335  
5336 0 $self->_addWord2Thesaurus($word, $postag, $wordInfo, $freDistThesaurus, $freDistThesaurusIdx, \@wordsInfos2);
5337 }
5338 0 close THESAURUS;
5339 }
5340  
5341 0 ▶sub _selectWordInfos {
Subroutine _selectWordInfos: not called CC=5 SCAR=34.0
5342 0 my ($self, $wordToSelect, $withPOStag, $freDistThesaurus, $freDistThesaurusIdx, $selectedWordsInThesaurus) = @_;
5343  
5344 0 my $wordInfo;
5345  
5346 0 %$selectedWordsInThesaurus = ();
5347 0 ▶ if (!$withPOStag) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $withPOStag) { } 0 0 0
5348 0 ▶ if (exists $freDistThesaurusIdx->{$wordToSelect}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $freDistThesaurusIdx->{$wordToSelect}) 0 0 0
5349 0 foreach $wordInfo (@{$freDistThesaurusIdx->{$wordToSelect}}) {
5350 0 $selectedWordsInThesaurus->{$wordInfo} = $freDistThesaurus->{$wordInfo};
5351 }
5352 }
5353 } else {
5354 # warn "$wordToSelect\n";
5355 0 ▶ if (exists $freDistThesaurus->{$wordToSelect}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $freDistThesaurus->{$wordToSelect}) 0 0 0
5356 0 $selectedWordsInThesaurus->{$wordToSelect} = $freDistThesaurus->{$wordToSelect};
5357 }
5358 }
5359 }
5360  
5361  
5362 0 ▶sub _mergeTerms {
Subroutine _mergeTerms: not called CC=76 SCAR=86.7
5363 0 my ($self, $document) = @_;
5364  
5365 0 my $term;
5366 my $token;
5367 0 my $semf;
5368 0 my $tmpSemf;
5369 0 my $nextSemf;
5370  
5371 0 my $tmpTerm;
5372 0 my $end_form;
5373 0 my @endTokens;
5374 0 my $type;
5375 0 my @tmpTermList;
5376 0 my %tmpTermListH;
5377 0 my $lang = $document->getAnnotations->getLanguage;
5378  
5379 0 my %medsep = ("," => 1);
5380  
5381 0 my @termlist = @{$document->getAnnotations->getSemanticUnitLevel->getElements};
5382  
5383 0 warn "[LOG] Merge Terms\n";
5384  
5385 0 foreach $term (@termlist) {
5386 # warn "termForm: " . $term->getForm . "\n";
5387 0 ▶ if ($document->getAnnotations->getSemanticUnitLevel->existsElement($term->getId)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($document->getAnnotations->getSemanticUnitLevel->existsElement($term->getId)) 0 0 0
5388 # nested Term ?
5389 0 $type = $term->type;
5390 0 $semf = "";
5391 # test exists semantic tag ?
5392 0 ▶ if (($term->isTerm) &&
Branch: 2 branches
BranchTrueFalseTotal
if ($term->isTerm and $document->getAnnotations->getSemanticFeaturesLevel->existsElementFromIndex('refid_semantic_unit', $term->getId) and defined $document->getAnnotations->getSemanticFeaturesLevel->getElementFromIndex('refid_semantic_unit', $term->getId)->[0]) { } 0 0 0
elsif ($term->isNamedEntity) { } 0 0 0
Condition0%0/6
$term->isTerm and $document->getAnnotations->getSemanticFeaturesLevel->existsElementFromIndex("refid_semantic_unit", $term->getId) and defined $document->getAnnotations->getSemanticFeaturesLevel->getElementFromIndex("refid_semantic_unit", $term->getId)->[0]
!ll&&!rl&&r
000
$term->isTerm and $document->getAnnotations->getSemanticFeaturesLevel->existsElementFromIndex("refid_semantic_unit", $term->getId)
!ll&&!rl&&r
000
MC/DC0%0/3
$term->isTerm and $document->getAnnotations->getSemanticFeaturesLevel->existsElementFromIndex("refid_semantic_unit", $term->getId) and defined $document->getAnnotations->getSemanticFeaturesLevel->getElementFromIndex("refid_semantic_unit", $term->getId)->[0]
$term->isTerm $document->getAnnotations->getSemanticFeaturesLevel->existsElementFromIndex("refid_semantic_unit", $term->getId) defined $document->getAnnotations->getSemanticFeaturesLevel->getElementFromIndex("refid_semantic_unit", $term->getId)->[0]
Truth table0%0/4
A and B and C
A= $term->isTermB= $document->getAnnotations->getSemanticFeaturesLevel->existsElementFromIndex("refid_semantic_unit", $term->getId)C= defined $document->getAnnotations->getSemanticFeaturesLevel->getElementFromIndex("refid_semantic_unit", $term->getId)->[0]
ABCresult
0XX0
10X0
1100
1111
5393 ($document->getAnnotations->getSemanticFeaturesLevel->existsElementFromIndex("refid_semantic_unit", $term->getId)) &&
5394 (defined($document->getAnnotations->getSemanticFeaturesLevel->getElementFromIndex("refid_semantic_unit", $term->getId)->[0]))) {
5395 0 ▶ if (!defined($document->getAnnotations->getSemanticFeaturesLevel->getElementFromIndex("refid_semantic_unit", $term->getId)->[0])) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $document->getAnnotations->getSemanticFeaturesLevel->getElementFromIndex("refid_semantic_unit", $term->getId)->[0]) 0 0 0
5396 0 warn $term->getForm . ": no defined semantic features\n";
5397 }
5398 0 $semf = $document->getAnnotations->getSemanticFeaturesLevel->getElementFromIndex("refid_semantic_unit", $term->getId)->[0]->first_node_first_semantic_category;
5399 } elsif ($term->isNamedEntity) {
5400 0 $semf = $term->NEtype;
5401 } else {
5402 0 $semf = "NA";
5403 }
5404 0 my $termToken = $term->start_token;
5405 0 @tmpTermList = ();
5406 0 %tmpTermListH = ();
5407
5408 0 foreach $tmpTerm (@{$document->getAnnotations->getSemanticUnitLevel->getElementByOffset($termToken->getFrom)}) {
5409 0 ▶ if ((!$tmpTerm->equals($term)) && ($tmpTerm->type eq $term->type) &&
Branch: 1 branch
BranchTrueFalseTotal
if (not $tmpTerm->equals($term) and $tmpTerm->type eq $term->type and $type eq "term" && ($semf eq "NA" || $tmpTerm->SemanticFeatureFCEquals($document, $term->getSemanticFeatureFC($document))) || $type eq "named_entity" && $tmpTerm->NEtype eq $term->NEtype) 0 0 0
Condition0%0/18
not $tmpTerm->equals($term) and $tmpTerm->type eq $term->type and $type eq "term" && ($semf eq "NA" || $tmpTerm->SemanticFeatureFCEquals($document, $term->getSemanticFeatureFC($document))) || $type eq "named_entity" && $tmpTerm->NEtype eq $term->NEtype
!ll&&!rl&&r
000
not $tmpTerm->equals($term) and $tmpTerm->type eq $term->type
!ll&&!rl&&r
000
$type eq "term" and $semf eq "NA" || $tmpTerm->SemanticFeatureFCEquals($document, $term->getSemanticFeatureFC($document)) or $type eq "named_entity" and $tmpTerm->NEtype eq $term->NEtype
l!l&&r!l&&!r
000
$type eq "term" and $semf eq "NA" || $tmpTerm->SemanticFeatureFCEquals($document, $term->getSemanticFeatureFC($document))
!ll&&!rl&&r
000
$semf eq "NA" or $tmpTerm->SemanticFeatureFCEquals($document, $term->getSemanticFeatureFC($document))
l!l&&r!l&&!r
000
$type eq "named_entity" and $tmpTerm->NEtype eq $term->NEtype
!ll&&!rl&&r
000
MC/DC0%0/7
not $tmpTerm->equals($term) and $tmpTerm->type eq $term->type and $type eq "term" && ($semf eq "NA" || $tmpTerm->SemanticFeatureFCEquals($document, $term->getSemanticFeatureFC($document))) || $type eq "named_entity" && $tmpTerm->NEtype eq $term->NEtype
not $tmpTerm->equals($term) $tmpTerm->type eq $term->type $type eq "term" $semf eq "NA" $tmpTerm->SemanticFeatureFCEquals($document, $term->getSemanticFeatureFC($document)) $type eq "named_entity" $tmpTerm->NEtype eq $term->NEtype
Truth table0%0/10
not(A) and B and C and D or E or F and G
A= not $tmpTerm->equals($term)B= $tmpTerm->type eq $term->typeC= $type eq "term"D= $semf eq "NA"E= $tmpTerm->SemanticFeatureFCEquals($document, $term->getSemanticFeatureFC($document))F= $type eq "named_entity"G= $tmpTerm->NEtype eq $term->NEtype
ABCDEFGresult
0XXXXXX0
10XXXXX0
110XX0X0
110XX100
111000X0
11100100
1111XXX1
11101XX1
110XX111
11100111
5410 ((($type eq "term") && (($semf eq "NA") ||
5411 ($tmpTerm->SemanticFeatureFCEquals($document, $term->getSemanticFeatureFC($document))))) ||
5412 (($type eq "named_entity") && ($tmpTerm->NEtype eq $term->NEtype)))
5413 ){
5414 0 $tmpTermListH{$tmpTerm->getId} = $tmpTerm;
5415 }
5416 }
5417 0 ▶ while(!$termToken->equals($term->end_token)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($termToken->equals($term->end_token)) 0 0 0
5418 0 $termToken = $termToken->next;
5419 0 foreach $tmpTerm (@{$document->getAnnotations->getSemanticUnitLevel->getElementByOffset($termToken->getFrom)}) {
5420 0 ▶ if ((!$tmpTerm->equals($term)) && ($tmpTerm->type eq $term->type) &&
Branch: 1 branch
BranchTrueFalseTotal
if (not $tmpTerm->equals($term) and $tmpTerm->type eq $term->type and $type eq "term" && ($semf eq "NA" || $tmpTerm->SemanticFeatureFCEquals($document, $term->getSemanticFeatureFC($document))) || $type eq "named_entity" && $tmpTerm->NEtype eq $term->NEtype) 0 0 0
Condition0%0/18
not $tmpTerm->equals($term) and $tmpTerm->type eq $term->type and $type eq "term" && ($semf eq "NA" || $tmpTerm->SemanticFeatureFCEquals($document, $term->getSemanticFeatureFC($document))) || $type eq "named_entity" && $tmpTerm->NEtype eq $term->NEtype
!ll&&!rl&&r
000
not $tmpTerm->equals($term) and $tmpTerm->type eq $term->type
!ll&&!rl&&r
000
$type eq "term" and $semf eq "NA" || $tmpTerm->SemanticFeatureFCEquals($document, $term->getSemanticFeatureFC($document)) or $type eq "named_entity" and $tmpTerm->NEtype eq $term->NEtype
l!l&&r!l&&!r
000
$type eq "term" and $semf eq "NA" || $tmpTerm->SemanticFeatureFCEquals($document, $term->getSemanticFeatureFC($document))
!ll&&!rl&&r
000
$semf eq "NA" or $tmpTerm->SemanticFeatureFCEquals($document, $term->getSemanticFeatureFC($document))
l!l&&r!l&&!r
000
$type eq "named_entity" and $tmpTerm->NEtype eq $term->NEtype
!ll&&!rl&&r
000
MC/DC0%0/7
not $tmpTerm->equals($term) and $tmpTerm->type eq $term->type and $type eq "term" && ($semf eq "NA" || $tmpTerm->SemanticFeatureFCEquals($document, $term->getSemanticFeatureFC($document))) || $type eq "named_entity" && $tmpTerm->NEtype eq $term->NEtype
not $tmpTerm->equals($term) $tmpTerm->type eq $term->type $type eq "term" $semf eq "NA" $tmpTerm->SemanticFeatureFCEquals($document, $term->getSemanticFeatureFC($document)) $type eq "named_entity" $tmpTerm->NEtype eq $term->NEtype
Truth table0%0/10
not(A) and B and C and D or E or F and G
A= not $tmpTerm->equals($term)B= $tmpTerm->type eq $term->typeC= $type eq "term"D= $semf eq "NA"E= $tmpTerm->SemanticFeatureFCEquals($document, $term->getSemanticFeatureFC($document))F= $type eq "named_entity"G= $tmpTerm->NEtype eq $term->NEtype
ABCDEFGresult
0XXXXXX0
10XXXXX0
110XX0X0
110XX100
111000X0
11100100
1111XXX1
11101XX1
110XX111
11100111
5421 ((($type eq "term") && (($semf eq "NA") ||
5422 ($tmpTerm->SemanticFeatureFCEquals($document, $term->getSemanticFeatureFC($document))))) ||
5423 (($type eq "named_entity") && ($tmpTerm->NEtype eq $term->NEtype)))
5424 ) {
5425 0 $tmpTermListH{$tmpTerm->getId} = $tmpTerm;
5426 }
5427 }
5428 }
5429 0 foreach $tmpTerm (values %tmpTermListH) {
5430 # warn "==> " . $tmpTerm->getForm . "(" . $tmpTerm->getId . " -- $type / " . $tmpTerm->type . ")\n";
5431 0 ▶ if (($document->getAnnotations->getSemanticUnitLevel->existsElement($term->getId)) &&
Branch: 1 branch
BranchTrueFalseTotal
if ($document->getAnnotations->getSemanticUnitLevel->existsElement($term->getId) and $document->getAnnotations->getSemanticUnitLevel->existsElement($tmpTerm->getId) and $tmpTerm->type eq $type) 0 0 0
Condition0%0/6
$document->getAnnotations->getSemanticUnitLevel->existsElement($term->getId) and $document->getAnnotations->getSemanticUnitLevel->existsElement($tmpTerm->getId) and $tmpTerm->type eq $type
!ll&&!rl&&r
000
$document->getAnnotations->getSemanticUnitLevel->existsElement($term->getId) and $document->getAnnotations->getSemanticUnitLevel->existsElement($tmpTerm->getId)
!ll&&!rl&&r
000
MC/DC0%0/3
$document->getAnnotations->getSemanticUnitLevel->existsElement($term->getId) and $document->getAnnotations->getSemanticUnitLevel->existsElement($tmpTerm->getId) and $tmpTerm->type eq $type
$document->getAnnotations->getSemanticUnitLevel->existsElement($term->getId) $document->getAnnotations->getSemanticUnitLevel->existsElement($tmpTerm->getId) $tmpTerm->type eq $type
Truth table0%0/4
A and B and C
A= $document->getAnnotations->getSemanticUnitLevel->existsElement($term->getId)B= $document->getAnnotations->getSemanticUnitLevel->existsElement($tmpTerm->getId)C= $tmpTerm->type eq $type
ABCresult
0XX0
10X0
1100
1111
5432 ($document->getAnnotations->getSemanticUnitLevel->existsElement($tmpTerm->getId)) &&
5433 ($tmpTerm->type eq $type)
5434 ) {
5435 0 ▶ if (defined $document->getAnnotations->getSemanticFeaturesLevel->getElementFromIndex("refid_semantic_unit", $tmpTerm->getId)->[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $document->getAnnotations->getSemanticFeaturesLevel->getElementFromIndex('refid_semantic_unit', $tmpTerm->getId)->[0]) { } 0 0 0
5436 0 $tmpSemf = $document->getAnnotations->getSemanticFeaturesLevel->getElementFromIndex("refid_semantic_unit", $tmpTerm->getId)->[0]->first_node_first_semantic_category;
5437 } else {
5438 0 $tmpSemf = "";
5439 }
5440 # warn " $semf / $tmpSemf\n";
5441 0 ▶ if ($term->start_token->getFrom <= $tmpTerm->start_token->getFrom) {
Branch: 1 branch
BranchTrueFalseTotal
if ($term->start_token->getFrom <= $tmpTerm->start_token->getFrom) { } 0 0 0
5442 0 ▶ if ($tmpTerm->end_token->getTo <= $term->end_token->getTo) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tmpTerm->end_token->getTo <= $term->end_token->getTo) { } 0 0 0
5443 0 ▶ if ($tmpSemf eq $semf) { # TO change to compare categories
Branch: 1 branch
BranchTrueFalseTotal
if ($tmpSemf eq $semf) 0 0 0
5444 0 ▶ if ((defined $tmpTerm->canonical_form) && (!defined ($term->canonical_form))) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $tmpTerm->canonical_form and not defined $term->canonical_form) 0 0 0
Condition0%0/3
defined $tmpTerm->canonical_form and not defined $term->canonical_form
!ll&&!rl&&r
000
MC/DC0%0/2
defined $tmpTerm->canonical_form and not defined $term->canonical_form
defined $tmpTerm->canonical_form not defined $term->canonical_form
Truth table0%0/3
A and not(B)
A= defined $tmpTerm->canonical_formB= not defined $term->canonical_form
ABresult
0X0
100
111
5445 0 $term->canonical_form($tmpTerm->canonical_form);
5446 }
5447 0 $document->getAnnotations->delSemanticUnit($tmpTerm);
5448 # $document->getAnnotations->delSemanticFeaturesFromTermId($tmpTerm);
5449 }
5450 } else {
5451 # Merge Term if same type
5452 0 ▶ if ($tmpSemf eq $semf) { # TO change to compare categories
Branch: 1 branch
BranchTrueFalseTotal
if ($tmpSemf eq $semf) 0 0 0
5453 0 $end_form = undef;
5454 0 @endTokens = ();
5455 # expansion
5456 0 ▶ if ($self->{"EXPAND_TERMS"}->{$lang} == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"EXPAND_TERMS"}{$lang} == 1) 0 0 0
5457 0 ▶ if (index($tmpTerm->getForm, "(") > -1) {
Branch: 1 branch
BranchTrueFalseTotal
if (index($tmpTerm->getForm, "(") != -1) 0 0 0
5458 0 $self->_getEndForm($tmpTerm, $document, \$end_form, \@endTokens);
5459 }
5460 }
5461  
5462 0 push @termlist, $self->_semanticUnitMerging($document, $term, $tmpTerm, undef, undef, $end_form, \@endTokens);
5463 }
5464 }
5465 } else {
5466 0 ▶ if (!defined $tmpSemf) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $tmpSemf) 0 0 0
5467 0 warn "tmpSemf not defined for " . $term->getForm . " / " . $tmpTerm->getForm . "\n";
5468 }
5469 # if ($tmpSemf eq $semf) { # TO change to compare categories
5470 # $document->getAnnotations->delSemanticUnit($tmpTerm);
5471 # # $document->getAnnotations->delSemanticFeaturesFromTermId($tmpTerm);
5472 # }
5473 0 ▶ if ($tmpTerm->end_token->getTo <= $term->end_token->getTo) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tmpTerm->end_token->getTo <= $term->end_token->getTo) { } 0 0 0
5474 # Merge Term if same type
5475 0 ▶ if ($tmpSemf eq $semf) { # TO change to compare categories
Branch: 1 branch
BranchTrueFalseTotal
if ($tmpSemf eq $semf) 0 0 0
5476 0 $end_form = undef;
5477 0 @endTokens = ();
5478 # expansion
5479 0 ▶ if ($self->{"EXPAND_TERMS"}->{$lang} == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"EXPAND_TERMS"}{$lang} == 1) 0 0 0
5480 0 ▶ if (index($term->getForm, "(") > -1) {
Branch: 1 branch
BranchTrueFalseTotal
if (index($term->getForm, "(") != -1) 0 0 0
5481 0 $self->_getEndForm($term, $document, \$end_form, \@endTokens);
5482 }
5483 }
5484 0 push @termlist, $self->_semanticUnitMerging($document, $tmpTerm, $term, undef, undef, $end_form, \@endTokens);
5485 }
5486 } else {
5487 0 ▶ if ($tmpSemf eq $semf) { # TO change to compare categories
Branch: 1 branch
BranchTrueFalseTotal
if ($tmpSemf eq $semf) 0 0 0
5488 0 ▶ if ((!defined $tmpTerm->canonical_form) && (defined ($term->canonical_form))) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $tmpTerm->canonical_form and defined $term->canonical_form) 0 0 0
Condition0%0/3
not defined $tmpTerm->canonical_form and defined $term->canonical_form
!ll&&!rl&&r
000
MC/DC0%0/2
not defined $tmpTerm->canonical_form and defined $term->canonical_form
not defined $tmpTerm->canonical_form defined $term->canonical_form
Truth table0%0/3
not(A) and B
A= not defined $tmpTerm->canonical_formB= defined $term->canonical_form
ABresult
0X0
100
111
5489 0 $tmpTerm->canonical_form($term->canonical_form);
5490 }
5491 0 $document->getAnnotations->delSemanticUnit($term);
5492 # $document->getAnnotations->delSemanticFeaturesFromTermId($term);
5493 }
5494 }
5495
5496 }
5497 }
5498 }
5499  
5500 0 ▶ if ($self->{"EXPAND_TERMS"}->{$lang} == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"EXPAND_TERMS"}{$lang} == 1) 0 0 0
5501  
5502 0 ▶ if ($document->getAnnotations->getSemanticUnitLevel->existsElement($term->getId)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($document->getAnnotations->getSemanticUnitLevel->existsElement($term->getId)) 0 0 0
5503 # expansion
5504 # following NEs with or without separators
5505 0 my @sepTokens;
5506 my $sep_form;
5507 0 $token = $term->end_token;
5508 0 ▶ while ((defined $token->next) &&
Branch: 1 branch
BranchTrueFalseTotal
if (defined $token->next and $token->next->isSep || $token->next->isSymb and not exists $medsep{$token->next->getContent} and not $document->getAnnotations->getSentenceLevel->existsElementFromIndex("refid_end_token", $token->getId)) 0 0 0
Condition0%0/12
defined $token->next and $token->next->isSep || $token->next->isSymb and not exists $medsep{$token->next->getContent} and not $document->getAnnotations->getSentenceLevel->existsElementFromIndex("refid_end_token", $token->getId)
!ll&&!rl&&r
000
defined $token->next and $token->next->isSep || $token->next->isSymb and not exists $medsep{$token->next->getContent}
!ll&&!rl&&r
000
defined $token->next and $token->next->isSep || $token->next->isSymb
!ll&&!rl&&r
000
$token->next->isSep or $token->next->isSymb
l!l&&r!l&&!r
000
MC/DC0%0/5
defined $token->next and $token->next->isSep || $token->next->isSymb and not exists $medsep{$token->next->getContent} and not $document->getAnnotations->getSentenceLevel->existsElementFromIndex("refid_end_token", $token->getId)
defined $token->next $token->next->isSep $token->next->isSymb not exists $medsep{$token->next->getContent} not $document->getAnnotations->getSentenceLevel->existsElementFromIndex("refid_end_token", $token->getId)
Truth table0%0/8
A and B or C and not(D) and not(E)
A= defined $token->nextB= $token->next->isSepC= $token->next->isSymbD= not exists $medsep{$token->next->getContent}E= not $document->getAnnotations->getSentenceLevel->existsElementFromIndex("refid_end_token", $token->getId)
ABCDEresult
0XXXX0
100XX0
11X0X0
1010X0
11X100
101100
11X111
101111
5509 (($token->next->isSep) || ($token->next->isSymb)) &&
5510 (!exists($medsep{$token->next->getContent})) &&
5511 (!$document->getAnnotations->getSentenceLevel->existsElementFromIndex("refid_end_token", $token->getId))
5512 ){
5513 0 $token = $token->next;
5514 0 push @sepTokens, $token;
5515 0 $sep_form .= $token->getContent;
5516 }
5517 # expansion
5518 0 ▶ if ((((defined $sep_form) && (index ($sep_form , "(") > -1 )) || (index ($term->getForm , "(") > -1 ))
Branch: 1 branch
BranchTrueFalseTotal
if (defined $sep_form && (index($sep_form, '(') != -1) || (index($term->getForm, '(') != -1) and (index($term->getForm, ')') == -1)) { } 0 0 0
Condition0%0/9
defined $sep_form && (index($sep_form, "(") != -1) || (index($term->getForm, "(") != -1) and (index($term->getForm, ")") == -1)
!ll&&!rl&&r
000
defined $sep_form and (index($sep_form, "(") != -1) or (index($term->getForm, "(") != -1)
l!l&&r!l&&!r
000
defined $sep_form and (index($sep_form, "(") != -1)
!ll&&!rl&&r
000
MC/DC0%0/4
defined $sep_form && (index($sep_form, "(") != -1) || (index($term->getForm, "(") != -1) and (index($term->getForm, ")") == -1)
defined $sep_form (index($sep_form, "(") != -1) (index($term->getForm, "(") != -1) (index($term->getForm, ")") == -1)
Truth table0%0/8
A and B or C and D
A= defined $sep_formB= (index($sep_form, "(") != -1)C= (index($term->getForm, "(") != -1)D= (index($term->getForm, ")") == -1)
ABCDresult
0X0X0
100X0
11X00
0X100
10100
11X11
0X111
10111
5519 && (index ($term->getForm , ")") == -1 )) {
5520 0 $end_form = "";
5521 0 @endTokens = ();
5522  
5523 # expansion
5524 0 ▶ while ((defined $token->next) &&
Branch: 1 branch
BranchTrueFalseTotal
if (defined $token->next and (index($token->next->getContent, ")") == -1) and not $document->getAnnotations->getSentenceLevel->existsElementFromIndex("refid_end_token", $token->getId)) 0 0 0
Condition0%0/6
defined $token->next and (index($token->next->getContent, ")") == -1) and not $document->getAnnotations->getSentenceLevel->existsElementFromIndex("refid_end_token", $token->getId)
!ll&&!rl&&r
000
defined $token->next and (index($token->next->getContent, ")") == -1)
!ll&&!rl&&r
000
MC/DC0%0/3
defined $token->next and (index($token->next->getContent, ")") == -1) and not $document->getAnnotations->getSentenceLevel->existsElementFromIndex("refid_end_token", $token->getId)
defined $token->next (index($token->next->getContent, ")") == -1) not $document->getAnnotations->getSentenceLevel->existsElementFromIndex("refid_end_token", $token->getId)
Truth table0%0/4
A and B and not(C)
A= defined $token->nextB= (index($token->next->getContent, ")") == -1)C= not $document->getAnnotations->getSentenceLevel->existsElementFromIndex("refid_end_token", $token->getId)
ABCresult
0XX0
10X0
1100
1111
5525 (index($token->next->getContent, ")") == -1) &&
5526 (!$document->getAnnotations->getSentenceLevel->existsElementFromIndex("refid_end_token", $token->getId))
5527 ) {
5528 0 $token = $token->next;
5529 0 push @endTokens, $token;
5530 0 $end_form .= $token->getContent;
5531 }
5532 # expansion
5533 0 ▶ if ((index($token->next->getContent, ")") > -1)) {
Branch: 1 branch
BranchTrueFalseTotal
if ((index($token->next->getContent, ')') != -1)) { } 0 0 0
5534 0 $token = $token->next;
5535 0 push @endTokens, $token;
5536 0 $end_form .= $token->getContent;
5537
5538 } else {
5539 0 $end_form = "";
5540 }
5541 0 ▶ if ($end_form eq "") {
Branch: 1 branch
BranchTrueFalseTotal
if ($end_form eq "") 0 0 0
5542 0 $end_form = undef;
5543 }
5544  
5545 0 ▶ if (defined $end_form) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $end_form) 0 0 0
5546 0 push @termlist, $self->_semanticUnitMerging($document, $term, undef, $sep_form, \@sepTokens, $end_form, \@endTokens);
5547 }
5548 } else {
5549 0 ▶ if (!$document->getAnnotations->getSentenceLevel->existsElementFromIndex("refid_end_token", $token->getId)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($document->getAnnotations->getSentenceLevel->existsElementFromIndex("refid_end_token", $token->getId)) 0 0 0
5550 0 foreach my $nextTerm (@{$document->getAnnotations->getSemanticUnitLevel->getElementByOffset($token->next->getFrom)}) {
5551 0 ▶ if (($nextTerm->type eq $type) && ($document->getAnnotations->getSemanticUnitLevel->existsElement($term->getId))) {
Branch: 1 branch
BranchTrueFalseTotal
if ($nextTerm->type eq $type and $document->getAnnotations->getSemanticUnitLevel->existsElement($term->getId)) 0 0 0
Condition0%0/3
$nextTerm->type eq $type and $document->getAnnotations->getSemanticUnitLevel->existsElement($term->getId)
!ll&&!rl&&r
000
MC/DC0%0/2
$nextTerm->type eq $type and $document->getAnnotations->getSemanticUnitLevel->existsElement($term->getId)
$nextTerm->type eq $type $document->getAnnotations->getSemanticUnitLevel->existsElement($term->getId)
Truth table0%0/3
A and B
A= $nextTerm->type eq $typeB= $document->getAnnotations->getSemanticUnitLevel->existsElement($term->getId)
ABresult
0X0
100
111
5552 0 ▶ if (defined $document->getAnnotations->getSemanticFeaturesLevel->getElementFromIndex("refid_semantic_unit", $nextTerm->getId)->[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $document->getAnnotations->getSemanticFeaturesLevel->getElementFromIndex('refid_semantic_unit', $nextTerm->getId)->[0]) { } 0 0 0
5553 0 $nextSemf = $document->getAnnotations->getSemanticFeaturesLevel->getElementFromIndex("refid_semantic_unit", $nextTerm->getId)->[0]->first_node_first_semantic_category;
5554 } else {
5555 0 $nextSemf = "";
5556 }
5557 # expansion
5558 0 ▶ if (($nextTerm->start_token->getTo >= $term->start_token->getFrom) && (
Branch: 1 branch
BranchTrueFalseTotal
if ($nextTerm->start_token->getTo >= $term->start_token->getFrom and !(defined $semf && defined $nextSemf) || $nextSemf eq $semf) 0 0 0
Condition0%0/9
$nextTerm->start_token->getTo >= $term->start_token->getFrom and !(defined $semf && defined $nextSemf) || $nextSemf eq $semf
!ll&&!rl&&r
000
not defined $semf && defined $nextSemf or $nextSemf eq $semf
l!l&&r!l&&!r
000
defined $semf && defined $nextSemf
!ll&&!rl&&r
000
MC/DC0%0/4
$nextTerm->start_token->getTo >= $term->start_token->getFrom and !(defined $semf && defined $nextSemf) || $nextSemf eq $semf
$nextTerm->start_token->getTo >= $term->start_token->getFrom defined $semf defined $nextSemf $nextSemf eq $semf
Truth table0%0/5
A and not(B && C) or D
A= $nextTerm->start_token->getTo >= $term->start_token->getFromB= defined $semfC= defined $nextSemfD= $nextSemf eq $semf
ABCDresult
0XXX0
11100
10XX1
110X1
11111
5559 (!defined $semf) || (!defined $nextSemf) || ($nextSemf eq $semf))) {
5560 # TODO if the sepform contains (, going to )
5561 0 $end_form = undef;
5562 0 @endTokens = ();
5563 0 ▶ if ((defined $sep_form) && (index ($sep_form , "(") > -1 ) || (index ($term->getForm , "(") > -1 ) || (index ($nextTerm->getForm , "(") > -1 )) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $sep_form and (index($sep_form, "(") != -1) or (index($term->getForm, "(") != -1) or (index($nextTerm->getForm, "(") != -1)) 0 0 0
Condition0%0/9
defined $sep_form and (index($sep_form, "(") != -1) or (index($term->getForm, "(") != -1) or (index($nextTerm->getForm, "(") != -1)
l!l&&r!l&&!r
000
defined $sep_form and (index($sep_form, "(") != -1) or (index($term->getForm, "(") != -1)
l!l&&r!l&&!r
000
defined $sep_form and (index($sep_form, "(") != -1)
!ll&&!rl&&r
000
MC/DC0%0/4
defined $sep_form and (index($sep_form, "(") != -1) or (index($term->getForm, "(") != -1) or (index($nextTerm->getForm, "(") != -1)
defined $sep_form (index($sep_form, "(") != -1) (index($term->getForm, "(") != -1) (index($nextTerm->getForm, "(") != -1)
Truth table0%0/7
A and B or C or D
A= defined $sep_formB= (index($sep_form, "(") != -1)C= (index($term->getForm, "(") != -1)D= (index($nextTerm->getForm, "(") != -1)
ABCDresult
11XX1
0X1X1
101X1
0X011
10011
0X000
10000
5564 0 $self->_getEndForm($nextTerm, $document, \$end_form, \@endTokens);
5565  
5566 }
5567 0 push @termlist, $self->_semanticUnitMerging($document, $term, $nextTerm, $sep_form, \@sepTokens, $end_form, \@endTokens);
5568 }
5569 }
5570 }
5571 }
5572 }
5573 }
5574 }
5575 }
5576 }
5577 }
5578  
5579 0 ▶sub _printVocabulary {
Subroutine _printVocabulary: not called CC=3 SCAR=24.8
5580 0 my ($self) = @_;
5581  
5582 0 my $word;
5583 my $lemma;
5584 0 my $document;
5585  
5586 0 my %vocabulary;
5587  
5588 0 foreach $document (@{$self->_documentSet}) {
5589 0 foreach $word (@{$document->getAnnotations->getWordLevel->getElements}) {
5590 0 $vocabulary{$word->getForm}++;
5591 0 $vocabulary{$word->getLemma($document)->canonical_form}++;
5592 }
5593 0 print lc(join("\n", keys(%vocabulary))) . "\n";
5594 }
5595 }
5596  
5597 0 ▶sub _printVocabulary_FF {
Subroutine _printVocabulary_FF: not called CC=3 SCAR=24.8
5598 0 my ($self) = @_;
5599  
5600 0 my $word;
5601 my $lemma;
5602 0 my $document;
5603  
5604 0 my %vocabulary;
5605  
5606 0 foreach $document (@{$self->_documentSet}) {
5607 0 foreach $word (@{$document->getAnnotations->getWordLevel->getElements}) {
5608 0 $vocabulary{$word->getForm}++;
5609 }
5610 0 print join("\n", keys(%vocabulary)) . "\n";
5611 }
5612 }
5613  
5614 0 ▶sub _printVocabulary_LM {
Subroutine _printVocabulary_LM: not called CC=3 SCAR=24.8
5615 0 my ($self) = @_;
5616  
5617 0 my $word;
5618 my $lemma;
5619 0 my $document;
5620  
5621 0 my %vocabulary;
5622  
5623 0 foreach $document (@{$self->_documentSet}) {
5624 0 foreach $word (@{$document->getAnnotations->getWordLevel->getElements}) {
5625 0 $vocabulary{$word->getLemma($document)->canonical_form}++;
5626 }
5627 0 print join("\n", keys(%vocabulary)) . "\n";
5628 }
5629 }
5630  
5631 0 ▶sub _printTagSet {
Subroutine _printTagSet: not called CC=3 SCAR=24.8
5632 0 my ($self) = @_;
5633  
5634 0 my $word;
5635 my $lemma;
5636 0 my $document;
5637  
5638 0 my %Tagset;
5639  
5640 0 foreach $document (@{$self->_documentSet}) {
5641 0 foreach $word (@{$document->getAnnotations->getWordLevel->getElements}) {
5642 0 $Tagset{$word->getMorphoSyntacticFeatures($document)->syntactic_category}++;
5643 }
5644 0 print join("\n", keys(%Tagset)) . "\n";
5645 }
5646 }
5647  
5648 0 ▶sub _convert2ascii {
Subroutine _convert2ascii: not called CC=2 SCAR=17.9
5649 0 my($self, $str, $sep) = @_;
5650  
5651 0 ▶ if (!defined $sep) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $sep) 0 0 0
5652 0 $sep = "_";
5653 }
5654  
5655 0 $str =~ tr/è/e/;
5656 0 $str =~ tr/ÁÂÀÅÃÄÇÉÊÈËÍÎÌÏÑÓÔÓØÕÖÚÛÙÜÝáâàåãäçéêèëíîìïñóôòøõöúûùüý/AAAAAACEEEEIIIINOOOOOOUUUUYaaaaaaceeeeiiiinoooooouuuuy/;
5657  
5658 0 $str =~ s/æ/ae/g;
5659 0 $str =~ s/Æ/AE/g;
5660 0 $str =~ s/œ/oe/g;
5661 0 $str =~ s/Œ/OE/g;
5662  
5663 0 return(lc($str));
5664 }
5665  
5666  
5667 0 ▶sub _convertHTML {
Subroutine _convertHTML: not called CC=2 SCAR=17.9
5668 0 my($self, $str, $sep) = @_;
5669  
5670 0 ▶ if (!defined $sep) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $sep) 0 0 0
5671 0 $sep = "_";
5672 }
5673  
5674 0 $str =~ s/&amp;/\&/go;
5675 0 $str =~ s/&quot;/\"/og;
5676 0 $str =~ s/&apos;/\'/og;
5677 0 $str =~ s/&lt;/</og;
5678 0 $str =~ s/&gt;/>/og;
5679  
5680 0 return(lc($str));
5681 }
5682  
5683 0 ▶sub _convertChar {
Subroutine _convertChar: not called CC=2 SCAR=17.9
5684 0 my($self, $str, $sep) = @_;
5685  
5686 0 ▶ if (!defined $sep) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $sep) 0 0 0
5687 0 $sep = "_";
5688 }
5689  
5690 0 $str =~ s/\//$sep/g;
5691 0 $str =~ s/ +/$sep/g;
5692 0 $str =~ s/:/$sep/g;
5693 0 $str =~ s/!/$sep/g;
5694 0 $str =~ s/\?/$sep/g;
5695 0 $str =~ s/\&/$sep/g;
5696 0 $str =~ s/\'/$sep/g;
5697 0 $str =~ s/$sep+/$sep/g;
5698 # $str =~ s/\.+$//g;
5699 0 return(lc($str));
5700 }
5701  
5702 0 ▶sub findNamedEntityAfter {
Subroutine findNamedEntityAfter: not called CC=19 SCAR=59.4
Pod undocumented
5703 0 my ($self, $semantic_unit, $categories, $semanticFeatures, $document, $windowLimits, $wordLimit) = @_;
5704  
5705 0 my $token;
5706 my $term;
5707 0 my @relatedNE;
5708  
5709 0 my %words;
5710 0 my $reachedLimit = 0;
5711  
5712 0 $token = $semantic_unit->end_token;
5713 0 $token = $token->next;
5714  
5715 # warn "Limit: " . $windowLimits->{'after'} . "\n";
5716  
5717 0 ▶ while((defined $token) && ($token->getFrom <= $windowLimits->{'after'}) && ($reachedLimit == 0) && ((!defined $wordLimit) || (scalar(keys %words) < $wordLimit))) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $token and $token->getFrom <= $windowLimits->{"after"} and $reachedLimit == 0 and !defined($wordLimit) || scalar keys %words < $wordLimit) 0 0 0
Condition0%0/12
defined $token and $token->getFrom <= $windowLimits->{"after"} and $reachedLimit == 0 and !defined($wordLimit) || scalar keys %words < $wordLimit
!ll&&!rl&&r
000
defined $token and $token->getFrom <= $windowLimits->{"after"} and $reachedLimit == 0
!ll&&!rl&&r
000
defined $token and $token->getFrom <= $windowLimits->{"after"}
!ll&&!rl&&r
000
not defined $wordLimit or scalar keys %words < $wordLimit
l!l&&r!l&&!r
000
MC/DC0%0/5
defined $token and $token->getFrom <= $windowLimits->{"after"} and $reachedLimit == 0 and !defined($wordLimit) || scalar keys %words < $wordLimit
defined $token $token->getFrom <= $windowLimits->{"after"} $reachedLimit == 0 not defined $wordLimit scalar keys %words < $wordLimit
Truth table0%0/6
A and B and C and not(D) or E
A= defined $tokenB= $token->getFrom <= $windowLimits->{"after"}C= $reachedLimit == 0D= not defined $wordLimitE= scalar keys %words < $wordLimit
ABCDEresult
0XXXX0
10XXX0
110XX0
111000
1111X1
111011
5718 # warn ">token: " . $token->getContent . " (" . $token->getFrom . ")\n";
5719 0 my @words = @{$document->getAnnotations->getWordLevel->getElementByToken($token)};
5720 0 ▶ if (scalar(@words) > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @words > 0) 0 0 0
5721 0 $words{$words[0]->getId}++;
5722 }
5723 0 foreach $term (@{$document->getAnnotations->getSemanticUnitLevel->getElementByToken($token)}) {
5724 # warn "\t=> " . $term->getForm . "?\n";
5725 0 ▶ if ($term->isNamedEntity) {
Branch: 2 branches
BranchTrueFalseTotal
if ($term->isNamedEntity) { } 0 0 0
elsif (not $term->equals($semantic_unit) and $term->isTerm) { } 0 0 0
5726 # warn "named entity: " . $term->getForm . "\n";
5727 0 ▶ if (exists $categories->{$term->NEtype}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $$categories{$term->NEtype}) 0 0 0
5728 # warn "===\n";
5729 0 push @relatedNE, $term;
5730 0 $token = $term->end_token;
5731 }
5732 ▶ } elsif ((!$term->equals($semantic_unit)) && ($term->isTerm)# &&
Condition0%0/3
not $term->equals($semantic_unit) and $term->isTerm
!ll&&!rl&&r
000
MC/DC0%0/2
not $term->equals($semantic_unit) and $term->isTerm
not $term->equals($semantic_unit) $term->isTerm
Truth table0%0/3
not(A) and B
A= not $term->equals($semantic_unit)B= $term->isTerm
ABresult
0X0
100
111
5733 # ($document->getAnnotations->getSemanticUnitLevel->existsElement($term->getId))
5734 ) {
5735 0 ▶ if ((defined $semanticFeatures) && (scalar(keys %$semanticFeatures) > 0)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $semanticFeatures and scalar keys %$semanticFeatures > 0) { } 0 0 0
Condition0%0/3
defined $semanticFeatures and scalar keys %$semanticFeatures > 0
!ll&&!rl&&r
000
MC/DC0%0/2
defined $semanticFeatures and scalar keys %$semanticFeatures > 0
defined $semanticFeatures scalar keys %$semanticFeatures > 0
Truth table0%0/3
A and B
A= defined $semanticFeaturesB= scalar keys %$semanticFeatures > 0
ABresult
0X0
100
111
5736 0 ▶ if ($document->getAnnotations->getSemanticFeaturesLevel->existsElementFromIndex("refid_semantic_unit", $term->getId)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($document->getAnnotations->getSemanticFeaturesLevel->existsElementFromIndex("refid_semantic_unit", $term->getId)) 0 0 0
5737 0 my $semf = $document->getAnnotations->getSemanticFeaturesLevel->getElementFromIndex("refid_semantic_unit", $term->getId)->[0];
5738 0 ▶ if ((defined $semf) && ($semanticFeatures->{$semf->first_node_first_semantic_category})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $semf and $$semanticFeatures{$semf->first_node_first_semantic_category}) 0 0 0
Condition0%0/3
defined $semf and $$semanticFeatures{$semf->first_node_first_semantic_category}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $semf and $$semanticFeatures{$semf->first_node_first_semantic_category}
defined $semf $$semanticFeatures{$semf->first_node_first_semantic_category}
Truth table0%0/3
A and B
A= defined $semfB= $$semanticFeatures{$semf->first_node_first_semantic_category}
ABresult
0X0
100
111
5739 0 $reachedLimit = 1;
5740 }
5741 }
5742 } else {
5743 0 $reachedLimit = 1;
5744 }
5745 }
5746 }
5747 0 ▶ if ($token->isNum) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token->isNum) 0 0 0
5748 0 ▶ if (!$document->getAnnotations->getSemanticUnitLevel->existsElementFromIndex("list_refid_token",$token->getId)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($document->getAnnotations->getSemanticUnitLevel->existsElementFromIndex("list_refid_token", $token->getId)) 0 0 0
5749 0 warn "add numeric as quantities\n";
5750 0 my $namedEntity = Lingua::Ogmios::Annotations::SemanticUnit->newNamedEntity(
5751 {'form' => $token->getContent,
5752 'named_entity_type' => 'numeric_internal',
5753 'list_refid_token' => [$token],
5754 'canonical_form' => $token->getContent,
5755 });
5756 0 $document->getAnnotations->addSemanticUnit($namedEntity);
5757 0 push @relatedNE, $namedEntity;
5758 }
5759 }
5760 0 $token = $token->next;
5761 # warn ">next token: " . $token->getContent . " (" . $token->getFrom . ") ($reachedLimit)\n";
5762 };
5763 # warn "OUT\n";
5764 0 return(\@relatedNE);
5765 }
5766  
5767  
5768 0 ▶sub findNamedEntityBefore {
Subroutine findNamedEntityBefore: not called CC=20 SCAR=60.4
Pod undocumented
5769 0 my ($self, $semantic_unit, $categories, $semanticFeatures, $document, $windowLimits, $wordLimit) = @_;
5770  
5771 0 my $token;
5772 my $term;
5773 0 my @relatedNE;
5774  
5775 0 my $category = "modeadm";
5776 0 my %words;
5777 0 my $reachedLimit = 0;
5778  
5779 0 $token = $semantic_unit->start_token;
5780 0 $token = $token->previous;
5781 0 %words = ();
5782  
5783 # warn "Limit: " . $windowLimits->{'before'} . "\n";
5784  
5785 # warn "Semantic_unit: " . $semantic_unit->getForm . "\n";
5786 0 ▶ while((defined $token) && ($token->getFrom >= $windowLimits->{'before'}) && ($reachedLimit == 0) && ((!defined $wordLimit) || (scalar(keys %words) < $wordLimit))) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $token and $token->getFrom >= $windowLimits->{"before"} and $reachedLimit == 0 and !defined($wordLimit) || scalar keys %words < $wordLimit) 0 0 0
Condition0%0/12
defined $token and $token->getFrom >= $windowLimits->{"before"} and $reachedLimit == 0 and !defined($wordLimit) || scalar keys %words < $wordLimit
!ll&&!rl&&r
000
defined $token and $token->getFrom >= $windowLimits->{"before"} and $reachedLimit == 0
!ll&&!rl&&r
000
defined $token and $token->getFrom >= $windowLimits->{"before"}
!ll&&!rl&&r
000
not defined $wordLimit or scalar keys %words < $wordLimit
l!l&&r!l&&!r
000
MC/DC0%0/5
defined $token and $token->getFrom >= $windowLimits->{"before"} and $reachedLimit == 0 and !defined($wordLimit) || scalar keys %words < $wordLimit
defined $token $token->getFrom >= $windowLimits->{"before"} $reachedLimit == 0 not defined $wordLimit scalar keys %words < $wordLimit
Truth table0%0/6
A and B and C and not(D) or E
A= defined $tokenB= $token->getFrom >= $windowLimits->{"before"}C= $reachedLimit == 0D= not defined $wordLimitE= scalar keys %words < $wordLimit
ABCDEresult
0XXXX0
10XXX0
110XX0
111000
1111X1
111011
5787 # warn ">token: " . $token->getContent . " (" . $token->getFrom . ")\n";
5788 0 my @words = @{$document->getAnnotations->getWordLevel->getElementByToken($token)};
5789 0 ▶ if (scalar(@words) > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @words > 0) 0 0 0
5790 0 $words{$words[0]->getId}++;
5791 }
5792 # if (!$reachedLimit) {
5793 0 foreach $term (@{$document->getAnnotations->getSemanticUnitLevel->getElementByToken($token)}) {
5794 # warn "\t=> " . $term->getForm . "?\n";
5795 0 ▶ if ($term->isNamedEntity) {
Branch: 2 branches
BranchTrueFalseTotal
if ($term->isNamedEntity) { } 0 0 0
elsif (not $term->equals($semantic_unit) and $term->isTerm) { } 0 0 0
5796 # warn "named entity: " . $term->getForm . "\n";
5797 0 ▶ if ((!defined $categories) || (exists $categories->{$term->NEtype})) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $categories or exists $$categories{$term->NEtype}) 0 0 0
Condition0%0/3
not defined $categories or exists $$categories{$term->NEtype}
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $categories or exists $$categories{$term->NEtype}
not defined $categories exists $$categories{$term->NEtype}
Truth table0%0/3
not(A) or B
A= not defined $categoriesB= exists $$categories{$term->NEtype}
ABresult
1X1
011
000
5798 # warn "===\n";
5799 0 push @relatedNE, $term;
5800 0 $token = $term->start_token;
5801 }
5802 ▶ } elsif ((!$term->equals($semantic_unit)) && ($term->isTerm)) {
Condition0%0/3
not $term->equals($semantic_unit) and $term->isTerm
!ll&&!rl&&r
000
MC/DC0%0/2
not $term->equals($semantic_unit) and $term->isTerm
not $term->equals($semantic_unit) $term->isTerm
Truth table0%0/3
not(A) and B
A= not $term->equals($semantic_unit)B= $term->isTerm
ABresult
0X0
100
111
5803 0 ▶ if ((defined $semanticFeatures) && (scalar(keys %$semanticFeatures) > 0)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $semanticFeatures and scalar keys %$semanticFeatures > 0) { } 0 0 0
Condition0%0/3
defined $semanticFeatures and scalar keys %$semanticFeatures > 0
!ll&&!rl&&r
000
MC/DC0%0/2
defined $semanticFeatures and scalar keys %$semanticFeatures > 0
defined $semanticFeatures scalar keys %$semanticFeatures > 0
Truth table0%0/3
A and B
A= defined $semanticFeaturesB= scalar keys %$semanticFeatures > 0
ABresult
0X0
100
111
5804 0 ▶ if ($document->getAnnotations->getSemanticFeaturesLevel->existsElementFromIndex("refid_semantic_unit", $term->getId)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($document->getAnnotations->getSemanticFeaturesLevel->existsElementFromIndex("refid_semantic_unit", $term->getId)) 0 0 0
5805 0 my $semf = $document->getAnnotations->getSemanticFeaturesLevel->getElementFromIndex("refid_semantic_unit", $term->getId)->[0];
5806 0 ▶ if ((defined $semf) && ($semanticFeatures->{$semf->first_node_first_semantic_category})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $semf and $$semanticFeatures{$semf->first_node_first_semantic_category}) 0 0 0
Condition0%0/3
defined $semf and $$semanticFeatures{$semf->first_node_first_semantic_category}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $semf and $$semanticFeatures{$semf->first_node_first_semantic_category}
defined $semf $$semanticFeatures{$semf->first_node_first_semantic_category}
Truth table0%0/3
A and B
A= defined $semfB= $$semanticFeatures{$semf->first_node_first_semantic_category}
ABresult
0X0
100
111
5807 0 $reachedLimit = 1;
5808 }
5809 }
5810 } else {
5811 0 $reachedLimit = 1;
5812 }
5813 }
5814 # }
5815 }
5816 0 ▶ if ($token->isNum) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token->isNum) 0 0 0
5817 0 ▶ if (!$document->getAnnotations->getSemanticUnitLevel->existsElementFromIndex("list_refid_token",$token->getId)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($document->getAnnotations->getSemanticUnitLevel->existsElementFromIndex("list_refid_token", $token->getId)) 0 0 0
5818 0 warn "add numeric as quantities\n";
5819 0 my $namedEntity = Lingua::Ogmios::Annotations::SemanticUnit->newNamedEntity(
5820 {'form' => $token->getContent,
5821 'named_entity_type' => 'numeric_internal',
5822 'list_refid_token' => [$token],
5823 'canonical_form' => $token->getContent,
5824 });
5825 0 $document->getAnnotations->addSemanticUnit($namedEntity);
5826 0 push @relatedNE, $namedEntity;
5827 }
5828 }
5829 0 $token = $token->previous;
5830 # warn ">prevtoken: " . $token->getContent . " (" . $token->getFrom . ") ($reachedLimit)\n";
5831 };
5832 # warn "OUT\n";
5833 0 return(\@relatedNE);
5834 }
5835  
5836 0 ▶sub getWindowLimits {
Subroutine getWindowLimits: not called CC=47 SCAR=77.2
Pod undocumented
5837 0 my ($self, $semantic_unit, $document, $semanticFeatures, $goThroughtList, $additionalLimits) = @_;
5838  
5839 0 my $limitBeforeOffset;
5840 my $limitAfterOffset;
5841  
5842 0 my $token;
5843 # my $limitLine;
5844  
5845 # my $line = $termIdx->{$semantic_unit->type . $semantic_unit->getId}->{info_e}->[0];
5846 # my $E_char = $termIdx->{$semantic_unit->type . $semantic_unit->getId}->{info_e}->[1];
5847  
5848 # # warn "\nSearch Window limits for " . $semantic_unit->getForm . " from $line / $E_char (" . $semantic_unit->start_token->getFrom . ")\n";
5849  
5850 # # comput before limit
5851 # my $shift = 0;
5852 # do {
5853 # $limitLine = $line - 2 - $shift;
5854 # if ($limitLine < 1) {
5855 # $limitLine = 1;
5856 # }
5857 # $shift++;
5858 # } while(!exists($documentIndex->{"I2O"}->{"$limitLine:0"}));
5859 # $limitBeforeOffset = $documentIndex->{"I2O"}->{"$limitLine:0"}->[2];
5860
5861  
5862 # comput after limit
5863 # $limitLine = $line + 2;
5864 # if ($limitLine > $documentIndex->{"I2OMaxLine"}) {
5865 # $limitLine = $documentIndex->{"I2OMaxLine"};
5866 # }
5867 # $limitLine++;
5868 # $limitAfterOffset = $documentIndex->{"I2O"}->{"$limitLine:0"}->[2];
5869  
5870 0 my $regex;
5871 0 my $continue = 1;
5872 0 my $nexttoken;
5873 my $semf;
5874 0 my $term;
5875 0 my $word;
5876  
5877 0 my $lang = $document->getAnnotations->getLanguage;
5878 0 $token = $semantic_unit->end_token;
5879 # warn $semantic_unit->getId . "\n";
5880 # warn $semantic_unit->getForm . "\n";
5881 do {
5882 0 ▶ if ((!$document->getAnnotations->getSentenceLevel->existsElementFromIndex("refid_end_token", $token->getId)) &&
Branch: 1 branch
BranchTrueFalseTotal
if (not $document->getAnnotations->getSentenceLevel->existsElementFromIndex("refid_end_token", $token->getId) || $document->getAnnotations->getSectionLevel->existsElementFromIndex("to", $token->getId) and !(defined $additionalLimits && defined $additionalLimits->{"afterLimit"}) || $token->getFrom < $additionalLimits->{"afterLimit"}) 0 0 0
Condition0%0/12
not $document->getAnnotations->getSentenceLevel->existsElementFromIndex("refid_end_token", $token->getId) || $document->getAnnotations->getSectionLevel->existsElementFromIndex("to", $token->getId) and !(defined $additionalLimits && defined $additionalLimits->{"afterLimit"}) || $token->getFrom < $additionalLimits->{"afterLimit"}
!ll&&!rl&&r
000
$document->getAnnotations->getSentenceLevel->existsElementFromIndex('refid_end_token', $token->getId) || $document->getAnnotations->getSectionLevel->existsElementFromIndex('to', $token->getId)
l!l&&r!l&&!r
000
not defined $additionalLimits && defined $additionalLimits->{"afterLimit"} or $token->getFrom < $additionalLimits->{"afterLimit"}
l!l&&r!l&&!r
000
defined $additionalLimits && defined $additionalLimits->{'afterLimit'}
!ll&&!rl&&r
000
MC/DC0%0/5
not $document->getAnnotations->getSentenceLevel->existsElementFromIndex("refid_end_token", $token->getId) || $document->getAnnotations->getSectionLevel->existsElementFromIndex("to", $token->getId) and !(defined $additionalLimits && defined $additionalLimits->{"afterLimit"}) || $token->getFrom < $additionalLimits->{"afterLimit"}
$document->getAnnotations->getSentenceLevel->existsElementFromIndex('refid_end_token', $token->getId) $document->getAnnotations->getSectionLevel->existsElementFromIndex('to', $token->getId) defined $additionalLimits defined $additionalLimits->{'afterLimit'} $token->getFrom < $additionalLimits->{"afterLimit"}
Truth table0%0/6
not(A || B) and not(C && D) or E
A= $document->getAnnotations->getSentenceLevel->existsElementFromIndex('refid_end_token', $token->getId)B= $document->getAnnotations->getSectionLevel->existsElementFromIndex('to', $token->getId)C= defined $additionalLimitsD= defined $additionalLimits->{'afterLimit'}E= $token->getFrom < $additionalLimits->{"afterLimit"}
ABCDEresult
1XXXX0
01XXX0
001100
000XX1
0010X1
001111
5883 (!$document->getAnnotations->getSectionLevel->existsElementFromIndex("to", $token->getId)) &&
5884 ((!defined $additionalLimits) || (!defined $additionalLimits->{'afterLimit'}) || ($token->getFrom < $additionalLimits->{'afterLimit'}))) {
5885  
5886 0 $token = $token->next;
5887 # warn $token->getContent . "\n";
5888 0 foreach $term (@{$document->getAnnotations->getSemanticUnitLevel->getElementByToken($token)}) {
5889 0 ▶ if ($term->isTerm) {
Branch: 1 branch
BranchTrueFalseTotal
if ($term->isTerm) 0 0 0
5890 0 $semf = $document->getAnnotations->getSemanticFeaturesLevel->getElementFromIndex("refid_semantic_unit", $term->getId)->[0];
5891 0 ▶ if ((defined $semf) && (exists $semanticFeatures->{$semf->first_node_first_semantic_category})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $semf and exists $$semanticFeatures{$semf->first_node_first_semantic_category}) 0 0 0
Condition0%0/3
defined $semf and exists $$semanticFeatures{$semf->first_node_first_semantic_category}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $semf and exists $$semanticFeatures{$semf->first_node_first_semantic_category}
defined $semf exists $$semanticFeatures{$semf->first_node_first_semantic_category}
Truth table0%0/3
A and B
A= defined $semfB= exists $$semanticFeatures{$semf->first_node_first_semantic_category}
ABresult
0X0
100
111
5892 0 $continue = 0;
5893 0 $token = $token->previous;
5894 0 last;
5895 }
5896 }
5897 }
5898 0 ▶ if ($continue) {
Branch: 1 branch
BranchTrueFalseTotal
if ($continue) 0 0 0
5899 0 foreach $word (@{$document->getAnnotations->getWordLevel->getElementByToken($token)}) {
5900 0 ▶ if (exists($self->{'lexicon_limit_after'}->{$lang}->{$word->getForm})) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{"lexicon_limit_after"}{$lang}{$word->getForm}) 0 0 0
5901 # warn "find and\n";
5902 0 $continue = 0;
5903 0 $token = $word->start_token->previous;
5904 0 last;
5905 }
5906 }
5907 }
5908 # punctuation ?
5909 # Taking into account list ?
5910 0 $regex = $additionalLimits->{'afterRegex'};
5911 # warn "regex: $regex\n";
5912 0 ▶ if ((defined $regex) && ($token->getContent =~ /$regex/)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $regex and $token->getContent =~ /$regex/) 0 0 0
Condition0%0/3
defined $regex and $token->getContent =~ /$regex/
!ll&&!rl&&r
000
MC/DC0%0/2
defined $regex and $token->getContent =~ /$regex/
defined $regex $token->getContent =~ /$regex/
Truth table0%0/3
A and B
A= defined $regexB= $token->getContent =~ /$regex/
ABresult
0X0
100
111
5913 0 $continue = 0; #by default
5914
5915 0 ▶ if ($goThroughtList > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($goThroughtList > 0) 0 0 0
5916 # warn "this part of the code has not been checked\n";
5917 0 $nexttoken = $token;
5918 0 $token = $token->previous;
5919 do {
5920 0 $nexttoken = $nexttoken->next;
5921 } while(($nexttoken->isSep) &&
5922 (!$document->getAnnotations->getSentenceLevel->existsElementFromIndex("refid_end_token", $nexttoken->getId)) &&
5923 (!$document->getAnnotations->getSectionLevel->existsElementFromIndex("to", $nexttoken->getId)) &&
5924 0 ▶ ((!defined $additionalLimits) || ($nexttoken->getFrom < $additionalLimits->{'afterLimit'}))
Branch: 1 branch
BranchTrueFalseTotal
$nexttoken->isSep and not $document->getAnnotations->getSentenceLevel->existsElementFromIndex("refid_end_token", $nexttoken->getId) and not $document->getAnnotations->getSectionLevel->existsElementFromIndex("to", $nexttoken->getId) and !defined($additionalLimits) || $nexttoken->getFrom < $additionalLimits->{"afterLimit"} and do { do { $nexttoken = $nexttoken->next } } 0 0 0
Condition0%0/12
$nexttoken->isSep and not $document->getAnnotations->getSentenceLevel->existsElementFromIndex("refid_end_token", $nexttoken->getId) and not $document->getAnnotations->getSectionLevel->existsElementFromIndex("to", $nexttoken->getId) and !defined($additionalLimits) || $nexttoken->getFrom < $additionalLimits->{"afterLimit"}
!ll&&!rl&&r
000
$nexttoken->isSep and not $document->getAnnotations->getSentenceLevel->existsElementFromIndex("refid_end_token", $nexttoken->getId) and not $document->getAnnotations->getSectionLevel->existsElementFromIndex("to", $nexttoken->getId)
!ll&&!rl&&r
000
$nexttoken->isSep and not $document->getAnnotations->getSentenceLevel->existsElementFromIndex("refid_end_token", $nexttoken->getId)
!ll&&!rl&&r
000
not defined $additionalLimits or $nexttoken->getFrom < $additionalLimits->{"afterLimit"}
l!l&&r!l&&!r
000
MC/DC0%0/5
$nexttoken->isSep and not $document->getAnnotations->getSentenceLevel->existsElementFromIndex("refid_end_token", $nexttoken->getId) and not $document->getAnnotations->getSectionLevel->existsElementFromIndex("to", $nexttoken->getId) and !defined($additionalLimits) || $nexttoken->getFrom < $additionalLimits->{"afterLimit"}
$nexttoken->isSep not $document->getAnnotations->getSentenceLevel->existsElementFromIndex("refid_end_token", $nexttoken->getId) not $document->getAnnotations->getSectionLevel->existsElementFromIndex("to", $nexttoken->getId) not defined $additionalLimits $nexttoken->getFrom < $additionalLimits->{"afterLimit"}
Truth table0%0/6
A and not(B) and not(C) and not(D) or E
A= $nexttoken->isSepB= not $document->getAnnotations->getSentenceLevel->existsElementFromIndex("refid_end_token", $nexttoken->getId)C= not $document->getAnnotations->getSectionLevel->existsElementFromIndex("to", $nexttoken->getId)D= not defined $additionalLimitsE= $nexttoken->getFrom < $additionalLimits->{"afterLimit"}
ABCDEresult
0XXXX0
10XXX0
110XX0
111000
1111X1
111011
5925 );
5926
5927 0 foreach my $term (@{$document->getAnnotations->getSemanticUnitLevel->getElementByToken($nexttoken)}) {
5928 0 ▶ if ($term->isNamedEntity) {
Branch: 1 branch
BranchTrueFalseTotal
if ($term->isNamedEntity) 0 0 0
5929 # warn "find a named Entity: " . $document->getAnnotations->getSemanticUnitLevel->getElementByToken($nexttoken)->[0]->getForm
5930 # . "\n";
5931 0 $continue = 1;
5932 0 $token = $term->end_token;
5933 0 last;
5934 }
5935 }
5936 0 ▶ if (!$continue) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($continue) 0 0 0
5937 0 foreach $word (@{$document->getAnnotations->getWordLevel->getElementByToken($token)}) {
5938 0 ▶ if ($word->getForm eq "and") {
Branch: 1 branch
BranchTrueFalseTotal
if ($word->getForm eq "and") 0 0 0
5939 # warn "find and\n";
5940 0 $continue = 1;
5941 0 $token = $word->end_token;
5942 last
5943 0 }
5944 }
5945 }
5946 }
5947 }
5948 # warn "continue : $continue\n";
5949 }
5950 } while ((!$document->getAnnotations->getSentenceLevel->existsElementFromIndex("refid_end_token", $token->getId)) &&
5951 (!$document->getAnnotations->getSectionLevel->existsElementFromIndex("to", $token->getId)) &&
5952 0 ▶ ((!defined $additionalLimits) || (!defined $additionalLimits->{'afterLimit'}) || ($token->getFrom < $additionalLimits->{'afterLimit'})) &&
Branch: 1 branch
BranchTrueFalseTotal
not $document->getAnnotations->getSentenceLevel->existsElementFromIndex("refid_end_token", $token->getId) || $document->getAnnotations->getSectionLevel->existsElementFromIndex("to", $token->getId) and !(defined $additionalLimits && defined $additionalLimits->{"afterLimit"}) || $token->getFrom < $additionalLimits->{"afterLimit"} and $continue and do { do { if (not $document->getAnnotations->getSentenceLevel->existsElementFromIndex("refid_end_token", $token->getId) || $document->getAnnotations->getSectionLevel->existsElementFromIndex("to", $token->getId) and !(defined $additionalLimits && defined $additionalLimits->{"afterLimit"}) || $token->getFrom < $additionalLimits->{"afterLimit"}) { $token = $token->next; foreach $term (@{$document->getAnnotations->getSemanticUnitLevel->getElementByToken($token);}) { if ($term->isTerm) { $semf = $document->getAnnotations->getSemanticFeaturesLevel->getElementFromIndex("refid_semantic_unit", $term->getId)->[0]; if (defined $semf and exists $$semanticFeatures{$semf->first_node_first_semantic_category}) { $continue = 0; $token = $token->previous; last; } ; } ; } ; if ($continue) { foreach $word (@{$document->getAnnotations->getWordLevel->getElementByToken($token);}) { if (exists $self->{"lexicon_limit_after"}{$lang}{$word->getForm}) { $continue = 0; $token = $word->start_token->previous; last; } ; } ; } ; $regex = $additionalLimits->{"afterRegex"}; if (defined $regex and $token->getContent =~ /$regex/) { $continue = 0; if ($goThroughtList > 0) { $nexttoken = $token; $token = $token->previous; do { $nexttoken = $nexttoken->next } while $nexttoken->isSep and not $document->getAnnotations->getSentenceLevel->existsElementFromIndex("refid_end_token", $nexttoken->getId) and not $document->getAnnotations->getSectionLevel->existsElementFromIndex("to", $nexttoken->getId) and !defined($additionalLimits) || $nexttoken->getFrom < $additionalLimits->{"afterLimit"}; foreach my $term (@{$document->getAnnotations->getSemanticUnitLevel->getElementByToken($nexttoken);}) { if ($term->isNamedEntity) { $continue = 1; $token = $term->end_token; last; } ; } ; unless ($continue) { foreach $word (@{$document->getAnnotations->getWordLevel->getElementByToken($token);}) { if ($word->getForm eq "and") { $continue = 1; $token = $word->end_token; last; } ; } ; } ; } ; } ; } } } 0 0 0
Condition0%0/15
not $document->getAnnotations->getSentenceLevel->existsElementFromIndex("refid_end_token", $token->getId) || $document->getAnnotations->getSectionLevel->existsElementFromIndex("to", $token->getId) and !(defined $additionalLimits && defined $additionalLimits->{"afterLimit"}) || $token->getFrom < $additionalLimits->{"afterLimit"} and $continue
!ll&&!rl&&r
000
not $document->getAnnotations->getSentenceLevel->existsElementFromIndex("refid_end_token", $token->getId) || $document->getAnnotations->getSectionLevel->existsElementFromIndex("to", $token->getId) and !(defined $additionalLimits && defined $additionalLimits->{"afterLimit"}) || $token->getFrom < $additionalLimits->{"afterLimit"}
!ll&&!rl&&r
000
$document->getAnnotations->getSentenceLevel->existsElementFromIndex('refid_end_token', $token->getId) || $document->getAnnotations->getSectionLevel->existsElementFromIndex('to', $token->getId)
l!l&&r!l&&!r
000
not defined $additionalLimits && defined $additionalLimits->{"afterLimit"} or $token->getFrom < $additionalLimits->{"afterLimit"}
l!l&&r!l&&!r
000
defined $additionalLimits && defined $additionalLimits->{'afterLimit'}
!ll&&!rl&&r
000
MC/DC0%0/6
not $document->getAnnotations->getSentenceLevel->existsElementFromIndex("refid_end_token", $token->getId) || $document->getAnnotations->getSectionLevel->existsElementFromIndex("to", $token->getId) and !(defined $additionalLimits && defined $additionalLimits->{"afterLimit"}) || $token->getFrom < $additionalLimits->{"afterLimit"} and $continue
$document->getAnnotations->getSentenceLevel->existsElementFromIndex('refid_end_token', $token->getId) $document->getAnnotations->getSectionLevel->existsElementFromIndex('to', $token->getId) defined $additionalLimits defined $additionalLimits->{'afterLimit'} $token->getFrom < $additionalLimits->{"afterLimit"} $continue
Truth table0%0/9
not(A || B) and not(C && D) or E and F
A= $document->getAnnotations->getSentenceLevel->existsElementFromIndex('refid_end_token', $token->getId)B= $document->getAnnotations->getSectionLevel->existsElementFromIndex('to', $token->getId)C= defined $additionalLimitsD= defined $additionalLimits->{'afterLimit'}E= $token->getFrom < $additionalLimits->{"afterLimit"}F= $continue
ABCDEFresult
1XXXXX0
01XXXX0
00110X0
000XX00
0010X00
0011100
000XX11
0010X11
0011111
5953 ($continue)
5954 );
5955  
5956 0 $limitAfterOffset = $token->getFrom;
5957  
5958 # warn "Limit\n";
5959 # warn "\tAfter: " . $token->getContent . " (" . $token->getId . ")\n";
5960  
5961  
5962 # warn "search restricted window before\n";
5963 0 $token = $semantic_unit->start_token;
5964 0 $continue = 1;
5965 0 ▶ while ((!$document->getAnnotations->getSentenceLevel->existsElementFromIndex("refid_start_token", $token->getId)) &&
Branch: 1 branch
BranchTrueFalseTotal
if (not $document->getAnnotations->getSentenceLevel->existsElementFromIndex("refid_start_token", $token->getId) || $document->getAnnotations->getSectionLevel->existsElementFromIndex("from", $token->getId) and !(defined $additionalLimits && defined $additionalLimits->{"beforeLimit"}) || $token->getFrom < $additionalLimits->{"beforeLimit"} and $continue) 0 0 0
Condition0%0/15
not $document->getAnnotations->getSentenceLevel->existsElementFromIndex("refid_start_token", $token->getId) || $document->getAnnotations->getSectionLevel->existsElementFromIndex("from", $token->getId) and !(defined $additionalLimits && defined $additionalLimits->{"beforeLimit"}) || $token->getFrom < $additionalLimits->{"beforeLimit"} and $continue
!ll&&!rl&&r
000
not $document->getAnnotations->getSentenceLevel->existsElementFromIndex("refid_start_token", $token->getId) || $document->getAnnotations->getSectionLevel->existsElementFromIndex("from", $token->getId) and !(defined $additionalLimits && defined $additionalLimits->{"beforeLimit"}) || $token->getFrom < $additionalLimits->{"beforeLimit"}
!ll&&!rl&&r
000
$document->getAnnotations->getSentenceLevel->existsElementFromIndex('refid_start_token', $token->getId) || $document->getAnnotations->getSectionLevel->existsElementFromIndex('from', $token->getId)
l!l&&r!l&&!r
000
not defined $additionalLimits && defined $additionalLimits->{"beforeLimit"} or $token->getFrom < $additionalLimits->{"beforeLimit"}
l!l&&r!l&&!r
000
defined $additionalLimits && defined $additionalLimits->{'beforeLimit'}
!ll&&!rl&&r
000
MC/DC0%0/6
not $document->getAnnotations->getSentenceLevel->existsElementFromIndex("refid_start_token", $token->getId) || $document->getAnnotations->getSectionLevel->existsElementFromIndex("from", $token->getId) and !(defined $additionalLimits && defined $additionalLimits->{"beforeLimit"}) || $token->getFrom < $additionalLimits->{"beforeLimit"} and $continue
$document->getAnnotations->getSentenceLevel->existsElementFromIndex('refid_start_token', $token->getId) $document->getAnnotations->getSectionLevel->existsElementFromIndex('from', $token->getId) defined $additionalLimits defined $additionalLimits->{'beforeLimit'} $token->getFrom < $additionalLimits->{"beforeLimit"} $continue
Truth table0%0/9
not(A || B) and not(C && D) or E and F
A= $document->getAnnotations->getSentenceLevel->existsElementFromIndex('refid_start_token', $token->getId)B= $document->getAnnotations->getSectionLevel->existsElementFromIndex('from', $token->getId)C= defined $additionalLimitsD= defined $additionalLimits->{'beforeLimit'}E= $token->getFrom < $additionalLimits->{"beforeLimit"}F= $continue
ABCDEFresult
1XXXXX0
01XXXX0
00110X0
000XX00
0010X00
0011100
000XX11
0010X11
0011111
5966 (!$document->getAnnotations->getSectionLevel->existsElementFromIndex("from", $token->getId)) &&
5967 ((!defined $additionalLimits) || (!defined $additionalLimits->{'beforeLimit'}) || ($token->getFrom < $additionalLimits->{'beforeLimit'})) &&
5968 ($continue)
5969 ) {
5970 0 $token = $token->previous;
5971 0 foreach $term (@{$document->getAnnotations->getSemanticUnitLevel->getElementByToken($token)}) {
5972 0 ▶ if ($term->isTerm) {
Branch: 1 branch
BranchTrueFalseTotal
if ($term->isTerm) 0 0 0
5973 0 $semf = $document->getAnnotations->getSemanticFeaturesLevel->getElementFromIndex("refid_semantic_unit", $term->getId)->[0];
5974 0 ▶ if ((defined $semf) && (exists $semanticFeatures->{$semf->first_node_first_semantic_category})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $semf and exists $$semanticFeatures{$semf->first_node_first_semantic_category}) 0 0 0
Condition0%0/3
defined $semf and exists $$semanticFeatures{$semf->first_node_first_semantic_category}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $semf and exists $$semanticFeatures{$semf->first_node_first_semantic_category}
defined $semf exists $$semanticFeatures{$semf->first_node_first_semantic_category}
Truth table0%0/3
A and B
A= defined $semfB= exists $$semanticFeatures{$semf->first_node_first_semantic_category}
ABresult
0X0
100
111
5975 0 $continue = 0;
5976 0 $token = $token->next;
5977 0 last;
5978 }
5979 }
5980 }
5981 0 ▶ if ($continue) {
Branch: 1 branch
BranchTrueFalseTotal
if ($continue) 0 0 0
5982 0 foreach $word (@{$document->getAnnotations->getWordLevel->getElementByToken($token)}) {
5983 0 ▶ if (exists($self->{'lexicon_limit_after'}->{$lang}->{$word->getForm})) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{"lexicon_limit_after"}{$lang}{$word->getForm}) 0 0 0
5984 # warn "find and\n";
5985 0 $continue = 0;
5986 0 $token = $word->start_token->previous;
5987 0 last;
5988 }
5989 }
5990 }
5991 0 $regex = $additionalLimits->{'beforeRegex'};
5992 # warn "regex: $regex\n";
5993 0 ▶ if ((defined $regex) && ($token->getContent =~ /$regex/)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $regex and $token->getContent =~ /$regex/) { } 0 0 0
Condition0%0/3
defined $regex and $token->getContent =~ /$regex/
!ll&&!rl&&r
000
MC/DC0%0/2
defined $regex and $token->getContent =~ /$regex/
defined $regex $token->getContent =~ /$regex/
Truth table0%0/3
A and B
A= defined $regexB= $token->getContent =~ /$regex/
ABresult
0X0
100
111
5994 0 $continue = 0; #by default
5995 0 $token = $token->next;
5996 } else {
5997 # warn "OK\n";
5998 }
5999 } ;
6000 0 $limitBeforeOffset = $token->getFrom;
6001 # warn "\tBefore: " . $token->getContent . "\n";
6002  
6003 0 return($limitBeforeOffset, $limitAfterOffset);
6004 }
6005  
6006 0 ▶sub _addRelation_NE_Term {
Subroutine _addRelation_NE_Term: not called CC=16 SCAR=56.1
6007 0 my ($self, $document, $semantic_feature_list, $additionalLimits, $correspondanceList) = @_;
6008  
6009 0 my $lang = $document->getAnnotations->getLanguage;
6010 0 my $term;
6011 my $semcat;
6012 0 my $semf;
6013 0 my $termlist;
6014 0 my @named_entities;
6015 0 my %limits;
6016 0 my $named_entity;
6017  
6018 0 foreach $term (@{$document->getAnnotations->getSemanticUnitLevel->getElements}) {
6019 0 ▶ if (($term->isTerm) && (defined $term->getSemanticFeatureFC($document))) {
Branch: 1 branch
BranchTrueFalseTotal
if ($term->isTerm and defined $term->getSemanticFeatureFC($document)) 0 0 0
Condition0%0/3
$term->isTerm and defined $term->getSemanticFeatureFC($document)
!ll&&!rl&&r
000
MC/DC0%0/2
$term->isTerm and defined $term->getSemanticFeatureFC($document)
$term->isTerm defined $term->getSemanticFeatureFC($document)
Truth table0%0/3
A and B
A= $term->isTermB= defined $term->getSemanticFeatureFC($document)
ABresult
0X0
100
111
6020 0 foreach $semf (@{$document->getAnnotations->getSemanticFeaturesLevel->getElementFromIndex("refid_semantic_unit", $term->getId)}) {
6021 0 $termlist = 0;
6022 0 foreach $semcat (@{$semf->semantic_category}) {
6023 0 ▶ if (!defined $semantic_feature_list) {
Branch: 2 branches
BranchTrueFalseTotal
if (not defined $semantic_feature_list) { } 0 0 0
elsif (exists $$semantic_feature_list{$semcat->[0]}) { } 0 0 0
6024 0 $termlist++;
6025 } elsif (exists($semantic_feature_list->{$semcat->[0]})) {
6026 0 $termlist++;
6027 }
6028 }
6029 }
6030 0 ▶ if ($termlist > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($termlist > 0) { } 0 0 0
6031 # warn "find named entities for " . $term->getForm . "(" . $term->getFrom . ")\n";
6032 0 @named_entities = ();
6033 0 ($limits{'before'}, $limits{'after'}) = $self->getWindowLimits($term, $document, undef, 0, $additionalLimits);
6034 0 push @named_entities, @{$self->findNamedEntityBefore($term, $self->{'named_entity_categories'}->{$lang}, undef, $document, \%limits, undef)};
6035 # warn "\tfound " . scalar(@named_entities) . " named entities (before)\n";
6036 0 push @named_entities, @{$self->findNamedEntityAfter($term, $self->{'named_entity_categories'}->{$lang}, undef, $document, \%limits, undef)};
6037 # warn "\tfound " . scalar(@named_entities) . " named entities (after)\n";
6038 0 foreach $named_entity (@named_entities) {
6039 0 ▶ if ($named_entity->NEtype eq 'numeric_internal') {
Branch: 1 branch
BranchTrueFalseTotal
if ($named_entity->NEtype eq 'numeric_internal') { } 0 0 0
6040 0 ▶ if ((defined $correspondanceList) && (exists $correspondanceList->{$term->getSemanticFeatureFC($document)})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $correspondanceList and exists $$correspondanceList{$term->getSemanticFeatureFC($document)}) 0 0 0
Condition0%0/3
defined $correspondanceList and exists $$correspondanceList{$term->getSemanticFeatureFC($document)}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $correspondanceList and exists $$correspondanceList{$term->getSemanticFeatureFC($document)}
defined $correspondanceList exists $$correspondanceList{$term->getSemanticFeatureFC($document)}
Truth table0%0/3
A and B
A= defined $correspondanceListB= exists $$correspondanceList{$term->getSemanticFeatureFC($document)}
ABresult
0X0
100
111
6041 # warn "change NE type in " . $corresondanceList->{$term->getSemanticFeatureFC($document)} . "\n";
6042 0 $named_entity->NEtype($correspondanceList->{$term->getSemanticFeatureFC($document)});
6043 0 $term->incr_weight('quantified', 1);
6044 }
6045 } else {
6046 0 $term->incr_weight('quantified', 1);
6047 }
6048 # warn "add relation between " . $term->getForm . " (" . $term->getId . ") and " . $named_entity->getForm . "\n";
6049 0 $document->getAnnotations->addDomainSpecificRelation(
6050 Lingua::Ogmios::Annotations::DomainSpecificRelation->new(
6051 {'domain_specific_relation_type' => "has_quantity",
6052 'list_refid_semantic_unit' => [$term, $named_entity]
6053 })
6054 );
6055 }
6056 0 ▶ if (scalar(@named_entities) == 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @named_entities == 0) 0 0 0
6057 0 ▶ if (!$term->existsWeight('quantified')) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($term->existsWeight("quantified")) 0 0 0
6058 0 $term->weight('quantified', 0);
6059 }
6060 }
6061 } else {
6062 0 ▶ if (!$term->existsWeight('quantified')) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($term->existsWeight("quantified")) 0 0 0
6063 0 $term->weight('quantified', 0);
6064 }
6065
6066 }
6067 }
6068 }
6069 }
6070  
6071 0 ▶sub _arff2deft {
Subroutine _arff2deft: not called CC=1 SCAR=6.9
6072 0 my ($self, $value) = @_;
6073 #[A-Z]
6074 # [a-z]
6075 0 $value =~ tr/ÁÂÀÅÃÄÇÉÊÈËÍÎÌÏÑÓÔÓØÕÖÚÛÙÜÝáâàåãäçéêèëíîìïñóôòøõöúûùüý[A-Z]/AAAAAACEEEEIIIINOOOOOOUUUUYaaaaaaceeeeiiiinoooooouuuuy[a-z]/;
6076 # $value =~ tr/ÁÂÀÅÃÄÇÉÊÈËÍÎÌÏÑÓÔÓØÕÖÚÛÙÜÝáâàåãäçéêèëíîìïñóôòøõöúûùüý/AAAAAACEEEEIIIINOOOOOOUUUUYaaaaaaceeeeiiiinoooooouuuuy/;
6077 # $value =~ tr/é[A-Z]/e[a-z]/;
6078 # $value = lc($value);
6079 # $str =~ $value =~ tr/ÁÂÀÅÃÄ/AAAAAA/;
6080 # $str =~ $value =~ tr/ÇÉÊÈËÍÎÌÏÑÓÔÓØÕÖÚÛÙÜÝ/CEEEEIIIINOOOOOOUUUUY/;
6081 # $str =~ $value =~ tr/áâàåãäçéêèëíîìïñóôòøõöúûùüý/aaaaaaceeeeiiiinoooooouuuuy/;
6082 # $str =~ $value =~ tr/[A-Z]/[a-z]/;
6083 # $str =~ s/é/e/g;
6084 # $str =~
6085 # $value =~ tr/ÁÂÀÅÃÄÇÉÊÈËÍÎÌÏÑÓÔÓØÕÖÚÛÙÜÝáâàåãäçéêèëíîìïñóôòøõöúûùüý[A-Z]/AAAAAACEEEEIIIINOOOOOOUUUUYaaaaaaceeeeiiiinoooooouuuuy[a-z]/;
6086 # $str =~
6087 # $value =~ tr/ÁÂÀÅÃÄÇÉÊÈËÍÎÌÏÑÓÔÓØÕÖÚÛÙÜÝáâàåãäçéêèëíîìïñóôòøõöúûùüý[A-Z]/AAAAAACEEEEIIIINOOOOOOUUUUYaaaaaaceeeeiiiinoooooouuuuy[a-z]/;
6088 # $str =~
6089 # $value =~ tr/ÁÂÀÅÃÄÇÉÊÈËÍÎÌÏÑÓÔÓØÕÖÚÛÙÜÝáâàåãäçéêèëíîìïñóôòøõöúûùüý[A-Z]/AAAAAACEEEEIIIINOOOOOOUUUUYaaaaaaceeeeiiiinoooooouuuuy[a-z]/;
6090 0 $value =~ s/æ/ae/g;
6091 0 $value =~ s/Æ/AE/g;
6092 0 $value =~ s/œ/oe/g;
6093 0 $value =~ s/Œ/OE/g;
6094 0 $value =~ s/&amp;/\&/go;
6095 0 $value =~ s/&quot;/\"/og;
6096 0 $value =~ s/&apos;/\'/og;
6097 0 $value =~ s/&lt;/</og;
6098 0 $value =~ s/&gt;/>/og;
6099 0 $value =~ s/œ/oe/og;
6100 0 $value =~ s/\//_/g;
6101 0 $value =~ s/ +/_/g;
6102 0 $value =~ s/:/_/g;
6103 0 $value =~ s/!/_/g;
6104 0 $value =~ s/\?/_/g;
6105 0 $value =~ s/\&/_/g;
6106 0 $value =~ s/\'/_/g;
6107 0 $value =~ s/_+/_/g;
6108 0 $value =~ s/_/ /go;
6109 0 $value =~ s/\n/ /go;
6110 0 $value =~ s/ +$//go;
6111 0 $value =~ s/^ +//go;
6112 0 $value =~ s/ /-/go;
6113 # warn "=====> $value\n";
6114  
6115 0 return($value);
6116 }
6117  
6118 0 ▶sub char_norm {
Subroutine char_norm: not called CC=1 SCAR=6.9
Pod undocumented
6119 0 my ($self, $str) = @_;
6120  
6121 0 $str =~ s/œ/oe/go;
6122 0 $str =~ s/ / /go;
6123 0 $str =~ s/’/'/go;
6124 0 $str =~ s/´/'/go;
6125 0 $str =~ s/•/-/go;
6126 0 $str =~ s/`/'/go;
6127 0 $str =~ s/“/ /go;
6128 0 $str =~ s/”/ /go;
6129 0 $str =~ s/‘/'/go;
6130 0 $str =~ s/œ/oe/og;
6131 0 $str =~ s/……/....../go;
6132 0 $str =~ s/þ//go;
6133 0 $str =~ s/([\.:;,?!])([A-Za-z])/$1 $2/go;
6134  
6135 0 return($str);
6136 }
6137  
6138 0 ▶sub _deft2arff {
Subroutine _deft2arff: not called CC=1 SCAR=6.9
6139 0 my ($self, $value) = @_;
6140  
6141 0 $value =~ s/ /_/go;
6142  
6143 0 return($value);
6144 }
6145  
6146 0 ▶sub _makeHeader {
Subroutine _makeHeader: not called CC=7 SCAR=40.3
6147 0 my ($self, $lang, $relation, $property, $classes) = @_;
6148  
6149 0 my $attr;
6150 my $LDS;
6151 0 my $type;
6152  
6153 0 $LDS = Lingua::Ogmios::LearningDataSet->new();
6154 0 $LDS->relation($relation);
6155 0 $LDS->classes($classes);
6156 0 ▶ if (defined $self->{"attribute_file"}->{$lang}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{'attribute_file'}{$lang}) { } 0 0 0
6157 0 warn "read from filelist\n";
6158 0 $self->_readAttributeList($lang, $relation, $property, $classes, $LDS);
6159 } else {
6160 0 warn "read from lists\n";
6161 0 foreach $attr (sort {$a->{ORDER} <=> $b->{ORDER}} values %{$self->{ATTRIBUTES}->{$lang}}) {
6162 0 ▶ if (defined $attr->{FILE}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $attr->{'FILE'}) { } 0 0 0
6163 # warn "==>" . $attr->{FILE} . "\n";
6164 0 $self->_load_attribute_file($attr->{FILE}, $attr->{TYPE}, $attr->{PREFIX}, $LDS);
6165 } else {
6166 0 ▶ if (defined $attr->{VALUE}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $attr->{"VALUE"}) 0 0 0
6167 # warn $attr->{VALUE} ."\n";
6168 0 my @typeValue = split /,/,$self->_deft2arff($attr->{TYPE});
6169  
6170 0 ▶ if (scalar(@typeValue) > 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @typeValue > 1) { } 0 0 0
6171 0 $type = \@typeValue;
6172 } else {
6173 0 $type = $self->_deft2arff($attr->{TYPE});
6174 }
6175 my $attribute = Lingua::Ogmios::LearningDataSet::Attribute->new(
6176 {"name" => $attr->{PREFIX} . "_" . $attr->{VALUE},
6177 "type" => $type,
6178 "prefix" => $attr->{PREFIX},
6179 "value" => $attr->{VALUE},
6180 }
6181 0 );
6182 # my $idx =
6183 0 $LDS->addAttribute($attribute);
6184 # warn "\t$idx\n";
6185 # $attribute = Lingua::Ogmios::LearningDataSet::Attribute->new(
6186 # {"name" => $attr->{PREFIX} . "_" . $attr->{VALUE},
6187 # "type" => [split /,/, $self->_deft2arff($attr->{TYPE})],
6188 # }
6189 # );
6190 # $LDS->addAttribute($attribute);
6191 }
6192 }
6193 }
6194 }
6195 0 ▶ if (defined $self->{ATTRIBUTES}->{$lang}->{DOCUMENTFREQUENCY}->{FILE}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"ATTRIBUTES"}{$lang}{"DOCUMENTFREQUENCY"}{"FILE"}) 0 0 0
6196 0 $self->{"attr2df"}->{$lang} = {};
6197 0 $self->_load_df_values($self->{ATTRIBUTES}->{$lang}->{DOCUMENTFREQUENCY}->{FILE}, $self->{"attr2df"}->{$lang});
6198 }
6199
6200 0 return($LDS);
6201 }
6202  
6203 0 ▶sub _load_attribute_file {
Subroutine _load_attribute_file: not called CC=4 SCAR=30.0
6204 0 my ($self,$file, $type, $prefix, $LDS) = @_;
6205 0 my $line;
6206 my $attr;
6207 0 my $attr_str;
6208 0 my $freq;
6209  
6210 0 warn "Loading $file ($type : $prefix)\n";
6211 0 ▶ open FILE, $file or die "No such file $file\n";
Branch: 1 branch
BranchTrueFalseTotal
open FILE, $file or die "No such file $file\n" 0 0 0
6212 0 binmode(FILE, ':utf8');
6213 0 ▶ while($line = <FILE>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($line = readline FILE)) 0 0 0
6214 0 chomp $line;
6215  
6216 0 ▶ if ($line !~ /^\s*#/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($line =~ /^\s*#/) 0 0 0
6217 0 ($attr_str, $freq) = split /\t/, $line;
6218 0 my $attr = Lingua::Ogmios::LearningDataSet::Attribute->new(
6219 {"name" => $prefix . "_" . $self->_deft2arff($self->_arff2deft($attr_str)),
6220 "type" => uc($type),
6221 "prefix" => $prefix,
6222 "value" => $attr_str,
6223  
6224 }
6225 );
6226 0 $LDS->addAttribute($attr);
6227  
6228 }
6229 }
6230 0 close FILE;
6231 }
6232  
6233  
6234 0 ▶sub _load_df_values {
Subroutine _load_df_values: not called CC=5 SCAR=34.0
6235 0 my ($self,$file, $attr2freq) = @_;
6236  
6237 0 my $line;
6238 my $attr_str;
6239 0 my $freq;
6240  
6241 0 warn "Loading $file (document frequency)\n";
6242 0 ▶ open FILE, $file or die "No such file $file\n";
Branch: 1 branch
BranchTrueFalseTotal
open FILE, $file or die "No such file $file\n" 0 0 0
6243 0 binmode(FILE, ':utf8');
6244 0 ▶ while($line = <FILE>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($line = readline FILE)) 0 0 0
6245 0 chomp $line;
6246  
6247 0 ▶ if ($line !~ /^\s*#/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($line =~ /^\s*#/) 0 0 0
6248 0 ($attr_str, $freq) = split /\t/, $line;
6249 0 ▶ if (defined $attr2freq) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $attr2freq) 0 0 0
6250 0 $attr2freq->{$self->_deft2arff($self->_arff2deft($attr_str))} = $freq;
6251 }
6252 }
6253 }
6254 0 close FILE;
6255 }
6256  
6257  
6258 0 ▶sub _readAttributeList {
Subroutine _readAttributeList: not called CC=6 SCAR=37.4
6259 0 my ($self, $lang, $relation, $property, $classes, $LDS) = @_;
6260  
6261 0 my $section;
6262 my $attr;
6263 0 my $string;
6264 0 my $attr_str;
6265 0 my $attr_str_wprefix;
6266 0 my $type;
6267 0 my $line;
6268 0 my $order;
6269 0 my $prefix;
6270  
6271 0 warn "readAttributeList ($relation - $property)\n";
6272  
6273 0 warn "Open " . $self->{"attribute_file"}->{$lang} . "\n";
6274 0 ▶ open FILE, $self->{"attribute_file"}->{$lang} or die "No such file ". $self->{"attribute_file"}->{$lang};
Branch: 1 branch
BranchTrueFalseTotal
open FILE, $self->{"attribute_file"}{$lang} or die 'No such file ' . $self->{"attribute_file"}{$lang} 0 0 0
6275 0 binmode(FILE, ":utf8");
6276 0 ▶ while($line = <FILE>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($line = readline FILE)) 0 0 0
6277 0 chomp $line;
6278  
6279 0 ▶ if ($line !~ /^\s*#/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($line =~ /^\s*#/) 0 0 0
6280 0 $prefix = undef;
6281 0 ($attr_str, $attr_str_wprefix, $type, $prefix) = split /\t/, $line;
6282 0 ▶ if (!exists $self->{ATTRIBUTES}->{$lang}->{uc($attr_str)}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $self->{"ATTRIBUTES"}{$lang}{uc $attr_str}) 0 0 0
6283 0 ▶ if (!defined $prefix) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $prefix) 0 0 0
6284 0 ($prefix, ) = split /_/, $attr_str_wprefix;
6285 }
6286 0 $self->{ATTRIBUTES}->{$lang}->{uc($prefix)}->{PREFIX} = $prefix;
6287 0 $self->{ATTRIBUTES}->{$lang}->{uc($prefix)}->{TYPE} = $type;
6288 }
6289 0 my $attr = Lingua::Ogmios::LearningDataSet::Attribute->new(
6290 {"name" => $self->_deft2arff($attr_str_wprefix),
6291 "type" => $self->_deft2arff($type),
6292 "prefix" => $prefix,
6293 "value" => $attr_str,
6294 }
6295 );
6296 0 $LDS->addAttribute($attr);
6297 }
6298 }
6299 0 close FILE;
6300  
6301 ###
6302  
6303 # foreach $document (@{$self->_documentSet}) {
6304 # foreach $word (@{$document->getAnnotations->getWordLevel->getElements}) {
6305 # $self->_postag_attribute($document, $LDS, $data, $word);
6306 # $self->_word_attribute($document, $LDS, $data, $word);
6307 # $self->_lemma_attribute($document, $LDS, $data, $word);
6308 # }
6309 # $self->_semtag_attribute($document, $LDS, $data);
6310 # }
6311 # $self->LDS($lang, $LDS);
6312 0 warn "done\n";
6313 }
6314  
6315 0 ▶sub _printLearningSet {
Subroutine _printLearningSet: not called CC=5 SCAR=34.0
6316 0 my ($self, $lang, $output, $fh, $printHeader) = @_;
6317  
6318 0 my $LDS = $self->LDS($lang);
6319  
6320 0 ▶ if ($output eq "ARFF+SVM") {
Branch: 1 branch
BranchTrueFalseTotal
if ($output eq "ARFF+SVM") 0 0 0
6321 0 print $fh "ARFF|";
6322 0 print $fh $LDS->getARFFData;
6323 0 print $fh "SVM|";
6324 0 print $fh $LDS->getSVM;
6325 }
6326 0 ▶ if ($output eq "ARFF") {
Branch: 1 branch
BranchTrueFalseTotal
if ($output eq "ARFF") 0 0 0
6327 0 ▶ if ($printHeader == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($printHeader == 1) 0 0 0
6328 0 print $fh $LDS->getARFFHeader;
6329 0 print $fh '@DATA' . "\n";
6330 }
6331 0 print $fh $LDS->getARFFData;
6332 }
6333 0 ▶ if ($output eq "SVM") {
Branch: 1 branch
BranchTrueFalseTotal
if ($output eq "SVM") 0 0 0
6334 0 print $fh $LDS->getSVM;
6335 }
6336 }
6337  
6338 0 ▶sub LDS {
Subroutine LDS: not called CC=2 SCAR=17.9
Pod undocumented
6339 0 my $self = shift;
6340 0 my $lang = shift;
6341  
6342 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
6343 0 $self->{'LDS'} = shift;
6344 }
6345 0 return($self->{'LDS'});
6346 }
6347  
6348  
6349 0 ▶sub _termWeight_attribute {
Subroutine _termWeight_attribute: not called CC=6 SCAR=37.4
6350 0 my ($self, $document, $LDS, $data, $term) = @_;
6351  
6352 0 my $lang = $document->getAnnotations->getLanguage;
6353 0 my $string;
6354 my $weight;
6355 0 my @weights;
6356  
6357 0 ▶ if (defined $self->{ATTRIBUTES}->{$lang}->{WEIGHT}->{PREFIX}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"ATTRIBUTES"}{$lang}{"WEIGHT"}{"PREFIX"}) 0 0 0
6358 0 my $prefix = $self->{ATTRIBUTES}->{$lang}->{WEIGHT}->{PREFIX};
6359 # warn "=> $prefix\n";
6360 0 foreach $weight (keys %{$term->weights}) {
6361 # warn "====> $weight\n";
6362 # $string = $prefix . "_" . $self->_deft2arff($self->_arff2deft($weight));
6363 0 $string = $prefix . "_" . $self->_deft2arff($weight);
6364 # warn "$string\n";
6365 0 ▶ if ($LDS->existsAttribute($string)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($LDS->existsAttribute($string)) 0 0 0
6366 0 $data->value($LDS->getAttributeIndex($string), $term->weight($weight));
6367 # $data->incr_value($LDS->getAttributeIndex($string));
6368 }
6369 }
6370 0 ▶ if ($LDS->existsAttribute($prefix . "_position")) {
Branch: 1 branch
BranchTrueFalseTotal
if ($LDS->existsAttribute($prefix . '_position')) 0 0 0
6371 # warn "====> position\n";
6372 0 $data->value($LDS->getAttributeIndex($prefix . "_position"), $term->start_token->getFrom);
6373 }
6374 0 ▶ if ($LDS->existsAttribute($prefix . "_wordLength")) {
Branch: 1 branch
BranchTrueFalseTotal
if ($LDS->existsAttribute($prefix . '_wordLength')) 0 0 0
6375 # warn "====> position\n";
6376 0 $data->value($LDS->getAttributeIndex($prefix . "_wordLength"), $term->getReferenceWordSize);
6377 }
6378
6379 }
6380 }
6381  
6382 0 ▶sub _termWeight_attribute_v2 {
Subroutine _termWeight_attribute_v2: not called CC=6 SCAR=37.4
6383 0 my ($self, $document, $LDS, $data, $term) = @_;
6384  
6385 0 my $lang = $document->getAnnotations->getLanguage;
6386 0 my $string;
6387 my $attr;
6388 0 my $weight;
6389  
6390 0 ▶ if (defined $self->{ATTRIBUTES}->{$lang}->{WEIGHT}->{PREFIX}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"ATTRIBUTES"}{$lang}{"WEIGHT"}{"PREFIX"}) 0 0 0
6391 0 my $prefix = $self->{ATTRIBUTES}->{$lang}->{WEIGHT}->{PREFIX};
6392 0 foreach $attr (keys %{$LDS->attributes}) {
6393 0 ▶ if ($attr->prefix eq "weight") {
Branch: 1 branch
BranchTrueFalseTotal
if ($attr->prefix eq "weight") 0 0 0
6394 0 $weight = $attr->value;
6395 # $string = $prefix . "_" . $self->_deft2arff($self->_arff2deft($term->weight($weight)));
6396 0 $string = $prefix . "_" . $self->_deft2arff($term->weight($weight));
6397 # warn "$string\n";
6398 0 ▶ if ($term->existsWeight($weight)) {
Branch: 2 branches
BranchTrueFalseTotal
if ($term->existsWeight($weight)) { } 0 0 0
elsif ($weight eq 'position') { } 0 0 0
6399 0 $data->value($LDS->getAttributeIndex($string), $term->weight($weight));
6400 } elsif ($weight eq "position") {
6401 0 $data->value($LDS->getAttributeIndex($string), $term->start_token->getFrom);
6402 }
6403  
6404 }
6405 }
6406 }
6407 }
6408  
6409 0 ▶sub _parseWekaEvalOutput {
Subroutine _parseWekaEvalOutput: not called CC=6 SCAR=37.4
6410 0 my ($self, $property) = @_;
6411  
6412 0 my $line;
6413 my $instnb;
6414 0 my $actual_nb_class;
6415 0 my $predicted_nb_class;
6416 0 my $actual_Class;
6417 0 my $predicted_Class;
6418 0 my $actual_classNb;
6419 0 my $predicted_classNb;
6420 0 my $error;
6421 0 my @distribution;
6422 0 my $document;
6423 0 my %results;
6424  
6425 0 ▶ open FILE, $self->_output_filename or die "No such file " . $self->_output_filename;
Branch: 1 branch
BranchTrueFalseTotal
open FILE, $self->_output_filename or die 'No such file ' . $self->_output_filename 0 0 0
6426 0 binmode(FILE, ":utf8");
6427 0 ▶ while($line = <FILE>){
Branch: 1 branch
BranchTrueFalseTotal
if (defined($line = readline FILE)) 0 0 0
6428 0 ▶ if ($line =~ /^inst\#/o) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /^inst\#/o) 0 0 0
6429 0 last;
6430 }
6431 };
6432  
6433 0 ▶ while($line = <FILE>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($line = readline FILE)) 0 0 0
6434 0 chomp $line;
6435  
6436 0 ▶ if ($line ne "") {
Branch: 1 branch
BranchTrueFalseTotal
if ($line ne "") 0 0 0
6437 0 warn "$line\n";
6438 0 ($instnb, $actual_nb_class, $predicted_nb_class, $error, @distribution) = split /\t/, $line;
6439 0 ($actual_classNb, $actual_Class) = split /:/, $actual_nb_class;
6440 0 ($predicted_classNb, $predicted_Class) = split /:/, $predicted_nb_class;
6441 # $document = $self->_documentSet->[$instnb - 1];
6442 # warn "$property,$predicted_Class\n";
6443 # $document->getAnnotations->replaceProperty($property,$predicted_Class);
6444 # warn $document->getAnnotations->getProperty($property) . "\n";;
6445 }
6446 }
6447  
6448 0 close FILE;
6449
6450 }
6451  
6452 0 ▶sub _createSemanticFeaturesFromString {
Subroutine _createSemanticFeaturesFromString: not called CC=3 SCAR=24.8
6453 0 my ($self, $semtags, $termUnitId) = @_;
6454  
6455 0 my $semtag;
6456 my $semFeatures;
6457 0 my @list_semtags;
6458  
6459 0 ▶ if (defined $semtags) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $semtags) 0 0 0
6460 0 foreach $semtag (split /;/, $semtags) {
6461 # warn "\t$semtag\n";
6462 0 my @semtags = split /\//, $semtag;
6463 0 push @list_semtags, \@semtags;
6464 # TODO Check if the semtag already exists in order to avoid to create one another?
6465 0 $semFeatures = Lingua::Ogmios::Annotations::SemanticFeatures->new(
6466 { 'semantic_category' => \@list_semtags,
6467 'refid_semantic_unit' => $termUnitId,
6468 });
6469 }
6470 }
6471 0 return($semFeatures);
6472 }
6473  
6474 0 ▶sub getTermsFromSpan {
Subroutine getTermsFromSpan: not called CC=8 SCAR=42.8
Pod undocumented
6475 0 my ($self, $document, $ref_start_token, $ref_end_token) = @_;
6476  
6477 0 my $word;
6478 # my $lemma;
6479  
6480 # my $sentLemma = "";;
6481 0 my $token = $ref_start_token;
6482  
6483 # my $token_prec = 0;
6484 0 my @terms = ();
6485 0 my @semfs;
6486 my $semf;
6487  
6488 0 ▶ if (defined $token) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $token) 0 0 0
6489 0 ▶ do {
Branch: 1 branch
BranchTrueFalseTotal
defined $token and defined $token->previous and not $token->previous->equals($ref_end_token) and do { do { warn $token->getId . ' : ' . $token->getContent . "\n"; if ($document->getAnnotations->getSemanticUnitLevel->existsElementFromIndex("list_refid_token", $token->getId)) { warn $token->getContent . "\n"; @semfs = @{$document->getAnnotations->getSemanticUnitLevel->getElementFromIndex("list_refid_token", $token->getId);}; foreach $semf (@semfs) { if ($semf->isTerm) { push @terms, $semf; } ; } ; } ; $token = $token->next } } 0 0 0
Condition0%0/6
defined $token and defined $token->previous and not $token->previous->equals($ref_end_token)
!ll&&!rl&&r
000
defined $token and defined $token->previous
!ll&&!rl&&r
000
MC/DC0%0/3
defined $token and defined $token->previous and not $token->previous->equals($ref_end_token)
defined $token defined $token->previous not $token->previous->equals($ref_end_token)
Truth table0%0/4
A and B and not(C)
A= defined $tokenB= defined $token->previousC= not $token->previous->equals($ref_end_token)
ABCresult
0XX0
10X0
1100
1111
6490 0 warn $token->getId . " : " . $token->getContent . "\n";
6491 0 ▶ if ($document->getAnnotations->getSemanticUnitLevel->existsElementFromIndex("list_refid_token", $token->getId)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($document->getAnnotations->getSemanticUnitLevel->existsElementFromIndex("list_refid_token", $token->getId)) 0 0 0
6492 0 warn $token->getContent . "\n";
6493 0 @semfs = @{$document->getAnnotations->getSemanticUnitLevel->getElementFromIndex("list_refid_token", $token->getId)};
6494 # $lemma = $document->getAnnotations->getLemmaLevel->getElementFromIndex("refid_word", $word->getId)->[0];
6495 0 foreach $semf (@semfs) {
6496 0 ▶ if ($semf->isTerm) {
Branch: 1 branch
BranchTrueFalseTotal
if ($semf->isTerm) 0 0 0
6497 0 push @terms, $semf;
6498 }
6499 }
6500 }
6501 0 $token = $token->next;
6502 } while((defined $token) && (defined $token->previous) && (!($token->previous->equals($ref_end_token))));
6503 }
6504 0 return(\@terms);
6505 }
6506  
6507  
6508 6 1;
6509  
6510 __END__
« blib/lib/Lingua/Ogmios/NLPWrappers/PerlWordSegmentizer.pm ↑ Summary blib/lib/Lingua/Ogmios/NLPWrappers/TreeTagger.pm »