« blib/lib/Lingua/Ogmios/NLPWrappers/MarkerDetection.pm
↑ Summary
blib/lib/Lingua/Ogmios/NLPWrappers/TermExpansion.pm »
| 1 | package Lingua::Ogmios::Annotations::Word; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 16 | ▶ | use Lingua::Ogmios::Annotations::Element; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 16 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 16 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 16 | our @ISA = qw(Lingua::Ogmios::Annotations::Element); | |||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | # <!-- word --> | ||||||||||||||||||||||||||||
| 11 | # <!ELEMENT word (id, log_id?, list_refid_token, | ||||||||||||||||||||||||||||
| 12 | # form?) > | ||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | # <!-- id of the element --> | ||||||||||||||||||||||||||||
| 15 | # <!ELEMENT id (#PCDATA) > | ||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | # <!-- list of the tokens which compose the words --> | ||||||||||||||||||||||||||||
| 18 | # <!ELEMENT list_refid_token (refid_token)+ > | ||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | # <!-- token id, part of the words --> | ||||||||||||||||||||||||||||
| 21 | # <!ELEMENT refid_token (#PCDATA) > | ||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | # <!-- form --> | ||||||||||||||||||||||||||||
| 24 | # <!ELEMENT form (#PCDATA) > | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: not called CC=8 SCAR=42.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 27 | 0 | my ($class, $fields) = @_; | |||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | 0 | ▶ | if (!defined $fields->{'id'}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 30 | 0 | $fields->{'id'} = -1; | |||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||
| 32 | my $word = $class->SUPER::new({ | ||||||||||||||||||||||||||||
| 33 | 0 | 'id' => $fields->{'id'}, | |||||||||||||||||||||||||||
| 34 | # 'form' => $fields->{'form'}, | ||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||
| 36 | ); | ||||||||||||||||||||||||||||
| 37 | 0 | bless ($word,$class); | |||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 0 | my $i = 0; | |||||||||||||||||||||||||||
| 40 | 0 | my $reference_name; | |||||||||||||||||||||||||||
| 41 | my $ref; | ||||||||||||||||||||||||||||
| 42 | 0 | foreach $ref ('refid_phrase', 'refid_word', 'list_refid_token') { | |||||||||||||||||||||||||||
| 43 | 0 | ▶ | if (defined $fields->{$ref}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 44 | 0 | $reference_name = $ref; | |||||||||||||||||||||||||||
| 45 | 0 | last; | |||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||
| 47 | 0 | $i++; | |||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||
| 49 | 0 | ▶ | if ($i == 3) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 50 | 0 | die("reference (list) is not defined"); | |||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||
| 52 | 0 | $word->reference($reference_name, $fields->{$reference_name}); | |||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | 0 | ▶ | if (defined $fields->{'form'}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 55 | 0 | $word->setForm($fields->{'form'}); | |||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||
| 57 | 0 | ▶ | if (defined $fields->{'isNE'}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 58 | 0 | $word->isNE($fields->{'isNE'}); | |||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | 0 | ▶ | if (defined $fields->{'log_id'}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 62 | 0 | $word->setLogId($fields->{'log_id'}); | |||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||
| 64 | 0 | return($word); | |||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | 0 | ▶ | sub reference_name { | ||||||||||||||||||||||||||
|
Subroutine
reference_name: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 69 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | 0 | ▶ | $self->{'reference'} = shift if @_; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 72 | 0 | return $self->{'reference'}; | |||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | 0 | ▶ | sub reference { | ||||||||||||||||||||||||||
|
Subroutine
reference: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 77 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 78 | 0 | my $ref; | |||||||||||||||||||||||||||
| 79 | my $elt; | ||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | 0 | ▶ | if ((@_) && (scalar @_ == 2)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@_ and scalar @_ == 2
MC/DC0%0/2
@_ and scalar @_ == 2
@_
scalar @_ == 2
Truth table0%0/3
A and B
A= @_B= scalar @_ == 2
| |||||||||||||||||||||||||||||
| 82 | 0 | $self->{'reference'} = shift; | |||||||||||||||||||||||||||
| 83 | 0 | $self->{$self->{'reference'}} = []; | |||||||||||||||||||||||||||
| 84 | 0 | $ref = shift; | |||||||||||||||||||||||||||
| 85 | 0 | foreach $elt (@$ref) { | |||||||||||||||||||||||||||
| 86 | 0 | push @{$self->{$self->{'reference'}}}, $elt; | |||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||
| 89 | 0 | return($self->{$self->{'reference'}}); | |||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | 0 | ▶ | sub end_token { | ||||||||||||||||||||||||||
|
Subroutine
end_token: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 95 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | 0 | ▶ | if ($self->reference_name eq "list_refid_token") { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 99 | 0 | return($self->reference->[$#{$self->reference}]); | |||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||
| 101 | #if list_refid token -> OK | ||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | # if refid word -> word->start_token | ||||||||||||||||||||||||||||
| 104 | # OR | ||||||||||||||||||||||||||||
| 105 | # if refid phrase -> phrase->start_token | ||||||||||||||||||||||||||||
| 106 | 0 | ▶ | if (($self->reference_name eq "refid_word") || | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->reference_name eq "refid_word" or $self->reference_name eq "refid_phrase"
MC/DC0%0/2
$self->reference_name eq "refid_word" or $self->reference_name eq "refid_phrase"
$self->reference_name eq "refid_word"
$self->reference_name eq "refid_phrase"
Truth table0%0/3
A or B
A= $self->reference_name eq "refid_word"B= $self->reference_name eq "refid_phrase"
| |||||||||||||||||||||||||||||
| 107 | ($self->reference_name eq "refid_phrase")){ | ||||||||||||||||||||||||||||
| 108 | 0 | return($self->reference->end_token); | |||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||
| 110 | 0 | return(undef); | |||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||
| 113 | 0 | ▶ | sub start_token { | ||||||||||||||||||||||||||
|
Subroutine
start_token: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 114 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||
| 117 | 0 | ▶ | if ($self->reference_name eq "list_refid_token") { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 118 | 0 | return($self->reference->[0]); | |||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||
| 120 | #if list_refid token -> OK | ||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||
| 122 | # if refid word -> word->start_token | ||||||||||||||||||||||||||||
| 123 | # OR | ||||||||||||||||||||||||||||
| 124 | # if refid phrase -> phrase->start_token | ||||||||||||||||||||||||||||
| 125 | 0 | ▶ | if (($self->reference_name eq "refid_word") || | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->reference_name eq "refid_word" or $self->reference_name eq "refid_phrase"
MC/DC0%0/2
$self->reference_name eq "refid_word" or $self->reference_name eq "refid_phrase"
$self->reference_name eq "refid_word"
$self->reference_name eq "refid_phrase"
Truth table0%0/3
A or B
A= $self->reference_name eq "refid_word"B= $self->reference_name eq "refid_phrase"
| |||||||||||||||||||||||||||||
| 126 | ($self->reference_name eq "refid_phrase")){ | ||||||||||||||||||||||||||||
| 127 | 0 | return($self->reference->start_token); | |||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||
| 129 | 0 | return(undef); | |||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||
| 133 | 0 | ▶ | sub getLastToken { | ||||||||||||||||||||||||||
|
Subroutine
getLastToken: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 134 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||
| 136 | 0 | my @Refs = @{$self->getReference}; | |||||||||||||||||||||||||||
| 137 | 0 | my $last_token = $Refs[$#Refs]; | |||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||
| 139 | 0 | return($last_token); | |||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||
| 142 | 0 | ▶ | sub getReferenceSize { | ||||||||||||||||||||||||||
|
Subroutine
getReferenceSize: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 143 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||
| 145 | 0 | return(scalar(@{$self->{$self->{'reference'}}})); | |||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||
| 148 | 0 | ▶ | sub getReference { | ||||||||||||||||||||||||||
|
Subroutine
getReference: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 149 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||
| 151 | 0 | return($self->{$self->{'reference'}}); | |||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||
| 154 | 0 | ▶ | sub getReferenceIndex { | ||||||||||||||||||||||||||
|
Subroutine
getReferenceIndex: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 155 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 156 | 0 | my $idx = shift; | |||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||
| 158 | 0 | return($self->{$self->{'reference'}}->[$idx]); | |||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||
| 161 | 0 | ▶ | sub isNE { | ||||||||||||||||||||||||||
|
Subroutine
isNE: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 162 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||
| 164 | 0 | ▶ | $self->{'isNE'} = shift if @_; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 165 | 0 | return($self->{'isNE'}); | |||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||
| 168 | 0 | ▶ | sub XMLout { | ||||||||||||||||||||||||||
|
Subroutine
XMLout: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 169 | 0 | my ($self, $order) = @_; | |||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||
| 171 | 0 | return($self->SUPER::XMLout("word", $order)); | |||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||
| 175 | 0 | ▶ | sub getMorphoSyntacticFeatures { | ||||||||||||||||||||||||||
|
Subroutine
getMorphoSyntacticFeatures: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 176 | 0 | my ($self, $document) = @_; | |||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||
| 178 | 0 | return($document->getAnnotations->getMorphosyntacticFeaturesLevel->getElementFromIndex("refid_word", $self->getId)->[0]); | |||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||
| 181 | 0 | ▶ | sub getLemma { | ||||||||||||||||||||||||||
|
Subroutine
getLemma: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 182 | 0 | my ($self, $document) = @_; | |||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||
| 184 | 0 | return($document->getAnnotations->getLemmaLevel->getElementFromIndex("refid_word", $self->getId)->[0]); | |||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||
| 187 | 0 | ▶ | sub getElementFormList { | ||||||||||||||||||||||||||
|
Subroutine
getElementFormList: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 188 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||
| 190 | # warn $self->getForm ."\n"; | ||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||
| 192 | 0 | return($self->getForm); | |||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||
| 196 | 16 | 1; | |||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||
| 198 | __END__ | ||||||||||||||||||||||||||||