line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Lingua::YaTeA::Occurrence; |
2
|
5
|
|
|
5
|
|
33
|
use strict; |
|
5
|
|
|
|
|
13
|
|
|
5
|
|
|
|
|
135
|
|
3
|
5
|
|
|
5
|
|
26
|
use warnings; |
|
5
|
|
|
|
|
54
|
|
|
5
|
|
|
|
|
4285
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $counter = 0; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION=$Lingua::YaTeA::VERSION; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub new |
10
|
|
|
|
|
|
|
{ |
11
|
377
|
|
|
377
|
1
|
625
|
my ($class,) = @_; |
12
|
377
|
|
|
|
|
671
|
my $this = {}; |
13
|
377
|
|
|
|
|
652
|
bless ($this,$class); |
14
|
377
|
|
|
|
|
871
|
$this->{ID} = $counter++; |
15
|
377
|
|
|
|
|
666
|
$this->{SENTENCE} = (); |
16
|
377
|
|
|
|
|
604
|
$this->{START_CHAR} = (); |
17
|
377
|
|
|
|
|
612
|
$this->{END_CHAR} = (); |
18
|
377
|
|
|
|
|
606
|
$this->{MAXIMAL} = (); |
19
|
377
|
|
|
|
|
794
|
return $this; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub getSentence |
23
|
|
|
|
|
|
|
{ |
24
|
1245
|
|
|
1245
|
1
|
1951
|
my ($this) = @_; |
25
|
1245
|
|
|
|
|
3488
|
return $this->{SENTENCE}; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub getStartChar |
29
|
|
|
|
|
|
|
{ |
30
|
915
|
|
|
915
|
1
|
1418
|
my ($this) = @_; |
31
|
915
|
|
|
|
|
2380
|
return $this->{START_CHAR}; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub getEndChar |
35
|
|
|
|
|
|
|
{ |
36
|
333
|
|
|
333
|
1
|
555
|
my ($this) = @_; |
37
|
333
|
|
|
|
|
890
|
return $this->{END_CHAR}; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub getID |
41
|
|
|
|
|
|
|
{ |
42
|
330
|
|
|
330
|
1
|
505
|
my ($this) = @_; |
43
|
330
|
|
|
|
|
928
|
return $this->{ID}; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub getDocument |
47
|
|
|
|
|
|
|
{ |
48
|
660
|
|
|
660
|
1
|
1051
|
my ($this) = @_; |
49
|
660
|
|
|
|
|
1060
|
return $this->getSentence->getDocument; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub isMaximal |
53
|
|
|
|
|
|
|
{ |
54
|
650
|
|
|
650
|
1
|
1043
|
my ($this) = @_; |
55
|
650
|
|
|
|
|
1712
|
return $this->{MAXIMAL}; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub setInfoForPhrase |
59
|
|
|
|
|
|
|
{ |
60
|
122
|
|
|
122
|
1
|
225
|
my ($this,$words_a,$maximal) = @_; |
61
|
122
|
|
|
|
|
216
|
my $first = $words_a->[0]; |
62
|
122
|
|
|
|
|
214
|
my $last = $words_a->[$#$words_a]; |
63
|
122
|
|
|
|
|
345
|
$this->{SENTENCE} = $first->getSentence; |
64
|
122
|
|
|
|
|
276
|
$this->{START_CHAR} = $first->getStartChar; |
65
|
122
|
|
|
|
|
246
|
$this->{END_CHAR} = $last->getStartChar + $last->getLexItem->getLength; |
66
|
122
|
|
|
|
|
276
|
$this->{MAXIMAL} = $maximal; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub setInfoForTestifiedTerm |
70
|
|
|
|
|
|
|
{ |
71
|
3
|
|
|
3
|
1
|
6
|
my ($this,$sentence,$start_char,$end_char) = @_; |
72
|
3
|
|
|
|
|
5
|
$this->{SENTENCE} = $sentence; |
73
|
3
|
|
|
|
|
6
|
$this->{START_CHAR} = $start_char; |
74
|
3
|
|
|
|
|
7
|
$this->{END_CHAR} = $end_char; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub print |
78
|
|
|
|
|
|
|
{ |
79
|
0
|
|
|
0
|
1
|
|
my ($this,$fh) = @_; |
80
|
0
|
0
|
|
|
|
|
if(defined $fh) |
81
|
|
|
|
|
|
|
{ |
82
|
0
|
|
|
|
|
|
print $fh "DOC: " . $this->getDocument . " - SENT: " . $this->getSentence . " from: " . $this->getStartChar . " to: " .$this->getEndChar . "\n"; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
else |
85
|
|
|
|
|
|
|
{ |
86
|
0
|
|
|
|
|
|
print "DOC: " . $this->getDocument->getID . " - SENT: " . $this->getSentence->getID . " from: " . $this->getStartChar . " to: " .$this->getEndChar . "\n"; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub isNotBest |
91
|
|
|
|
|
|
|
{ |
92
|
0
|
|
|
0
|
1
|
|
my ($this,$other_occurrences_a,$parsing_direction) = @_; |
93
|
0
|
|
|
|
|
|
my $other; |
94
|
|
|
|
|
|
|
|
95
|
0
|
|
|
|
|
|
foreach $other (@$other_occurrences_a) |
96
|
|
|
|
|
|
|
{ |
97
|
0
|
0
|
|
|
|
|
if($this->isIncludedIn($other)) # best is the largest |
98
|
|
|
|
|
|
|
{ |
99
|
0
|
|
|
|
|
|
return 1; |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
# best is the one that has the position corresponding to the parsing direction (ex: leftmost TT for parsing direction = LEFT) |
102
|
0
|
0
|
|
|
|
|
if($this->crossesWithoutPriority($other,$parsing_direction)) |
103
|
|
|
|
|
|
|
{ |
104
|
0
|
|
|
|
|
|
return 1; |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
} |
107
|
0
|
|
|
|
|
|
return; |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
sub crossesWithoutPriority |
112
|
|
|
|
|
|
|
{ |
113
|
0
|
|
|
0
|
1
|
|
my ($this,$other,$parsing_direction) = @_; |
114
|
0
|
0
|
0
|
|
|
|
if( |
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
115
|
|
|
|
|
|
|
($this->getStartChar > $other->getStartChar) |
116
|
|
|
|
|
|
|
&& |
117
|
|
|
|
|
|
|
($this->getStartChar < $other->getEndChar) |
118
|
|
|
|
|
|
|
&& |
119
|
|
|
|
|
|
|
($this->getEndChar > $other->getEndChar) |
120
|
|
|
|
|
|
|
&& |
121
|
|
|
|
|
|
|
($parsing_direction eq "LEFT") |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
) |
124
|
|
|
|
|
|
|
{ |
125
|
0
|
|
|
|
|
|
return 1; |
126
|
|
|
|
|
|
|
} |
127
|
0
|
0
|
0
|
|
|
|
if( |
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
128
|
|
|
|
|
|
|
($this->getEndChar < $other->getEndChar) |
129
|
|
|
|
|
|
|
&& |
130
|
|
|
|
|
|
|
($this->getEndChar > $other->getStartChar) |
131
|
|
|
|
|
|
|
&& |
132
|
|
|
|
|
|
|
($this->getStartChar < $other->getStartChar) |
133
|
|
|
|
|
|
|
&& |
134
|
|
|
|
|
|
|
($parsing_direction eq "RIGHT") |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
) |
137
|
|
|
|
|
|
|
{ |
138
|
0
|
|
|
|
|
|
return 1; |
139
|
|
|
|
|
|
|
} |
140
|
0
|
|
|
|
|
|
return; |
141
|
|
|
|
|
|
|
} |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
sub isIncludedIn |
144
|
|
|
|
|
|
|
{ |
145
|
0
|
|
|
0
|
1
|
|
my ($this,$other) = @_; |
146
|
0
|
0
|
0
|
|
|
|
if( |
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
147
|
|
|
|
|
|
|
( |
148
|
|
|
|
|
|
|
($this->getStartChar >= $other->getStartChar) |
149
|
|
|
|
|
|
|
&& |
150
|
|
|
|
|
|
|
($this->getEndChar < $other->getEndChar) |
151
|
|
|
|
|
|
|
) |
152
|
|
|
|
|
|
|
|| |
153
|
|
|
|
|
|
|
( |
154
|
|
|
|
|
|
|
( |
155
|
|
|
|
|
|
|
($this->getStartChar > $other->getStartChar) |
156
|
|
|
|
|
|
|
&& |
157
|
|
|
|
|
|
|
($this->getEndChar <= $other->getEndChar) |
158
|
|
|
|
|
|
|
) |
159
|
|
|
|
|
|
|
) |
160
|
|
|
|
|
|
|
) |
161
|
|
|
|
|
|
|
{ |
162
|
0
|
|
|
|
|
|
return 1; |
163
|
|
|
|
|
|
|
} |
164
|
0
|
|
|
|
|
|
return; |
165
|
|
|
|
|
|
|
} |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
1; |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
__END__ |