line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Lingua::YaTeA::TermCandidate; |
2
|
5
|
|
|
5
|
|
32
|
use strict; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
135
|
|
3
|
5
|
|
|
5
|
|
27
|
use warnings; |
|
5
|
|
|
|
|
22
|
|
|
5
|
|
|
|
|
7793
|
|
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
|
537
|
my ($class) = @_; |
13
|
306
|
|
|
|
|
463
|
my $this; |
14
|
306
|
|
|
|
|
751
|
$this->{ID} = $id++; |
15
|
306
|
|
|
|
|
550
|
$this->{KEY} = ""; |
16
|
306
|
|
|
|
|
518
|
$this->{HEAD} = (); |
17
|
306
|
|
|
|
|
622
|
$this->{WORDS} = []; |
18
|
306
|
|
|
|
|
609
|
$this->{OCCURRENCES} = []; |
19
|
306
|
|
|
|
|
501
|
$this->{RELIABILITY} = (); |
20
|
306
|
|
|
|
|
467
|
$this->{TERM_STATUS} = 1; |
21
|
306
|
|
|
|
|
643
|
$this->{ORIGINAL_PHRASE} = (); |
22
|
|
|
|
|
|
|
# $this->{WEIGHT} = 0; |
23
|
306
|
|
|
|
|
633
|
$this->{WEIGHTS} = {}; |
24
|
306
|
|
|
|
|
492
|
$this->{ROOT} = (); |
25
|
306
|
|
|
|
|
531
|
$this->{MNP_STATUS} = 0; # added by SA 13/02/2009 |
26
|
306
|
|
|
|
|
515
|
bless ($this,$class); |
27
|
306
|
|
|
|
|
706
|
return $this; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub setROOT { |
31
|
301
|
|
|
301
|
0
|
489
|
my ($this, $ROOT) = @_; |
32
|
301
|
|
|
|
|
415
|
push @{$this->{ROOT}}, $ROOT; |
|
301
|
|
|
|
|
661
|
|
33
|
301
|
|
|
|
|
611
|
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
|
1870
|
my ($this) = @_; |
61
|
1210
|
|
|
|
|
1515
|
return scalar @{$this->getWords}; |
|
1210
|
|
|
|
|
1983
|
|
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub addWord |
65
|
|
|
|
|
|
|
{ |
66
|
408
|
|
|
408
|
1
|
748
|
my ($this,$leaf,$words_a) = @_; |
67
|
408
|
|
|
|
|
562
|
push @{$this->{WORDS}}, $words_a->[$leaf->getIndex]; |
|
408
|
|
|
|
|
911
|
|
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub addOccurrence |
71
|
|
|
|
|
|
|
{ |
72
|
319
|
|
|
319
|
1
|
547
|
my ($this,$occurrence) = @_; |
73
|
319
|
100
|
|
|
|
697
|
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
|
319
|
|
|
|
|
496
|
push @{$this->{OCCURRENCES}}, $occurrence; |
|
319
|
|
|
|
|
1069
|
|
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub addOccurrences |
81
|
|
|
|
|
|
|
{ |
82
|
66
|
|
|
66
|
1
|
115
|
my ($this,$occurrences_a) = @_; |
83
|
66
|
|
|
|
|
90
|
my $occurrence; |
84
|
66
|
|
|
|
|
122
|
foreach $occurrence (@$occurrences_a) |
85
|
|
|
|
|
|
|
{ |
86
|
67
|
|
|
|
|
133
|
$this->addOccurrence($occurrence); |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub getKey |
91
|
|
|
|
|
|
|
{ |
92
|
1140
|
|
|
1140
|
1
|
1880
|
my ($this) = @_; |
93
|
1140
|
|
|
|
|
4114
|
return $this->{KEY}; |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
sub getID |
97
|
|
|
|
|
|
|
{ |
98
|
2291
|
|
|
2291
|
1
|
3650
|
my ($this) = @_; |
99
|
2291
|
|
|
|
|
5679
|
return $this->{ID}; |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
sub getMNPStatus |
103
|
|
|
|
|
|
|
{ |
104
|
240
|
|
|
240
|
1
|
405
|
my ($this) = @_; |
105
|
240
|
|
|
|
|
936
|
return $this->{MNP_STATUS}; |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
sub editKey |
109
|
|
|
|
|
|
|
{ |
110
|
692
|
|
|
692
|
1
|
1228
|
my ($this,$string) = @_; |
111
|
692
|
|
|
|
|
1828
|
$this->{KEY} .= $string; |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
sub setHead |
115
|
|
|
|
|
|
|
{ |
116
|
240
|
|
|
240
|
1
|
392
|
my ($this) = @_; |
117
|
240
|
|
|
|
|
528
|
$this->{HEAD} = $this->searchHead(0); |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
sub getHead |
121
|
|
|
|
|
|
|
{ |
122
|
352
|
|
|
352
|
1
|
600
|
my ($this) = @_; |
123
|
352
|
|
|
|
|
776
|
return $this->{HEAD}; |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
sub setWeight |
127
|
|
|
|
|
|
|
{ |
128
|
240
|
|
|
240
|
1
|
343
|
my $this = shift; |
129
|
240
|
|
|
|
|
312
|
my $weight; |
130
|
|
|
|
|
|
|
my $weight_name; |
131
|
240
|
50
|
|
|
|
420
|
if (scalar(@_) == 2) { |
132
|
0
|
|
|
|
|
0
|
$weight_name = shift; |
133
|
|
|
|
|
|
|
} else { |
134
|
|
|
|
|
|
|
# default weight because it's the first |
135
|
240
|
|
|
|
|
328
|
$weight_name = "DDW"; |
136
|
|
|
|
|
|
|
} |
137
|
240
|
|
|
|
|
332
|
$weight = shift; |
138
|
240
|
|
|
|
|
374
|
$this->getWeights->{$weight_name} = $weight; |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
# $this->{WEIGHT} = $weight; |
141
|
|
|
|
|
|
|
} |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
sub getWeight |
144
|
|
|
|
|
|
|
{ |
145
|
1316
|
|
|
1316
|
1
|
1873
|
my $this = shift; |
146
|
|
|
|
|
|
|
|
147
|
1316
|
|
|
|
|
1694
|
my $weight_name; |
148
|
1316
|
50
|
|
|
|
2177
|
if (@_) { |
149
|
1316
|
|
|
|
|
1816
|
$weight_name = shift; |
150
|
|
|
|
|
|
|
} else { |
151
|
|
|
|
|
|
|
# default wieght because it's the first |
152
|
0
|
|
|
|
|
0
|
$weight_name = "DDW"; |
153
|
|
|
|
|
|
|
} |
154
|
1316
|
|
|
|
|
2150
|
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
|
1558
|
|
|
1558
|
1
|
2389
|
my ($this) = @_; |
168
|
1558
|
|
|
|
|
4779
|
return($this->{WEIGHTS}); |
169
|
|
|
|
|
|
|
} |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
sub getWeightNames |
172
|
|
|
|
|
|
|
{ |
173
|
240
|
|
|
240
|
1
|
444
|
my ($this) = @_; |
174
|
240
|
|
|
|
|
328
|
return(keys %{$this->{WEIGHTS}}); |
|
240
|
|
|
|
|
1011
|
|
175
|
|
|
|
|
|
|
} |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
sub getWords |
178
|
|
|
|
|
|
|
{ |
179
|
1893
|
|
|
1893
|
1
|
3271
|
my ($this) = @_; |
180
|
1893
|
|
|
|
|
4779
|
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
|
2960
|
|
|
2960
|
1
|
4459
|
my ($this) = @_; |
192
|
2960
|
|
|
|
|
7805
|
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
|
506
|
my ($this,$tagset) = @_; |
204
|
240
|
|
|
|
|
649
|
my $if; |
205
|
|
|
|
|
|
|
my $pos; |
206
|
240
|
|
|
|
|
0
|
my $lf; |
207
|
240
|
|
|
|
|
0
|
my $word; |
208
|
|
|
|
|
|
|
|
209
|
240
|
|
|
|
|
355
|
foreach $word (@{$this->getWords}) |
|
240
|
|
|
|
|
466
|
|
210
|
|
|
|
|
|
|
{ |
211
|
489
|
|
|
|
|
1194
|
$if .= $word->getIF . " " ; |
212
|
489
|
100
|
|
|
|
1100
|
if ($tagset->existTag('PREPOSITIONS',$word->getIF)) |
213
|
|
|
|
|
|
|
{ |
214
|
45
|
|
|
|
|
123
|
$pos .= $word->getLF . " "; |
215
|
|
|
|
|
|
|
} |
216
|
|
|
|
|
|
|
else |
217
|
|
|
|
|
|
|
{ |
218
|
444
|
|
|
|
|
933
|
$pos .= $word->getPOS . " "; |
219
|
|
|
|
|
|
|
} |
220
|
489
|
|
|
|
|
1147
|
$lf .= $word->getLF . " " ; |
221
|
|
|
|
|
|
|
} |
222
|
240
|
|
|
|
|
1426
|
$if =~ s/\s+$//; |
223
|
240
|
|
|
|
|
905
|
$pos =~ s/\s+$//; |
224
|
240
|
|
|
|
|
848
|
$lf =~ s/\s+$//; |
225
|
240
|
|
|
|
|
892
|
return ($if,$pos,$lf); |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
} |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
sub getIF |
230
|
|
|
|
|
|
|
{ |
231
|
123
|
|
|
123
|
1
|
224
|
my ($this) = @_; |
232
|
123
|
|
|
|
|
189
|
my $word; |
233
|
|
|
|
|
|
|
my $if; |
234
|
123
|
|
|
|
|
164
|
foreach $word (@{$this->getWords}) |
|
123
|
|
|
|
|
218
|
|
235
|
|
|
|
|
|
|
{ |
236
|
386
|
|
|
|
|
884
|
$if .= $word->getIF . " " ; |
237
|
|
|
|
|
|
|
} |
238
|
123
|
|
|
|
|
696
|
$if =~ s/\s+$//; |
239
|
123
|
|
|
|
|
454
|
return $if; |
240
|
|
|
|
|
|
|
} |
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
sub getLF |
243
|
|
|
|
|
|
|
{ |
244
|
112
|
|
|
112
|
1
|
203
|
my ($this) = @_; |
245
|
112
|
|
|
|
|
162
|
my $word; |
246
|
|
|
|
|
|
|
my $lf; |
247
|
112
|
|
|
|
|
160
|
foreach $word (@{$this->getWords}) |
|
112
|
|
|
|
|
173
|
|
248
|
|
|
|
|
|
|
{ |
249
|
361
|
|
|
|
|
737
|
$lf .= $word->getLF . " " ; |
250
|
|
|
|
|
|
|
} |
251
|
112
|
|
|
|
|
494
|
$lf =~ s/\s+$//; |
252
|
112
|
|
|
|
|
372
|
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
|
2296
|
|
|
2296
|
1
|
3742
|
my ($this) = @_; |
271
|
2296
|
|
|
|
|
2848
|
return scalar @{$this->getOccurrences}; |
|
2296
|
|
|
|
|
3523
|
|
272
|
|
|
|
|
|
|
} |
273
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
sub setReliability |
275
|
|
|
|
|
|
|
{ |
276
|
240
|
|
|
240
|
1
|
416
|
my ($this,$reliability) = @_; |
277
|
240
|
|
|
|
|
501
|
$this->{RELIABILITY} = $reliability; |
278
|
|
|
|
|
|
|
} |
279
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
sub getReliability |
281
|
|
|
|
|
|
|
{ |
282
|
240
|
|
|
240
|
1
|
400
|
my ($this) = @_; |
283
|
240
|
|
|
|
|
1425
|
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__ |