line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Lingua::YaTeA::TermCandidate; |
2
|
5
|
|
|
5
|
|
34
|
use strict; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
137
|
|
3
|
5
|
|
|
5
|
|
26
|
use warnings; |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
7803
|
|
4
|
|
|
|
|
|
|
# use UNIVERSAL; |
5
|
|
|
|
|
|
|
# use Scalar::Util qw(blessed); |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $id = 0; |
8
|
|
|
|
|
|
|
our $VERSION=$Lingua::YaTeA::VERSION; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub new |
11
|
|
|
|
|
|
|
{ |
12
|
306
|
|
|
306
|
1
|
525
|
my ($class) = @_; |
13
|
306
|
|
|
|
|
407
|
my $this; |
14
|
306
|
|
|
|
|
722
|
$this->{ID} = $id++; |
15
|
306
|
|
|
|
|
604
|
$this->{KEY} = ""; |
16
|
306
|
|
|
|
|
574
|
$this->{HEAD} = (); |
17
|
306
|
|
|
|
|
566
|
$this->{WORDS} = []; |
18
|
306
|
|
|
|
|
611
|
$this->{OCCURRENCES} = []; |
19
|
306
|
|
|
|
|
483
|
$this->{RELIABILITY} = (); |
20
|
306
|
|
|
|
|
497
|
$this->{TERM_STATUS} = 1; |
21
|
306
|
|
|
|
|
651
|
$this->{ORIGINAL_PHRASE} = (); |
22
|
|
|
|
|
|
|
# $this->{WEIGHT} = 0; |
23
|
306
|
|
|
|
|
717
|
$this->{WEIGHTS} = {}; |
24
|
306
|
|
|
|
|
524
|
$this->{ROOT} = (); |
25
|
306
|
|
|
|
|
531
|
$this->{MNP_STATUS} = 0; # added by SA 13/02/2009 |
26
|
306
|
|
|
|
|
529
|
bless ($this,$class); |
27
|
306
|
|
|
|
|
708
|
return $this; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub setROOT { |
31
|
301
|
|
|
301
|
0
|
485
|
my ($this, $ROOT) = @_; |
32
|
301
|
|
|
|
|
418
|
push @{$this->{ROOT}}, $ROOT; |
|
301
|
|
|
|
|
672
|
|
33
|
301
|
|
|
|
|
616
|
return($this->{ROOT}); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub getROOT { |
37
|
0
|
|
|
0
|
0
|
0
|
my ($this) = @_; |
38
|
0
|
|
|
|
|
0
|
return($this->{ROOT}); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub setTermStatus { |
42
|
0
|
|
|
0
|
1
|
0
|
my ($this, $status) = @_; |
43
|
0
|
|
|
|
|
0
|
$this->{TERM_STATUS} = $status; |
44
|
0
|
|
|
|
|
0
|
return($this->{TERM_STATUS}); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub getTermStatus { |
48
|
0
|
|
|
0
|
1
|
0
|
my ($this) = @_; |
49
|
0
|
|
|
|
|
0
|
return($this->{TERM_STATUS}); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub isTerm { |
53
|
0
|
|
|
0
|
1
|
0
|
my ($this) = @_; |
54
|
|
|
|
|
|
|
|
55
|
0
|
|
|
|
|
0
|
return($this->getTermStatus != 0); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub getLength |
59
|
|
|
|
|
|
|
{ |
60
|
1210
|
|
|
1210
|
1
|
1766
|
my ($this) = @_; |
61
|
1210
|
|
|
|
|
1476
|
return scalar @{$this->getWords}; |
|
1210
|
|
|
|
|
1733
|
|
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub addWord |
65
|
|
|
|
|
|
|
{ |
66
|
408
|
|
|
408
|
1
|
683
|
my ($this,$leaf,$words_a) = @_; |
67
|
408
|
|
|
|
|
566
|
push @{$this->{WORDS}}, $words_a->[$leaf->getIndex]; |
|
408
|
|
|
|
|
943
|
|
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub addOccurrence |
71
|
|
|
|
|
|
|
{ |
72
|
320
|
|
|
320
|
1
|
548
|
my ($this,$occurrence) = @_; |
73
|
320
|
100
|
|
|
|
690
|
if($occurrence->isMaximal) |
74
|
|
|
|
|
|
|
{ |
75
|
1
|
|
|
|
|
4
|
$this->{MNP_STATUS} = 1; # added by SA 13/02/2009:: if at least one occurrence is a MNP, TC is a MNP |
76
|
|
|
|
|
|
|
} |
77
|
320
|
|
|
|
|
480
|
push @{$this->{OCCURRENCES}}, $occurrence; |
|
320
|
|
|
|
|
1124
|
|
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub addOccurrences |
81
|
|
|
|
|
|
|
{ |
82
|
66
|
|
|
66
|
1
|
107
|
my ($this,$occurrences_a) = @_; |
83
|
66
|
|
|
|
|
92
|
my $occurrence; |
84
|
66
|
|
|
|
|
133
|
foreach $occurrence (@$occurrences_a) |
85
|
|
|
|
|
|
|
{ |
86
|
68
|
|
|
|
|
128
|
$this->addOccurrence($occurrence); |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub getKey |
91
|
|
|
|
|
|
|
{ |
92
|
1140
|
|
|
1140
|
1
|
1817
|
my ($this) = @_; |
93
|
1140
|
|
|
|
|
3918
|
return $this->{KEY}; |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
sub getID |
97
|
|
|
|
|
|
|
{ |
98
|
2323
|
|
|
2323
|
1
|
3493
|
my ($this) = @_; |
99
|
2323
|
|
|
|
|
5529
|
return $this->{ID}; |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
sub getMNPStatus |
103
|
|
|
|
|
|
|
{ |
104
|
240
|
|
|
240
|
1
|
378
|
my ($this) = @_; |
105
|
240
|
|
|
|
|
987
|
return $this->{MNP_STATUS}; |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
sub editKey |
109
|
|
|
|
|
|
|
{ |
110
|
692
|
|
|
692
|
1
|
1284
|
my ($this,$string) = @_; |
111
|
692
|
|
|
|
|
1825
|
$this->{KEY} .= $string; |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
sub setHead |
115
|
|
|
|
|
|
|
{ |
116
|
240
|
|
|
240
|
1
|
365
|
my ($this) = @_; |
117
|
240
|
|
|
|
|
514
|
$this->{HEAD} = $this->searchHead(0); |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
sub getHead |
121
|
|
|
|
|
|
|
{ |
122
|
352
|
|
|
352
|
1
|
575
|
my ($this) = @_; |
123
|
352
|
|
|
|
|
783
|
return $this->{HEAD}; |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
sub setWeight |
127
|
|
|
|
|
|
|
{ |
128
|
240
|
|
|
240
|
1
|
323
|
my $this = shift; |
129
|
240
|
|
|
|
|
329
|
my $weight; |
130
|
|
|
|
|
|
|
my $weight_name; |
131
|
240
|
50
|
|
|
|
410
|
if (scalar(@_) == 2) { |
132
|
0
|
|
|
|
|
0
|
$weight_name = shift; |
133
|
|
|
|
|
|
|
} else { |
134
|
|
|
|
|
|
|
# default weight because it's the first |
135
|
240
|
|
|
|
|
312
|
$weight_name = "DDW"; |
136
|
|
|
|
|
|
|
} |
137
|
240
|
|
|
|
|
333
|
$weight = shift; |
138
|
240
|
|
|
|
|
356
|
$this->getWeights->{$weight_name} = $weight; |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
# $this->{WEIGHT} = $weight; |
141
|
|
|
|
|
|
|
} |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
sub getWeight |
144
|
|
|
|
|
|
|
{ |
145
|
1341
|
|
|
1341
|
1
|
1913
|
my $this = shift; |
146
|
|
|
|
|
|
|
|
147
|
1341
|
|
|
|
|
1699
|
my $weight_name; |
148
|
1341
|
50
|
|
|
|
2436
|
if (@_) { |
149
|
1341
|
|
|
|
|
1799
|
$weight_name = shift; |
150
|
|
|
|
|
|
|
} else { |
151
|
|
|
|
|
|
|
# default wieght because it's the first |
152
|
0
|
|
|
|
|
0
|
$weight_name = "DDW"; |
153
|
|
|
|
|
|
|
} |
154
|
1341
|
|
|
|
|
2134
|
return($this->getWeights->{$weight_name}); |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
# return $this->{WEIGHT}; |
157
|
|
|
|
|
|
|
} |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
sub setWeights |
160
|
|
|
|
|
|
|
{ |
161
|
0
|
|
|
0
|
1
|
0
|
my ($this,$weight) = @_; |
162
|
0
|
|
|
|
|
0
|
$this->{WEIGHTS} = $weight; |
163
|
|
|
|
|
|
|
} |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
sub getWeights |
166
|
|
|
|
|
|
|
{ |
167
|
1583
|
|
|
1583
|
1
|
2301
|
my ($this) = @_; |
168
|
1583
|
|
|
|
|
4553
|
return($this->{WEIGHTS}); |
169
|
|
|
|
|
|
|
} |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
sub getWeightNames |
172
|
|
|
|
|
|
|
{ |
173
|
240
|
|
|
240
|
1
|
428
|
my ($this) = @_; |
174
|
240
|
|
|
|
|
325
|
return(keys %{$this->{WEIGHTS}}); |
|
240
|
|
|
|
|
1050
|
|
175
|
|
|
|
|
|
|
} |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
sub getWords |
178
|
|
|
|
|
|
|
{ |
179
|
1893
|
|
|
1893
|
1
|
2855
|
my ($this) = @_; |
180
|
1893
|
|
|
|
|
4569
|
return $this->{WORDS}; |
181
|
|
|
|
|
|
|
} |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
sub getWord |
184
|
|
|
|
|
|
|
{ |
185
|
0
|
|
|
0
|
0
|
0
|
my ($this,$index) = @_; |
186
|
0
|
|
|
|
|
0
|
return $this->getWords->[$index]; |
187
|
|
|
|
|
|
|
} |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
sub getOccurrences |
190
|
|
|
|
|
|
|
{ |
191
|
3010
|
|
|
3010
|
1
|
4490
|
my ($this) = @_; |
192
|
3010
|
|
|
|
|
7799
|
return $this->{OCCURRENCES}; |
193
|
|
|
|
|
|
|
} |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
sub getOccurrencesNumber |
196
|
|
|
|
|
|
|
{ |
197
|
0
|
|
|
0
|
0
|
0
|
my ($this) = @_; |
198
|
0
|
|
|
|
|
0
|
return scalar @{$this->getOccurrences}; |
|
0
|
|
|
|
|
0
|
|
199
|
|
|
|
|
|
|
} |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
sub buildLinguisticInfos |
202
|
|
|
|
|
|
|
{ |
203
|
240
|
|
|
240
|
1
|
420
|
my ($this,$tagset) = @_; |
204
|
240
|
|
|
|
|
647
|
my $if; |
205
|
|
|
|
|
|
|
my $pos; |
206
|
240
|
|
|
|
|
0
|
my $lf; |
207
|
240
|
|
|
|
|
0
|
my $word; |
208
|
|
|
|
|
|
|
|
209
|
240
|
|
|
|
|
331
|
foreach $word (@{$this->getWords}) |
|
240
|
|
|
|
|
412
|
|
210
|
|
|
|
|
|
|
{ |
211
|
489
|
|
|
|
|
1154
|
$if .= $word->getIF . " " ; |
212
|
489
|
100
|
|
|
|
1070
|
if ($tagset->existTag('PREPOSITIONS',$word->getIF)) |
213
|
|
|
|
|
|
|
{ |
214
|
45
|
|
|
|
|
108
|
$pos .= $word->getLF . " "; |
215
|
|
|
|
|
|
|
} |
216
|
|
|
|
|
|
|
else |
217
|
|
|
|
|
|
|
{ |
218
|
444
|
|
|
|
|
937
|
$pos .= $word->getPOS . " "; |
219
|
|
|
|
|
|
|
} |
220
|
489
|
|
|
|
|
1144
|
$lf .= $word->getLF . " " ; |
221
|
|
|
|
|
|
|
} |
222
|
240
|
|
|
|
|
1417
|
$if =~ s/\s+$//; |
223
|
240
|
|
|
|
|
838
|
$pos =~ s/\s+$//; |
224
|
240
|
|
|
|
|
813
|
$lf =~ s/\s+$//; |
225
|
240
|
|
|
|
|
849
|
return ($if,$pos,$lf); |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
} |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
sub getIF |
230
|
|
|
|
|
|
|
{ |
231
|
123
|
|
|
123
|
1
|
512
|
my ($this) = @_; |
232
|
123
|
|
|
|
|
175
|
my $word; |
233
|
|
|
|
|
|
|
my $if; |
234
|
123
|
|
|
|
|
169
|
foreach $word (@{$this->getWords}) |
|
123
|
|
|
|
|
212
|
|
235
|
|
|
|
|
|
|
{ |
236
|
386
|
|
|
|
|
824
|
$if .= $word->getIF . " " ; |
237
|
|
|
|
|
|
|
} |
238
|
123
|
|
|
|
|
712
|
$if =~ s/\s+$//; |
239
|
123
|
|
|
|
|
423
|
return $if; |
240
|
|
|
|
|
|
|
} |
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
sub getLF |
243
|
|
|
|
|
|
|
{ |
244
|
112
|
|
|
112
|
1
|
210
|
my ($this) = @_; |
245
|
112
|
|
|
|
|
156
|
my $word; |
246
|
|
|
|
|
|
|
my $lf; |
247
|
112
|
|
|
|
|
148
|
foreach $word (@{$this->getWords}) |
|
112
|
|
|
|
|
205
|
|
248
|
|
|
|
|
|
|
{ |
249
|
361
|
|
|
|
|
709
|
$lf .= $word->getLF . " " ; |
250
|
|
|
|
|
|
|
} |
251
|
112
|
|
|
|
|
483
|
$lf =~ s/\s+$//; |
252
|
112
|
|
|
|
|
350
|
return $lf; |
253
|
|
|
|
|
|
|
} |
254
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
sub getPOS |
256
|
|
|
|
|
|
|
{ |
257
|
0
|
|
|
0
|
1
|
0
|
my ($this) = @_; |
258
|
0
|
|
|
|
|
0
|
my $word; |
259
|
|
|
|
|
|
|
my $pos; |
260
|
0
|
|
|
|
|
0
|
foreach $word (@{$this->getWords}) |
|
0
|
|
|
|
|
0
|
|
261
|
|
|
|
|
|
|
{ |
262
|
0
|
|
|
|
|
0
|
$pos .= $word->getPOS . " " ; |
263
|
|
|
|
|
|
|
} |
264
|
0
|
|
|
|
|
0
|
$pos =~ s/\s+$//; |
265
|
0
|
|
|
|
|
0
|
return $pos; |
266
|
|
|
|
|
|
|
} |
267
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
sub getFrequency |
269
|
|
|
|
|
|
|
{ |
270
|
2346
|
|
|
2346
|
1
|
3440
|
my ($this) = @_; |
271
|
2346
|
|
|
|
|
2941
|
return scalar @{$this->getOccurrences}; |
|
2346
|
|
|
|
|
4180
|
|
272
|
|
|
|
|
|
|
} |
273
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
sub setReliability |
275
|
|
|
|
|
|
|
{ |
276
|
240
|
|
|
240
|
1
|
477
|
my ($this,$reliability) = @_; |
277
|
240
|
|
|
|
|
522
|
$this->{RELIABILITY} = $reliability; |
278
|
|
|
|
|
|
|
} |
279
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
sub getReliability |
281
|
|
|
|
|
|
|
{ |
282
|
240
|
|
|
240
|
1
|
375
|
my ($this) = @_; |
283
|
240
|
|
|
|
|
1356
|
return $this->{RELIABILITY}; |
284
|
|
|
|
|
|
|
} |
285
|
|
|
|
|
|
|
|
286
|
|
|
|
|
|
|
sub getOriginalPhrase |
287
|
|
|
|
|
|
|
{ |
288
|
0
|
|
|
0
|
1
|
|
my ($this) = @_; |
289
|
0
|
|
|
|
|
|
return $this->{ORIGINAL_PHRASE}; |
290
|
|
|
|
|
|
|
} |
291
|
|
|
|
|
|
|
|
292
|
|
|
|
|
|
|
|
293
|
|
|
|
|
|
|
|
294
|
|
|
|
|
|
|
1; |
295
|
|
|
|
|
|
|
|
296
|
|
|
|
|
|
|
__END__ |