blib/lib/Lingua/Ogmios/Annotations.pm

filter: Statementstmt 36.5% 253 / 693 Branchbran 22.6% 38 / 168 Conditioncond 23.8% 5 / 21 MC/DCmcdc 15.3% 2 / 13 Subroutinesub 43.7% 49 / 112 Podpod 0.0% 0 / 91 totaltotal 31.6% 347 / 1098 CC 129 SCAR 41.9
CC
129
Cov
34%
load_Level
506.0
makeElementRefFromId
210.0
load_LogLevel
56.0
CRAP 66.0
« blib/lib/Lingua/Ogmios/NLPWrappers/HeidelTime.pm ↑ Summary blib/lib/Lingua/Ogmios/NLPWrappers/Faster.pm »
1 package Lingua::Ogmios::Annotations;
2  
3 16 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 16 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 16 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 16 ▶use Lingua::Ogmios::Annotations::Level;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 16 ▶use Lingua::Ogmios::Annotations::Section;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 16 ▶use Lingua::Ogmios::Annotations::Token;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 16 ▶use Lingua::Ogmios::Annotations::Word;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 16 ▶use Lingua::Ogmios::Annotations::Sentence;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 16 ▶use Lingua::Ogmios::Annotations::Lemma;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 16 ▶use Lingua::Ogmios::Annotations::MorphosyntacticFeatures;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 16 ▶use Lingua::Ogmios::Annotations::Stem;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 16 ▶use Lingua::Ogmios::Annotations::Phrase;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 16 ▶use Lingua::Ogmios::Annotations::Enumeration;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 16 ▶use Lingua::Ogmios::Annotations::SemanticUnit;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 16 ▶use Lingua::Ogmios::Annotations::SyntacticRelation;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 16 ▶use Lingua::Ogmios::Annotations::DomainSpecificRelation;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 16 ▶use Lingua::Ogmios::Annotations::AnaphoraRelation;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 16 ▶use Lingua::Ogmios::Annotations::SemanticFeatures;
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24 16 my $debug_devel_level = 2;
25  
26 14 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
27 14 my ($class, $platformConfig) = @_;
28  
29 14 my $Annotations = {
30 'language' => undef,
31 'properties' => {},
32 'Namespace' => undef,
33 'urls' => undef,
34 'acquisition_section' => undef,
35 'relevance_section' => undef,
36 'canonical_document' => undef,
37 'platformConfig' => $platformConfig,
38 # 'canonical_document_section_positions' => [], # to delete
39  
40 'section_level' => => Lingua::Ogmios::Annotations::Level->new ({
41 'name' => 'section',
42 'indexes' => ['from', 'to', 'title', 'type'],
43 'XML_order' => ['id', 'from', 'to'],
44 }),
45  
46 'log_level' => Lingua::Ogmios::Annotations::Level->new ({
47 'name' => 'log',
48 'indexes' => ['log_id'],
49 'XML_order' => ['log_id', 'software_name', 'command_line', 'stamp',
50 'tagset', 'comments', 'list_modified_level'],
51 }),
52 'token_level' => Lingua::Ogmios::Annotations::Level->new ({
53 'name' => 'token',
54 'indexes' => ['from', 'to', 'content'],
55 'XML_order' => ['id', 'type', 'content', 'from', 'to'],
56 }),
57 'word_level' => Lingua::Ogmios::Annotations::Level->new ({
58 'name' => 'word',
59 'indexes' => ['list_refid_token', 'form'],
60 'XML_order' => ['id', 'log_id', 'list_refid_token', 'form'],
61 }),
62 'phrase_level' => Lingua::Ogmios::Annotations::Level->new ({
63 'name' => 'phrase',
64 'indexes' => ['list_refid_components'],
65 'XML_order' => ['id', 'log_id', 'type', 'list_refid_components', 'form'],
66 }),
67 'enumeration_level' => Lingua::Ogmios::Annotations::Level->new ({
68 'name' => 'enumeration',
69 'indexes' => ['list_refid_components'],
70 'XML_order' => ['id', 'log_id', 'type', 'list_refid_components', 'form'],
71 }),
72 'sentence_level' => Lingua::Ogmios::Annotations::Level->new ({
73 'name' => 'sentence',
74 'indexes' => ['refid_start_token', 'refid_end_token'],
75 'XML_order' => ['id', 'log_id', 'refid_start_token', 'refid_end_token', 'form', 'lang'],
76 }),
77 'syntactic_relation_level' => Lingua::Ogmios::Annotations::Level->new ({
78 'name' => 'syntactic_relation',
79 'indexes' => ['refid_head', 'refid_modifier', 'syntactic_relation_type'],
80 'XML_order' => ['id', 'log_id', 'syntactic_relation_type', 'refid_head', 'refid_modifier'],
81 }),
82 'semantic_unit_level' => Lingua::Ogmios::Annotations::Level->new ({
83 'name' => 'semantic_unit',
84 'indexes' => ['refid_phrase', 'refid_word', 'list_refid_token', 'form', 'type', 'canonical_form'],
85 'XML_order' => ['id', 'log_id', 'refid_phrase', 'refid_word', 'list_refid_token',
86 'form', 'canonical_form', 'named_entity_type', 'weights', 'negation'],
87 }),
88 'domain_specific_relation_level' => Lingua::Ogmios::Annotations::Level->new ({
89 'name' => 'domain_specific_relation',
90 'indexes' => ['list_refid_semantic_unit'],
91 'XML_order' => ['id', 'log_id', 'domain_specific_relation_type', 'list_refid_semantic_unit'],
92 }),
93 'anaphora_relation_level' => Lingua::Ogmios::Annotations::Level->new ({
94 'name' => 'anaphora_relation',
95 'indexes' => ['anaphora', 'antecent'],
96 'XML_order' => ['id', 'log_id', 'anaphora_relation_type', 'anaphora', 'antecedent'],
97 }),
98 'lemma_level' => Lingua::Ogmios::Annotations::Level->new ({
99 'name' => 'lemma',
100 'indexes' => ['refid_word'],
101 'XML_order' => ['id', 'log_id', 'canonical_form', 'refid_word', 'form'],
102 }),
103 'morphosyntactic_features_level' => Lingua::Ogmios::Annotations::Level->new ({
104 'name' => 'morphosyntactic_features',
105 'indexes' => ['refid_word', 'refid_phrase'],
106 'XML_order' => ['id', 'log_id', 'refid_word', 'refid_phrase', 'syntactic_category',
107 'category', 'type', 'gender', 'number', 'case', 'mood_vform', 'tense', 'person',
108 'degree', 'possessor', 'formation', 'form'],
109 }),
110 'semantic_features_level' => Lingua::Ogmios::Annotations::Level->new ({
111 'name' => 'semantic_features',
112 'indexes' => ['refid_semantic_unit'],
113 'XML_order' => ['id', 'log_id', 'refid_semantic_unit', 'semantic_category'],
114 }),
115 'stem_level' => Lingua::Ogmios::Annotations::Level->new ({
116 'name' => 'stem',
117 'indexes' => ['refid_word'],
118 'XML_order' => ['id', 'log_id', 'stem_form', 'refid_word', 'form'],
119 }),
120  
121 };
122 14 bless $Annotations, $class;
123 14 return ($Annotations);
124 }
125  
126 1 ▶sub getLevels4Print {
Subroutine getLevels4Print: called CC=7 SCAR=21.3
Pod undocumented
127 1 my ($self) = @_;
128  
129 # 'section_level',
130  
131 1 my @levels_id = ('log_level',
132 'token_level');
133  
134 1 ▶ if ((defined $self->platformConfig->xmloutput_sectionLevel) &&
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->platformConfig->xmloutput_sectionLevel and $self->platformConfig->xmloutput_sectionLevel == 1) 0 1 1
Condition33%1/3
defined $self->platformConfig->xmloutput_sectionLevel and $self->platformConfig->xmloutput_sectionLevel == 1
!ll&&!rl&&r
100
MC/DC0%0/2
defined $self->platformConfig->xmloutput_sectionLevel and $self->platformConfig->xmloutput_sectionLevel == 1
defined $self->platformConfig->xmloutput_sectionLevel $self->platformConfig->xmloutput_sectionLevel == 1
Truth table33%1/3
A and B
A= defined $self->platformConfig->xmloutput_sectionLevelB= $self->platformConfig->xmloutput_sectionLevel == 1
ABresult
0X0
100
111
135 ($self->platformConfig->xmloutput_sectionLevel == 1)) {
136 0 push @levels_id, 'section_level';
137 }
138  
139 1 push @levels_id, ('word_level',
140 'sentence_level',
141 'phrase_level');
142 1 ▶ if ((defined $self->platformConfig->xmloutput_enumerationLevel) &&
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->platformConfig->xmloutput_enumerationLevel and $self->platformConfig->xmloutput_enumerationLevel == 1) 0 1 1
Condition33%1/3
defined $self->platformConfig->xmloutput_enumerationLevel and $self->platformConfig->xmloutput_enumerationLevel == 1
!ll&&!rl&&r
100
MC/DC0%0/2
defined $self->platformConfig->xmloutput_enumerationLevel and $self->platformConfig->xmloutput_enumerationLevel == 1
defined $self->platformConfig->xmloutput_enumerationLevel $self->platformConfig->xmloutput_enumerationLevel == 1
Truth table33%1/3
A and B
A= defined $self->platformConfig->xmloutput_enumerationLevelB= $self->platformConfig->xmloutput_enumerationLevel == 1
ABresult
0X0
100
111
143 ($self->platformConfig->xmloutput_enumerationLevel == 1)) {
144 0 push @levels_id, 'enumeration_level';
145 }
146  
147 1 push @levels_id, ('semantic_unit_level',
148 'lemma_level',
149 'stem_level',
150 'morphosyntactic_features_level',
151 'syntactic_relation_level',
152 'semantic_features_level',
153 'domain_specific_relation_level',
154 'anaphora_relation_level',
155 );
156 1 my $id;
157 my @levels;
158  
159 1 foreach $id (@levels_id) {
160 13 ▶ if ($self->{$id}->getId > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{$id}->getId > 0) 2 11 13
161 2 warn "level: $id\n";
162 2 push @levels, $self->{$id};
163 }
164 }
165 1 return(@levels);
166 }
167  
168 0 ▶sub getLevels {
Subroutine getLevels: not called CC=3 SCAR=24.8
Pod undocumented
169 0 my ($self) = @_;
170  
171 # 'section_level',
172  
173 0 my @levels_id = ('log_level',
174 'token_level',
175 'word_level',
176 'sentence_level',
177 'phrase_level',
178 'enumeration_level',
179 'semantic_unit_level',
180 'lemma_level',
181 'stem_level',
182 'morphosyntactic_features_level',
183 'syntactic_relation_level',
184 'semantic_features_level',
185 'domain_specific_relation_level',
186 'anaphora_relation_level',
187 );
188 0 my $id;
189 my @levels;
190  
191 0 foreach $id (@levels_id) {
192 0 ▶ if ($self->{$id}->getId > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{$id}->getId > 0) 0 0 0
193 0 warn "level: $id\n";
194 0 push @levels, $self->{$id};
195 }
196 }
197 0 return(@levels);
198 }
199  
200 14 ▶sub setLanguageFromXMLAndProperties {
Subroutine setLanguageFromXMLAndProperties: called CC=7 SCAR=20.2
Pod undocumented
201 14 my $self = shift;
202 14 my $acquisition_section_node = shift;
203  
204 14 ▶ print STDERR "\nSetting Language: " unless $debug_devel_level != 2;
Branch: 1 branch
BranchTrueFalseTotal
unless $debug_devel_level != 2 14 0 14
205  
206 14 my $analysis = $acquisition_section_node->getChildrenByTagName('analysis')->get_node(1);
207 14 ▶ if (defined $analysis) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $analysis) 14 0 14
208 # my @properties = $analysis->getChildrenByTagName('property');
209 # warn join(":", @properties) . "\n";
210 14 my $prop;
211
212 # warn $analysis->getChildrenByTagName('property')->get_node(1)->getAttribute("name") . "\n";
213
214 14 foreach $prop ($analysis->getChildrenByTagName('property')) {
215 # warn "$prop\n";
216 14 ▶ if (defined $prop->hasAttribute("name")) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $prop->hasAttribute("name")) 14 0 14
217 14 ▶ if ($prop->getAttribute("name") eq "language") {
Branch: 1 branch
BranchTrueFalseTotal
if ($prop->getAttribute("name") eq "language") 14 0 14
218 # warn $prop->firstChild->toString . "\n";
219 # warn $prop->toString . "\n";
220 14 $self->{"language"} = uc($prop->firstChild->toString);
221 14 ▶ warn $self->{"language"} . "\n" unless $debug_devel_level != 2;
Branch: 1 branch
BranchTrueFalseTotal
unless $debug_devel_level != 2 14 0 14
222 }
223 14 $self->{'properties'}->{$prop->getAttribute("name")} = $prop->firstChild->toString;
224 }
225 }
226 }
227 }
228  
229 125 ▶sub getLanguage {
Subroutine getLanguage: called CC=1 SCAR=0.0
Pod undocumented
230 125 my $self = shift;
231  
232 125 return($self->{"language"});
233 }
234  
235 0 ▶sub setLanguage {
Subroutine setLanguage: not called CC=1 SCAR=6.9
Pod undocumented
236 0 my $self = shift;
237  
238 0 $self->{"language"} = shift;
239 0 return($self->{"language"});
240 }
241  
242 0 ▶sub getProperties {
Subroutine getProperties: not called CC=1 SCAR=6.9
Pod undocumented
243 0 my $self = shift;
244  
245 0 return($self->{"properties"});
246 }
247  
248 0 ▶sub getProperty {
Subroutine getProperty: not called CC=1 SCAR=6.9
Pod undocumented
249 0 my ($self, $propertyName) = @_;
250  
251 0 return($self->getProperties->{$propertyName});
252 }
253  
254 0 ▶sub delProperty {
Subroutine delProperty: not called CC=1 SCAR=6.9
Pod undocumented
255 0 my ($self, $propertyName) = @_;
256  
257 0 delete($self->getProperties->{$propertyName});
258 0 return(undef);
259 }
260  
261 0 ▶sub setProperty {
Subroutine setProperty: not called CC=3 SCAR=24.8
Pod undocumented
262 0 my ($self, $propertyName, $value, $separator) = @_;
263 0 ▶ if (!defined $separator) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $separator) 0 0 0
264 0 $separator = ";";
265 }
266  
267 0 ▶ if (!exists $self->getProperties->{$propertyName}) {
Branch: 1 branch
BranchTrueFalseTotal
if (not exists $self->getProperties->{$propertyName}) { } 0 0 0
268 0 $self->getProperties->{$propertyName} = $value;
269 } else {
270 0 $self->getProperties->{$propertyName} .= "$separator$value";
271 }
272  
273 0 return($self->getProperties->{$propertyName});
274 }
275  
276 0 ▶sub replaceProperty {
Subroutine replaceProperty: not called CC=1 SCAR=6.9
Pod undocumented
277 0 my ($self, $propertyName, $value) = @_;
278  
279 0 $self->getProperties->{$propertyName} = $value;
280  
281 0 return($self->getProperties->{$propertyName});
282 }
283  
284 2 ▶sub platformConfig {
Subroutine platformConfig: called CC=2 SCAR=7.6
Pod undocumented
285 2 my $self = shift;
286  
287 2 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 2 2
288 0 $self->{"platformConfig"} = shift;
289 }
290  
291 2 return($self->{"platformConfig"});
292 }
293  
294 14 ▶sub setURLs {
Subroutine setURLs: called CC=5 SCAR=16.3
Pod undocumented
295 14 my $self = shift;
296 14 my $acquisition_section_node = shift;
297  
298 14 my $url;
299  
300 14 ▶ print STDERR "\nSetting URLs: " unless $debug_devel_level != 2;
Branch: 1 branch
BranchTrueFalseTotal
unless $debug_devel_level != 2 14 0 14
301  
302 14 my $acquisitionData = $acquisition_section_node->getChildrenByTagName('acquisitionData')->get_node(1);
303  
304 14 ▶ if (defined $acquisitionData) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $acquisitionData) 14 0 14
305 14 my $urls = $acquisitionData->getChildrenByTagName('urls')->get_node(1);
306 14 ▶ if (defined $urls) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $urls) 14 0 14
307 14 my @urls;
308 14 $self->{'urls'} = \@urls;
309 14 foreach $url ($urls->getChildrenByTagName('url')) {
310 # warn $url->firstChild->toString . "\n";
311 14 push @urls, $url->firstChild->toString;
312 }
313 }
314 }
315  
316 }
317  
318  
319 0 ▶sub getURLs {
Subroutine getURLs: not called CC=1 SCAR=6.9
Pod undocumented
320 0 my $self = shift;
321  
322 0 return($self->{"urls"});
323 }
324  
325 14 ▶sub setCanonicalDocument {
Subroutine setCanonicalDocument: called CC=1 SCAR=0.0
Pod undocumented
326 14 my ($self, $canonicalDocument) = @_;
327  
328 14 $self->{'canonical_document'} = $canonicalDocument;
329 }
330  
331 0 ▶sub load_LogLevel {
Subroutine load_LogLevel: not called CC=7 SCAR=40.3
Pod undocumented
332 0 my ($self, $linguistic_analysis_node) = @_;
333
334 0 my $LogLevel = $linguistic_analysis_node->getChildrenByTagName('log_level')->get_node(1);
335  
336 0 my $logprocessing_node;
337 my $fields;
338 0 my $XML_order = $self->getLogLevel->getXMLorder;;
339 0 my $element;
340 my @nodes;
341 0 my $node;
342  
343 0 ▶ if (defined $LogLevel) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $LogLevel) 0 0 0
344 0 warn "Loading Log Level\n";
345 0 foreach $logprocessing_node ($LogLevel->getChildrenByTagName('log_processing')) {
346 0 $fields = {};
347 0 foreach $element (@$XML_order) {
348 0 @nodes = $logprocessing_node->getChildrenByTagName($element);
349 # warn "$element (" . scalar(@nodes) .")\n";
350 # if (scalar(@nodes) > 1) {
351 0 ▶ if ($element =~ /^list_/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($element =~ /^list_/) { } 0 0 0
352 0 my @values;
353 0 foreach $node (@nodes) {
354 # warn "$element:" . $node->textContent . "\n";
355 0 push @values, $node->textContent;
356 }
357 0 $fields->{$element} = \@values;
358 } else {
359 0 ▶ if (scalar(@nodes) > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @nodes > 0) 0 0 0
360 # warn "$element:" . $nodes[0]->textContent . "\n";
361 0 $fields->{$element} = $nodes[0]->textContent;
362 }
363 }
364 }
365 0 $self->addLogProcessing(Lingua::Ogmios::Annotations::LogProcessing->new($fields));
366  
367 }
368 0 warn "done\n";
369 }
370 }
371  
372  
373 0 ▶sub load_TokenLevel {
Subroutine load_TokenLevel: not called CC=4 SCAR=30.0
Pod undocumented
374 0 my ($self, $linguistic_analysis_node) = @_;
375  
376  
377 0 my $token_level_node = $linguistic_analysis_node->getChildrenByTagName('token_level')->get_node(1);
378 0 my $token_node;
379 0 my $XML_order = $self->getTokenLevel->getXMLorder;
380 0 my $element;
381 my $token;
382 0 my $fields;
383  
384 0 ▶ if (defined $token_level_node) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $token_level_node) 0 0 0
385 0 warn "Loading Token Level\n";
386 0 warn " " . $token_level_node->getChildrenByTagName('token')->size . " to load\n";
387 0 foreach $token_node ($token_level_node->getChildrenByTagName('token')) {
388 # warn "$token_node\n";
389 0 $fields = {};
390 0 foreach $element (@$XML_order) {
391 # warn "$element:" . $token_node->getChildrenByTagName($element)->get_node(1)->textContent . "\n";
392 0 $fields->{$element} = $token_node->getChildrenByTagName($element)->get_node(1)->textContent;
393 }
394 0 $self->addToken(Lingua::Ogmios::Annotations::Token->new($fields));
395 }
396 0 warn "done\n";
397 }
398
399 }
400  
401 0 ▶sub makeElementRefFromId {
Subroutine makeElementRefFromId: not called CC=14 SCAR=53.5
Pod undocumented
402 0 my ($self, $fields) = @_;
403 0 my $element;
404  
405 # print STDERR Dumper($fields) . "\n";
406  
407 0 ▶ if (exists $fields->{'list_refid_token'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $fields->{"list_refid_token"}) 0 0 0
408 0 my @element_list;
409 0 foreach $element (@{$fields->{'list_refid_token'}}) {
410 0 push @element_list, $self->getTokenLevel->getElementById($element);
411 }
412 0 $fields->{'list_refid_token'} = \@element_list;
413 }
414 0 ▶ if (exists $fields->{'refid_word'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $fields->{"refid_word"}) 0 0 0
415 0 my @element_list;
416 0 ▶ if (ref($fields->{'refid_word'}) eq "ARRAY") {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $fields->{'refid_word'} eq 'ARRAY') { } 0 0 0
417 0 foreach $element (@{$fields->{'refid_word'}}) {
418 0 push @element_list, $self->getWordLevel->getElementById($element);
419 }
420 0 $fields->{'refid_word'} = \@element_list;
421 } else {
422 0 $fields->{'refid_word'} = $self->getWordLevel->getElementById($fields->{'refid_word'});
423 }
424 }
425 0 ▶ if (exists $fields->{'refid_phrase'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $fields->{"refid_phrase"}) 0 0 0
426 0 my @element_list;
427 0 ▶ if (ref($fields->{'refid_phrase'}) eq "ARRAY") {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $fields->{'refid_phrase'} eq 'ARRAY') { } 0 0 0
428 0 foreach $element (@{$fields->{'refid_phrase'}}) {
429 0 push @element_list, $self->getPhraseLevel->getElementById($element);
430 }
431 0 $fields->{'refid_phrase'} = \@element_list;
432 } else {
433 0 $fields->{'refid_phrase'} = $self->getPhraseLevel->getElementById($fields->{'refid_phrase'});
434 }
435 }
436 0 ▶ if (exists $fields->{'refid_semantic_unit'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $fields->{"refid_semantic_unit"}) 0 0 0
437 0 my @element_list;
438 0 ▶ if (ref($fields->{'refid_semantic_unit'}) eq "ARRAY") {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $fields->{'refid_semantic_unit'} eq 'ARRAY') { } 0 0 0
439 0 foreach $element (@{$fields->{'refid_semantic_unit'}}) {
440 0 push @element_list, $self->getSemanticUnitLevel->getElementById($element);
441 }
442 0 $fields->{'refid_semantic_unit'} = \@element_list;
443 } else {
444 0 $fields->{'refid_semantic_unit'} = $self->getSemanticUnitLevel->getElementById($fields->{'refid_semantic_unit'});
445 }
446 }
447 0 ▶ if (exists $fields->{'refid_start_token'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $fields->{"refid_start_token"}) 0 0 0
448 0 $fields->{'refid_start_token'} = $self->getTokenLevel->getElementById($fields->{'refid_start_token'});
449 }
450 0 ▶ if (exists $fields->{'refid_end_token'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $fields->{"refid_end_token"}) 0 0 0
451 0 $fields->{'refid_end_token'} = $self->getTokenLevel->getElementById($fields->{'refid_end_token'});
452 }
453 # print STDERR Dumper($fields) . "\n";
454 }
455  
456  
457 0 ▶sub load_Level {
Subroutine load_Level: not called CC=22 SCAR=62.3
Pod undocumented
458 0 my ($self, $linguistic_analysis_node, $level_name, $node_name, $XML_order) = @_;
459  
460 0 my $word_node;
461 # my $XML_order = $self->getWordLevel->getXMLorder;
462 my $element;
463 # my $fields;
464 0 my @nodes;
465 0 my $node;
466 0 my $inner_node;
467  
468 0 my @nodeList;
469 0 my $inner_element;
470  
471 0 my $level_node = $linguistic_analysis_node->getChildrenByTagName($level_name)->get_node(1);
472 0 ▶ if (defined $level_node) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $level_node) 0 0 0
473 # warn "Loading $node_name Level\n";
474 # warn " " . $level_node->getElementsByTagName($node_name)->size . " to load\n";
475 0 foreach $node ($level_node->getElementsByTagName($node_name)) {
476 0 my $fields = {};
477 0 foreach $element (@$XML_order) {
478 0 @nodes = $node->getChildrenByTagName($element);
479 # warn "\tnb nodes: " . scalar(@nodes) . "\n";
480 0 ▶ if (scalar(@nodes) > 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @nodes > 1) { } 0 0 0
481 # warn "+++++\n";
482 0 my @values;
483 0 foreach $inner_node (@nodes) {
484 # warn "$element (1):" . $inner_node->textContent . "\n";
485 0 push @values, $inner_node->textContent;
486 }
487 0 $fields->{$element} = \@values;
488 } else {
489 0 ▶ if (scalar(@nodes) == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @nodes == 1) 0 0 0
490 # warn " => " . $nodes[0]->nodeName . "\n";
491 # warn "$element (2): " . $nodes[0]->hasChildNodes . "\n";
492 # warn "$element (2): " . $nodes[0]->textContent . "\n";
493 # childNodes
494 0 ▶ if ($nodes[0]->hasChildNodes) {
Branch: 1 branch
BranchTrueFalseTotal
if ($nodes[0]->hasChildNodes) { } 0 0 0
495 # hasAttribute
496  
497 # warn "=> " . $nodes[0]->childNodes . "\n";
498 # warn "=>(NT) " . $nodes[0]->nodeType . "\n";
499 0 ▶ if ((scalar(@{$nodes[0]->childNodes}) == 1) && ($nodes[0]->childNodes->get_node(1)->nodeName eq "#text")){
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @{$nodes[0]->childNodes;} == 1 and $nodes[0]->childNodes->get_node(1)->nodeName eq '#text') { } 0 0 0
Condition0%0/3
scalar @{$nodes[0]->childNodes;} == 1 and $nodes[0]->childNodes->get_node(1)->nodeName eq "#text"
!ll&&!rl&&r
000
MC/DC0%0/2
scalar @{$nodes[0]->childNodes;} == 1 and $nodes[0]->childNodes->get_node(1)->nodeName eq "#text"
scalar @{$nodes[0]->childNodes;} == 1 $nodes[0]->childNodes->get_node(1)->nodeName eq "#text"
Truth table0%0/3
A and B
A= scalar @{$nodes[0]->childNodes;} == 1B= $nodes[0]->childNodes->get_node(1)->nodeName eq "#text"
ABresult
0X0
100
111
500 # warn "----->" . $nodes[0]->childNodes->[0]->textContent . "\n";
501 0 $fields->{$element} = $nodes[0]->childNodes->get_node(1)->textContent;
502 # } else {
503 # warn "===> " . $nodes[0]->childNodes->get_node(1)->nodeName . "\n";
504 # if (($nodes[0]->childNodes->get_node(1)->nodeName ne "#text") &&
505 # ($nodes[0]->childNodes->get_node(1)->hasAttribute)) {
506 # # if (($nodes[0]->childNodes->get_node(1)->nodeName ne "#text") &&
507 # # ($nodes[0]->childNodes->get_node(1)->hasAttribute)) {
508 # # my %values;
509 # warn "===> " . $nodes[0]->childNodes->get_node(1)->textContent . "\n";
510 # warn "\tAttributes\n";
511 # warn "\t" . Dumper($node->attributes()) . "\n";
512 # # foreach $inner_node ($nodes[0]->childNodes) {
513 # # warn "====\n";
514 # # warn " " . $inner_node->nodeName . "\n";
515 # # if ($inner_node->hasChildNodes) {
516 # # warn $inner_node->nodeName . " (3):" . $inner_node->textContent . "\n";
517 # # warn " (NT) " . $inner_node->nodeType . "\n";
518 # # $values{$nodes[0]->childNodes->getAttribute} = $inner_node->textContent;
519 # # }
520 # # }
521 # # $fields->{$element} = \%values;
522
523 } else {
524 0 my @values_t;
525 my %values_h;
526 0 my $nodetmp = $nodes[0];
527 # warn "===>>>>$element\n";
528 0 ▶ if ($element eq "semantic_category") {
Branch: 1 branch
BranchTrueFalseTotal
if ($element eq "semantic_category") 0 0 0
529 # warn "+++++++++\n";
530 0 $nodetmp = $nodetmp->getChildrenByTagName("list_refid_ontology_node")->get_node(1);
531 }
532 0 foreach $inner_node ($nodetmp->childNodes) {
533 # warn "====\n";
534 # warn " " . $inner_node->nodeName . "\n";
535 0 ▶ if ($inner_node->hasChildNodes) {
Branch: 1 branch
BranchTrueFalseTotal
if ($inner_node->hasChildNodes) 0 0 0
536 0 $inner_element = $inner_node->nodeName;
537 # warn $inner_node->nodeName . " ($element -- 3):" . $inner_node->textContent . "\n";
538 0 ▶ if ($inner_node->hasAttributes) {
Branch: 1 branch
BranchTrueFalseTotal
if ($inner_node->hasAttributes) { } 0 0 0
539 0 my @tmp = $inner_node->attributes();
540 0 foreach my $a (@tmp) {
541 # warn "\tAttributes: " . ($a->getValue) . "\n";
542 # warn "\tAttributes: " . ($a->getName) . "\n";
543 0 $values_h{$a->getValue} = $inner_node->textContent;
544 }
545 } else {
546 0 ▶ if ($element eq "semantic_category") {
Branch: 1 branch
BranchTrueFalseTotal
if ($element eq 'semantic_category') { } 0 0 0
547 0 my @semf = split /\//, $inner_node->textContent;
548 0 push @values_t, \@semf;
549 } else {
550 0 push @values_t, $inner_node->textContent;
551 }
552 }
553 }
554 }
555 0 ▶ if (scalar(@values_t) == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @values_t == 0) { } 0 0 0
556 0 $fields->{$element} = \%values_h;
557 } else {
558 0 ▶ if (($element eq "list_refid_components") ||
Branch: 3 branches
BranchTrueFalseTotal
if ($element eq 'list_refid_components' or $element eq 'list_refid_semantic_unit' or $element eq 'list_refid_ontology_node') { } 0 0 0
elsif ($element eq 'refid_head') { } 0 0 0
elsif ($element eq 'refid_modifier') { } 0 0 0
Condition0%0/6
$element eq "list_refid_components" or $element eq "list_refid_semantic_unit" or $element eq "list_refid_ontology_node"
l!l&&r!l&&!r
000
$element eq "list_refid_components" or $element eq "list_refid_semantic_unit"
l!l&&r!l&&!r
000
MC/DC0%0/3
$element eq "list_refid_components" or $element eq "list_refid_semantic_unit" or $element eq "list_refid_ontology_node"
$element eq "list_refid_components" $element eq "list_refid_semantic_unit" $element eq "list_refid_ontology_node"
Truth table0%0/4
A or B or C
A= $element eq "list_refid_components"B= $element eq "list_refid_semantic_unit"C= $element eq "list_refid_ontology_node"
ABCresult
1XX1
01X1
0011
0000
559 ($element eq "list_refid_semantic_unit") ||
560 ($element eq "list_refid_ontology_node")) {
561 # warn ">>>>$inner_element\n";
562 0 $fields->{$inner_element} = \@values_t;
563 } elsif ($element eq "refid_head") {
564 0 $fields->{$inner_element. "_head"} = \@values_t;
565  
566 } elsif ($element eq "refid_modifier") {
567 0 $fields->{$inner_element. "_modifier"} = \@values_t;
568 } else {
569 0 $fields->{$element} = \@values_t;
570 }
571 }
572 # }
573 }
574 } else {
575 0 $fields->{$element} = $nodes[0]->textContent;
576 }
577 }
578 }
579 # $fields->{$element} = $node->getChildrenByTagName($element)->get_node(1)->textContent;
580 # warn "--------------------\n";
581 }
582 0 push @nodeList, $fields;
583 # $self->addWord(Lingua::Ogmios::Annotations::Word->new($fields));
584 }
585 0 warn "Loading $level_node done\n";
586 }
587 0 return(@nodeList);
588 }
589  
590 0 ▶sub load_WordLevel {
Subroutine load_WordLevel: not called CC=2 SCAR=17.9
Pod undocumented
591 0 my ($self, $linguistic_analysis_node) = @_;
592  
593 0 my @nodeList;
594 my $fields;
595 0 my $token;
596 0 my @token_list;
597  
598 0 warn "[LOG] Word Level Loading\n";
599  
600 0 @nodeList = $self->load_Level($linguistic_analysis_node, "word_level", 'word', $self->getWordLevel->getXMLorder);
601  
602 0 foreach $fields (@nodeList) {
603  
604 0 $self->makeElementRefFromId($fields);
605 # my @token_list;
606 # foreach $token (@{$fields->{'list_refid_token'}}) {
607 # push @token_list, $self->getTokenLevel->getElementById($token);
608 # }
609 # $fields->{'list_refid_token'} = \@token_list;
610  
611 0 $self->addWord(Lingua::Ogmios::Annotations::Word->new($fields));
612 }
613  
614 0 warn "\tdone\n";
615 }
616  
617 # sub load_WordLevel1 {
618 # my ($self, $linguistic_analysis_node) = @_;
619  
620 # my $word_node;
621 # my $XML_order = $self->getWordLevel->getXMLorder;
622 # my $element;
623 # my $word;
624 # my $fields;
625 # my @nodes;
626 # my $node;
627  
628 # my $word_level_node = $linguistic_analysis_node->getChildrenByTagName('word_level')->get_node(1);
629 # if (defined $word_level_node) {
630 # warn "Loading Word Level\n";
631 # warn " " . $word_level_node->getChildrenByTagName('word')->size . " to load\n";
632 # foreach $word_node ($word_level_node->getChildrenByTagName('word')) {
633 # $fields = {};
634 # foreach $element (@$XML_order) {
635 # # warn "element: $element\n";
636 # @nodes = $word_node->getChildrenByTagName($element);
637 # # warn "\tnb nodes: " . scalar(@nodes) . "\n";
638 # if (scalar(@nodes) > 1) {
639 # # warn "===\n";
640 # my @values;
641 # foreach $node (@nodes) {
642 # # warn "$element (1):" . $node->textContent . "\n";
643 # push @values, $node->textContent;
644 # }
645 # $fields->{$element} = \@values;
646 # } else {
647 # if (scalar(@nodes) == 1) {
648 # # warn " => " . $nodes[0]->nodeName . "\n";
649 # # warn "$element (2): " . $nodes[0]->hasChildNodes . "\n";
650 # # warn "$element (2): " . $nodes[0]->textContent . "\n";
651 # # childNodes
652 # if ($nodes[0]->hasChildNodes) {
653 # my @values;
654 # # warn "=> " . $nodes[0]->childNodes . "\n";
655 # # warn "=>(NT) " . $nodes[0]->nodeType . "\n";
656 # if ((scalar(@{$nodes[0]->childNodes}) == 1) && ($nodes[0]->childNodes->get_node(1)->nodeName eq "#text")){
657 # # warn $nodes[0]->childNodes->[0]->textContent . "\n";
658 # $fields->{$element} = $nodes[0]->childNodes->get_node(1)->textContent;
659 # } else {
660 # foreach $node ($nodes[0]->childNodes) {
661 # # warn "====\n";
662 # # warn " " . $node->nodeName . "\n";
663 # if ($node->hasChildNodes) {
664 # # warn $node->nodeName . " (3):" . $node->textContent . "\n";
665 # # warn " (NT) " . $node->nodeType . "\n";
666 # push @values, $node->textContent;
667 # }
668 # }
669 # $fields->{$element} = \@values;
670 # }
671 # } else {
672 # $fields->{$element} = $nodes[0]->textContent;
673 # }
674 # }
675 # }
676 # # $fields->{$element} = $word_node->getChildrenByTagName($element)->get_node(1)->textContent;
677 # # warn "--------------------\n";
678 # }
679 # $self->addWord(Lingua::Ogmios::Annotations::Word->new($fields));
680 # }
681 # warn "done\n";
682 # }
683 # }
684  
685 0 ▶sub load_PhraseLevel {
Subroutine load_PhraseLevel: not called CC=2 SCAR=17.9
Pod undocumented
686 0 my ($self, $linguistic_analysis_node) = @_;
687  
688 0 my @nodeList;
689 my $fields;
690  
691 0 my $element;
692 0 my $elemnt_list;
693  
694 0 warn "[LOG] Phrase Level Loading\n";
695  
696 0 @nodeList = $self->load_Level($linguistic_analysis_node, "phrase_level", 'phrase', $self->getPhraseLevel->getXMLorder);
697  
698 0 foreach $fields (@nodeList) {
699 0 $self->makeElementRefFromId($fields);
700 0 $self->addPhrase(Lingua::Ogmios::Annotations::Phrase->new($fields));
701 }
702  
703 0 warn "\tdone\n";
704 }
705  
706 0 ▶sub load_EnumerationLevel {
Subroutine load_EnumerationLevel: not called CC=2 SCAR=17.9
Pod undocumented
707 0 my ($self, $linguistic_analysis_node) = @_;
708  
709 0 my @nodeList;
710 my $fields;
711  
712 0 my $element;
713 0 my $elemnt_list;
714  
715 0 warn "[LOG] Enumeration Level Loading (CODE NOT CHECK)\n";
716  
717 0 @nodeList = $self->load_Level($linguistic_analysis_node, "enumeration_level", 'enumeration', $self->getEnumerationLevel->getXMLorder);
718  
719 0 foreach $fields (@nodeList) {
720 0 $self->makeElementRefFromId($fields);
721 0 $self->addEnumeration(Lingua::Ogmios::Annotations::Enumeration->new($fields));
722 }
723  
724 0 warn "\tdone\n";
725 }
726  
727 0 ▶sub load_SentenceLevel {
Subroutine load_SentenceLevel: not called CC=2 SCAR=17.9
Pod undocumented
728 0 my ($self, $linguistic_analysis_node) = @_;
729  
730 0 my @nodeList;
731 my $fields;
732  
733 0 warn "[LOG] Sentence Level Loading\n";
734  
735 0 @nodeList = $self->load_Level($linguistic_analysis_node, "sentence_level", 'sentence', $self->getSentenceLevel->getXMLorder);
736  
737 0 warn "Make Sentences (" . scalar(@nodeList) . ")\n";
738 0 foreach $fields (@nodeList) {
739 0 $self->makeElementRefFromId($fields);
740 0 $self->addSentence(Lingua::Ogmios::Annotations::Sentence->new($fields));
741 }
742  
743 0 warn "\tdone\n";
744  
745 }
746  
747 0 ▶sub load_Syntactic_relationLevel {
Subroutine load_Syntactic_relationLevel: not called CC=2 SCAR=17.9
Pod undocumented
748 0 my ($self, $linguistic_analysis_node) = @_;
749  
750 0 my @nodeList;
751 my $fields;
752  
753 0 my $element;
754 0 my $elemnt_list;
755  
756 0 warn "[LOG] Syntatic Relation Level Loading\n";
757  
758 0 @nodeList = $self->load_Level($linguistic_analysis_node, "syntactic_relation_level", 'syntactic_relation', $self->getSyntacticRelationLevel->getXMLorder);
759  
760 0 foreach $fields (@nodeList) {
761 0 $self->makeElementRefFromId($fields);
762 0 $self->addSyntacticRelation(Lingua::Ogmios::Annotations::SyntacticRelation->new($fields));
763 }
764  
765 0 warn "\tdone\n";
766  
767 }
768  
769 0 ▶sub load_Semantic_unitLevel {
Subroutine load_Semantic_unitLevel: not called CC=3 SCAR=24.8
Pod undocumented
770 0 my ($self, $linguistic_analysis_node) = @_;
771  
772 0 my @nodeList;
773 my $fields;
774 0 my $type;
775  
776 0 warn "[LOG] Semantic Unit Level Loading\n";
777  
778 0 for $type ('named_entity', 'term', 'undefined') {
779 # 'semantic_unit'
780 0 @nodeList = $self->load_Level($linguistic_analysis_node, "semantic_unit_level", $type, $self->getSemanticUnitLevel->getXMLorder);
781
782 0 foreach $fields (@nodeList) {
783 # print STDERR Dumper($fields) . "\n";
784 0 $fields->{'type'} = $type;
785 0 $self->makeElementRefFromId($fields);
786 0 $self->addSemanticUnit(Lingua::Ogmios::Annotations::SemanticUnit->new($fields));
787 }
788 }
789 0 warn "\tdone\n";
790 }
791  
792 0 ▶sub load_Domain_specific_relationLevel {
Subroutine load_Domain_specific_relationLevel: not called CC=2 SCAR=17.9
Pod undocumented
793 0 my ($self, $linguistic_analysis_node) = @_;
794  
795 0 my @nodeList;
796 my $fields;
797  
798 0 my $element;
799 0 my $elemnt_list;
800  
801 0 warn "[LOG] Domain Specific Relation Level Loading (CODE NOT CHECK)\n";
802  
803 0 @nodeList = $self->load_Level($linguistic_analysis_node, "domain_specific_relation_level", 'domain_specific_relation', $self->getDomainSpecificRelationLevel->getXMLorder);
804  
805 0 foreach $fields (@nodeList) {
806 0 $self->makeElementRefFromId($fields);
807 0 $self->addDomainSpecificRelation(Lingua::Ogmios::Annotations::DomainSpecificRelation->new($fields));
808 }
809  
810 0 warn "\tdone\n";
811 }
812  
813 0 ▶sub load_Anaphora_relationLevel {
Subroutine load_Anaphora_relationLevel: not called CC=2 SCAR=17.9
Pod undocumented
814 0 my ($self, $linguistic_analysis_node) = @_;
815  
816 0 my @nodeList;
817 my $fields;
818  
819 0 my $element;
820 0 my $elemnt_list;
821  
822 0 warn "[LOG] Anaphora Relation Level Loading (CODE NOT CHECK)\n";
823  
824 0 @nodeList = $self->load_Level($linguistic_analysis_node, "anaphora_relation_level", 'anaphora_relation', $self->getAnaphoraRelationLevel->getXMLorder);
825  
826 0 foreach $fields (@nodeList) {
827 0 $self->makeElementRefFromId($fields);
828 0 $self->addAnaphoraRelation(Lingua::Ogmios::Annotations::AnaphoraRelation->new($fields));
829 }
830  
831 0 warn "\tdone\n";
832  
833 }
834  
835 0 ▶sub load_LemmaLevel {
Subroutine load_LemmaLevel: not called CC=2 SCAR=17.9
Pod undocumented
836 0 my ($self, $linguistic_analysis_node) = @_;
837  
838 0 my @nodeList;
839 my $fields;
840  
841 0 warn "[LOG] Lemma Level Loading\n";
842  
843 0 @nodeList = $self->load_Level($linguistic_analysis_node, "lemma_level", 'lemma', $self->getLemmaLevel->getXMLorder);
844  
845 0 foreach $fields (@nodeList) {
846 0 $self->makeElementRefFromId($fields);
847 0 $self->addLemma(Lingua::Ogmios::Annotations::Lemma->new($fields));
848 }
849  
850 0 warn "\tdone\n";
851 }
852  
853 0 ▶sub load_Morphosyntactic_featuresLevel {
Subroutine load_Morphosyntactic_featuresLevel: not called CC=2 SCAR=17.9
Pod undocumented
854 0 my ($self, $linguistic_analysis_node) = @_;
855  
856 0 my @nodeList;
857 my $fields;
858  
859 0 warn "[LOG] Morphosyntactic Features Level Loading\n";
860  
861 0 @nodeList = $self->load_Level($linguistic_analysis_node, "morphosyntactic_features_level", 'morphosyntactic_features', $self->getMorphosyntacticFeaturesLevel->getXMLorder);
862  
863 0 foreach $fields (@nodeList) {
864 0 $self->makeElementRefFromId($fields);
865 0 $self->addMorphosyntacticFeatures(Lingua::Ogmios::Annotations::MorphosyntacticFeatures->new($fields));
866 }
867  
868 0 warn "\tdone\n";
869 }
870  
871 0 ▶sub load_Semantic_featuresLevel {
Subroutine load_Semantic_featuresLevel: not called CC=3 SCAR=24.8
Pod undocumented
872 0 my ($self, $linguistic_analysis_node) = @_;
873  
874 0 my @nodeList;
875 my $fields;
876  
877 0 my $element;
878 0 my $elemnt_list;
879  
880 0 warn "[LOG] Semantic Features Level Loading\n";
881  
882 0 @nodeList = $self->load_Level($linguistic_analysis_node, "semantic_features_level", 'semantic_features', $self->getSemanticFeaturesLevel->getXMLorder);
883  
884 0 warn "Make Semantic Features (" . scalar(@nodeList) . ")\n";
885 0 foreach $fields (@nodeList) {
886 0 $self->makeElementRefFromId($fields);
887 # warn ref($fields->{'semantic_category'}) . "\n";
888 0 ▶ if (ref($fields->{'semantic_category'}) eq "ARRAY") {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $fields->{"semantic_category"} eq "ARRAY") 0 0 0
889 0 $self->addSemanticFeatures(Lingua::Ogmios::Annotations::SemanticFeatures->new($fields));
890 }
891 }
892  
893 0 warn "\tdone\n";
894  
895 }
896  
897 0 ▶sub load_StemLevel {
Subroutine load_StemLevel: not called CC=2 SCAR=17.9
Pod undocumented
898 0 my ($self, $linguistic_analysis_node) = @_;
899  
900  
901 0 my @nodeList;
902 my $fields;
903  
904 0 warn "[LOG] Stem Level Loading\n";
905  
906 0 @nodeList = $self->load_Level($linguistic_analysis_node, "stem_level", 'stem', $self->getStemLevel->getXMLorder);
907  
908 0 foreach $fields (@nodeList) {
909 0 $self->makeElementRefFromId($fields);
910 0 $self->addStem(Lingua::Ogmios::Annotations::Stem->new($fields));
911 }
912  
913 0 warn "\tdone\n";
914  
915 }
916  
917 0 ▶sub loadLinguisticAnalysis {
Subroutine loadLinguisticAnalysis: not called CC=2 SCAR=17.9
Pod undocumented
918 0 my ($self, $linguistic_analysis_node) = @_;
919 # my ($self, $document_record_node) = @_;
920  
921 # my $linguistic_analysis_node = $document_record_node->getChildrenByTagName('linguisticAnalysis')->get_node(1);
922  
923 0 ▶ if (defined $linguistic_analysis_node) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $linguistic_analysis_node) 0 0 0
924 0 warn "Load existing linguistic annotations\n";
925  
926 # load token level
927 0 $self->load_TokenLevel($linguistic_analysis_node);
928 0 $self->load_WordLevel($linguistic_analysis_node);
929 0 $self->load_PhraseLevel($linguistic_analysis_node);
930 0 $self->load_SentenceLevel($linguistic_analysis_node);
931 0 $self->load_Semantic_unitLevel($linguistic_analysis_node);
932 0 $self->load_LemmaLevel($linguistic_analysis_node);
933 0 $self->load_LogLevel($linguistic_analysis_node);
934 0 $self->load_Morphosyntactic_featuresLevel($linguistic_analysis_node);
935 0 $self->load_StemLevel($linguistic_analysis_node);
936 0 $self->load_Syntactic_relationLevel($linguistic_analysis_node);
937 0 $self->load_Semantic_featuresLevel($linguistic_analysis_node);
938 0 $self->load_EnumerationLevel($linguistic_analysis_node);
939 0 $self->load_Domain_specific_relationLevel($linguistic_analysis_node);
940 0 $self->load_Anaphora_relationLevel($linguistic_analysis_node);
941 }
942 }
943  
944  
945 14 ▶sub loadCanonicalDocument {
Subroutine loadCanonicalDocument: called CC=4 SCAR=14.2
Pod undocumented
946 14 my ($self, $acquisition_section_node) = @_;
947  
948 14 my $canonical_document;
949 my $canonical_document_section_positions;
950 14 my $canonical_document_node = $acquisition_section_node->getChildrenByTagName('canonicalDocument')->get_node(1);
951 14 my $section;
952  
953 14 ▶ if (defined $canonical_document_node) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $canonical_document_node) { } 14 0 14
954 14 ($canonical_document, $canonical_document_section_positions) = $self->_parseCanonicalDocument($canonical_document_node);
955 14 $self->setCanonicalDocument($canonical_document);
956 14 foreach $section (@$canonical_document_section_positions) {
957 78 $self->addSection($section);
958 78 ▶ warn "section from " . $section->getFrom . " to " . $section->getTo . "\n" unless $debug_devel_level != 1;
Branch: 1 branch
BranchTrueFalseTotal
unless $debug_devel_level != 1 0 78 78
959 }
960 # $self->setCanonicalDocument_SectionPosition($canonical_document_section_positions);
961 } else {
962 0 warn "no canonicalDocument (" . $self->getId . ")\n";
963 }
964 }
965  
966 0 ▶sub _parseCanonicalDocument_SectionPosition {
Subroutine _parseCanonicalDocument_SectionPosition: not called CC=1 SCAR=6.9
967  
968 0 my ($self, $canonical_document_node) = @_;
969  
970 0 my @sections;
971 0 my $canonicalDocumentString = "";
972  
973 0 return(\@sections);
974 }
975  
976  
977 14 ▶sub _parseCanonicalDocument {
Subroutine _parseCanonicalDocument: called CC=11 SCAR=24.0
978  
979 14 my ($self, $canonical_document_node) = @_;
980  
981 # warn "in parseCanonicalDocument\n";
982  
983 14 my @sections;
984 my @section_starts;
985 14 my @section_ends;
986 14 my $canonicalDocumentString = "";
987 14 my @canonicalDocument_sections;
988 my $section;
989 14 my $start_position;
990 14 my $end_position;
991  
992 14 my $i;
993  
994 14 $canonicalDocumentString = $canonical_document_node->toString;
995
996  
997 14 $canonicalDocumentString =~ s/[\s\n]*<\/?canonicalDocument>\s*//go;
998  
999 14 my $temp_canonicalDocumentString = $canonicalDocumentString;
1000  
1001 14 my @section_infos;
1002 my $section_string;
1003  
1004 14 ▶ while($temp_canonicalDocumentString =~ /<section[^>]*>|<list>|<item>/o) {
Branch: 1 branch
BranchTrueFalseTotal
if ($temp_canonicalDocumentString =~ /<section[^>]*>|<list>|<item>/o) 78 14 92
1005 78 push @canonicalDocument_sections, $`; #` }
1006 78 $temp_canonicalDocumentString = $';
1007  
1008  
1009 78 $section_string = $&; # '
1010 # warn "section string: $section_string\n";
1011 # warn $temp_canonicalDocumentString . "\n\n";
1012 78 my %tmp;
1013 78 $tmp{'type'} = "empty";
1014 78 $tmp{'title'} = "empty";
1015 78 ▶ if ($section_string =~ /<item>/o) {
Branch: 1 branch
BranchTrueFalseTotal
if ($section_string =~ /<item>/o) { } 12 66 78
1016 12 $tmp{'type'} = "item";
1017 12 $tmp{'title'} = undef;
1018 } else {
1019 66 ▶ if ($section_string =~ /<list>/o) {
Branch: 1 branch
BranchTrueFalseTotal
if ($section_string =~ /<list>/o) { } 3 63 66
1020 3 $tmp{'type'} = "list";
1021 3 $tmp{'title'} = undef;
1022 } else {
1023 63 $tmp{'type'} = "narrative";
1024 63 ▶ if ($section_string =~ /<section(\s+sectionType=\"(?<st>[^"]+)\")?(\s+title=\"(?<t>[^"]+)\")?>/o) { #"
Branch: 1 branch
BranchTrueFalseTotal
if ($section_string =~ /<section(\s+sectionType=\"(?<st>[^"]+)\")?(\s+title=\"(?<t>[^"]+)\")?>/o) { } 63 0 63
1025 63 $tmp{'type'} = $+{st};
1026 63 $tmp{'title'} = $+{t};
1027 } else {
1028 0 $tmp{'title'} = undef;
1029 }
1030 }
1031 }
1032 78 push @section_infos, \%tmp;
1033 }
1034 14 push @canonicalDocument_sections, $temp_canonicalDocumentString;
1035  
1036 14 shift @canonicalDocument_sections; # what is before the first section cannot be into the document
1037
1038 # shift @section_infos;
1039  
1040 14 $start_position = 0;
1041 14 $end_position = 0;
1042  
1043 14 warn "[LOG] Identifying start position of the sections\n";
1044  
1045 14 my $j;
1046 14 ▶ for($j=0;$j < scalar(@canonicalDocument_sections);$j++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($j < scalar @canonicalDocument_sections) 78 14 92
1047 78 $section = $canonicalDocument_sections[$j];
1048 # warn "-> $section\n";
1049 # push @section_starts, $start_position;
1050 78 my @tmp = ($start_position, $section_infos[$j], $section);
1051 78 push @section_starts, \@tmp;
1052 78 $section =~ s/<[^>]+>//go;
1053 # warn "$section\n";
1054 # warn "\t" . length(Lingua::Ogmios::Annotations::Element->_xmldecode($section)) . "\n";
1055 78 $start_position += length(Lingua::Ogmios::Annotations::Element->_xmldecode($section));
1056 # warn "\t" . $start_position . "\n";
1057 }
1058  
1059 14 warn "\n[LOG] Identifying end position of the sections\n";
1060  
1061 14 @canonicalDocument_sections = split m!</section>|</list>|</item>!, $canonicalDocumentString;
1062  
1063 14 foreach $section (@canonicalDocument_sections) {
1064 78 ▶ if ($section eq "") {
Branch: 1 branch
BranchTrueFalseTotal
if ($section eq '') { } 2 76 78
1065 # warn "empty section content ($end_position)\n";
1066 2 ▶ if ($end_position != 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($end_position != 0) { } 2 0 2
1067 2 push @section_ends, $end_position-1;
1068 } else {
1069 0 push @section_ends, $end_position;
1070 }
1071 } else {
1072 # warn "-> $section\n";
1073 # warn "\t" . $end_position . "(a)\n";
1074 # if ($section =~ /([^<]*)<[^>]+>/os) {
1075 # $end_position += length($1);
1076 # }
1077 76 ▶ while($section =~ s/([^<]*)<[^>]+>//os) {
Branch: 1 branch
BranchTrueFalseTotal
if ($section =~ s/([^<]*)<[^>]+>//os) 84 76 160
1078 84 $end_position += length($1);
1079 }
1080 # warn "\t" . $end_position . "(b)\n";
1081 # $section =~ s/<[^>]+>//go;
1082 # warn "$section\n";
1083 # warn "\t" . length(Lingua::Ogmios::Annotations::Element->_xmldecode($section)) . "\n";
1084 76 $end_position += length(Lingua::Ogmios::Annotations::Element->_xmldecode($section));
1085 76 $end_position--;
1086 # warn "\t" . $end_position . "(c)\n";
1087 76 push @section_ends, $end_position;
1088 76 $end_position++;
1089 # push @section_ends, $section_starts[$#section_ends + 1] + length(Lingua::Ogmios::Annotations::Element->_xmldecode($section)) - 1;
1090 }
1091 }
1092  
1093 # as empty trailing fields are deleted with split, put empty
1094 # string instead to get the same number of start and end section
1095 # position
1096  
1097 14 ▶ for($i = scalar(@section_ends); $i < scalar @section_starts; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < scalar @section_starts) 0 14 14
1098 0 $section_ends[$i] = $section_ends[$#section_ends];
1099 }
1100  
1101  
1102  
1103 14 $canonicalDocumentString =~ s/<[^>]+>//go;
1104  
1105 14 $canonicalDocumentString = Lingua::Ogmios::Annotations::Element->_xmldecode($canonicalDocumentString);
1106  
1107 14 warn "[LOG] Merging identification of the end and start position\n";
1108 14 $start_position = 0;
1109 14 $end_position = 0;
1110 14 &_merge_sections(\@section_starts, \@section_ends, \$start_position, \$end_position, \@sections, \@section_infos, 0, undef);
1111  
1112 # if ($debug_devel_level == 1) {
1113 # warn "[LOG/$debug_devel_level] Check merging identification of the end and start position\n";
1114
1115 # foreach $section (@sections) {
1116 # ($start_position, $end_position) = ($section->getFrom, $section->getTo);
1117 # warn "[LOG/$debug_devel_level] Section from $start_position to $end_position\n";
1118 # print STDERR "\t" . substr($canonicalDocumentString, $start_position, $end_position - $start_position + 1) . "\n";
1119 # }
1120 # }
1121  
1122 # exit;
1123  
1124 14 return($canonicalDocumentString, \@sections);
1125 }
1126  
1127 92 ▶sub _merge_sections {
Subroutine _merge_sections: called CC=3 SCAR=11.0
1128  
1129 92 my ($start_position_ref, $end_position_ref, $i_start_ref, $i_end_ref, $sections_ref, $section_infos_ref, $depth, $parent_section) = @_;
1130  
1131 92 my $section;
1132 92 my $current_start_position = $$i_start_ref;
1133  
1134 92 my @child_sections;
1135 my $i;
1136 92 my $newparent_section;
1137 92 my @created_sections;
1138  
1139 92 my $rank = 0;
1140  
1141 92 ▶ while(($$i_start_ref < scalar(@$start_position_ref)) && ($start_position_ref->[$$i_start_ref]->[0] < $end_position_ref->[$$i_end_ref])) {
Branch: 1 branch
BranchTrueFalseTotal
if ($$i_start_ref < scalar @$start_position_ref and $$start_position_ref[$$i_start_ref][0] < $$end_position_ref[$$i_end_ref]) 78 92 170
Condition100%3/3
$$i_start_ref < scalar @$start_position_ref and $$start_position_ref[$$i_start_ref][0] < $$end_position_ref[$$i_end_ref]
!ll&&!rl&&r
563678
MC/DC100%2/2
$$i_start_ref < scalar @$start_position_ref and $$start_position_ref[$$i_start_ref][0] < $$end_position_ref[$$i_end_ref]
$$i_start_ref < scalar @$start_position_ref $$start_position_ref[$$i_start_ref][0] < $$end_position_ref[$$i_end_ref]
Truth table100%3/3
A and B
A= $$i_start_ref < scalar @$start_position_refB= $$start_position_ref[$$i_start_ref][0] < $$end_position_ref[$$i_end_ref]
ABresult
0X0
100
111
1142 78 $$i_start_ref++;
1143  
1144 78 my @tmp;
1145 $section = Lingua::Ogmios::Annotations::Section->new({
1146 'from' => $start_position_ref->[$current_start_position]->[0],
1147 'to' => $end_position_ref->[$$i_end_ref],
1148 'title' => $start_position_ref->[$current_start_position]->[1]->{'title'},
1149 78 'type' => $start_position_ref->[$current_start_position]->[1]->{'type'},
1150 # 'title' => $section_infos_ref->[$current_start_position]->{'title'},
1151 # 'type' => $section_infos_ref->[$current_start_position]->{'type'},
1152 'parent_section' => $parent_section,
1153 'child_sections' => \@tmp,
1154 # 'child_sections' => \@child_sections,
1155 'rank' => $rank++,
1156 }
1157 );
1158  
1159 78 push @created_sections, $section;
1160 78 $newparent_section = $section;
1161  
1162 78 push @{$section->child_sections}, &_merge_sections($start_position_ref, $end_position_ref, $i_start_ref, $i_end_ref, $sections_ref, $section_infos_ref , $depth + 1, $newparent_section);
1163  
1164 78 $section->setTo($end_position_ref->[$$i_end_ref]);
1165 78 push @$sections_ref, $section;
1166 78 $current_start_position = $$i_start_ref;
1167  
1168 78 $$i_end_ref++;
1169  
1170 }
1171 92 return(@created_sections);
1172 }
1173  
1174  
1175  
1176 11 ▶sub getCanonicalDocument {
Subroutine getCanonicalDocument: called CC=1 SCAR=0.0
Pod undocumented
1177 11 my ($self) = @_;
1178  
1179 11 return($self->{'canonical_document'});
1180 }
1181  
1182 # sub setCanonicalDocument_SectionPosition {
1183 # my ($self, $canonicalDocument_SectionPosition) = @_;
1184  
1185 # $self->{'canonical_document_section_position'} = $canonicalDocument_SectionPosition;
1186 # }
1187  
1188 # sub getCanonicalDocument_SectionPosition {
1189 # my ($self) = @_;
1190  
1191 # return($self->{'canonical_document_section_position'});
1192 # }
1193  
1194 0 ▶sub setRelevanceSection {
Subroutine setRelevanceSection: not called CC=1 SCAR=6.9
Pod undocumented
1195 0 my ($self, $relevance_section) = @_;
1196  
1197 0 $self->{'relevance_section'} = $relevance_section->toString;
1198 }
1199  
1200 1 ▶sub getRelevanceSection {
Subroutine getRelevanceSection: called CC=1 SCAR=0.0
Pod undocumented
1201 1 my ($self) = @_;
1202  
1203 1 return($self->{'relevance_section'});
1204 }
1205  
1206 14 ▶sub setAcquisitionSection {
Subroutine setAcquisitionSection: called CC=1 SCAR=0.0
Pod undocumented
1207 14 my ($self, $acquisition_section) = @_;
1208  
1209 14 $self->{'acquisition_section'} = $acquisition_section->cloneNode(1); #->toString;
1210 }
1211  
1212 1 ▶sub getAcquisitionSection {
Subroutine getAcquisitionSection: called CC=1 SCAR=0.0
Pod undocumented
1213 1 my ($self) = @_;
1214  
1215 1 return($self->{'acquisition_section'});
1216 }
1217  
1218 sub getNamespace
1219 0 ▶{
Subroutine getNamespace: not called CC=4 SCAR=30.0
Pod undocumented
1220 0 my $self;
1221 0 ▶ if (UNIVERSAL::isa($_[0], 'Lingua::Ogmios::Annotations')) {
Branch: 1 branch
BranchTrueFalseTotal
if (UNIVERSAL::isa($_[0], 'Lingua::Ogmios::Annotations')) { } 0 0 0
1222 0 $self = shift;
1223 } else {
1224 0 $self = Lingua::Ogmios::Annotations->new;
1225 }
1226 0 my $file = shift;
1227  
1228 0 my $line;
1229 0 my $xmlns = undef;
1230  
1231 0 open FILE, $file;
1232 0 binmode(FILE);
1233  
1234 0 ▶ while(($line=<FILE>)){
Branch: 1 branch
BranchTrueFalseTotal
if (defined($line = readline FILE)) 0 0 0
1235 0 ▶ if ($line =~ /xmlns=\"?([^\"]+)\"?/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /xmlns=\"?([^\"]+)\"?/) 0 0 0
1236 0 $xmlns = $1;
1237 0 next;
1238 }
1239 };
1240 0 close FILE;
1241  
1242 0 $self->setNamespace($xmlns);
1243  
1244 0 return($xmlns);
1245 }
1246  
1247 0 ▶sub setNamespace {
Subroutine setNamespace: not called CC=1 SCAR=6.9
Pod undocumented
1248 0 my ($self, $ns) = @_;
1249  
1250 0 $self->{"Namespace"} = $ns;
1251 }
1252  
1253 33990 ▶sub getSectionLevel {
Subroutine getSectionLevel: called CC=1 SCAR=0.0
Pod undocumented
1254 33990 my ($self) = @_;
1255  
1256 33990 return($self->{'section_level'});
1257 }
1258  
1259 41479 ▶sub getTokenLevel {
Subroutine getTokenLevel: called CC=1 SCAR=0.0
Pod undocumented
1260 41479 my ($self) = @_;
1261  
1262 41479 return($self->{'token_level'});
1263 }
1264  
1265 7266 ▶sub getWordLevel {
Subroutine getWordLevel: called CC=1 SCAR=0.0
Pod undocumented
1266 7266 my ($self) = @_;
1267  
1268 7266 return($self->{'word_level'});
1269 }
1270  
1271 0 ▶sub getPhraseLevel {
Subroutine getPhraseLevel: not called CC=1 SCAR=6.9
Pod undocumented
1272 0 my ($self) = @_;
1273  
1274 0 return($self->{'phrase_level'});
1275 }
1276  
1277 0 ▶sub getEnumerationLevel {
Subroutine getEnumerationLevel: not called CC=1 SCAR=6.9
Pod undocumented
1278 0 my ($self) = @_;
1279  
1280 0 return($self->{'enumeration_level'});
1281 }
1282  
1283 7176 ▶sub getSentenceLevel {
Subroutine getSentenceLevel: called CC=1 SCAR=0.0
Pod undocumented
1284 7176 my ($self) = @_;
1285  
1286 7176 return($self->{'sentence_level'});
1287 }
1288  
1289 0 ▶sub getSyntacticRelationLevel {
Subroutine getSyntacticRelationLevel: not called CC=1 SCAR=6.9
Pod undocumented
1290 0 my ($self) = @_;
1291  
1292 0 return($self->{'syntactic_relation_level'});
1293 }
1294  
1295 5256 ▶sub getSemanticUnitLevel {
Subroutine getSemanticUnitLevel: called CC=1 SCAR=0.0
Pod undocumented
1296 5256 my ($self) = @_;
1297  
1298 5256 return($self->{'semantic_unit_level'});
1299 }
1300  
1301 0 ▶sub getDomainSpecificRelationLevel {
Subroutine getDomainSpecificRelationLevel: not called CC=1 SCAR=6.9
Pod undocumented
1302 0 my ($self) = @_;
1303  
1304 0 return($self->{'domain_specific_relation_level'});
1305 }
1306  
1307 0 ▶sub getAnaphoraRelationLevel {
Subroutine getAnaphoraRelationLevel: not called CC=1 SCAR=6.9
Pod undocumented
1308 0 my ($self) = @_;
1309  
1310 0 return($self->{'anaphora_relation_level'});
1311 }
1312  
1313 18 ▶sub getLemmaLevel {
Subroutine getLemmaLevel: called CC=1 SCAR=0.0
Pod undocumented
1314 18 my ($self) = @_;
1315  
1316 18 return($self->{'lemma_level'});
1317 }
1318  
1319 96 ▶sub getLogLevel {
Subroutine getLogLevel: called CC=1 SCAR=0.0
Pod undocumented
1320 96 my ($self) = @_;
1321  
1322 96 return($self->{'log_level'});
1323 }
1324  
1325 18 ▶sub getMorphosyntacticFeaturesLevel {
Subroutine getMorphosyntacticFeaturesLevel: called CC=1 SCAR=0.0
Pod undocumented
1326 18 my ($self) = @_;
1327  
1328 18 return($self->{'morphosyntactic_features_level'});
1329 }
1330  
1331 0 ▶sub getSemanticFeaturesLevel {
Subroutine getSemanticFeaturesLevel: not called CC=1 SCAR=6.9
Pod undocumented
1332 0 my ($self) = @_;
1333  
1334 0 return($self->{'semantic_features_level'});
1335 }
1336  
1337 0 ▶sub getStemLevel {
Subroutine getStemLevel: not called CC=1 SCAR=6.9
Pod undocumented
1338 0 my ($self) = @_;
1339  
1340 0 return($self->{'stem_level'});
1341 }
1342  
1343 78 ▶sub addSection {
Subroutine addSection: called CC=6 SCAR=28.1
Pod undocumented
1344 78 my ($self, $section, $parentSection) = @_;
1345  
1346 78 my $parentSection2;
1347  
1348 78 my $id = $self->getSectionLevel->addElement($section);
1349  
1350 78 ▶ if (defined $parentSection) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $parentSection) 0 78 78
1351 0 ▶ if (ref($parentSection) eq "") {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $parentSection eq '') { } 0 0 0
1352 0 ▶ if ($self->getSectionLevel->existsElement($parentSection)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->getSectionLevel->existsElement($parentSection)) 0 0 0
1353 0 $parentSection2 = $self->getSectionLevel->getElement($parentSection);
1354 }
1355 } else {
1356 0 $parentSection2 = $parentSection;
1357 }
1358 0 ▶ if (defined $parentSection2) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $parentSection2) 0 0 0
1359 0 $section->parent_section($parentSection2);
1360 0 push @{$parentSection2->child_sections}, $section;
1361 }
1362 }
1363  
1364 78 ▶ warn "section $id added\n" unless $debug_devel_level != 1;
Branch: 1 branch
BranchTrueFalseTotal
unless $debug_devel_level != 1 0 78 78
1365 78 return($id);
1366 }
1367  
1368 6463 ▶sub addToken {
Subroutine addToken: called CC=2 SCAR=7.0
Pod undocumented
1369 6463 my ($self, $token) = @_;
1370  
1371 6463 my $id = $self->getTokenLevel->addElement($token);
1372 6463 ▶ warn "token $id added\n" unless $debug_devel_level != 1;
Branch: 1 branch
BranchTrueFalseTotal
unless $debug_devel_level != 1 0 6463 6463
1373 6463 return($id);
1374 }
1375  
1376 0 ▶sub addWord {
Subroutine addWord: not called CC=2 SCAR=17.9
Pod undocumented
1377 0 my ($self, $word) = @_;
1378  
1379  
1380 0 my $id = $self->getWordLevel->addElement($word);
1381 0 ▶ warn "word $id added\n" unless $debug_devel_level != 1;
Branch: 1 branch
BranchTrueFalseTotal
unless $debug_devel_level != 1 0 0 0
1382 0 return($id);
1383 }
1384  
1385 123 ▶sub addSentence {
Subroutine addSentence: called CC=2 SCAR=7.0
Pod undocumented
1386 123 my ($self, $sentence) = @_;
1387  
1388 123 my $id = $self->getSentenceLevel->addElement($sentence);
1389 123 ▶ warn "sentence $id added\n" unless $debug_devel_level != 1;
Branch: 1 branch
BranchTrueFalseTotal
unless $debug_devel_level != 1 0 123 123
1390 123 return($id);
1391 }
1392  
1393  
1394 0 ▶sub addAnaphoraRelation {
Subroutine addAnaphoraRelation: not called CC=2 SCAR=17.9
Pod undocumented
1395 0 my ($self, $anaphorarelation) = @_;
1396  
1397 0 my $id = $self->getAnaphoraRelationLevel->addElement($anaphorarelation);
1398 0 ▶ warn "Anaphora relation $id added\n" unless $debug_devel_level != 1;
Branch: 1 branch
BranchTrueFalseTotal
unless $debug_devel_level != 1 0 0 0
1399 0 return($id);
1400 }
1401  
1402  
1403
1404  
1405 0 ▶sub addDomainSpecificRelation {
Subroutine addDomainSpecificRelation: not called CC=2 SCAR=17.9
Pod undocumented
1406 0 my ($self, $domainspecificrelation) = @_;
1407  
1408 0 my $id = $self->getDomainSpecificRelationLevel->addElement($domainspecificrelation);
1409 0 ▶ warn "Domain specific relation $id added\n" unless $debug_devel_level != 1;
Branch: 1 branch
BranchTrueFalseTotal
unless $debug_devel_level != 1 0 0 0
1410 0 return($id);
1411 }
1412  
1413 0 ▶sub addLemma {
Subroutine addLemma: not called CC=2 SCAR=17.9
Pod undocumented
1414 0 my ($self, $lemma) = @_;
1415  
1416 0 my $id = $self->getLemmaLevel->addElement($lemma);
1417 0 ▶ warn "Lemma $id added\n" unless $debug_devel_level != 1;
Branch: 1 branch
BranchTrueFalseTotal
unless $debug_devel_level != 1 0 0 0
1418 0 return($id);
1419 }
1420  
1421
1422 0 ▶sub addMorphosyntacticFeatures {
Subroutine addMorphosyntacticFeatures: not called CC=2 SCAR=17.9
Pod undocumented
1423 0 my ($self, $morphosyntacticfeatures) = @_;
1424  
1425 0 my $id = $self->getMorphosyntacticFeaturesLevel->addElement($morphosyntacticfeatures);
1426 0 ▶ warn "Morphosyntactic features $id added\n" unless $debug_devel_level != 1;
Branch: 1 branch
BranchTrueFalseTotal
unless $debug_devel_level != 1 0 0 0
1427 0 return($id);
1428 }
1429  
1430  
1431 0 ▶sub addPhrase {
Subroutine addPhrase: not called CC=1 SCAR=6.9
Pod undocumented
1432 0 my ($self, $phrase) = @_;
1433  
1434 # warn "AddPhrase\n";
1435 0 my $id = $self->getPhraseLevel->addElement($phrase);
1436 # warn "Phrase $id added\n"; # unless $debug_devel_level != 1;
1437 0 return($id);
1438 }
1439  
1440 0 ▶sub addEnumeration {
Subroutine addEnumeration: not called CC=1 SCAR=6.9
Pod undocumented
1441 0 my ($self, $enumeration) = @_;
1442  
1443 # warn "AddEnumeration\n";
1444 0 my $id = $self->getEnumerationLevel->addElement($enumeration);
1445 # warn "Enumeration $id added\n"; # unless $debug_devel_level != 1;
1446 0 return($id);
1447 }
1448  
1449
1450 0 ▶sub addSemanticFeatures {
Subroutine addSemanticFeatures: not called CC=2 SCAR=17.9
Pod undocumented
1451 0 my ($self, $semanticfeatures) = @_;
1452  
1453 0 my $id = $self->getSemanticFeaturesLevel->addElement($semanticfeatures);
1454 0 ▶ warn "Semantic features $id added\n" unless $debug_devel_level != 1;
Branch: 1 branch
BranchTrueFalseTotal
unless $debug_devel_level != 1 0 0 0
1455 0 return($id);
1456 }
1457  
1458 0 ▶sub delSemanticFeaturesFromTermId {
Subroutine delSemanticFeaturesFromTermId: not called CC=4 SCAR=30.0
Pod undocumented
1459 0 my ($self, $semanticUnit) = @_;
1460  
1461 0 my $id;
1462 my $semanticFeatures ;
1463  
1464 0 my @tmp;
1465  
1466 0 my $i = 0;
1467 # warn "#SemF: " . scalar(@{$self->getSemanticFeaturesLevel->getElementFromIndex("refid_semantic_unit", $semanticUnit->getId)}) . "\n";
1468  
1469 0 foreach $semanticFeatures (@{$self->getSemanticFeaturesLevel->getElementFromIndex("refid_semantic_unit", $semanticUnit->getId)}) {
1470 0 ▶ if (defined $semanticFeatures) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $semanticFeatures) { } 0 0 0
1471 # warn "=>" . $semanticFeatures->getId . " (" . $i++ . ")\n";
1472 0 $id = $self->getSemanticFeaturesLevel->delElement($semanticFeatures);
1473 0 ▶ warn "semantic features $id deleted\n" unless $debug_devel_level != 1;
Branch: 1 branch
BranchTrueFalseTotal
unless $debug_devel_level != 1 0 0 0
1474 0 push @tmp, $id;
1475 } else {
1476 # warn "No semantic features\n";
1477 }
1478 }
1479 0 return(\@tmp);
1480 }
1481  
1482  
1483  
1484 0 ▶sub addStem {
Subroutine addStem: not called CC=2 SCAR=17.9
Pod undocumented
1485 0 my ($self, $stem) = @_;
1486  
1487 0 my $id = $self->getStemLevel->addElement($stem);
1488 0 ▶ warn "stem $id added\n" unless $debug_devel_level != 1;
Branch: 1 branch
BranchTrueFalseTotal
unless $debug_devel_level != 1 0 0 0
1489 0 return($id);
1490 }
1491  
1492 0 ▶sub addSyntacticRelation {
Subroutine addSyntacticRelation: not called CC=2 SCAR=17.9
Pod undocumented
1493 0 my ($self, $syntacticrelation) = @_;
1494  
1495 0 my $id = $self->getSyntacticRelationLevel->addElement($syntacticrelation);
1496 0 ▶ warn "Syntactic relation $id added\n" unless $debug_devel_level != 1;
Branch: 1 branch
BranchTrueFalseTotal
unless $debug_devel_level != 1 0 0 0
1497 0 return($id);
1498 }
1499  
1500 96 ▶sub addLogProcessing {
Subroutine addLogProcessing: called CC=2 SCAR=7.1
Pod undocumented
1501 96 my ($self, $logprocessing) = @_;
1502  
1503 96 my $id = $self->getLogLevel->addElement($logprocessing);
1504 96 ▶ warn "Log processing $id added\n" unless $debug_devel_level != 1;
Branch: 1 branch
BranchTrueFalseTotal
unless $debug_devel_level != 1 0 96 96
1505 }
1506  
1507 0 ▶sub addSemanticUnit {
Subroutine addSemanticUnit: not called CC=2 SCAR=17.9
Pod undocumented
1508 0 my ($self, $semanticUnit) = @_;
1509  
1510 0 my $id = $self->getSemanticUnitLevel->addElement($semanticUnit);
1511 0 ▶ warn "semantic unit $id added\n" unless $debug_devel_level != 1;
Branch: 1 branch
BranchTrueFalseTotal
unless $debug_devel_level != 1 0 0 0
1512 0 return($id);
1513 }
1514  
1515 0 ▶sub delSemanticUnit {
Subroutine delSemanticUnit: not called CC=2 SCAR=17.9
Pod undocumented
1516 0 my ($self, $semanticUnit) = @_;
1517  
1518 # warn "del : " . $semanticUnit->getId . "\n";
1519 0 $self->delSemanticFeaturesFromTermId($semanticUnit);
1520 # warn "OK\n";
1521 0 my $id = $self->getSemanticUnitLevel->delElement($semanticUnit);
1522 # warn "End\n";
1523 # if ($semanticUnit->reference_name eq "refid_phrase") {
1524 # warn "remove " . $semanticUnit->reference . "\n";
1525 # $self->getSemanticUnitLevel->delElementToIndexes($semanticUnit->reference);
1526 # }
1527  
1528  
1529 0 ▶ warn "semantic unit $id deleted\n" unless $debug_devel_level != 1;
Branch: 1 branch
BranchTrueFalseTotal
unless $debug_devel_level != 1 0 0 0
1530 0 return($id);
1531 }
1532  
1533 0 ▶sub delEnumeration {
Subroutine delEnumeration: not called CC=2 SCAR=17.9
Pod undocumented
1534 0 my ($self, $enumeration) = @_;
1535  
1536 0 my $id = $self->getEnumerationLevel->delElement($enumeration);
1537  
1538 # if ($semanticUnit->reference_name eq "refid_phrase") {
1539 # warn "remove " . $semanticUnit->reference . "\n";
1540 # $self->getSemanticUnitLevel->delElementToIndexes($semanticUnit->reference);
1541 # }
1542  
1543  
1544 0 ▶ warn "semantic unit $id deleted\n" unless $debug_devel_level != 1;
Branch: 1 branch
BranchTrueFalseTotal
unless $debug_devel_level != 1 0 0 0
1545 0 return($id);
1546 }
1547  
1548  
1549 1 ▶sub XMLout {
Subroutine XMLout: called CC=3 SCAR=11.1
Pod undocumented
1550 1 my ($self) = @_;
1551 1 my $level;
1552  
1553 my $str;
1554  
1555 1 $str = $self->getAcquisitionSection->toString;
1556 1 $str .= "\n <linguisticAnalysis>\n";
1557 1 foreach $level ($self->getLevels4Print) {
1558 # warn "$level\n";
1559 2 $str .= $level->XMLout;
1560 }
1561 1 $str .= " </linguisticAnalysis>\n";
1562 1 ▶ if (defined $self->getRelevanceSection) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->getRelevanceSection) 0 1 1
1563 0 $self->getRelevanceSection; #->toString;
1564 }
1565  
1566 1 return($str);
1567 }
1568  
1569 0 ▶sub getNamedEntitiesByType {
Subroutine getNamedEntitiesByType: not called CC=4 SCAR=30.0
Pod undocumented
1570 0 my ($self, $type) = @_;
1571  
1572 0 my $element;
1573 my @tmp;
1574  
1575 0 foreach $element (@{$self->getSemanticUnitLevel->getElements}) {
1576 0 ▶ if (($element->isNamedEntity) && ($element->NEtype eq $type)){
Branch: 1 branch
BranchTrueFalseTotal
if ($element->isNamedEntity and $element->NEtype eq $type) 0 0 0
Condition0%0/3
$element->isNamedEntity and $element->NEtype eq $type
!ll&&!rl&&r
000
MC/DC0%0/2
$element->isNamedEntity and $element->NEtype eq $type
$element->isNamedEntity $element->NEtype eq $type
Truth table0%0/3
A and B
A= $element->isNamedEntityB= $element->NEtype eq $type
ABresult
0X0
100
111
1577 0 push @tmp, $element;
1578 }
1579 }
1580 0 return(\@tmp);
1581 }
1582  
1583 0 ▶sub getTermsByType {
Subroutine getTermsByType: not called CC=5 SCAR=34.0
Pod undocumented
1584 0 my ($self, $type) = @_;
1585  
1586 0 my $element;
1587 my @tmp;
1588 0 my $semf;
1589  
1590 0 foreach $element (@{$self->getSemanticUnitLevel->getElements}) {
1591 0 ▶ if ($element->isTerm) {
Branch: 1 branch
BranchTrueFalseTotal
if ($element->isTerm) 0 0 0
1592 0 ▶ if ($self->getSemanticFeaturesLevel->existsElementFromIndex("refid_semantic_unit", $element->getId)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->getSemanticFeaturesLevel->existsElementFromIndex("refid_semantic_unit", $element->getId)) 0 0 0
1593 0 $semf = $self->getSemanticFeaturesLevel->getElementFromIndex("refid_semantic_unit", $element->getId)->[0];
1594 0 ▶ if ($semf->first_node_first_semantic_category eq $type) {
Branch: 1 branch
BranchTrueFalseTotal
if ($semf->first_node_first_semantic_category eq $type) 0 0 0
1595 0 push @tmp, $element;
1596 }
1597 }
1598 }
1599 }
1600 0 return(\@tmp);
1601 }
1602  
1603 0 ▶sub existsSectionLevel {
Subroutine existsSectionLevel: not called CC=1 SCAR=6.9
Pod undocumented
1604 0 my ($self) = @_;
1605  
1606 0 return($self->{'section_level'}->getSize != 0);
1607 }
1608  
1609 0 ▶sub existsTokenLevel {
Subroutine existsTokenLevel: not called CC=1 SCAR=6.9
Pod undocumented
1610 0 my ($self) = @_;
1611  
1612 0 return($self->{'token_level'}->getSize != 0);
1613 }
1614  
1615 6 ▶sub existsWordLevel {
Subroutine existsWordLevel: called CC=1 SCAR=0.0
Pod undocumented
1616 6 my ($self) = @_;
1617  
1618 6 return($self->{'word_level'}->getSize != 0);
1619 }
1620  
1621 0 ▶sub existsPhraseLevel {
Subroutine existsPhraseLevel: not called CC=1 SCAR=6.9
Pod undocumented
1622 0 my ($self) = @_;
1623  
1624 0 return($self->{'phrase_level'}->getSize != 0);
1625 }
1626  
1627 0 ▶sub existsEnumerationLevel {
Subroutine existsEnumerationLevel: not called CC=1 SCAR=6.9
Pod undocumented
1628 0 my ($self) = @_;
1629  
1630 0 return($self->{'enumeration_level'}->getSize != 0);
1631 }
1632  
1633 6 ▶sub existsSentenceLevel {
Subroutine existsSentenceLevel: called CC=1 SCAR=0.0
Pod undocumented
1634 6 my ($self) = @_;
1635  
1636 6 return($self->{'sentence_level'}->getSize != 0);
1637 }
1638  
1639 0 ▶sub existsSyntacticRelationLevel {
Subroutine existsSyntacticRelationLevel: not called CC=1 SCAR=6.9
Pod undocumented
1640 0 my ($self) = @_;
1641  
1642 0 return($self->{'syntactic_relation_level'}->getSize != 0);
1643 }
1644  
1645 0 ▶sub existsSemanticUnitLevel {
Subroutine existsSemanticUnitLevel: not called CC=1 SCAR=6.9
Pod undocumented
1646 0 my ($self) = @_;
1647  
1648 0 return($self->{'semantic_unit_level'}->getSize != 0);
1649 }
1650  
1651 0 ▶sub existsDomainSpecificRelationLevel {
Subroutine existsDomainSpecificRelationLevel: not called CC=1 SCAR=6.9
Pod undocumented
1652 0 my ($self) = @_;
1653  
1654 0 return($self->{'domain_specific_relation_level'}->getSize != 0);
1655 }
1656  
1657 0 ▶sub existsAnaphoraRelationLevel {
Subroutine existsAnaphoraRelationLevel: not called CC=1 SCAR=6.9
Pod undocumented
1658 0 my ($self) = @_;
1659  
1660 0 return($self->{'anaphora_relation_level'}->getSize != 0);
1661 }
1662  
1663 6 ▶sub existsLemmaLevel {
Subroutine existsLemmaLevel: called CC=1 SCAR=0.0
Pod undocumented
1664 6 my ($self) = @_;
1665  
1666 6 return($self->{'lemma_level'}->getSize != 0);
1667 }
1668  
1669 0 ▶sub existsLogLevel {
Subroutine existsLogLevel: not called CC=1 SCAR=6.9
Pod undocumented
1670 0 my ($self) = @_;
1671  
1672 0 return($self->{'log_level'}->getSize != 0);
1673 }
1674  
1675 6 ▶sub existsMorphosyntacticFeaturesLevel {
Subroutine existsMorphosyntacticFeaturesLevel: called CC=1 SCAR=0.0
Pod undocumented
1676 6 my ($self) = @_;
1677  
1678 6 return($self->{'morphosyntactic_features_level'}->getSize != 0);
1679 }
1680  
1681 0 ▶sub existsSemanticFeaturesLevel {
Subroutine existsSemanticFeaturesLevel: not called CC=1 SCAR=6.9
Pod undocumented
1682 0 my ($self) = @_;
1683  
1684 0 return($self->{'semantic_features_level'}->getSize != 0);
1685 }
1686  
1687 0 ▶sub existsStemLevel {
Subroutine existsStemLevel: not called CC=1 SCAR=6.9
Pod undocumented
1688 0 my ($self) = @_;
1689  
1690 0 return($self->{'stem_level'}->getSize != 0);
1691 }
1692  
1693  
1694 16 1;
1695  
1696 __END__
« blib/lib/Lingua/Ogmios/NLPWrappers/HeidelTime.pm ↑ Summary blib/lib/Lingua/Ogmios/NLPWrappers/Faster.pm »