line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Lingua::Ogmios::Annotations::Sentence; |
2
|
|
|
|
|
|
|
|
3
|
16
|
|
|
16
|
|
68
|
use strict; |
|
16
|
|
|
|
|
19
|
|
|
16
|
|
|
|
|
632
|
|
4
|
16
|
|
|
16
|
|
66
|
use warnings; |
|
16
|
|
|
|
|
22
|
|
|
16
|
|
|
|
|
347
|
|
5
|
|
|
|
|
|
|
|
6
|
16
|
|
|
16
|
|
57
|
use Lingua::Ogmios::Annotations::Element; |
|
16
|
|
|
|
|
19
|
|
|
16
|
|
|
|
|
10712
|
|
7
|
|
|
|
|
|
|
our @ISA = qw(Lingua::Ogmios::Annotations::Element); |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# |
11
|
|
|
|
|
|
|
# |
12
|
|
|
|
|
|
|
# |
13
|
|
|
|
|
|
|
# |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# |
16
|
|
|
|
|
|
|
#
|
17
|
|
|
|
|
|
|
# refid_end_token, form?) > |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# |
20
|
|
|
|
|
|
|
# |
21
|
|
|
|
|
|
|
#
|
22
|
|
|
|
|
|
|
# (#PCDATA) > |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
# |
25
|
|
|
|
|
|
|
# |
26
|
|
|
|
|
|
|
#
|
27
|
|
|
|
|
|
|
# (#PCDATA) > |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# |
30
|
|
|
|
|
|
|
# |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub new { |
34
|
0
|
|
|
0
|
0
|
|
my ($class, $fields) = @_; |
35
|
|
|
|
|
|
|
|
36
|
0
|
0
|
|
|
|
|
if (!defined $fields->{'id'}) { |
37
|
0
|
|
|
|
|
|
$fields->{'id'} = -1; |
38
|
|
|
|
|
|
|
} |
39
|
0
|
0
|
|
|
|
|
if (!defined $fields->{'refid_start_token'}) { # refid_start_token |
40
|
0
|
|
|
|
|
|
die("refid_start_token is not defined"); |
41
|
|
|
|
|
|
|
} |
42
|
0
|
0
|
|
|
|
|
if (!defined $fields->{'refid_end_token'}) { # refid_end_token |
43
|
0
|
|
|
|
|
|
die("refid_end_token is not defined"); |
44
|
|
|
|
|
|
|
} |
45
|
0
|
|
|
|
|
|
my $sentence = $class->SUPER::new({ |
46
|
|
|
|
|
|
|
'id' => $fields->{'id'}, |
47
|
|
|
|
|
|
|
# 'form' => $fields->{'form'}, |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
); |
50
|
0
|
|
|
|
|
|
bless ($sentence,$class); |
51
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
$sentence->refid_start_token($fields->{'refid_start_token'}); |
53
|
0
|
|
|
|
|
|
$sentence->refid_end_token($fields->{'refid_end_token'}); |
54
|
|
|
|
|
|
|
|
55
|
0
|
0
|
|
|
|
|
if (defined $fields->{'form'}) { |
56
|
0
|
|
|
|
|
|
$sentence->setForm($fields->{'form'}); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
0
|
0
|
|
|
|
|
if (defined $fields->{'log_id'}) { |
60
|
0
|
|
|
|
|
|
$sentence->setLogId($fields->{'log_id'}); |
61
|
|
|
|
|
|
|
} |
62
|
0
|
0
|
|
|
|
|
if (defined $fields->{'lang'}) { |
63
|
0
|
|
|
|
|
|
$sentence->Lang($fields->{'lang'}); |
64
|
|
|
|
|
|
|
} |
65
|
0
|
|
|
|
|
|
return($sentence); |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub start_token { |
69
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
70
|
|
|
|
|
|
|
|
71
|
0
|
|
|
|
|
|
return($self->refid_start_token); |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub refid_start_token { |
75
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
76
|
|
|
|
|
|
|
|
77
|
0
|
0
|
|
|
|
|
$self->{refid_start_token} = shift if @_; |
78
|
0
|
|
|
|
|
|
return($self->{refid_start_token}); |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
# sub getFrom { |
82
|
|
|
|
|
|
|
# my $self = shift; |
83
|
|
|
|
|
|
|
# return($self->{refid_start_token}); |
84
|
|
|
|
|
|
|
# } |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub end_token { |
87
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
88
|
|
|
|
|
|
|
|
89
|
0
|
|
|
|
|
|
return($self->refid_end_token); |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub refid_end_token { |
93
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
94
|
|
|
|
|
|
|
|
95
|
0
|
0
|
|
|
|
|
$self->{refid_end_token} = shift if @_; |
96
|
0
|
|
|
|
|
|
return($self->{refid_end_token}); |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
sub lang { |
100
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
101
|
|
|
|
|
|
|
|
102
|
0
|
0
|
|
|
|
|
$self->{"lang"} = shift if @_; |
103
|
0
|
|
|
|
|
|
return($self->{"lang"}); |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
# sub getTo { |
107
|
|
|
|
|
|
|
# my $self = shift; |
108
|
|
|
|
|
|
|
# return($self->{refid_end_token}); |
109
|
|
|
|
|
|
|
# } |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
sub XMLout { |
113
|
0
|
|
|
0
|
0
|
|
my ($self, $order) = @_; |
114
|
|
|
|
|
|
|
|
115
|
0
|
|
|
|
|
|
return($self->SUPER::XMLout("sentence", $order)); |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
sub reference { |
119
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
120
|
|
|
|
|
|
|
|
121
|
0
|
|
|
|
|
|
my @refs; |
122
|
|
|
|
|
|
|
my $token; |
123
|
|
|
|
|
|
|
|
124
|
0
|
|
|
|
|
|
$token = $self->refid_start_token; |
125
|
0
|
|
|
|
|
|
push @refs, $token; |
126
|
0
|
|
|
|
|
|
while(!$token->equals($self->refid_end_token)) { |
127
|
0
|
|
|
|
|
|
$token = $token->next; |
128
|
0
|
|
|
|
|
|
push @refs, $token; |
129
|
|
|
|
|
|
|
}; |
130
|
0
|
|
|
|
|
|
return(\@refs); |
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
sub getWordsFromSentence { |
135
|
0
|
|
|
0
|
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
|
0
|
|
|
|
|
if (defined $token) { |
147
|
0
|
|
0
|
|
|
|
do { |
|
|
|
0
|
|
|
|
|
148
|
0
|
0
|
|
|
|
|
if ($document->getAnnotations->getWordLevel->existsElementFromIndex("list_refid_token", $token->getId)) { |
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
|
0
|
|
|
|
|
if (defined $token) { |
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
|
|
|
|
|
|
|
sub getTermsFromSentence { |
169
|
0
|
|
|
0
|
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
|
0
|
|
|
|
|
if (defined $token) { |
183
|
0
|
|
0
|
|
|
|
do { |
|
|
|
0
|
|
|
|
|
184
|
0
|
0
|
|
|
|
|
if ($document->getAnnotations->getSemanticUnitLevel->existsElementFromIndex("start_token", $token->getId)) { |
185
|
0
|
|
|
|
|
|
@semfs = @{$document->getAnnotations->getSemanticUnitLevel->getElementFromIndex("start_token", $token->getId)}; |
|
0
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
# $lemma = $document->getAnnotations->getLemmaLevel->getElementFromIndex("refid_word", $word->getId)->[0]; |
187
|
0
|
|
|
|
|
|
foreach $semf (@semfs) { |
188
|
0
|
0
|
|
|
|
|
if ($semf->isTerm) { |
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
|
|
|
|
|
|
|
1; |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
__END__ |