line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Lingua::YaTeA::MultiWordUnit; |
2
|
5
|
|
|
5
|
|
35
|
use strict; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
151
|
|
3
|
5
|
|
|
5
|
|
30
|
use warnings; |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
150
|
|
4
|
5
|
|
|
5
|
|
32
|
use NEXT; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
36
|
|
5
|
5
|
|
|
5
|
|
125
|
use Data::Dumper; |
|
5
|
|
|
|
|
13
|
|
|
5
|
|
|
|
|
216
|
|
6
|
5
|
|
|
5
|
|
28
|
use UNIVERSAL; |
|
5
|
|
|
|
|
14
|
|
|
5
|
|
|
|
|
25
|
|
7
|
5
|
|
|
5
|
|
178
|
use Scalar::Util qw(blessed); |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
393
|
|
8
|
5
|
|
|
5
|
|
51
|
use Lingua::YaTeA::MultiWordPhrase; |
|
5
|
|
|
|
|
12
|
|
|
5
|
|
|
|
|
50
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION=$Lingua::YaTeA::VERSION; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub new |
13
|
|
|
|
|
|
|
{ |
14
|
81
|
|
|
81
|
1
|
9157
|
my ($class_or_object,$num_content_words,$words_a) = @_; |
15
|
81
|
|
|
|
|
138
|
my $this = shift; |
16
|
81
|
50
|
|
|
|
224
|
$this = bless {}, $this unless ref $this; |
17
|
81
|
|
|
|
|
195
|
$this->{FOREST} = (); |
18
|
81
|
|
|
|
|
155
|
$this->{CONTENT_WORDS} = $num_content_words; |
19
|
81
|
|
|
|
|
145
|
$this->{PARSING_METHOD} = (); |
20
|
81
|
|
|
|
|
280
|
$this->{LENGTH} = scalar @$words_a; |
21
|
81
|
|
|
|
|
642
|
$this->NEXT::new(@_); |
22
|
81
|
|
|
|
|
8505
|
return $this; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub getContentWordNumber |
28
|
|
|
|
|
|
|
{ |
29
|
0
|
|
|
0
|
1
|
0
|
my ($this) = @_; |
30
|
0
|
|
|
|
|
0
|
return $this->{CONTENT_WORDS}; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub getLength |
34
|
|
|
|
|
|
|
{ |
35
|
224
|
|
|
224
|
1
|
334
|
my ($this) = @_; |
36
|
224
|
|
|
|
|
517
|
return $this->{LENGTH}; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub addTree |
40
|
|
|
|
|
|
|
{ |
41
|
103
|
|
|
103
|
1
|
205
|
my ($this,$tree) = @_; |
42
|
103
|
|
|
|
|
169
|
push @{$this->{FOREST}}, $tree; |
|
103
|
|
|
|
|
383
|
|
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub getForest |
46
|
|
|
|
|
|
|
{ |
47
|
432
|
|
|
432
|
1
|
711
|
my ($this) = @_; |
48
|
432
|
|
|
|
|
1452
|
return $this->{FOREST}; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub forestSize |
52
|
|
|
|
|
|
|
{ |
53
|
1
|
|
|
1
|
1
|
3
|
my ($this) = @_; |
54
|
1
|
|
|
|
|
1
|
return scalar @{$this->getForest}; |
|
1
|
|
|
|
|
13
|
|
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub emptyForest |
58
|
|
|
|
|
|
|
{ |
59
|
8
|
|
|
8
|
1
|
22
|
my ($this) = @_; |
60
|
8
|
|
|
|
|
16
|
@{$this->getForest} = (); |
|
8
|
|
|
|
|
19
|
|
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub getTree |
64
|
|
|
|
|
|
|
{ |
65
|
70
|
|
|
70
|
1
|
149
|
my ($this,$index) = @_; |
66
|
70
|
|
|
|
|
150
|
return $this->getForest->[$index]; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub exportNodeSets |
71
|
|
|
|
|
|
|
{ |
72
|
9
|
|
|
9
|
1
|
25
|
my ($this) = @_; |
73
|
9
|
|
|
|
|
20
|
my $tree; |
74
|
|
|
|
|
|
|
my @node_sets; |
75
|
9
|
|
|
|
|
22
|
foreach $tree (@{$this->getForest}) |
|
9
|
|
|
|
|
33
|
|
76
|
|
|
|
|
|
|
{ |
77
|
9
|
|
|
|
|
54
|
push @node_sets, $tree->getNodeSet->copy; |
78
|
|
|
|
|
|
|
} |
79
|
9
|
|
|
|
|
35
|
return \@node_sets; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub searchParsingPattern |
84
|
|
|
|
|
|
|
{ |
85
|
73
|
|
|
73
|
1
|
162
|
my ($this,$parsing_pattern_set,$tag_set,$parsing_direction) = @_; |
86
|
73
|
|
|
|
|
161
|
my $record; |
87
|
|
|
|
|
|
|
my $simplified_pos; |
88
|
73
|
|
|
|
|
0
|
my $tree; |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
# if ($this->{CONTENT_WORDS} <= $Lingua::YaTeA::ParsingPatternRecordSet::max_content_words) # commented by SA: limite l'analyse le terme a deja ete simplifie par un ilot |
91
|
|
|
|
|
|
|
# { |
92
|
|
|
|
|
|
|
|
93
|
73
|
100
|
|
|
|
202
|
if(!defined $this->getForest) |
94
|
|
|
|
|
|
|
{ |
95
|
70
|
100
|
|
|
|
210
|
if ($record = $parsing_pattern_set->existRecord($this->getPOS)) |
96
|
|
|
|
|
|
|
{ |
97
|
45
|
|
|
|
|
154
|
return $this->getParseFromPattern($record,$tag_set); |
98
|
|
|
|
|
|
|
} |
99
|
25
|
|
|
|
|
76
|
return; |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
# exogenous islands were found (used for Phrases only) |
102
|
|
|
|
|
|
|
else |
103
|
|
|
|
|
|
|
{ |
104
|
3
|
|
|
|
|
6
|
foreach $tree (@{$this->getForest}) |
|
3
|
|
|
|
|
7
|
|
105
|
|
|
|
|
|
|
{ |
106
|
3
|
|
|
|
|
10
|
$simplified_pos = $tree->getSimplifiedIndexSet->buildPOSSequence($this->getWords,$tag_set); |
107
|
|
|
|
|
|
|
|
108
|
3
|
100
|
|
|
|
15
|
if ($record = $parsing_pattern_set->existRecord($simplified_pos)) |
109
|
|
|
|
|
|
|
{ |
110
|
1
|
|
|
|
|
7
|
return $this->getParseFromPattern($record,$parsing_direction,$tag_set); |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
#} |
115
|
2
|
|
|
|
|
8
|
return; |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
sub getParseFromPattern |
120
|
|
|
|
|
|
|
{ |
121
|
46
|
|
|
46
|
1
|
112
|
my ($this,$pattern_record,$parsing_direction,$tag_set) = @_; |
122
|
46
|
|
|
|
|
162
|
my $pattern; |
123
|
|
|
|
|
|
|
my $node_set; |
124
|
46
|
|
|
|
|
0
|
my $tree; |
125
|
46
|
|
|
|
|
0
|
my @concurrent_trees; |
126
|
46
|
|
|
|
|
72
|
my $parsed = 0; |
127
|
|
|
|
|
|
|
|
128
|
46
|
100
|
66
|
|
|
126
|
if( |
129
|
|
|
|
|
|
|
(defined $this->{FOREST}) |
130
|
|
|
|
|
|
|
&& |
131
|
|
|
|
|
|
|
($this->forestSize > 0) |
132
|
|
|
|
|
|
|
) |
133
|
|
|
|
|
|
|
{ |
134
|
1
|
|
|
|
|
8
|
$pattern = $this->chooseBestPattern($pattern_record->{PARSING_PATTERNS},$parsing_direction); |
135
|
1
|
|
|
|
|
3
|
foreach $tree (@{$this->{FOREST}}) |
|
1
|
|
|
|
|
4
|
|
136
|
|
|
|
|
|
|
{ |
137
|
1
|
|
|
|
|
6
|
$node_set = $pattern->getNodeSet->copy; |
138
|
1
|
|
|
|
|
5
|
$node_set->fillNodeLeaves($tree->getSimplifiedIndexSet); |
139
|
|
|
|
|
|
|
|
140
|
1
|
50
|
|
|
|
5
|
if($tree->append($node_set,$tree->getSimplifiedIndexSet,\@concurrent_trees,$this->getWords,$tag_set) == 1) |
141
|
|
|
|
|
|
|
{ |
142
|
1
|
|
|
|
|
5
|
$tree->setHead; |
143
|
1
|
|
|
|
|
3
|
$parsed = 1; |
144
|
|
|
|
|
|
|
} |
145
|
|
|
|
|
|
|
} |
146
|
|
|
|
|
|
|
} |
147
|
|
|
|
|
|
|
else |
148
|
|
|
|
|
|
|
{ |
149
|
45
|
|
|
|
|
106
|
foreach $pattern (@{$pattern_record->{PARSING_PATTERNS}}) |
|
45
|
|
|
|
|
147
|
|
150
|
|
|
|
|
|
|
{ |
151
|
45
|
|
|
|
|
168
|
$tree = Lingua::YaTeA::Tree->new; |
152
|
45
|
|
|
|
|
130
|
$tree->{INDEX_SET} = $this->getIndexSet; |
153
|
45
|
|
|
|
|
158
|
$tree->{NODE_SET} = $pattern->getNodeSet->copy; |
154
|
45
|
|
|
|
|
152
|
$tree->fillNodeLeaves; |
155
|
|
|
|
|
|
|
|
156
|
45
|
50
|
|
|
|
190
|
if($tree->check($this)) |
157
|
|
|
|
|
|
|
{ |
158
|
45
|
|
|
|
|
145
|
$tree->setReliability(1); |
159
|
45
|
|
|
|
|
137
|
$tree->setHead; |
160
|
45
|
|
|
|
|
173
|
$this->addTree($tree); |
161
|
45
|
|
|
|
|
114
|
$parsed = 1; |
162
|
|
|
|
|
|
|
} |
163
|
|
|
|
|
|
|
} |
164
|
|
|
|
|
|
|
} |
165
|
46
|
|
|
|
|
182
|
return $parsed; |
166
|
|
|
|
|
|
|
} |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
sub getPartialPattern |
171
|
|
|
|
|
|
|
{ |
172
|
66
|
|
|
66
|
1
|
183
|
my ($this,$simplified_index_set,$tag_set,$parsing_direction,$parsing_pattern_set,$fh) = @_; |
173
|
66
|
|
|
|
|
115
|
my $pattern; |
174
|
|
|
|
|
|
|
my $position; |
175
|
66
|
|
|
|
|
195
|
my $POS = $simplified_index_set->buildPOSSequence($this->getWords,$tag_set); |
176
|
|
|
|
|
|
|
# print $fh "pos: ". $POS . "\n"; |
177
|
66
|
50
|
|
|
|
177
|
if($parsing_direction eq "LEFT") |
178
|
|
|
|
|
|
|
{ |
179
|
0
|
|
|
|
|
0
|
($pattern,$position) = $this->getPatternsLeftFirst($POS,$parsing_pattern_set,$parsing_direction); |
180
|
|
|
|
|
|
|
} |
181
|
|
|
|
|
|
|
else{ |
182
|
66
|
|
|
|
|
199
|
($pattern,$position) = $this->getPatternsRightFirst($POS,$parsing_pattern_set,$parsing_direction); |
183
|
|
|
|
|
|
|
} |
184
|
66
|
|
|
|
|
187
|
return ($pattern,$position); |
185
|
|
|
|
|
|
|
} |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
sub getPatternsLeftFirst |
189
|
|
|
|
|
|
|
{ |
190
|
0
|
|
|
0
|
1
|
0
|
my ($this,$POS,$parsing_pattern_set,$parsing_direction) = @_; |
191
|
0
|
|
|
|
|
0
|
my $pattern; |
192
|
0
|
|
|
|
|
0
|
my $position = "LEFT"; |
193
|
0
|
|
|
|
|
0
|
$pattern = $this->getPatternOnTheLeft($POS,$parsing_pattern_set,$parsing_direction); |
194
|
0
|
0
|
0
|
|
|
0
|
if (!((blessed($pattern)) && ($pattern->isa('Lingua::YaTeA::ParsingPattern')))) { |
195
|
0
|
|
|
|
|
0
|
$pattern = $this->getPatternOnTheRight($POS,$parsing_pattern_set,$parsing_direction); |
196
|
0
|
|
|
|
|
0
|
$position = "RIGHT"; |
197
|
|
|
|
|
|
|
} |
198
|
0
|
|
|
|
|
0
|
return ($pattern,$position); |
199
|
|
|
|
|
|
|
} |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
sub getPatternsRightFirst |
202
|
|
|
|
|
|
|
{ |
203
|
66
|
|
|
66
|
1
|
186
|
my ($this,$POS,$parsing_pattern_set,$parsing_direction) = @_; |
204
|
66
|
|
|
|
|
95
|
my $pattern; |
205
|
66
|
|
|
|
|
102
|
my $position = "RIGHT"; |
206
|
|
|
|
|
|
|
|
207
|
66
|
|
|
|
|
226
|
$pattern = $this->getPatternOnTheRight($POS,$parsing_pattern_set,$parsing_direction); |
208
|
66
|
100
|
66
|
|
|
619
|
if (!((blessed($pattern)) && ($pattern->isa('Lingua::YaTeA::ParsingPattern')))) |
209
|
|
|
|
|
|
|
{ |
210
|
2
|
|
|
|
|
29
|
$pattern = $this->getPatternOnTheLeft($POS,$parsing_pattern_set,$parsing_direction); |
211
|
2
|
|
|
|
|
7
|
$position = "LEFT"; |
212
|
|
|
|
|
|
|
} |
213
|
66
|
|
|
|
|
230
|
return ($pattern,$position); |
214
|
|
|
|
|
|
|
} |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
sub getPatternOnTheLeft |
217
|
|
|
|
|
|
|
{ |
218
|
2
|
|
|
2
|
1
|
10
|
my ($this,$POS,$parsing_pattern_set,$parsing_direction) = @_; |
219
|
2
|
|
|
|
|
16
|
my @selection; |
220
|
|
|
|
|
|
|
my $key; |
221
|
2
|
|
|
|
|
0
|
my $record; |
222
|
2
|
|
|
|
|
0
|
my $pattern; |
223
|
2
|
|
|
|
|
0
|
my $bounded_key; |
224
|
2
|
|
|
|
|
0
|
my $qm_key; |
225
|
2
|
|
|
|
|
35
|
my $bounded_POS = "-" . $POS . "-"; |
226
|
2
|
|
|
|
|
20
|
$bounded_POS =~ s/ /-/g; |
227
|
2
|
|
|
|
|
6
|
while (($key,$record) = each %{$parsing_pattern_set->getRecordSet}) |
|
142
|
|
|
|
|
345
|
|
228
|
|
|
|
|
|
|
{ |
229
|
140
|
|
|
|
|
285
|
$bounded_key = "-" . $key . "-"; |
230
|
140
|
|
|
|
|
366
|
$bounded_key =~ s/ /-/g; |
231
|
140
|
|
|
|
|
230
|
$qm_key = quotemeta($bounded_key); |
232
|
140
|
50
|
|
|
|
1257
|
if ($bounded_POS =~ /^$qm_key/) |
233
|
|
|
|
|
|
|
{ |
234
|
0
|
|
|
|
|
0
|
foreach $pattern (@{$record->getPatterns}) |
|
0
|
|
|
|
|
0
|
|
235
|
|
|
|
|
|
|
{ |
236
|
0
|
|
|
|
|
0
|
push @selection, $pattern; |
237
|
|
|
|
|
|
|
} |
238
|
|
|
|
|
|
|
} |
239
|
|
|
|
|
|
|
} |
240
|
2
|
|
|
|
|
11
|
$pattern = $this->chooseBestPattern(\@selection,$parsing_direction); |
241
|
2
|
|
|
|
|
5
|
return $pattern; |
242
|
|
|
|
|
|
|
} |
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
sub getPatternOnTheRight |
245
|
|
|
|
|
|
|
{ |
246
|
66
|
|
|
66
|
1
|
150
|
my ($this,$POS,$parsing_pattern_set,$parsing_direction) = @_; |
247
|
66
|
|
|
|
|
318
|
my @selection; |
248
|
|
|
|
|
|
|
my $key; |
249
|
66
|
|
|
|
|
0
|
my $record; |
250
|
66
|
|
|
|
|
0
|
my $pattern; |
251
|
66
|
|
|
|
|
0
|
my $bounded_key; |
252
|
66
|
|
|
|
|
0
|
my $qm_key; |
253
|
|
|
|
|
|
|
|
254
|
66
|
|
|
|
|
165
|
my $bounded_POS = "-" . $POS . "-"; |
255
|
66
|
|
|
|
|
397
|
$bounded_POS =~ s/ /-/g; |
256
|
66
|
|
|
|
|
148
|
while (($key,$record) = each %{$parsing_pattern_set->getRecordSet}) |
|
4686
|
|
|
|
|
11775
|
|
257
|
|
|
|
|
|
|
{ |
258
|
4620
|
|
|
|
|
8977
|
$bounded_key = "-" . $key . "-"; |
259
|
4620
|
|
|
|
|
12154
|
$bounded_key =~ s/ /-/g; |
260
|
4620
|
|
|
|
|
7887
|
$qm_key = quotemeta($bounded_key); |
261
|
4620
|
100
|
|
|
|
39569
|
if ($bounded_POS =~ /$qm_key$/) |
262
|
|
|
|
|
|
|
{ |
263
|
66
|
|
|
|
|
145
|
foreach $pattern (@{$record->getPatterns}) |
|
66
|
|
|
|
|
281
|
|
264
|
|
|
|
|
|
|
{ |
265
|
66
|
|
|
|
|
188
|
push @selection, $pattern; |
266
|
|
|
|
|
|
|
} |
267
|
|
|
|
|
|
|
} |
268
|
|
|
|
|
|
|
} |
269
|
66
|
|
|
|
|
232
|
$pattern = $this->chooseBestPattern(\@selection,$parsing_direction); |
270
|
66
|
|
|
|
|
159
|
return $pattern; |
271
|
|
|
|
|
|
|
} |
272
|
|
|
|
|
|
|
|
273
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
sub chooseBestPattern |
277
|
|
|
|
|
|
|
{ |
278
|
69
|
|
|
69
|
1
|
164
|
my ($this,$patterns_a,$parsing_direction) = @_; |
279
|
|
|
|
|
|
|
|
280
|
69
|
|
|
|
|
193
|
my @tmp = sort {$this->sortPatternsByPriority($a,$b,$parsing_direction)} @$patterns_a; |
|
2
|
|
|
|
|
28
|
|
281
|
|
|
|
|
|
|
|
282
|
69
|
|
|
|
|
127
|
my @sorted = @tmp; |
283
|
|
|
|
|
|
|
|
284
|
69
|
|
|
|
|
163
|
return $sorted[0]; |
285
|
|
|
|
|
|
|
} |
286
|
|
|
|
|
|
|
|
287
|
|
|
|
|
|
|
sub sortPatternsByPriority |
288
|
|
|
|
|
|
|
{ |
289
|
2
|
|
|
2
|
1
|
9
|
my ($this,$first,$second,$parsing_direction) = @_; |
290
|
|
|
|
|
|
|
|
291
|
2
|
50
|
|
|
|
12
|
if($first->getDirection eq $parsing_direction) |
292
|
|
|
|
|
|
|
{ |
293
|
2
|
50
|
|
|
|
8
|
if($second->getDirection eq $parsing_direction) |
294
|
|
|
|
|
|
|
{ |
295
|
2
|
100
|
|
|
|
10
|
if($first->getNumContentWords > $second->getNumContentWords) |
296
|
|
|
|
|
|
|
{ |
297
|
1
|
|
|
|
|
6
|
return -1; |
298
|
|
|
|
|
|
|
} |
299
|
|
|
|
|
|
|
else |
300
|
|
|
|
|
|
|
{ |
301
|
1
|
50
|
|
|
|
5
|
if($first->getNumContentWords < $second->getNumContentWords) |
302
|
|
|
|
|
|
|
{ |
303
|
1
|
|
|
|
|
6
|
return 1; |
304
|
|
|
|
|
|
|
} |
305
|
|
|
|
|
|
|
else |
306
|
|
|
|
|
|
|
{ |
307
|
0
|
|
|
|
|
0
|
return ($second->getPriority <=> $first->getPriority); |
308
|
|
|
|
|
|
|
} |
309
|
|
|
|
|
|
|
} |
310
|
|
|
|
|
|
|
} |
311
|
|
|
|
|
|
|
else |
312
|
|
|
|
|
|
|
{ |
313
|
0
|
|
|
|
|
0
|
return -1; |
314
|
|
|
|
|
|
|
} |
315
|
|
|
|
|
|
|
} |
316
|
|
|
|
|
|
|
else |
317
|
|
|
|
|
|
|
{ |
318
|
0
|
0
|
|
|
|
0
|
if($second->getDirection eq $parsing_direction) |
319
|
|
|
|
|
|
|
{ |
320
|
0
|
|
|
|
|
0
|
return 1; |
321
|
|
|
|
|
|
|
} |
322
|
|
|
|
|
|
|
else |
323
|
|
|
|
|
|
|
{ |
324
|
0
|
0
|
|
|
|
0
|
if($first->getNumContentWords > $second->getNumContentWords) |
325
|
|
|
|
|
|
|
{ |
326
|
0
|
|
|
|
|
0
|
return -1; |
327
|
|
|
|
|
|
|
} |
328
|
|
|
|
|
|
|
else |
329
|
|
|
|
|
|
|
{ |
330
|
0
|
0
|
|
|
|
0
|
if($first->getNumContentWords < $second->getNumContentWords) |
331
|
|
|
|
|
|
|
{ |
332
|
0
|
|
|
|
|
0
|
return 1; |
333
|
|
|
|
|
|
|
} |
334
|
|
|
|
|
|
|
else |
335
|
|
|
|
|
|
|
{ |
336
|
0
|
|
|
|
|
0
|
return ($second->getPriority <=> $first->getPriority); |
337
|
|
|
|
|
|
|
} |
338
|
|
|
|
|
|
|
} |
339
|
|
|
|
|
|
|
} |
340
|
|
|
|
|
|
|
} |
341
|
|
|
|
|
|
|
} |
342
|
|
|
|
|
|
|
|
343
|
|
|
|
|
|
|
|
344
|
|
|
|
|
|
|
sub setParsingMethod |
345
|
|
|
|
|
|
|
{ |
346
|
71
|
|
|
71
|
1
|
155
|
my ($this,$method) = @_; |
347
|
71
|
50
|
33
|
|
|
550
|
if ((blessed($this)) && ($this->isa('Lingua::YaTeA::Phrase'))) |
348
|
|
|
|
|
|
|
{ |
349
|
71
|
|
|
|
|
141
|
$Lingua::YaTeA::MultiWordPhrase::parsed++; |
350
|
|
|
|
|
|
|
} |
351
|
71
|
|
|
|
|
200
|
$this->{PARSING_METHOD} = $method; |
352
|
|
|
|
|
|
|
} |
353
|
|
|
|
|
|
|
|
354
|
|
|
|
|
|
|
|
355
|
|
|
|
|
|
|
sub getParsingMethod |
356
|
|
|
|
|
|
|
{ |
357
|
48
|
|
|
48
|
1
|
97
|
my ($this) = @_; |
358
|
48
|
50
|
|
|
|
110
|
if(defined $this->{PARSING_METHOD}) |
359
|
|
|
|
|
|
|
{ |
360
|
48
|
|
|
|
|
151
|
return $this->{PARSING_METHOD}; |
361
|
|
|
|
|
|
|
} |
362
|
|
|
|
|
|
|
else |
363
|
|
|
|
|
|
|
{ |
364
|
0
|
|
|
|
|
0
|
return "UNPARSED"; |
365
|
|
|
|
|
|
|
} |
366
|
|
|
|
|
|
|
} |
367
|
|
|
|
|
|
|
|
368
|
|
|
|
|
|
|
|
369
|
|
|
|
|
|
|
sub parseProgressively |
370
|
|
|
|
|
|
|
{ |
371
|
27
|
|
|
27
|
1
|
77
|
my ($this,$tag_set,$parsing_direction,$parsing_pattern_set, $fh) = @_; |
372
|
27
|
|
|
|
|
142
|
my $tree; |
373
|
|
|
|
|
|
|
my $pattern; |
374
|
27
|
|
|
|
|
0
|
my $position; |
375
|
27
|
|
|
|
|
0
|
my $partial_index_set; |
376
|
27
|
|
|
|
|
0
|
my $node_set; |
377
|
27
|
|
|
|
|
0
|
my @concurrent_trees; |
378
|
27
|
|
|
|
|
54
|
my $parsed = 0; |
379
|
|
|
|
|
|
|
|
380
|
|
|
|
|
|
|
# print $fh "parseProgressively\n"; |
381
|
|
|
|
|
|
|
# print $fh $this->getIF . "\n"; |
382
|
|
|
|
|
|
|
|
383
|
27
|
100
|
|
|
|
73
|
if(!defined $this->getForest) |
384
|
|
|
|
|
|
|
{ |
385
|
19
|
|
|
|
|
93
|
$tree = Lingua::YaTeA::Tree->new; |
386
|
19
|
|
|
|
|
72
|
$tree->setSimplifiedIndexSet($this->getIndexSet); |
387
|
19
|
|
|
|
|
48
|
push @concurrent_trees, $tree; |
388
|
|
|
|
|
|
|
} |
389
|
|
|
|
|
|
|
else |
390
|
|
|
|
|
|
|
{ |
391
|
8
|
|
|
|
|
20
|
@concurrent_trees = @{$this->getForest}; |
|
8
|
|
|
|
|
21
|
|
392
|
|
|
|
|
|
|
# print $fh scalar @concurrent_trees . " arbres\n"; |
393
|
8
|
|
|
|
|
50
|
$this->emptyForest; |
394
|
|
|
|
|
|
|
} |
395
|
27
|
|
|
|
|
93
|
while (scalar @concurrent_trees != 0) |
396
|
|
|
|
|
|
|
{ |
397
|
106
|
|
|
|
|
263
|
foreach ($tree = pop (@concurrent_trees)) |
398
|
|
|
|
|
|
|
{ |
399
|
|
|
|
|
|
|
# print $fh "TREE parse\n"; |
400
|
|
|
|
|
|
|
# $tree->print($this->getWords,$fh); |
401
|
106
|
100
|
|
|
|
272
|
if($tree->getSimplifiedIndexSet->getSize == 1) |
402
|
|
|
|
|
|
|
{ |
403
|
40
|
50
|
|
|
|
155
|
if($tree->check($this)) |
404
|
|
|
|
|
|
|
{ |
405
|
40
|
|
|
|
|
85
|
$parsed = 1; |
406
|
40
|
|
|
|
|
128
|
$tree->setHead; |
407
|
40
|
|
|
|
|
155
|
$tree->setReliability(2); |
408
|
40
|
|
|
|
|
121
|
$this->addTree($tree); |
409
|
|
|
|
|
|
|
} |
410
|
|
|
|
|
|
|
} |
411
|
|
|
|
|
|
|
else |
412
|
|
|
|
|
|
|
{ |
413
|
|
|
|
|
|
|
# $tree->getSimplifiedIndexSet->print($fh); |
414
|
|
|
|
|
|
|
# print $fh "\n"; |
415
|
66
|
|
|
|
|
170
|
($pattern,$position) = $this->getPartialPattern($tree->getSimplifiedIndexSet,$tag_set,$parsing_direction,$parsing_pattern_set,$fh); |
416
|
|
|
|
|
|
|
# $tree->getSimplifiedIndexSet->print($fh); |
417
|
66
|
100
|
66
|
|
|
368
|
if ((blessed($pattern)) && ($pattern->isa('Lingua::YaTeA::ParsingPattern'))) { |
418
|
|
|
|
|
|
|
# print $fh "trouve partial pattern\n"; |
419
|
64
|
|
|
|
|
225
|
$partial_index_set = $tree->getSimplifiedIndexSet->getPartial($pattern->getLength,$position); |
420
|
64
|
|
|
|
|
198
|
$node_set = $pattern->getNodeSet->copy; |
421
|
64
|
|
|
|
|
234
|
$node_set->fillNodeLeaves($partial_index_set); |
422
|
|
|
|
|
|
|
|
423
|
64
|
50
|
|
|
|
285
|
if ($tree->append($node_set,$partial_index_set,\@concurrent_trees,$this->getWords,$tag_set,$fh) == -1) { |
424
|
|
|
|
|
|
|
# print $fh "termine append avec -1\n"; |
425
|
0
|
|
|
|
|
0
|
return 0; |
426
|
|
|
|
|
|
|
} |
427
|
|
|
|
|
|
|
} |
428
|
|
|
|
|
|
|
else |
429
|
|
|
|
|
|
|
{ |
430
|
2
|
|
|
|
|
9
|
next; |
431
|
|
|
|
|
|
|
} |
432
|
|
|
|
|
|
|
} |
433
|
|
|
|
|
|
|
} |
434
|
|
|
|
|
|
|
} |
435
|
|
|
|
|
|
|
#$this->printDebug($fh); |
436
|
27
|
|
|
|
|
176
|
return $parsed; |
437
|
|
|
|
|
|
|
} |
438
|
|
|
|
|
|
|
|
439
|
|
|
|
|
|
|
|
440
|
|
|
|
|
|
|
|
441
|
|
|
|
|
|
|
|
442
|
|
|
|
|
|
|
sub printForest |
443
|
|
|
|
|
|
|
{ |
444
|
0
|
|
|
0
|
1
|
0
|
my ($this,$fh) = @_; |
445
|
0
|
|
|
|
|
0
|
my $tree; |
446
|
|
|
|
|
|
|
# print "FOREST\n"; |
447
|
0
|
0
|
|
|
|
0
|
if(defined $this->getForest) |
448
|
|
|
|
|
|
|
{ |
449
|
|
|
|
|
|
|
#print "Taille de la foret: " . $this->forestSize . "\n"; |
450
|
0
|
|
|
|
|
0
|
foreach $tree (@{$this->getForest}) |
|
0
|
|
|
|
|
0
|
|
451
|
|
|
|
|
|
|
{ |
452
|
0
|
|
|
|
|
0
|
$tree->print($this->getWords,$fh); |
453
|
|
|
|
|
|
|
} |
454
|
|
|
|
|
|
|
} |
455
|
|
|
|
|
|
|
else |
456
|
|
|
|
|
|
|
{ |
457
|
0
|
|
|
|
|
0
|
print "Pas d'analyse\n"; |
458
|
|
|
|
|
|
|
} |
459
|
|
|
|
|
|
|
} |
460
|
|
|
|
|
|
|
|
461
|
|
|
|
|
|
|
|
462
|
|
|
|
|
|
|
sub printForestParenthesised |
463
|
|
|
|
|
|
|
{ |
464
|
45
|
|
|
45
|
1
|
78
|
my ($this,$fh) = @_; |
465
|
45
|
|
|
|
|
63
|
my $tree; |
466
|
45
|
|
|
|
|
67
|
my $tree_counter = 1; |
467
|
|
|
|
|
|
|
|
468
|
45
|
50
|
|
|
|
80
|
if(defined $fh) |
469
|
|
|
|
|
|
|
{ |
470
|
45
|
50
|
|
|
|
91
|
if(defined $this->getForest) |
471
|
|
|
|
|
|
|
{ |
472
|
45
|
|
|
|
|
73
|
print $fh " number of trees: " . scalar @{$this->getForest} . "\n"; |
|
45
|
|
|
|
|
73
|
|
473
|
45
|
|
|
|
|
69
|
foreach $tree (@{$this->getForest}) |
|
45
|
|
|
|
|
77
|
|
474
|
|
|
|
|
|
|
{ |
475
|
|
|
|
|
|
|
# print STDERR "$tree\n"; |
476
|
45
|
|
|
|
|
103
|
print $fh "\tT" . $tree_counter++ .": "; |
477
|
45
|
|
|
|
|
109
|
$tree->printParenthesised($this->getWords,$fh); |
478
|
|
|
|
|
|
|
} |
479
|
|
|
|
|
|
|
} |
480
|
|
|
|
|
|
|
else |
481
|
|
|
|
|
|
|
{ |
482
|
0
|
|
|
|
|
|
print $fh "Pas d'analyse\n"; |
483
|
|
|
|
|
|
|
} |
484
|
|
|
|
|
|
|
} |
485
|
|
|
|
|
|
|
else |
486
|
|
|
|
|
|
|
{ |
487
|
0
|
0
|
|
|
|
|
if(defined $this->getForest) |
488
|
|
|
|
|
|
|
{ |
489
|
0
|
|
|
|
|
|
print " : number of trees" . scalar @{$this->getForest} . "\n"; |
|
0
|
|
|
|
|
|
|
490
|
0
|
|
|
|
|
|
foreach $tree (@{$this->getForest}) |
|
0
|
|
|
|
|
|
|
491
|
|
|
|
|
|
|
{ |
492
|
0
|
|
|
|
|
|
$tree->printParenthesised($this->getWords); |
493
|
|
|
|
|
|
|
} |
494
|
|
|
|
|
|
|
} |
495
|
|
|
|
|
|
|
else |
496
|
|
|
|
|
|
|
{ |
497
|
0
|
|
|
|
|
|
print "Pas d'analyse\n"; |
498
|
|
|
|
|
|
|
} |
499
|
|
|
|
|
|
|
} |
500
|
|
|
|
|
|
|
} |
501
|
|
|
|
|
|
|
|
502
|
|
|
|
|
|
|
sub printDebug |
503
|
|
|
|
|
|
|
{ |
504
|
0
|
|
|
0
|
0
|
|
my ($this, $fh) = @_; |
505
|
|
|
|
|
|
|
|
506
|
0
|
|
|
|
|
|
print $fh "\n\n"; |
507
|
0
|
|
|
|
|
|
print $fh "$this\n"; |
508
|
0
|
|
|
|
|
|
print $fh $this->{'IF'} . "\n"; |
509
|
0
|
|
|
|
|
|
$this->print($fh); |
510
|
0
|
|
|
|
|
|
$this->printForestParenthesised($fh); |
511
|
0
|
|
|
|
|
|
print $fh "\n\n"; |
512
|
|
|
|
|
|
|
|
513
|
|
|
|
|
|
|
} |
514
|
|
|
|
|
|
|
|
515
|
|
|
|
|
|
|
|
516
|
|
|
|
|
|
|
1; |
517
|
|
|
|
|
|
|
|
518
|
|
|
|
|
|
|
__END__ |