« blib/lib/Lingua/Ogmios/Annotations/MorphosyntacticFeatures.pm
↑ Summary
blib/lib/Lingua/Ogmios/Annotations/Enumeration.pm »
| 1 | package Lingua::Ogmios::Annotations::Sentence; | ||||||||||||||||||||||||||||||||||||||||||
| 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 Lingua::Ogmios::Annotations::Element; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 16 | our @ISA = qw(Lingua::Ogmios::Annotations::Element); | |||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||
| 10 | # <!-- =================================================== --> | ||||||||||||||||||||||||||||||||||||||||||
| 11 | # <!-- SENTENCE LEVEL --> | ||||||||||||||||||||||||||||||||||||||||||
| 12 | # <!-- =================================================== --> | ||||||||||||||||||||||||||||||||||||||||||
| 13 | # <!ELEMENT sentence_level (log_id?, comments*, sentence+) > | ||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||
| 15 | # <!-- sentence --> | ||||||||||||||||||||||||||||||||||||||||||
| 16 | # <!ELEMENT sentence (id, log_id?, refid_start_token, | ||||||||||||||||||||||||||||||||||||||||||
| 17 | # refid_end_token, form?) > | ||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||
| 19 | # <!-- Reference of the token at the beginning --> | ||||||||||||||||||||||||||||||||||||||||||
| 20 | # <!-- of the sentence --> | ||||||||||||||||||||||||||||||||||||||||||
| 21 | # <!ELEMENT refid_start_token | ||||||||||||||||||||||||||||||||||||||||||
| 22 | # (#PCDATA) > | ||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||
| 24 | # <!-- Reference of the token at the end --> | ||||||||||||||||||||||||||||||||||||||||||
| 25 | # <!-- of the sentence --> | ||||||||||||||||||||||||||||||||||||||||||
| 26 | # <!ELEMENT refid_end_token | ||||||||||||||||||||||||||||||||||||||||||
| 27 | # (#PCDATA) > | ||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||
| 29 | # <!-- word id, part of the word --> | ||||||||||||||||||||||||||||||||||||||||||
| 30 | # <!ELEMENT refid_word (#PCDATA) > | ||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||
| 33 | 123 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=7 SCAR=21.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 34 | 123 | my ($class, $fields) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||
| 36 | 123 | ▶ | if (!defined $fields->{'id'}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 37 | 123 | $fields->{'id'} = -1; | |||||||||||||||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||||||||||||||||
| 39 | 123 | ▶ | if (!defined $fields->{'refid_start_token'}) { # refid_start_token | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | die("refid_start_token is not defined"); | |||||||||||||||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||||||||||||||||
| 42 | 123 | ▶ | if (!defined $fields->{'refid_end_token'}) { # refid_end_token | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | die("refid_end_token is not defined"); | |||||||||||||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||||||||||||
| 45 | my $sentence = $class->SUPER::new({ | ||||||||||||||||||||||||||||||||||||||||||
| 46 | 123 | 'id' => $fields->{'id'}, | |||||||||||||||||||||||||||||||||||||||||
| 47 | # 'form' => $fields->{'form'}, | ||||||||||||||||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||||||||||||||||
| 49 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 50 | 123 | bless ($sentence,$class); | |||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||
| 52 | 123 | $sentence->refid_start_token($fields->{'refid_start_token'}); | |||||||||||||||||||||||||||||||||||||||||
| 53 | 123 | $sentence->refid_end_token($fields->{'refid_end_token'}); | |||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||
| 55 | 123 | ▶ | if (defined $fields->{'form'}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 56 | 123 | $sentence->setForm($fields->{'form'}); | |||||||||||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||
| 59 | 123 | ▶ | if (defined $fields->{'log_id'}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | $sentence->setLogId($fields->{'log_id'}); | |||||||||||||||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||||||||||||||||
| 62 | 123 | ▶ | if (defined $fields->{'lang'}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | $sentence->Lang($fields->{'lang'}); | |||||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||||||
| 65 | 123 | return($sentence); | |||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | ▶ | sub start_token { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
start_token: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | return($self->refid_start_token); | |||||||||||||||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||
| 74 | 246 | ▶ | sub refid_start_token { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
refid_start_token: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 75 | 246 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||
| 77 | 246 | ▶ | $self->{refid_start_token} = shift if @_; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 78 | 246 | return($self->{refid_start_token}); | |||||||||||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||
| 81 | # sub getFrom { | ||||||||||||||||||||||||||||||||||||||||||
| 82 | # my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||
| 83 | # return($self->{refid_start_token}); | ||||||||||||||||||||||||||||||||||||||||||
| 84 | # } | ||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | ▶ | sub end_token { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
end_token: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | return($self->refid_end_token); | |||||||||||||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||
| 92 | 5136 | ▶ | sub refid_end_token { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
refid_end_token: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 93 | 5136 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||
| 95 | 5136 | ▶ | $self->{refid_end_token} = shift if @_; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 96 | 5136 | return($self->{refid_end_token}); | |||||||||||||||||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||
| 99 | 123 | ▶ | sub lang { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
lang: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 100 | 123 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||
| 102 | 123 | ▶ | $self->{"lang"} = shift if @_; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 103 | 123 | return($self->{"lang"}); | |||||||||||||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||
| 106 | # sub getTo { | ||||||||||||||||||||||||||||||||||||||||||
| 107 | # my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||
| 108 | # return($self->{refid_end_token}); | ||||||||||||||||||||||||||||||||||||||||||
| 109 | # } | ||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | ▶ | sub XMLout { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
XMLout: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | my ($self, $order) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | return($self->SUPER::XMLout("sentence", $order)); | |||||||||||||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||
| 118 | 123 | ▶ | sub reference { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
reference: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 119 | 123 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||
| 121 | 123 | my @refs; | |||||||||||||||||||||||||||||||||||||||||
| 122 | my $token; | ||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||
| 124 | 123 | $token = $self->refid_start_token; | |||||||||||||||||||||||||||||||||||||||||
| 125 | 123 | push @refs, $token; | |||||||||||||||||||||||||||||||||||||||||
| 126 | 123 | ▶ | while(!$token->equals($self->refid_end_token)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 127 | 4890 | $token = $token->next; | |||||||||||||||||||||||||||||||||||||||||
| 128 | 4890 | push @refs, $token; | |||||||||||||||||||||||||||||||||||||||||
| 129 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 130 | 123 | return(\@refs); | |||||||||||||||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | ▶ | sub getWordsFromSentence { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getWordsFromSentence: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | my ($self, $document) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | my $word; | |||||||||||||||||||||||||||||||||||||||||
| 138 | # my $lemma; | ||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||
| 140 | # my $sentLemma = "";; | ||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | my $token = $self->start_token; | |||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||
| 143 | # my $token_prec = 0; | ||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | my @words = (); | |||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | ▶ | if (defined $token) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | ▶ | do { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
defined $token and defined $token->previous and not $token->previous->equals($self->end_token)
defined $token and defined $token->previous
MC/DC0%0/3
defined $token and defined $token->previous and not $token->previous->equals($self->end_token)
defined $token
defined $token->previous
not $token->previous->equals($self->end_token)
Truth table0%0/4
A and B and not(C)
A= defined $tokenB= defined $token->previousC= not $token->previous->equals($self->end_token)
| |||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | ▶ | if ($document->getAnnotations->getWordLevel->existsElementFromIndex("list_refid_token", $token->getId)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | $word = $document->getAnnotations->getWordLevel->getElementFromIndex("list_refid_token", $token->getId)->[0]; | |||||||||||||||||||||||||||||||||||||||||
| 150 | # $lemma = $document->getAnnotations->getLemmaLevel->getElementFromIndex("refid_word", $word->getId)->[0]; | ||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | push @words, $word; | |||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | $token = $word->end_token; | |||||||||||||||||||||||||||||||||||||||||
| 153 | # $token_prec = 0; | ||||||||||||||||||||||||||||||||||||||||||
| 154 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 155 | # $offsets{length($sentLemma)} = [$token]; | ||||||||||||||||||||||||||||||||||||||||||
| 156 | # $sentLemma .= $token->getContent; | ||||||||||||||||||||||||||||||||||||||||||
| 157 | # $token_prec = 1; | ||||||||||||||||||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | ▶ | if (defined $token) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | $token = $token->next; | |||||||||||||||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||||||||||||||||
| 162 | } while((defined $token) && (defined $token->previous) && (!($token->previous->equals($self->end_token)))); | ||||||||||||||||||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | return(\@words); | |||||||||||||||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | ▶ | sub getTermsFromSentence { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getTermsFromSentence: not called CC=8 SCAR=42.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | my ($self, $document) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | my $word; | |||||||||||||||||||||||||||||||||||||||||
| 172 | # my $lemma; | ||||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||
| 174 | # my $sentLemma = "";; | ||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | my $token = $self->start_token; | |||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||
| 177 | # my $token_prec = 0; | ||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | my @terms = (); | |||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | my @semfs; | |||||||||||||||||||||||||||||||||||||||||
| 180 | my $semf; | ||||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | ▶ | if (defined $token) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | ▶ | do { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
defined $token and defined $token->previous and not $token->previous->equals($self->end_token)
defined $token and defined $token->previous
MC/DC0%0/3
defined $token and defined $token->previous and not $token->previous->equals($self->end_token)
defined $token
defined $token->previous
not $token->previous->equals($self->end_token)
Truth table0%0/4
A and B and not(C)
A= defined $tokenB= defined $token->previousC= not $token->previous->equals($self->end_token)
| |||||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | ▶ | if ($document->getAnnotations->getSemanticUnitLevel->existsElementFromIndex("start_token", $token->getId)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | @semfs = @{$document->getAnnotations->getSemanticUnitLevel->getElementFromIndex("start_token", $token->getId)}; | |||||||||||||||||||||||||||||||||||||||||
| 186 | # $lemma = $document->getAnnotations->getLemmaLevel->getElementFromIndex("refid_word", $word->getId)->[0]; | ||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | foreach $semf (@semfs) { | |||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | ▶ | if ($semf->isTerm) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | push @terms, $semf; | |||||||||||||||||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | $token = $token->next; | |||||||||||||||||||||||||||||||||||||||||
| 194 | } while((defined $token) && (defined $token->previous) && (!($token->previous->equals($self->end_token)))); | ||||||||||||||||||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | return(\@terms); | |||||||||||||||||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||||||||||||
| 201 | 16 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||
| 203 | __END__ | ||||||||||||||||||||||||||||||||||||||||||