line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package RDF::NLP::SPARQLQuery::Query; |
2
|
|
|
|
|
|
|
|
3
|
11
|
|
|
11
|
|
103
|
use utf8; |
|
11
|
|
|
|
|
18
|
|
|
11
|
|
|
|
|
94
|
|
4
|
11
|
|
|
11
|
|
296
|
use strict; |
|
11
|
|
|
|
|
21
|
|
|
11
|
|
|
|
|
341
|
|
5
|
11
|
|
|
11
|
|
59
|
use warnings; |
|
11
|
|
|
|
|
28
|
|
|
11
|
|
|
|
|
327
|
|
6
|
11
|
|
|
11
|
|
58
|
use Data::Dumper; |
|
11
|
|
|
|
|
21
|
|
|
11
|
|
|
|
|
651
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
# use JSON:PP; |
9
|
11
|
|
|
11
|
|
9426
|
use HTTP::Request; |
|
11
|
|
|
|
|
311652
|
|
|
11
|
|
|
|
|
368
|
|
10
|
11
|
|
|
11
|
|
11636
|
use LWP::UserAgent; |
|
11
|
|
|
|
|
272440
|
|
|
11
|
|
|
|
|
467
|
|
11
|
11
|
|
|
11
|
|
9634
|
use URL::Encode; |
|
11
|
|
|
|
|
59828
|
|
|
11
|
|
|
|
|
556
|
|
12
|
|
|
|
|
|
|
# use XML::Simple; |
13
|
|
|
|
|
|
|
|
14
|
11
|
|
|
11
|
|
93
|
use Storable qw (dclone); |
|
11
|
|
|
|
|
23
|
|
|
11
|
|
|
|
|
782
|
|
15
|
|
|
|
|
|
|
|
16
|
11
|
|
|
11
|
|
68
|
use Mouse; |
|
11
|
|
|
|
|
24
|
|
|
11
|
|
|
|
|
134
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
our $VERSION='0.1'; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
has 'verbose' => (is => 'rw', isa => 'Int'); |
21
|
|
|
|
|
|
|
has 'docId' => (is => 'rw', isa => 'Str'); |
22
|
|
|
|
|
|
|
has 'language' => (is => 'rw', isa => 'Str'); |
23
|
|
|
|
|
|
|
has 'queryString' => (is => 'rw', isa => 'Str'); |
24
|
|
|
|
|
|
|
has 'queryXMLString' => (is => 'rw', isa => 'Str'); |
25
|
|
|
|
|
|
|
has 'queryAnswers' => (is => 'rw', isa => 'HashRef'); |
26
|
|
|
|
|
|
|
has 'selectPart' => (is => 'rw', isa => 'ArrayRef'); |
27
|
|
|
|
|
|
|
has 'wherePart' => (is => 'rw', isa => 'ArrayRef'); |
28
|
|
|
|
|
|
|
has 'aggregation' => (is => 'rw', isa => 'HashRef'); |
29
|
|
|
|
|
|
|
has 'conjunction' => (is => 'rw', isa => 'Int'); |
30
|
|
|
|
|
|
|
has 'sentences' => (is => 'rw', isa => 'ArrayRef'); |
31
|
|
|
|
|
|
|
has 'negation' => (is => 'rw', isa => 'HashRef'); |
32
|
|
|
|
|
|
|
has 'varPrefix' => (is => 'rw', isa => 'Str'); |
33
|
|
|
|
|
|
|
has 'variableCounter' => (is => 'rw', isa => 'Int'); |
34
|
|
|
|
|
|
|
has 'variableSet' => (is => 'rw', isa => 'HashRef'); |
35
|
|
|
|
|
|
|
has 'union' => (is => 'rw', isa => 'ArrayRef'); |
36
|
|
|
|
|
|
|
has 'semanticCorrespondance' => (is => 'rw', isa => 'HashRef'); |
37
|
|
|
|
|
|
|
has 'questionTopic' => (is => 'rw', isa => 'Str'); |
38
|
|
|
|
|
|
|
has 'semFeaturesIndex' => (is => 'rw', isa => 'HashRef'); |
39
|
|
|
|
|
|
|
has 'sortedSemanticUnits' => (is => 'rw', isa => 'ArrayRef'); |
40
|
|
|
|
|
|
|
has 'config' => (is => 'rw', isa => 'HashRef'); |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# has '' => (is => 'rw', isa => 'HashRef'); |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
# DOC |
46
|
|
|
|
|
|
|
sub new { |
47
|
9
|
|
|
9
|
1
|
20
|
my $class = shift; |
48
|
9
|
|
|
|
|
89
|
my %args = @_; |
49
|
|
|
|
|
|
|
|
50
|
9
|
|
|
|
|
243
|
my $Query = { |
51
|
|
|
|
|
|
|
"verbose" => 0, |
52
|
|
|
|
|
|
|
"docId" => undef, |
53
|
|
|
|
|
|
|
"language" => undef, |
54
|
|
|
|
|
|
|
"selectPart" => [], |
55
|
|
|
|
|
|
|
"wherePart" => [], |
56
|
|
|
|
|
|
|
"aggregation" => {'TERM' => { |
57
|
|
|
|
|
|
|
'count' => {}, |
58
|
|
|
|
|
|
|
'max' => {}, |
59
|
|
|
|
|
|
|
'min' => {}, |
60
|
|
|
|
|
|
|
'distinct' => {}, |
61
|
|
|
|
|
|
|
'per' => {}, |
62
|
|
|
|
|
|
|
}, |
63
|
|
|
|
|
|
|
'QT' => {}, |
64
|
|
|
|
|
|
|
'QTVAR' => {}, |
65
|
|
|
|
|
|
|
'PREDICATE' => {}, |
66
|
|
|
|
|
|
|
'ASK' => 0, |
67
|
|
|
|
|
|
|
}, |
68
|
|
|
|
|
|
|
"conjunction" => 0, |
69
|
|
|
|
|
|
|
"sentences" => [], |
70
|
|
|
|
|
|
|
"negation" => {}, |
71
|
|
|
|
|
|
|
"config" => undef, |
72
|
|
|
|
|
|
|
"union" => [], |
73
|
|
|
|
|
|
|
"varPrefix" => "?v", |
74
|
|
|
|
|
|
|
"variableCounter" => 0, |
75
|
|
|
|
|
|
|
"variableSet" => {}, |
76
|
|
|
|
|
|
|
"semanticCorrespondance" => undef, |
77
|
|
|
|
|
|
|
"questionTopic" => undef, |
78
|
|
|
|
|
|
|
'semFeaturesIndex' => {}, |
79
|
|
|
|
|
|
|
'queryString' => "", |
80
|
|
|
|
|
|
|
'queryXMLString' => "", |
81
|
|
|
|
|
|
|
'queryAnswers' => {}, |
82
|
|
|
|
|
|
|
}; |
83
|
9
|
|
|
|
|
41
|
bless $Query, $class; |
84
|
|
|
|
|
|
|
|
85
|
9
|
|
|
|
|
64
|
$Query->verbose($args{'verbose'}); |
86
|
9
|
|
|
|
|
56
|
$Query->docId($args{'docId'}); |
87
|
9
|
|
|
|
|
49
|
$Query->language($args{'language'}); |
88
|
9
|
|
|
|
|
50
|
$Query->negation($args{'negation'}); |
89
|
9
|
|
|
|
|
52
|
$Query->sentences($args{'sentences'}); |
90
|
9
|
|
|
|
|
48
|
$Query->union($args{'union'}); |
91
|
9
|
|
|
|
|
50
|
$Query->aggregation($args{'aggregation'}); |
92
|
9
|
|
|
|
|
66
|
$Query->semFeaturesIndex($args{'semFeaturesIndex'}); |
93
|
9
|
|
|
|
|
41
|
$Query->config($args{'config'}); |
94
|
9
|
|
|
|
|
42
|
$Query->semanticCorrespondance($args{'semanticCorrespondance'}); |
95
|
9
|
|
|
|
|
45
|
$Query->sortedSemanticUnits($args{'sortedSemanticUnits'}); |
96
|
|
|
|
|
|
|
|
97
|
9
|
|
|
|
|
98
|
return($Query); |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
sub _sortedSemanticUnits { |
101
|
2
|
|
|
2
|
|
4
|
my $self = shift; |
102
|
|
|
|
|
|
|
|
103
|
2
|
|
|
|
|
10
|
return($self->sortedSemanticUnits); |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
sub _regexForm { |
107
|
1
|
|
|
1
|
|
2
|
my $self = shift; |
108
|
|
|
|
|
|
|
|
109
|
1
|
|
|
|
|
11
|
return($self->config->{'NLQUESTION'}->{'language="' . uc($self->language) . '"'}->{'REGEXFORM'}); |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
sub _unionOpt { |
113
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
114
|
|
|
|
|
|
|
|
115
|
0
|
|
|
|
|
0
|
return($self->config->{'NLQUESTION'}->{'language="' . uc($self->language) . '"'}->{'UNION'}); |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
sub _addQueryString { |
120
|
54
|
|
|
54
|
|
70
|
my $self = shift; |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
|
123
|
54
|
50
|
|
|
|
123
|
if (@_) { |
124
|
54
|
|
|
|
|
71
|
my $str = shift; |
125
|
54
|
|
|
|
|
178
|
my $newStr = $self->queryString . $str; |
126
|
|
|
|
|
|
|
# warn $newStr; |
127
|
54
|
|
|
|
|
297
|
$self->queryString($newStr); |
128
|
|
|
|
|
|
|
} |
129
|
|
|
|
|
|
|
|
130
|
54
|
|
|
|
|
138
|
return($self->queryString); |
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
sub _addQueryXMLString { |
134
|
54
|
|
|
54
|
|
73
|
my $self = shift; |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
|
137
|
54
|
50
|
|
|
|
125
|
if (@_) { |
138
|
54
|
|
|
|
|
67
|
my $str = shift; |
139
|
54
|
|
|
|
|
369
|
my $newStr = $self->queryXMLString . $str; |
140
|
|
|
|
|
|
|
# warn $newStr; |
141
|
54
|
|
|
|
|
194
|
$self->queryXMLString($newStr); |
142
|
|
|
|
|
|
|
} |
143
|
|
|
|
|
|
|
|
144
|
54
|
|
|
|
|
234
|
return($self->queryXMLString); |
145
|
|
|
|
|
|
|
} |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
sub _IncrVariableCounter { |
148
|
12
|
|
|
12
|
|
22
|
my $self = shift; |
149
|
12
|
|
|
|
|
23
|
my $step = 1; |
150
|
|
|
|
|
|
|
|
151
|
12
|
50
|
|
|
|
38
|
if (@_) { |
152
|
0
|
|
|
|
|
0
|
$step = shift; |
153
|
|
|
|
|
|
|
} |
154
|
|
|
|
|
|
|
|
155
|
12
|
|
|
|
|
68
|
$self->variableCounter($self->variableCounter + $step); |
156
|
12
|
|
|
|
|
32
|
return($self->variableCounter); |
157
|
|
|
|
|
|
|
} |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
sub wherePart { |
160
|
|
|
|
|
|
|
my ($self) = @_; |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
my $wherePart = []; |
163
|
|
|
|
|
|
|
# $self->_newWherePartLine($wherePart); |
164
|
|
|
|
|
|
|
return($wherePart); |
165
|
|
|
|
|
|
|
} |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
sub _newWherePartLine { |
168
|
12
|
|
|
12
|
|
21
|
my ($self, $wherePart) = @_; |
169
|
|
|
|
|
|
|
|
170
|
12
|
100
|
|
|
|
40
|
if (!defined $wherePart) { |
171
|
11
|
|
|
|
|
40
|
$wherePart = $self->wherePart; |
172
|
|
|
|
|
|
|
} |
173
|
|
|
|
|
|
|
|
174
|
12
|
|
|
|
|
21
|
push @{$wherePart}, {'SUBJECT' => "", |
|
12
|
|
|
|
|
77
|
|
175
|
|
|
|
|
|
|
'PREDICATE' => [], |
176
|
|
|
|
|
|
|
'OBJECT' => "", |
177
|
|
|
|
|
|
|
'NEGATION' => 0, |
178
|
|
|
|
|
|
|
'SEEN' => 0, |
179
|
|
|
|
|
|
|
}; |
180
|
12
|
|
|
|
|
19
|
return(scalar(@{$wherePart})-1); |
|
12
|
|
|
|
|
39
|
|
181
|
|
|
|
|
|
|
} |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
sub _addNegation2Predicate { |
184
|
0
|
|
|
0
|
|
0
|
my ($self,$line) = @_; |
185
|
|
|
|
|
|
|
|
186
|
0
|
|
|
|
|
0
|
$line->{'NEGATION'} = 1; |
187
|
|
|
|
|
|
|
} |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
sub _cloneLine { |
190
|
0
|
|
|
0
|
|
0
|
my ($self, $position, $line) = @_; |
191
|
|
|
|
|
|
|
|
192
|
0
|
|
|
|
|
0
|
my $pos = $position; |
193
|
0
|
0
|
|
|
|
0
|
if ($position eq 'last') { |
194
|
0
|
|
|
|
|
0
|
$pos = scalar(@{$self->wherePart}) - 1; |
|
0
|
|
|
|
|
0
|
|
195
|
|
|
|
|
|
|
} |
196
|
0
|
0
|
|
|
|
0
|
if ($position eq 'first') { |
197
|
0
|
|
|
|
|
0
|
$pos = 0; |
198
|
|
|
|
|
|
|
} |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
# my $line; |
201
|
0
|
|
|
|
|
0
|
$line = $self->wherePart->[$pos]; |
202
|
0
|
|
|
|
|
0
|
$pos = $self->_newWherePartLine; # ($wherePart); |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
# warn "position: $pos -- $position\n";; |
205
|
0
|
|
|
|
|
0
|
$self->_addPredicate($pos, $line->{'PREDICATE'}->[0]); |
206
|
|
|
|
|
|
|
|
207
|
0
|
|
|
|
|
0
|
$self->_addSubject($pos, $line->{'SUBJECT'}->[1]); |
208
|
0
|
|
|
|
|
0
|
$self->_addObject($pos, $line->{'OBJECT'}->[1]); |
209
|
0
|
|
|
|
|
0
|
return($self->wherePart->[$pos]); |
210
|
|
|
|
|
|
|
} |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
sub _addPredicate { |
213
|
11
|
|
|
11
|
|
29
|
my ($self, $position, $predicate) = @_; |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
# warn $position; |
216
|
11
|
|
|
|
|
20
|
my $pos = $position; |
217
|
11
|
50
|
|
|
|
39
|
if ($position eq 'last') { |
218
|
11
|
|
|
|
|
20
|
$pos = scalar(@{$self->wherePart}) - 1; |
|
11
|
|
|
|
|
42
|
|
219
|
|
|
|
|
|
|
} |
220
|
11
|
50
|
|
|
|
38
|
if ($position eq 'first') { |
221
|
0
|
|
|
|
|
0
|
$pos=0; |
222
|
|
|
|
|
|
|
} |
223
|
|
|
|
|
|
|
# warn "$pos : " . $self->wherePart . "\n"; |
224
|
|
|
|
|
|
|
# warn "==> ". $self->semanticCorrespondance->{$self->language}->{'PREDICATE'}->{$predicate}->{'SUBJECT_TYPE'} . "\n"; |
225
|
11
|
|
|
|
|
68
|
$self->_printVerbose("\t\tPredicate: $predicate\n",2); |
226
|
11
|
|
|
|
|
161
|
$self->wherePart->[$pos]->{'SUBJECT'} = [ $self->semanticCorrespondance->{$self->language}->{'PREDICATE'}->{$predicate}->{'SUBJECT_TYPE'}, ""]; |
227
|
11
|
|
|
|
|
96
|
$self->wherePart->[$pos]->{'PREDICATE'} = [ $predicate, |
228
|
|
|
|
|
|
|
$self->semanticCorrespondance->{$self->language}->{'PREDICATE'}->{$predicate}->{'NAME'}, |
229
|
|
|
|
|
|
|
]; |
230
|
11
|
|
|
|
|
89
|
$self->wherePart->[$pos]->{'OBJECT'} = [$self->semanticCorrespondance->{$self->language}->{'PREDICATE'}->{$predicate}->{'OBJECT_TYPE'}, ""]; |
231
|
11
|
|
|
|
|
38
|
$self->wherePart->[$pos]->{'SEEN'} = 0; |
232
|
11
|
|
|
|
|
45
|
return($self->wherePart->[$pos]); |
233
|
|
|
|
|
|
|
} |
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
sub _addPredicateSameAs { |
236
|
1
|
|
|
1
|
|
3
|
my ($self, $wherePart, $position, $subject) = @_; |
237
|
|
|
|
|
|
|
|
238
|
1
|
|
|
|
|
2
|
my $pos = $position; |
239
|
|
|
|
|
|
|
|
240
|
1
|
50
|
|
|
|
5
|
if ($position eq 'last') { |
241
|
1
|
|
|
|
|
3
|
$pos=$#$wherePart; |
242
|
|
|
|
|
|
|
# $pos = scalar(@{$self->wherePart}) - 1; |
243
|
|
|
|
|
|
|
} |
244
|
1
|
50
|
|
|
|
5
|
if ($position eq 'first') { |
245
|
0
|
|
|
|
|
0
|
$pos=0; |
246
|
|
|
|
|
|
|
} |
247
|
|
|
|
|
|
|
# warn "pos: $pos\n"; |
248
|
|
|
|
|
|
|
# warn "==> ". $self->semanticCorrespondance->{$self->language}->{'PREDICATE'}->{$predicate}->{'SUBJECT_TYPE'} . "\n"; |
249
|
1
|
|
|
|
|
4
|
$wherePart->[$pos]->{'SUBJECT'} = [ $subject, ""]; |
250
|
1
|
|
|
|
|
10
|
$wherePart->[$pos]->{'PREDICATE'} = [ "sameAs", |
251
|
|
|
|
|
|
|
$self->semanticCorrespondance->{$self->language}->{'SAMEAS'}->{'ROOT'}, |
252
|
|
|
|
|
|
|
]; |
253
|
1
|
|
|
|
|
8
|
$wherePart->[$pos]->{'OBJECT'} = [$self->semanticCorrespondance->{$self->language}->{'SAMEAS'}->{'CORRESP'}->{$subject}, ""]; |
254
|
1
|
|
|
|
|
2
|
$wherePart->[$pos]->{'SEEN'} = 0; |
255
|
|
|
|
|
|
|
} |
256
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
sub _addSubject { |
258
|
0
|
|
|
0
|
|
0
|
my ($self, $position, $subject) = @_; |
259
|
|
|
|
|
|
|
|
260
|
0
|
|
|
|
|
0
|
my $pos = $position; |
261
|
0
|
0
|
|
|
|
0
|
if ($position eq 'last') { |
262
|
0
|
|
|
|
|
0
|
$pos = scalar(@{$self->wherePart}) - 1; |
|
0
|
|
|
|
|
0
|
|
263
|
|
|
|
|
|
|
} |
264
|
0
|
0
|
|
|
|
0
|
if ($position eq 'first') { |
265
|
0
|
|
|
|
|
0
|
$pos=0; |
266
|
|
|
|
|
|
|
} |
267
|
0
|
|
|
|
|
0
|
$self->wherePart->[$pos]->{'SUBJECT'}->[1] = $subject; |
268
|
0
|
|
|
|
|
0
|
$self->wherePart->[$pos]->{'SEEN'} = 1; |
269
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
} |
271
|
|
|
|
|
|
|
sub _addSubjectLine { |
272
|
12
|
|
|
12
|
|
25
|
my ($self, $line, $subject) = @_; |
273
|
|
|
|
|
|
|
|
274
|
12
|
|
|
|
|
34
|
$line->{'SUBJECT'}->[1] = $subject; |
275
|
12
|
|
|
|
|
25
|
$line->{'SEEN'} = 1; |
276
|
|
|
|
|
|
|
|
277
|
|
|
|
|
|
|
} |
278
|
|
|
|
|
|
|
|
279
|
|
|
|
|
|
|
sub _addObject { |
280
|
0
|
|
|
0
|
|
0
|
my ($self, $position, $object) = @_; |
281
|
|
|
|
|
|
|
|
282
|
0
|
|
|
|
|
0
|
my $pos = $position; |
283
|
0
|
0
|
|
|
|
0
|
if ($position eq 'last') { |
284
|
0
|
|
|
|
|
0
|
$pos = scalar(@{$self->wherePart}) - 1; |
|
0
|
|
|
|
|
0
|
|
285
|
|
|
|
|
|
|
} |
286
|
0
|
0
|
|
|
|
0
|
if ($position eq 'first') { |
287
|
0
|
|
|
|
|
0
|
$pos=0; |
288
|
|
|
|
|
|
|
} |
289
|
|
|
|
|
|
|
# warn "pos: $pos\n"; |
290
|
0
|
|
|
|
|
0
|
$self->wherePart->[$pos]->{'OBJECT'}->[1] = $object; |
291
|
0
|
|
|
|
|
0
|
$self->wherePart->[$pos]->{'SEEN'} = 1; |
292
|
|
|
|
|
|
|
|
293
|
|
|
|
|
|
|
} |
294
|
|
|
|
|
|
|
|
295
|
|
|
|
|
|
|
sub _addObjectLine { |
296
|
12
|
|
|
12
|
|
30
|
my ($self, $line, $object) = @_; |
297
|
|
|
|
|
|
|
|
298
|
12
|
|
|
|
|
32
|
$line->{'OBJECT'}->[1] = $object; |
299
|
12
|
|
|
|
|
29
|
$line->{'SEEN'} = 1; |
300
|
|
|
|
|
|
|
|
301
|
|
|
|
|
|
|
} |
302
|
|
|
|
|
|
|
|
303
|
|
|
|
|
|
|
sub _internalPrintOfWherePart { |
304
|
81
|
|
|
81
|
|
115
|
my ($self) = @_; |
305
|
81
|
|
|
|
|
113
|
my $line; |
306
|
|
|
|
|
|
|
|
307
|
81
|
50
|
|
|
|
425
|
if ($self->verbose == 0) { |
308
|
81
|
|
|
|
|
150
|
return(0); |
309
|
|
|
|
|
|
|
} |
310
|
|
|
|
|
|
|
|
311
|
0
|
|
|
|
|
0
|
foreach $line (@{$self->wherePart}) { |
|
0
|
|
|
|
|
0
|
|
312
|
0
|
|
|
|
|
0
|
warn $line->{'SUBJECT'}->[0] . " : " . $line->{'PREDICATE'}->[0] . " : " . $line->{'OBJECT'}->[0] . "\n"; |
313
|
0
|
0
|
|
|
|
0
|
if ($line->{'SUBJECT'}->[1] ne "") { |
314
|
0
|
|
|
|
|
0
|
print STDERR $line->{'SUBJECT'}->[1]; |
315
|
|
|
|
|
|
|
} else { |
316
|
0
|
|
|
|
|
0
|
print STDERR " # "; |
317
|
|
|
|
|
|
|
} |
318
|
0
|
|
|
|
|
0
|
print STDERR " : "; |
319
|
0
|
0
|
|
|
|
0
|
if ($line->{'PREDICATE'}->[1] ne "") { |
320
|
0
|
|
|
|
|
0
|
print STDERR $line->{'PREDICATE'}->[1]; |
321
|
|
|
|
|
|
|
} else { |
322
|
0
|
|
|
|
|
0
|
print STDERR " # "; |
323
|
|
|
|
|
|
|
} |
324
|
0
|
|
|
|
|
0
|
print STDERR " : "; |
325
|
0
|
0
|
|
|
|
0
|
if ($line->{'OBJECT'}->[1] ne "") { |
326
|
0
|
|
|
|
|
0
|
print STDERR $line->{'OBJECT'}->[1]; |
327
|
|
|
|
|
|
|
} else { |
328
|
0
|
|
|
|
|
0
|
print STDERR " # "; |
329
|
|
|
|
|
|
|
} |
330
|
0
|
|
|
|
|
0
|
print STDERR "\n\n"; |
331
|
|
|
|
|
|
|
} |
332
|
0
|
|
|
|
|
0
|
print STDERR "********************\n"; |
333
|
|
|
|
|
|
|
|
334
|
|
|
|
|
|
|
} |
335
|
|
|
|
|
|
|
|
336
|
|
|
|
|
|
|
# DOC |
337
|
|
|
|
|
|
|
sub queryConstruction { |
338
|
9
|
|
|
9
|
1
|
20
|
my $self = shift; |
339
|
9
|
|
|
|
|
16
|
my $questionTopic = shift; |
340
|
|
|
|
|
|
|
|
341
|
|
|
|
|
|
|
# my $varPrefix="?v"; |
342
|
|
|
|
|
|
|
# my $variableCounter = 0; |
343
|
|
|
|
|
|
|
# my $variable = ""; |
344
|
|
|
|
|
|
|
# my $i; |
345
|
|
|
|
|
|
|
|
346
|
9
|
|
|
|
|
66
|
$self->questionTopic($questionTopic); |
347
|
|
|
|
|
|
|
|
348
|
|
|
|
|
|
|
# Add question topic variable |
349
|
9
|
|
|
|
|
55
|
$self->_printVerbose("[LOG] Add question topic variable (" . $self->questionTopic . ")\n"); |
350
|
9
|
|
|
|
|
34
|
$self->_setQuestionTopicVariable; # ($self->questionTopic); |
351
|
9
|
|
|
|
|
56
|
$self->_printVerbose("[LOG] Question Topic (1): " . $self->questionTopic . "\n"); |
352
|
|
|
|
|
|
|
|
353
|
9
|
|
|
|
|
18
|
$self->_printVerbose("Select Part: " . join(';',@{$self->selectPart}) . "\n",2); |
|
9
|
|
|
|
|
58
|
|
354
|
|
|
|
|
|
|
|
355
|
9
|
|
|
|
|
28
|
$self->_internalPrintOfWherePart; |
356
|
|
|
|
|
|
|
|
357
|
|
|
|
|
|
|
|
358
|
9
|
|
|
|
|
26
|
$self->_printVerbose("[LOG] Unified internal subject/object\n"); |
359
|
|
|
|
|
|
|
# PROBLEM HERE: KEEP THIS? |
360
|
9
|
50
|
|
|
|
50
|
if ($self->conjunction == 1) { |
361
|
0
|
|
|
|
|
0
|
$self->_unifiedVariables; |
362
|
0
|
|
|
|
|
0
|
$self->_internalPrintOfWherePart; |
363
|
|
|
|
|
|
|
} |
364
|
|
|
|
|
|
|
# Get Property |
365
|
9
|
|
|
|
|
26
|
$self->_printVerbose("[LOG] Get Property\n"); |
366
|
9
|
|
|
|
|
40
|
$self->_getProperty; |
367
|
|
|
|
|
|
|
|
368
|
|
|
|
|
|
|
|
369
|
9
|
|
|
|
|
25
|
$self->_internalPrintOfWherePart; |
370
|
9
|
|
|
|
|
27
|
$self->_printVerbose("[LOG] Complete property with REGEX\n"); |
371
|
|
|
|
|
|
|
# $self->_getPropertyFromRegex(\@wherePart, \%semFeaturesIndex, \$replacedPredicate, $conjunction, $lang); |
372
|
|
|
|
|
|
|
|
373
|
|
|
|
|
|
|
# $self->_internalPrintOfWherePart; |
374
|
9
|
|
|
|
|
24
|
$self->_printVerbose("[LOG] if semantic Type remaining\n"); |
375
|
|
|
|
|
|
|
|
376
|
9
|
|
|
|
|
28
|
$self->_printVerbose("[LOG] Unified internal subject/object\n"); |
377
|
9
|
|
|
|
|
84
|
$self->_unifiedVariables; |
378
|
9
|
|
|
|
|
26
|
$self->_internalPrintOfWherePart; |
379
|
|
|
|
|
|
|
|
380
|
|
|
|
|
|
|
|
381
|
9
|
|
|
|
|
35
|
$self->_UsingSameAs; |
382
|
9
|
|
|
|
|
25
|
$self->_internalPrintOfWherePart; |
383
|
|
|
|
|
|
|
|
384
|
9
|
|
|
|
|
25
|
$self->_printVerbose("[LOG] Unified internal subject/object (2)\n"); |
385
|
9
|
|
|
|
|
113
|
$self->_unifiedVariables; |
386
|
9
|
|
|
|
|
24
|
$self->_internalPrintOfWherePart; |
387
|
|
|
|
|
|
|
|
388
|
|
|
|
|
|
|
|
389
|
9
|
|
|
|
|
26
|
$self->_printVerbose("[LOG] connect question Topic (2)\n"); |
390
|
9
|
|
|
|
|
34
|
$self->_setQuestionTopicVariable2; |
391
|
9
|
|
|
|
|
41
|
$self->_printVerbose("Question Topic (2): $questionTopic\n"); |
392
|
|
|
|
|
|
|
|
393
|
9
|
|
|
|
|
25
|
$self->_internalPrintOfWherePart; |
394
|
|
|
|
|
|
|
|
395
|
9
|
|
|
|
|
29
|
$self->_printVerbose("[LOG] Add variables for remaining unconnected Property\n"); |
396
|
9
|
|
|
|
|
39
|
$self->_connectRemainingElementsWithString; # (\%semFeaturesIndex, \@sortedSemanticUnits); |
397
|
9
|
|
|
|
|
31
|
$self->_connectRemainingElements; # (\%semFeaturesIndex); |
398
|
|
|
|
|
|
|
|
399
|
9
|
|
|
|
|
27
|
$self->_internalPrintOfWherePart; |
400
|
|
|
|
|
|
|
|
401
|
9
|
|
|
|
|
26
|
$self->_printVerbose("[LOG] Add Negation\n"); |
402
|
9
|
|
|
|
|
33
|
$self->_addNegation; |
403
|
9
|
|
|
|
|
23
|
$self->_internalPrintOfWherePart; |
404
|
|
|
|
|
|
|
|
405
|
|
|
|
|
|
|
} |
406
|
|
|
|
|
|
|
|
407
|
|
|
|
|
|
|
sub _setQuestionTopicVariable { |
408
|
9
|
|
|
9
|
|
18
|
my ($self) = @_; |
409
|
9
|
|
|
|
|
18
|
my $i; |
410
|
|
|
|
|
|
|
my $line; |
411
|
0
|
|
|
|
|
0
|
my $variable; |
412
|
0
|
|
|
|
|
0
|
my $aggregOp; |
413
|
|
|
|
|
|
|
|
414
|
9
|
|
|
|
|
22
|
for($i=0; $i < scalar(@{$self->wherePart}); $i++) { |
|
9
|
|
|
|
|
51
|
|
415
|
9
|
|
|
|
|
34
|
$line = $self->wherePart->[$i]; |
416
|
9
|
50
|
|
|
|
42
|
if ($line->{'SUBJECT'}->[1] eq "") { |
417
|
|
|
|
|
|
|
# new variable; |
418
|
9
|
100
|
|
|
|
50
|
if (($self->questionTopic eq $line->{'SUBJECT'}->[0]) # || |
419
|
|
|
|
|
|
|
# ($self->{'SEMTYPECORRESP'}->{$lang}->{'SAMEAS'}->{'CORRESP'}->{$line->{'SUBJECT'}->[0]} eq $self->questionTopic) || |
420
|
|
|
|
|
|
|
# ($self->{'SEMTYPECORRESP'}->{$lang}->{'SAMEAS'}->{'CORRESP'}->{$self->questionTopic} eq $line->{'SUBJECT'}->[0]) |
421
|
|
|
|
|
|
|
) { |
422
|
7
|
|
|
|
|
48
|
$variable=$self->varPrefix . $self->variableCounter; |
423
|
7
|
|
|
|
|
32
|
$self->_IncrVariableCounter; |
424
|
7
|
|
|
|
|
30
|
$self->_addSubjectLine($line, $variable); |
425
|
|
|
|
|
|
|
# $line->{'SUBJECT'}->[1] = $variable; |
426
|
7
|
|
|
|
|
35
|
$self->variableSet->{$variable}++; |
427
|
7
|
|
|
|
|
40
|
$self->_printVerbose("\tvariable: $variable\n",2); |
428
|
7
|
|
|
|
|
11
|
push @{$self->selectPart}, $variable; |
|
7
|
|
|
|
|
35
|
|
429
|
7
|
|
|
|
|
16
|
foreach $aggregOp (keys %{$self->aggregation->{'TERM'}}) { |
|
7
|
|
|
|
|
182
|
|
430
|
35
|
50
|
|
|
|
262
|
if (exists $self->aggregation->{'QT'}->{$aggregOp}->{$self->questionTopic}) { |
431
|
0
|
|
|
|
|
0
|
$self->_printVerbose("aggregation Op: $aggregOp (S)\n",2); |
432
|
0
|
|
|
|
|
0
|
$self->aggregation->{'QTVAR'}->{$aggregOp}->{$variable} = $self->questionTopic; |
433
|
|
|
|
|
|
|
} |
434
|
|
|
|
|
|
|
} |
435
|
7
|
|
|
|
|
26
|
last; |
436
|
|
|
|
|
|
|
} |
437
|
|
|
|
|
|
|
} |
438
|
2
|
50
|
|
|
|
11
|
if ($line->{'OBJECT'}->[1] eq "") { |
439
|
|
|
|
|
|
|
# new variable |
440
|
|
|
|
|
|
|
# warn "new variable (Obj)?\n"; |
441
|
2
|
50
|
|
|
|
13
|
if (($self->questionTopic eq $line->{'OBJECT'}->[0]) # || |
442
|
|
|
|
|
|
|
# ($self->{'SEMTYPECORRESP'}->{$lang}->{'SAMEAS'}->{'CORRESP'}->{$line->{'OBJECT'}->[0]} eq $self->questionTopic) || |
443
|
|
|
|
|
|
|
# ($self->{'SEMTYPECORRESP'}->{$lang}->{'SAMEAS'}->{'CORRESP'}->{$self->questionTopic} eq $line->{'OBJECT'}->[0]) |
444
|
|
|
|
|
|
|
) { |
445
|
2
|
|
|
|
|
11
|
$variable=$self->varPrefix . $self->variableCounter; |
446
|
|
|
|
|
|
|
# warn "\t==> $variable\n"; |
447
|
2
|
|
|
|
|
9
|
$self->_IncrVariableCounter; |
448
|
2
|
|
|
|
|
8
|
$self->_addObjectLine($line, $variable); |
449
|
|
|
|
|
|
|
# $line->{'OBJECT'}->[1] = $variable; |
450
|
2
|
|
|
|
|
8
|
$self->variableSet->{$variable}++; |
451
|
2
|
|
|
|
|
10
|
$self->_printVerbose("\tvariable: $variable\n",2); |
452
|
2
|
|
|
|
|
3
|
push @{$self->selectPart}, $variable; |
|
2
|
|
|
|
|
38
|
|
453
|
2
|
|
|
|
|
4
|
foreach $aggregOp (keys %{$self->aggregation->{'TERM'}}) { |
|
2
|
|
|
|
|
11
|
|
454
|
10
|
50
|
|
|
|
46
|
if (exists $self->aggregation->{'QT'}->{$aggregOp}->{$self->questionTopic}) { |
455
|
0
|
|
|
|
|
0
|
$self->_printVerbose("aggregation Op: $aggregOp (O) $variable - $self->questionTopic\n",2); |
456
|
|
|
|
|
|
|
|
457
|
0
|
|
|
|
|
0
|
$self->aggregation->{'QTVAR'}->{$aggregOp}->{$variable} = $self->questionTopic; |
458
|
|
|
|
|
|
|
} |
459
|
|
|
|
|
|
|
} |
460
|
2
|
|
|
|
|
6
|
last; |
461
|
|
|
|
|
|
|
} |
462
|
|
|
|
|
|
|
} |
463
|
|
|
|
|
|
|
} |
464
|
|
|
|
|
|
|
} |
465
|
|
|
|
|
|
|
|
466
|
|
|
|
|
|
|
sub _setQuestionTopicVariable2 { |
467
|
9
|
|
|
9
|
|
14
|
my ($self) = @_; |
468
|
9
|
|
|
|
|
15
|
my $i; |
469
|
|
|
|
|
|
|
my $line; |
470
|
0
|
|
|
|
|
0
|
my $variable; |
471
|
0
|
|
|
|
|
0
|
my $aggregOp; |
472
|
|
|
|
|
|
|
|
473
|
9
|
|
|
|
|
19
|
my %invnegation = reverse %{$self->negation}; |
|
9
|
|
|
|
|
45
|
|
474
|
|
|
|
|
|
|
|
475
|
9
|
|
|
|
|
24
|
for($i=0; $i < scalar(@{$self->wherePart}); $i++) { |
|
21
|
|
|
|
|
91
|
|
476
|
|
|
|
|
|
|
# warn "new variable ($i)?\n"; |
477
|
12
|
50
|
|
|
|
46
|
if (!exists $invnegation{$i}) { |
478
|
12
|
|
|
|
|
35
|
$line = $self->wherePart->[$i]; |
479
|
12
|
100
|
|
|
|
43
|
if ($line->{'SUBJECT'}->[1] eq "") { |
480
|
|
|
|
|
|
|
# new variable; |
481
|
|
|
|
|
|
|
# warn "$self->questionTopic eq " . $line->{'SUBJECT'}->[0] . "?\n"; |
482
|
1
|
0
|
0
|
|
|
7
|
if (($self->questionTopic eq $line->{'SUBJECT'}->[0]) || |
|
|
|
33
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
483
|
|
|
|
|
|
|
((exists $self->semanticCorrespondance->{$self->language}->{'SAMEAS'}->{'CORRESP'}->{$line->{'SUBJECT'}->[0]}) && |
484
|
|
|
|
|
|
|
($self->semanticCorrespondance->{$self->language}->{'SAMEAS'}->{'CORRESP'}->{$line->{'SUBJECT'}->[0]} eq $self->questionTopic)) || |
485
|
|
|
|
|
|
|
((exists $self->semanticCorrespondance->{$self->language}->{'SAMEAS'}->{'CORRESP'}->{$self->questionTopic}) && |
486
|
|
|
|
|
|
|
($self->semanticCorrespondance->{$self->language}->{'SAMEAS'}->{'CORRESP'}->{$self->questionTopic} eq $line->{'SUBJECT'}->[0])) |
487
|
|
|
|
|
|
|
) { |
488
|
1
|
50
|
|
|
|
2
|
if (scalar(@{$self->selectPart}) == 0) { |
|
1
|
|
|
|
|
6
|
|
489
|
0
|
|
|
|
|
0
|
$variable=$self->varPrefix . $self->variableCounter; |
490
|
0
|
|
|
|
|
0
|
$self->_IncrVariableCounter; |
491
|
0
|
|
|
|
|
0
|
push @{$self->selectPart}, $variable; |
|
0
|
|
|
|
|
0
|
|
492
|
|
|
|
|
|
|
} else { |
493
|
1
|
|
|
|
|
5
|
$variable=$self->selectPart->[0]; |
494
|
|
|
|
|
|
|
} |
495
|
1
|
|
|
|
|
3
|
$self->_printVerbose("ADD QT2S\n",2); |
496
|
1
|
|
|
|
|
3
|
$self->_addSubjectLine($line, $variable); |
497
|
1
|
|
|
|
|
4
|
$self->variableSet->{$variable}++; |
498
|
1
|
|
|
|
|
2
|
foreach $aggregOp (keys %{$self->aggregation->{'TERM'}}) { |
|
1
|
|
|
|
|
7
|
|
499
|
5
|
50
|
|
|
|
31
|
if (exists $self->aggregation->{'QT'}->{$aggregOp}->{$self->questionTopic}) { |
500
|
0
|
|
|
|
|
0
|
$self->_printVerbose("aggregation Op: $aggregOp (S)\n", 2); |
501
|
0
|
|
|
|
|
0
|
$self->aggregation->{'QTVAR'}->{$aggregOp}->{$variable} = $self->questionTopic; |
502
|
|
|
|
|
|
|
} |
503
|
|
|
|
|
|
|
} |
504
|
|
|
|
|
|
|
} |
505
|
|
|
|
|
|
|
} |
506
|
12
|
100
|
|
|
|
58
|
if ($line->{'OBJECT'}->[1] eq "") { |
507
|
|
|
|
|
|
|
# new variable |
508
|
|
|
|
|
|
|
# warn "$self->questionTopic eq " . $line->{'OBJECT'}->[0] . "?\n"; |
509
|
1
|
50
|
33
|
|
|
39
|
if (($self->questionTopic eq $line->{'OBJECT'}->[0]) || |
|
|
|
33
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
33
|
|
|
|
|
510
|
|
|
|
|
|
|
((exists $self->semanticCorrespondance->{$self->language}->{'SAMEAS'}->{'CORRESP'}->{$line->{'OBJECT'}->[0]}) && |
511
|
|
|
|
|
|
|
($self->semanticCorrespondance->{$self->language}->{'SAMEAS'}->{'CORRESP'}->{$line->{'OBJECT'}->[0]} eq $self->questionTopic)) || |
512
|
|
|
|
|
|
|
((exists $self->semanticCorrespondance->{$self->language}->{'SAMEAS'}->{'CORRESP'}->{$self->questionTopic}) && |
513
|
|
|
|
|
|
|
($self->semanticCorrespondance->{$self->language}->{'SAMEAS'}->{'CORRESP'}->{$self->questionTopic} eq $line->{'OBJECT'}->[0])) |
514
|
|
|
|
|
|
|
) { |
515
|
0
|
0
|
|
|
|
0
|
if (scalar(@{$self->selectPart}) == 0) { |
|
0
|
|
|
|
|
0
|
|
516
|
0
|
|
|
|
|
0
|
$variable=$self->varPrefix . $self->variableCounter; |
517
|
0
|
|
|
|
|
0
|
$self->_IncrVariableCounter; |
518
|
0
|
|
|
|
|
0
|
push @{$self->selectPart}, $variable; |
|
0
|
|
|
|
|
0
|
|
519
|
|
|
|
|
|
|
} else { |
520
|
0
|
|
|
|
|
0
|
$variable=$self->selectPart->[0]; |
521
|
|
|
|
|
|
|
} |
522
|
0
|
|
|
|
|
0
|
$self->_printVerbose("ADD QT2O\n",2); |
523
|
0
|
|
|
|
|
0
|
$self->_addObjectLine($line, $variable); |
524
|
0
|
|
|
|
|
0
|
$self->variableSet->{$variable}++; |
525
|
0
|
|
|
|
|
0
|
foreach $aggregOp (keys %{$self->aggregation->{'TERM'}}) { |
|
0
|
|
|
|
|
0
|
|
526
|
0
|
0
|
|
|
|
0
|
if (exists $self->aggregation->{'QT'}->{$aggregOp}->{$self->questionTopic}) { |
527
|
0
|
|
|
|
|
0
|
$self->_printVerbose("aggregation Op: $aggregOp (O)\n",2); |
528
|
0
|
|
|
|
|
0
|
$self->aggregation->{'QTVAR'}->{$aggregOp}->{$variable} = $self->questionTopic; |
529
|
|
|
|
|
|
|
} |
530
|
|
|
|
|
|
|
} |
531
|
|
|
|
|
|
|
} |
532
|
|
|
|
|
|
|
} |
533
|
|
|
|
|
|
|
} |
534
|
|
|
|
|
|
|
} |
535
|
|
|
|
|
|
|
# warn "done\n"; |
536
|
|
|
|
|
|
|
} |
537
|
|
|
|
|
|
|
|
538
|
|
|
|
|
|
|
sub _addNegation { |
539
|
9
|
|
|
9
|
|
18
|
my ($self) = @_; |
540
|
|
|
|
|
|
|
|
541
|
9
|
|
|
|
|
16
|
my $line; |
542
|
|
|
|
|
|
|
my $lineNb; |
543
|
|
|
|
|
|
|
|
544
|
|
|
|
|
|
|
# warn "in addNegation\n"; |
545
|
9
|
50
|
|
|
|
15
|
if (scalar(keys(%{$self->negation})) > 0) { |
|
9
|
|
|
|
|
54
|
|
546
|
0
|
|
|
|
|
0
|
foreach $lineNb (values %{$self->negation}) { |
|
0
|
|
|
|
|
0
|
|
547
|
0
|
0
|
|
|
|
0
|
if (scalar(@{$self->wherePart}) == 1) { |
|
0
|
|
|
|
|
0
|
|
548
|
0
|
|
|
|
|
0
|
$self->_newWherePartLine; |
549
|
0
|
|
|
|
|
0
|
$line = $self->_addPredicate('last', 'rdf:type'); |
550
|
|
|
|
|
|
|
# TO CHANGE |
551
|
0
|
|
|
|
|
0
|
$self->_addSubjectLine($line, $self->selectPart->[0]); |
552
|
|
|
|
|
|
|
} |
553
|
0
|
|
|
|
|
0
|
$self->_addNegation2Predicate($self->wherePart->[$lineNb]); |
554
|
|
|
|
|
|
|
|
555
|
0
|
0
|
|
|
|
0
|
if ($self->wherePart->[$lineNb]->{'SUBJECT'}->[1] eq $self->selectPart->[0]) { |
|
|
0
|
|
|
|
|
|
556
|
0
|
|
|
|
|
0
|
$self->_printVerbose($self->wherePart->[$lineNb]->{'SUBJECT'}->[0] . "\n",2); |
557
|
0
|
|
|
|
|
0
|
$self->_addObjectLine($line, $self->semanticCorrespondance->{$self->language}->{'DEFAULT_ROOT'} . "/" . |
558
|
|
|
|
|
|
|
$self->semanticCorrespondance->{$self->language}->{'RDFTYPE'}->{$self->wherePart->[$lineNb]->{'SUBJECT'}->[0]}); |
559
|
|
|
|
|
|
|
} elsif ($self->wherePart->[$lineNb]->{'OBJECT'}->[1] eq $self->selectPart->[0]) { |
560
|
0
|
|
|
|
|
0
|
$self->_printVerbose($self->wherePart->[$lineNb]->{'OBJECT'}->[0] . "\n",2); |
561
|
0
|
|
|
|
|
0
|
$self->_addObjectLine($line, $self->semanticCorrespondance->{$self->language}->{'DEFAULT_ROOT'} . "/" . |
562
|
|
|
|
|
|
|
$self->semanticCorrespondance->{$self->language}->{'RDFTYPE'}->{$self->wherePart->[$lineNb]->{'OBJECT'}->[0]}); |
563
|
|
|
|
|
|
|
} |
564
|
|
|
|
|
|
|
} |
565
|
|
|
|
|
|
|
} |
566
|
|
|
|
|
|
|
# warn "done\n"; |
567
|
|
|
|
|
|
|
} |
568
|
|
|
|
|
|
|
|
569
|
|
|
|
|
|
|
|
570
|
|
|
|
|
|
|
sub _UsingSameAs { |
571
|
9
|
|
|
9
|
|
17
|
my ($self) = @_; |
572
|
|
|
|
|
|
|
|
573
|
9
|
|
|
|
|
17
|
my $i; |
574
|
|
|
|
|
|
|
my $line; |
575
|
0
|
|
|
|
|
0
|
my $j; |
576
|
0
|
|
|
|
|
0
|
my $line2; |
577
|
9
|
|
|
|
|
28
|
$self->_printVerbose("[LOG] UsingSameAs?\n"); |
578
|
|
|
|
|
|
|
|
579
|
9
|
|
|
|
|
12
|
my @wherePartAdd; |
580
|
|
|
|
|
|
|
|
581
|
9
|
|
|
|
|
20
|
for($i=0; $i < scalar(@{$self->wherePart}); $i++) { |
|
20
|
|
|
|
|
82
|
|
582
|
11
|
|
|
|
|
33
|
$line = $self->wherePart->[$i]; |
583
|
11
|
100
|
|
|
|
42
|
if ($line->{'SUBJECT'}->[1] eq "") { |
584
|
3
|
|
|
|
|
4
|
for($j=$i+1;$j < scalar(@{$self->wherePart}); $j++) { |
|
4
|
|
|
|
|
13
|
|
585
|
1
|
|
|
|
|
4
|
$line2 = $self->wherePart->[$j]; |
586
|
1
|
50
|
33
|
|
|
15
|
if ((exists $self->semanticCorrespondance->{$self->language}->{'SAMEAS'}->{'CORRESP'}->{$line->{'SUBJECT'}->[0]}) && |
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
587
|
|
|
|
|
|
|
($self->semanticCorrespondance->{$self->language}->{'SAMEAS'}->{'CORRESP'}->{$line->{'SUBJECT'}->[0]} eq $line2->{'SUBJECT'}->[0])) { |
588
|
1
|
|
|
|
|
5
|
$self->_newWherePartLine(\@wherePartAdd); |
589
|
1
|
|
|
|
|
5
|
$self->_addPredicateSameAs(\@wherePartAdd, 'last', $line->{'SUBJECT'}->[0]); |
590
|
1
|
|
|
|
|
3
|
$self->_printVerbose("1a\n",2); |
591
|
|
|
|
|
|
|
} elsif ((exists $self->semanticCorrespondance->{$self->language}->{'SAMEAS'}->{'CORRESP'}->{$line->{'SUBJECT'}->[0]}) && |
592
|
|
|
|
|
|
|
($self->semanticCorrespondance->{$self->language}->{'SAMEAS'}->{'CORRESP'}->{$line->{'SUBJECT'}->[0]} eq $line2->{'OBJECT'}->[0])) { |
593
|
0
|
|
|
|
|
0
|
$self->_newWherePartLine(\@wherePartAdd); |
594
|
0
|
|
|
|
|
0
|
$self->_addPredicateSameAs(\@wherePartAdd, 'last', $line->{'SUBJECT'}->[0]); |
595
|
0
|
|
|
|
|
0
|
$self->_printVerbose("2a\n",2); |
596
|
|
|
|
|
|
|
} elsif ((exists $self->semanticCorrespondance->{$self->language}->{'SAMEAS'}->{'CORRESP'}->{$line2->{'SUBJECT'}->[0]}) && |
597
|
|
|
|
|
|
|
($line->{'SUBJECT'}->[0] eq $self->semanticCorrespondance->{$self->language}->{'SAMEAS'}->{'CORRESP'}->{$line2->{'SUBJECT'}->[0]})) { |
598
|
0
|
|
|
|
|
0
|
$self->_newWherePartLine(\@wherePartAdd); |
599
|
0
|
|
|
|
|
0
|
$self->_addPredicateSameAs(\@wherePartAdd, 'last', $line2->{'SUBJECT'}->[0]); |
600
|
0
|
|
|
|
|
0
|
$self->_printVerbose("3a\n",2); |
601
|
|
|
|
|
|
|
} elsif ((exists $self->semanticCorrespondance->{$self->language}->{'SAMEAS'}->{'CORRESP'}->{$line2->{'OBJECT'}->[0]}) && |
602
|
|
|
|
|
|
|
($line->{'SUBJECT'}->[0] eq $self->semanticCorrespondance->{$self->language}->{'SAMEAS'}->{'CORRESP'}->{$line2->{'OBJECT'}->[0]})) { |
603
|
0
|
|
|
|
|
0
|
$self->_newWherePartLine(\@wherePartAdd); |
604
|
0
|
|
|
|
|
0
|
$self->_addPredicateSameAs(\@wherePartAdd, 'last', $line2->{'OBJECT'}->[0]); |
605
|
0
|
|
|
|
|
0
|
$self->_printVerbose("4a\n",2); |
606
|
|
|
|
|
|
|
} |
607
|
|
|
|
|
|
|
} |
608
|
|
|
|
|
|
|
} |
609
|
11
|
100
|
|
|
|
47
|
if ($line->{'OBJECT'}->[1] eq "") { |
610
|
1
|
|
|
|
|
3
|
for($j=$i+1;$j < scalar(@{$self->wherePart}); $j++) { |
|
1
|
|
|
|
|
5
|
|
611
|
0
|
|
|
|
|
0
|
$line2 = $self->wherePart->[$j]; |
612
|
0
|
0
|
0
|
|
|
0
|
if ((exists $self->semanticCorrespondance->{$self->language}->{'SAMEAS'}->{'CORRESP'}->{$line->{'OBJECT'}->[0]}) && |
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
613
|
|
|
|
|
|
|
($self->semanticCorrespondance->{$self->language}->{'SAMEAS'}->{'CORRESP'}->{$line->{'OBJECT'}->[0]} eq $line2->{'SUBJECT'}->[0])) { |
614
|
0
|
|
|
|
|
0
|
$self->_printVerbose("1b\n",2); |
615
|
0
|
|
|
|
|
0
|
$self->_newWherePartLine(\@wherePartAdd); |
616
|
0
|
|
|
|
|
0
|
$self->_addPredicateSameAs(\@wherePartAdd, 'last', $line->{'OBJECT'}->[0]); |
617
|
|
|
|
|
|
|
} elsif ((exists $self->semanticCorrespondance->{$self->language}->{'SAMEAS'}->{'CORRESP'}->{$line->{'OBJECT'}->[0]}) && |
618
|
|
|
|
|
|
|
($self->semanticCorrespondance->{$self->language}->{'SAMEAS'}->{'CORRESP'}->{$line->{'OBJECT'}->[0]} eq $line2->{'OBJECT'}->[0])) { |
619
|
0
|
|
|
|
|
0
|
$self->_printVerbose("2b\n",2); |
620
|
0
|
|
|
|
|
0
|
$self->_newWherePartLine(\@wherePartAdd); |
621
|
0
|
|
|
|
|
0
|
$self->_addPredicateSameAs(\@wherePartAdd, 'last', $line->{'OBJECT'}->[0]); |
622
|
|
|
|
|
|
|
} elsif ((exists $self->semanticCorrespondance->{$self->language}->{'SAMEAS'}->{'CORRESP'}->{$line2->{'OBJECT'}->[0]}) && |
623
|
|
|
|
|
|
|
($line->{'OBJECT'}->[0] eq $self->semanticCorrespondance->{$self->language}->{'SAMEAS'}->{'CORRESP'}->{$line2->{'OBJECT'}->[0]})) { |
624
|
0
|
|
|
|
|
0
|
$self->_printVerbose("3b\n",2); |
625
|
0
|
|
|
|
|
0
|
$self->_newWherePartLine(\@wherePartAdd); |
626
|
0
|
|
|
|
|
0
|
$self->_addPredicateSameAs(\@wherePartAdd, 'last', $line2->{'OBJECT'}->[0]); |
627
|
|
|
|
|
|
|
} elsif ((exists $self->semanticCorrespondance->{$self->language}->{'SAMEAS'}->{'CORRESP'}->{$line2->{'SUBJECT'}->[0]}) && |
628
|
|
|
|
|
|
|
($line->{'OBJECT'}->[0] eq $self->semanticCorrespondance->{$self->language}->{'SAMEAS'}->{'CORRESP'}->{$line2->{'SUBJECT'}->[0]})) { |
629
|
0
|
|
|
|
|
0
|
$self->_printVerbose("4b\n",2); |
630
|
0
|
|
|
|
|
0
|
$self->_newWherePartLine(\@wherePartAdd); |
631
|
0
|
|
|
|
|
0
|
$self->_addPredicateSameAs(\@wherePartAdd, 'last', $line2->{'SUBJECT'}->[0]); |
632
|
|
|
|
|
|
|
} |
633
|
|
|
|
|
|
|
} |
634
|
|
|
|
|
|
|
} |
635
|
|
|
|
|
|
|
} |
636
|
9
|
|
|
|
|
16
|
push @{$self->wherePart}, @wherePartAdd; |
|
9
|
|
|
|
|
29
|
|
637
|
9
|
|
|
|
|
27
|
$self->_printVerbose("done\n"); |
638
|
|
|
|
|
|
|
|
639
|
|
|
|
|
|
|
} |
640
|
|
|
|
|
|
|
|
641
|
|
|
|
|
|
|
sub _unifiedVariables { |
642
|
18
|
|
|
18
|
|
29
|
my ($self) = @_; |
643
|
|
|
|
|
|
|
|
644
|
|
|
|
|
|
|
# Unified internal subject/object |
645
|
18
|
|
|
|
|
28
|
my $variable; |
646
|
|
|
|
|
|
|
my $i; |
647
|
0
|
|
|
|
|
0
|
my $line; |
648
|
0
|
|
|
|
|
0
|
my $j; |
649
|
0
|
|
|
|
|
0
|
my $line2; |
650
|
18
|
|
|
|
|
34
|
for($i=0; $i < scalar(@{$self->wherePart}); $i++) { |
|
41
|
|
|
|
|
162
|
|
651
|
23
|
|
|
|
|
59
|
$line = $self->wherePart->[$i]; |
652
|
23
|
100
|
|
|
|
72
|
if ($line->{'SUBJECT'}->[1] eq "") { |
653
|
6
|
|
|
|
|
8
|
for($j=$i+1;$j < scalar(@{$self->wherePart}); $j++) { |
|
10
|
|
|
|
|
34
|
|
654
|
4
|
|
|
|
|
8
|
$line2 = $self->wherePart->[$j]; |
655
|
4
|
100
|
100
|
|
|
37
|
if (($line2->{'SUBJECT'}->[1] eq "") && ($line->{'SUBJECT'}->[0] eq $line2->{'SUBJECT'}->[0])) { |
|
|
100
|
66
|
|
|
|
|
656
|
1
|
|
|
|
|
5
|
$variable=$self->varPrefix . $self->variableCounter; |
657
|
|
|
|
|
|
|
# warn "\t==> $variable (Subj/Subj)\n"; |
658
|
1
|
|
|
|
|
4
|
$self->_IncrVariableCounter; |
659
|
1
|
|
|
|
|
3
|
$self->_addSubjectLine($line, $variable); |
660
|
1
|
|
|
|
|
4
|
$self->_addSubjectLine($line2, $variable); |
661
|
|
|
|
|
|
|
} elsif (($line2->{'OBJECT'}->[1] eq "") && ($line->{'SUBJECT'}->[0] eq $line2->{'OBJECT'}->[0])) { |
662
|
1
|
|
|
|
|
4
|
$variable=$self->varPrefix . $self->variableCounter; |
663
|
|
|
|
|
|
|
# warn "\t==> $variable (Obj/Subj)\n"; |
664
|
1
|
|
|
|
|
3
|
$self->_IncrVariableCounter; |
665
|
1
|
|
|
|
|
3
|
$self->_addSubjectLine($line, $variable); |
666
|
1
|
|
|
|
|
3
|
$self->_addObjectLine($line2, $variable); |
667
|
|
|
|
|
|
|
} |
668
|
|
|
|
|
|
|
} |
669
|
|
|
|
|
|
|
} |
670
|
23
|
100
|
|
|
|
77
|
if ($line->{'OBJECT'}->[1] eq "") { |
671
|
2
|
|
|
|
|
3
|
for($j=$i+1;$j < scalar(@{$self->wherePart}); $j++) { |
|
2
|
|
|
|
|
9
|
|
672
|
0
|
|
|
|
|
0
|
$line2 = $self->wherePart->[$j]; |
673
|
0
|
0
|
0
|
|
|
0
|
if (($line2->{'SUBJECT'}->[1] eq "") && ($line->{'OBJECT'}->[0] eq $line2->{'SUBJECT'}->[0])) { |
|
|
0
|
0
|
|
|
|
|
674
|
0
|
|
|
|
|
0
|
$variable=$self->varPrefix . $self->variableCounter; |
675
|
|
|
|
|
|
|
# warn "\t==> $variable (Subj/Subj)\n"; |
676
|
0
|
|
|
|
|
0
|
$self->_IncrVariableCounter; |
677
|
0
|
|
|
|
|
0
|
$self->_addObjectLine($line, $variable); |
678
|
0
|
|
|
|
|
0
|
$self->_addSubjectLine($line2, $variable); |
679
|
|
|
|
|
|
|
} elsif (($line2->{'OBJECT'}->[1] eq "") && ($line->{'OBJECT'}->[0] eq $line2->{'OBJECT'}->[0])) { |
680
|
0
|
|
|
|
|
0
|
$variable=$self->varPrefix . $self->variableCounter; |
681
|
|
|
|
|
|
|
# warn "\t==> $variable (Obj/Subj)\n"; |
682
|
0
|
|
|
|
|
0
|
$self->_IncrVariableCounter; |
683
|
0
|
|
|
|
|
0
|
$self->_addObjectLine($line, $variable); |
684
|
0
|
|
|
|
|
0
|
$self->_addObjectLine($line2, $variable); |
685
|
|
|
|
|
|
|
} |
686
|
|
|
|
|
|
|
} |
687
|
|
|
|
|
|
|
} |
688
|
|
|
|
|
|
|
} |
689
|
|
|
|
|
|
|
} |
690
|
|
|
|
|
|
|
|
691
|
|
|
|
|
|
|
|
692
|
|
|
|
|
|
|
sub _connectRemainingElements { |
693
|
9
|
|
|
9
|
|
19
|
my ($self) = @_; |
694
|
|
|
|
|
|
|
|
695
|
|
|
|
|
|
|
# Unified internal subject/object |
696
|
9
|
|
|
|
|
18
|
my $variable; |
697
|
|
|
|
|
|
|
my $i; |
698
|
0
|
|
|
|
|
0
|
my $line; |
699
|
0
|
|
|
|
|
0
|
my $term; |
700
|
0
|
|
|
|
|
0
|
my $indexCat; |
701
|
0
|
|
|
|
|
0
|
my $str; |
702
|
|
|
|
|
|
|
|
703
|
9
|
|
|
|
|
20
|
for($i=0; $i < scalar(@{$self->wherePart}); $i++) { |
|
21
|
|
|
|
|
88
|
|
704
|
12
|
|
|
|
|
81
|
$line = $self->wherePart->[$i]; |
705
|
12
|
50
|
|
|
|
46
|
if ($line->{'SUBJECT'}->[1] eq "") { |
706
|
0
|
|
|
|
|
0
|
$variable=$self->varPrefix .$self->variableCounter; |
707
|
|
|
|
|
|
|
# warn "\t==> $variable (Subj/Subj)\n"; |
708
|
0
|
|
|
|
|
0
|
$self->_IncrVariableCounter; |
709
|
0
|
|
|
|
|
0
|
$self->_addSubjectLine($line, $variable); |
710
|
|
|
|
|
|
|
} |
711
|
12
|
50
|
|
|
|
47
|
if ($line->{'OBJECT'}->[1] eq "") { |
712
|
0
|
|
|
|
|
0
|
$variable=$self->varPrefix .$self->variableCounter; |
713
|
|
|
|
|
|
|
# warn "\t==> $variable (Subj/Subj)\n"; |
714
|
0
|
|
|
|
|
0
|
$self->_IncrVariableCounter; |
715
|
0
|
|
|
|
|
0
|
$self->_addObjectLine($line, $variable); |
716
|
|
|
|
|
|
|
} |
717
|
|
|
|
|
|
|
} |
718
|
|
|
|
|
|
|
|
719
|
|
|
|
|
|
|
} |
720
|
|
|
|
|
|
|
|
721
|
|
|
|
|
|
|
sub _connectRemainingElementsWithString { |
722
|
9
|
|
|
9
|
|
16
|
my ($self) = @_; |
723
|
|
|
|
|
|
|
|
724
|
|
|
|
|
|
|
# Unified internal subject/object |
725
|
9
|
|
|
|
|
16
|
my $variable; |
726
|
|
|
|
|
|
|
my $i; |
727
|
0
|
|
|
|
|
0
|
my $line; |
728
|
0
|
|
|
|
|
0
|
my $term; |
729
|
0
|
|
|
|
|
0
|
my $term2; |
730
|
0
|
|
|
|
|
0
|
my $indexCat; |
731
|
0
|
|
|
|
|
0
|
my $str; |
732
|
9
|
|
|
|
|
18
|
my $found = 0; |
733
|
9
|
|
|
|
|
14
|
my $j; |
734
|
|
|
|
|
|
|
|
735
|
9
|
|
|
|
|
15
|
for($i=scalar(@{$self->wherePart}) - 1; $i >= 0; $i--) { |
|
9
|
|
|
|
|
56
|
|
736
|
12
|
|
|
|
|
41
|
$line = $self->wherePart->[$i]; |
737
|
12
|
50
|
33
|
|
|
58
|
if (($line->{'SUBJECT'}->[1] eq "") && ($line->{'SUBJECT'}->[0] eq "STRING")) { |
738
|
|
|
|
|
|
|
# warn $line->{'PREDICATE'}->[0] . " (S)\n"; |
739
|
|
|
|
|
|
|
|
740
|
0
|
|
|
|
|
0
|
$found = 0; |
741
|
0
|
|
|
|
|
0
|
for($j=scalar(@{$self->_sortedSemanticUnits})-1;$j>=0;$j--) { |
|
0
|
|
|
|
|
0
|
|
742
|
0
|
|
|
|
|
0
|
$term = $self->_sortedSemanticUnits->[$j]; |
743
|
0
|
|
|
|
|
0
|
foreach $indexCat (keys %{$self->semFeaturesIndex}) { |
|
0
|
|
|
|
|
0
|
|
744
|
|
|
|
|
|
|
# warn "indexCat: $indexCat\n"; |
745
|
0
|
0
|
0
|
|
|
0
|
if ((exists $self->semFeaturesIndex->{$indexCat}->{'TERM'}->{$term->{'id'}}) && |
|
|
|
0
|
|
|
|
|
746
|
|
|
|
|
|
|
(($self->semFeaturesIndex->{$indexCat}->{'SEEN_S'} == -1) && ($self->semFeaturesIndex->{$indexCat}->{'SEEN_O'} == -1))) { |
747
|
0
|
|
|
|
|
0
|
$self->_printVerbose("=-> " . $term->{'semanticUnit'} . " ($indexCat)\n",2); |
748
|
0
|
0
|
|
|
|
0
|
if ($self->_regexForm == 1) { |
749
|
0
|
|
|
|
|
0
|
$str = "REGEX/:LABELREGEX:" . $term->{'semanticUnit'} ; |
750
|
|
|
|
|
|
|
} else { |
751
|
0
|
|
|
|
|
0
|
$str = "REGEX/:LABELREGEX:" . $term->{'canonical_form'} ; |
752
|
|
|
|
|
|
|
} |
753
|
0
|
|
|
|
|
0
|
$self->_addSubjectLine($line, $str); |
754
|
0
|
0
|
|
|
|
0
|
if ($self->conjunction == 1) { |
755
|
0
|
|
|
|
|
0
|
my $line2 = $self->_cloneLine($i, $line); |
756
|
0
|
|
|
|
|
0
|
foreach $term2 (values %{$self->semFeaturesIndex->{$indexCat}->{'TERM'}}) { |
|
0
|
|
|
|
|
0
|
|
757
|
0
|
0
|
|
|
|
0
|
if ($term2->{'id'} ne $term->{'id'}) { |
758
|
0
|
|
|
|
|
0
|
$self->_printVerbose("=-> " . $term2->{'semanticUnit'} . " ($indexCat - 2 - conj)\n",2); |
759
|
0
|
0
|
|
|
|
0
|
if ($self->_regexForm == 1) { |
760
|
0
|
|
|
|
|
0
|
$str = "REGEX/:LABELREGEX:" . $term2->{'semanticUnit'} ; |
761
|
|
|
|
|
|
|
} else { |
762
|
0
|
|
|
|
|
0
|
$str = "REGEX/:LABELREGEX:" . $term2->{'canonical_form'} ; |
763
|
|
|
|
|
|
|
} |
764
|
0
|
|
|
|
|
0
|
$self->_addSubjectLine($line2, $str); |
765
|
|
|
|
|
|
|
} |
766
|
|
|
|
|
|
|
} |
767
|
|
|
|
|
|
|
} |
768
|
0
|
|
|
|
|
0
|
$found = 1; |
769
|
0
|
|
|
|
|
0
|
last; |
770
|
|
|
|
|
|
|
} |
771
|
|
|
|
|
|
|
} |
772
|
0
|
|
|
|
|
0
|
$self->_printVerbose("==\n",2); |
773
|
0
|
0
|
|
|
|
0
|
if ($found == 1) { |
774
|
0
|
|
|
|
|
0
|
last; |
775
|
|
|
|
|
|
|
} |
776
|
|
|
|
|
|
|
} |
777
|
|
|
|
|
|
|
} |
778
|
12
|
100
|
66
|
|
|
100
|
if (($line->{'OBJECT'}->[1] eq "") && ($line->{'OBJECT'}->[0] eq "STRING")) { |
779
|
1
|
|
|
|
|
6
|
$self->_printVerbose($line->{'PREDICATE'}->[0] . " (O)\n",2); |
780
|
|
|
|
|
|
|
|
781
|
1
|
|
|
|
|
2
|
$found = 0; |
782
|
1
|
|
|
|
|
2
|
for($j=scalar(@{$self->_sortedSemanticUnits})-1;$j>=0;$j--) { |
|
1
|
|
|
|
|
4
|
|
783
|
1
|
|
|
|
|
3
|
$term = $self->_sortedSemanticUnits->[$j]; |
784
|
1
|
|
|
|
|
2
|
foreach $indexCat (keys %{$self->semFeaturesIndex}) { |
|
1
|
|
|
|
|
5
|
|
785
|
1
|
|
|
|
|
5
|
$self->_printVerbose("indexCat: $indexCat\n",2); |
786
|
1
|
50
|
33
|
|
|
16
|
if ((exists $self->semFeaturesIndex->{$indexCat}->{'TERM'}->{$term->{'id'}}) && |
|
|
|
33
|
|
|
|
|
787
|
|
|
|
|
|
|
(($self->semFeaturesIndex->{$indexCat}->{'SEEN_S'} == -1) && ($self->semFeaturesIndex->{$indexCat}->{'SEEN_O'} == -1))) { |
788
|
1
|
|
|
|
|
5
|
$self->_printVerbose("=-> " . $term->{'semanticUnit'} . " ($indexCat)\n",2); |
789
|
1
|
50
|
|
|
|
4
|
if ($self->_regexForm == 1) { |
790
|
1
|
|
|
|
|
2
|
$str = "REGEX/:LABELREGEX:" . $term->{'semanticUnit'} ; |
791
|
|
|
|
|
|
|
} else { |
792
|
0
|
|
|
|
|
0
|
$str = "REGEX/:LABELREGEX:" . $term->{'canonical_form'} ; |
793
|
|
|
|
|
|
|
} |
794
|
1
|
|
|
|
|
5
|
$self->_addObjectLine($line, $str); |
795
|
1
|
50
|
|
|
|
6
|
if ($self->conjunction == 1) { |
796
|
0
|
|
|
|
|
0
|
my $line2 = $self->_cloneLine($i, $line); |
797
|
0
|
|
|
|
|
0
|
foreach $term2 (values %{$self->semFeaturesIndex->{$indexCat}->{'TERM'}}) { |
|
0
|
|
|
|
|
0
|
|
798
|
0
|
0
|
|
|
|
0
|
if ($term2->{'id'} ne $term->{'id'}) { |
799
|
0
|
|
|
|
|
0
|
$self->_printVerbose("=-> " . $term2->{'semanticUnit'} . " ($indexCat - 2 - conj)\n",2); |
800
|
0
|
0
|
|
|
|
0
|
if ($self->_regexForm == 1) { |
801
|
0
|
|
|
|
|
0
|
$str = "REGEX/:LABELREGEX:" . $term2->{'semanticUnit'} ; |
802
|
|
|
|
|
|
|
} else { |
803
|
0
|
|
|
|
|
0
|
$str = "REGEX/:LABELREGEX:" . $term2->{'canonical_form'} ; |
804
|
|
|
|
|
|
|
} |
805
|
0
|
|
|
|
|
0
|
$self->_addObjectLine($line2, $str); |
806
|
|
|
|
|
|
|
} |
807
|
|
|
|
|
|
|
} |
808
|
|
|
|
|
|
|
} |
809
|
1
|
|
|
|
|
1
|
$found = 1; |
810
|
1
|
|
|
|
|
2
|
last; |
811
|
|
|
|
|
|
|
} |
812
|
|
|
|
|
|
|
} |
813
|
1
|
|
|
|
|
4
|
$self->_printVerbose("==\n",2); |
814
|
1
|
50
|
|
|
|
3
|
if ($found == 1) { |
815
|
1
|
|
|
|
|
3
|
last; |
816
|
|
|
|
|
|
|
} |
817
|
|
|
|
|
|
|
} |
818
|
|
|
|
|
|
|
} |
819
|
|
|
|
|
|
|
} |
820
|
|
|
|
|
|
|
|
821
|
|
|
|
|
|
|
} |
822
|
|
|
|
|
|
|
|
823
|
|
|
|
|
|
|
sub _getProperty { |
824
|
9
|
|
|
9
|
|
18
|
my ($self) = @_; |
825
|
|
|
|
|
|
|
|
826
|
|
|
|
|
|
|
# $conjunction2 = 0; |
827
|
|
|
|
|
|
|
|
828
|
9
|
|
|
|
|
17
|
my $replacedPredicate; |
829
|
|
|
|
|
|
|
my $i; |
830
|
0
|
|
|
|
|
0
|
my $line; |
831
|
0
|
|
|
|
|
0
|
my $semCat; |
832
|
9
|
|
|
|
|
15
|
my $wherePartSize = scalar(@{$self->wherePart})-1; |
|
9
|
|
|
|
|
35
|
|
833
|
|
|
|
|
|
|
|
834
|
9
|
|
|
|
|
23
|
my $tmpSuffix=""; |
835
|
9
|
|
|
|
|
40
|
for($i=$wherePartSize;$i >= 0; $i--) { |
836
|
11
|
|
|
|
|
56
|
$self->_printVerbose("# " . $wherePartSize . "\n",2); |
837
|
11
|
|
|
|
|
33
|
$line = $self->wherePart->[$i]; |
838
|
11
|
|
|
|
|
21
|
$replacedPredicate=0; |
839
|
11
|
|
|
|
|
64
|
$self->_printVerbose(">> " . $line->{'PREDICATE'}->[0] . " ($i)\n",2); |
840
|
11
|
100
|
66
|
|
|
143
|
if (($self->semanticCorrespondance->{$self->language}->{'PREDICATE'}->{$line->{'PREDICATE'}->[0]}->{'OBJECT_TYPE'} ne "") |
841
|
|
|
|
|
|
|
&& ($line->{'OBJECT'}->[1] eq "") |
842
|
|
|
|
|
|
|
) { |
843
|
9
|
|
|
|
|
65
|
my $tmp = $self->semanticCorrespondance->{$self->language}->{'PREDICATE'}->{$line->{'PREDICATE'}->[0]}->{'OBJECT_TYPE'}; |
844
|
9
|
|
|
|
|
39
|
$self->_printVerbose("==> $tmp\n",2); |
845
|
|
|
|
|
|
|
# if (exists $self->semanticCorrespondance->{$self->language}->{'RESOURCE'}->{$tmp}) { |
846
|
9
|
100
|
66
|
|
|
105
|
if ((exists $self->semFeaturesIndex->{$tmp}) && ($self->semFeaturesIndex->{$tmp}->{'SEEN_O'} == -1)){ |
847
|
|
|
|
|
|
|
# if (exists $self->semFeaturesIndex->{$tmp}) { |
848
|
|
|
|
|
|
|
# warn "OK\n"; |
849
|
|
|
|
|
|
|
# warn "ROOT: " . $self->semanticCorrespondance->{$self->language}->{'RESOURCE'}->{$self->semFeaturesIndex->{$tmp}->{'ROOT'}}->{'ROOT'} . "\n"; |
850
|
8
|
|
|
|
|
15
|
my $str; |
851
|
|
|
|
|
|
|
my @t; |
852
|
8
|
100
|
|
|
|
87
|
if (exists $self->semanticCorrespondance->{$self->language}->{'RESOURCE'}->{$self->semFeaturesIndex->{$tmp}->{'ROOT'}}->{'ROOT'}) { |
853
|
6
|
|
|
|
|
96
|
$str = $self->semanticCorrespondance->{$self->language}->{'RESOURCE'}->{$self->semFeaturesIndex->{$tmp}->{'ROOT'}}->{'ROOT'}; |
854
|
6
|
|
|
|
|
66
|
$str .= "/"; |
855
|
|
|
|
|
|
|
|
856
|
6
|
|
|
|
|
13
|
@t = @{$self->semFeaturesIndex->{$tmp}->{'CAT'}->[0]}; |
|
6
|
|
|
|
|
40
|
|
857
|
6
|
|
|
|
|
64
|
$str .= $self->semanticCorrespondance->{$self->language}->{'RESOURCE'}->{$self->semFeaturesIndex->{$tmp}->{'ROOT'}}->{'CORRESP'}->{$t[$#t-1]}; |
858
|
6
|
|
|
|
|
21
|
$str .= "/" . $t[$#t]; |
859
|
|
|
|
|
|
|
} else { |
860
|
2
|
|
|
|
|
9
|
$str=$self->semFeaturesIndex->{$tmp}->{'ROOT'} . '/' . join('/', @{$self->semFeaturesIndex->{$tmp}->{'CAT'}->[0]}); |
|
2
|
|
|
|
|
9
|
|
861
|
2
|
|
|
|
|
3
|
@t = @{$self->semFeaturesIndex->{$tmp}->{'CAT'}->[0]}; |
|
2
|
|
|
|
|
8
|
|
862
|
|
|
|
|
|
|
} |
863
|
8
|
|
|
|
|
86
|
$self->_printVerbose(">>>>$str (S - " . $self->conjunction . ")\n",2); |
864
|
8
|
|
|
|
|
38
|
$self->_addObjectLine($line, $str); |
865
|
8
|
|
|
|
|
29
|
$self->semFeaturesIndex->{$tmp}->{'SEEN_O'}++; |
866
|
8
|
|
|
|
|
15
|
$replacedPredicate=1; |
867
|
|
|
|
|
|
|
# delete $self->semFeaturesIndex->{$tmp}; |
868
|
8
|
50
|
|
|
|
57
|
if ($self->conjunction == 1) { |
869
|
0
|
|
|
|
|
0
|
$self->_printVerbose(">>>>$str (S - conj)\n",2); |
870
|
0
|
|
|
|
|
0
|
$self->_printVerbose(" " . join(':',keys(%{$self->semFeaturesIndex->{$tmp}->{'CAT2'}})) . "\n",2); |
|
0
|
|
|
|
|
0
|
|
871
|
0
|
|
|
|
|
0
|
$self->_printVerbose(" " . join(':',@t) . "\n",2); |
872
|
0
|
0
|
0
|
|
|
0
|
if (($t[0] eq "drug") && ($self->_unionOpt == 1)) { |
873
|
0
|
|
|
|
|
0
|
$self->_printVerbose("UNION ($i)\n",2); |
874
|
0
|
|
|
|
|
0
|
push @{$self->union}, $i; |
|
0
|
|
|
|
|
0
|
|
875
|
|
|
|
|
|
|
} |
876
|
0
|
|
|
|
|
0
|
foreach $semCat (keys(%{$self->semFeaturesIndex->{$tmp}->{'CAT2'}})) { |
|
0
|
|
|
|
|
0
|
|
877
|
0
|
|
|
|
|
0
|
$self->_printVerbose("$semCat\n",2); |
878
|
|
|
|
|
|
|
# warn "ROOT: ". $self->semFeaturesIndex->{$tmp}->{'ROOT'} . "\n"; |
879
|
0
|
0
|
|
|
|
0
|
if ($semCat ne join('/', @t)) { |
880
|
0
|
|
|
|
|
0
|
$self->_printVerbose("==> Duplicate last (S - $i)\n",2); |
881
|
0
|
|
|
|
|
0
|
my $line2 = $self->_cloneLine($i, $line); |
882
|
0
|
|
|
|
|
0
|
my @t2 = @{$self->semFeaturesIndex->{$tmp}->{'CAT2'}->{$semCat}}; |
|
0
|
|
|
|
|
0
|
|
883
|
0
|
|
|
|
|
0
|
$self->_printVerbose(join('/', @t2) . " - $tmp\n",2); |
884
|
0
|
|
|
|
|
0
|
my $str = $self->semanticCorrespondance->{$self->language}->{'RESOURCE'}->{$self->semFeaturesIndex->{$tmp}->{'ROOT'}}->{'ROOT'}; |
885
|
0
|
|
|
|
|
0
|
$str .= "/"; |
886
|
0
|
|
|
|
|
0
|
$str .= $self->semanticCorrespondance->{$self->language}->{'RESOURCE'}->{$self->semFeaturesIndex->{$tmp}->{'ROOT'}}->{'CORRESP'}->{$t2[$#t2-1]}; |
887
|
0
|
|
|
|
|
0
|
$str .= "/" . $t2[$#t2]; |
888
|
0
|
|
|
|
|
0
|
$self->_addObjectLine($line2, $str); |
889
|
0
|
|
|
|
|
0
|
$self->_printVerbose("done - $str\n",2); |
890
|
|
|
|
|
|
|
} |
891
|
|
|
|
|
|
|
} |
892
|
|
|
|
|
|
|
} |
893
|
|
|
|
|
|
|
} |
894
|
|
|
|
|
|
|
} |
895
|
11
|
100
|
66
|
|
|
176
|
if (($self->semanticCorrespondance->{$self->language}->{'PREDICATE'}->{$line->{'PREDICATE'}->[0]}->{'SUBJECT_TYPE'} ne "") |
896
|
|
|
|
|
|
|
&& ($line->{'SUBJECT'}->[1] eq "") |
897
|
|
|
|
|
|
|
) { |
898
|
4
|
|
|
|
|
21
|
my $tmp = $self->semanticCorrespondance->{$self->language}->{'PREDICATE'}->{$line->{'PREDICATE'}->[0]}->{'SUBJECT_TYPE'}; |
899
|
4
|
50
|
66
|
|
|
40
|
if ((exists $self->semFeaturesIndex->{$tmp}) && ($self->semFeaturesIndex->{$tmp}->{'SEEN_S'} == -1) && ($replacedPredicate==0)){ |
|
|
|
66
|
|
|
|
|
900
|
1
|
|
|
|
|
8
|
my $str = $self->semanticCorrespondance->{$self->language}->{'RESOURCE'}->{$self->semFeaturesIndex->{$tmp}->{'ROOT'}}->{'ROOT'}; |
901
|
1
|
|
|
|
|
3
|
$str .= "/"; |
902
|
|
|
|
|
|
|
|
903
|
1
|
|
|
|
|
1
|
my @t = @{$self->semFeaturesIndex->{$tmp}->{'CAT'}->[0]}; |
|
1
|
|
|
|
|
6
|
|
904
|
1
|
|
|
|
|
10
|
$str .= $self->semanticCorrespondance->{$self->language}->{'RESOURCE'}->{$self->semFeaturesIndex->{$tmp}->{'ROOT'}}->{'CORRESP'}->{$t[$#t-1]}; |
905
|
1
|
|
|
|
|
3
|
$str .= "/" . $t[$#t]; |
906
|
1
|
|
|
|
|
10
|
$self->_printVerbose(">>>>$str (O - " . $self->conjunction . ")\n",2); |
907
|
1
|
|
|
|
|
5
|
$self->_addSubjectLine($line, $str); |
908
|
1
|
|
|
|
|
4
|
$self->semFeaturesIndex->{$tmp}->{'SEEN_S'}++; |
909
|
|
|
|
|
|
|
# delete $self->semFeaturesIndex{$tmp}; |
910
|
1
|
50
|
|
|
|
10
|
if ($self->conjunction == 1) { |
911
|
0
|
|
|
|
|
0
|
$self->_printVerbose(">>>>$str (O - conj)\n",2); |
912
|
0
|
|
|
|
|
0
|
$self->_printVerbose(" " . join(':',keys(%{$self->semFeaturesIndex->{$tmp}->{'CAT2'}})) . "\n",2); |
|
0
|
|
|
|
|
0
|
|
913
|
0
|
|
|
|
|
0
|
$self->_printVerbose(" " . join(':',@t) . "\n",2); |
914
|
0
|
0
|
0
|
|
|
0
|
if (($t[0] eq "drug") && ($self->_unionOpt == 1)) { |
915
|
0
|
|
|
|
|
0
|
$self->_printVerbose("UNION ($i)\n",2); |
916
|
0
|
|
|
|
|
0
|
push @{$self->union}, $i; |
|
0
|
|
|
|
|
0
|
|
917
|
|
|
|
|
|
|
} |
918
|
0
|
|
|
|
|
0
|
foreach $semCat (keys(%{$self->semFeaturesIndex->{$tmp}->{'CAT2'}})) { |
|
0
|
|
|
|
|
0
|
|
919
|
0
|
|
|
|
|
0
|
$self->_printVerbose("$semCat\n",2); |
920
|
|
|
|
|
|
|
# warn "ROOT: ". $self->semFeaturesIndex->{$tmp}->{'ROOT'} . "\n"; |
921
|
0
|
0
|
|
|
|
0
|
if ($semCat ne join('/', @t)) { |
922
|
0
|
|
|
|
|
0
|
$self->_printVerbose("==> Duplicate last (O - $i)\n",2); |
923
|
0
|
|
|
|
|
0
|
my $line2 = $self->_cloneLine($i, $line); |
924
|
0
|
|
|
|
|
0
|
my @t2 = @{$self->semFeaturesIndex->{$tmp}->{'CAT2'}->{$semCat}}; |
|
0
|
|
|
|
|
0
|
|
925
|
0
|
|
|
|
|
0
|
$self->_printVerbose(join('/', @t2) . " - $tmp\n",2); |
926
|
0
|
|
|
|
|
0
|
my $str = $self->semanticCorrespondance->{$self->language}->{'RESOURCE'}->{$self->semFeaturesIndex->{$tmp}->{'ROOT'}}->{'ROOT'}; |
927
|
0
|
|
|
|
|
0
|
$str .= "/"; |
928
|
0
|
|
|
|
|
0
|
$str .= $self->semanticCorrespondance->{$self->language}->{'RESOURCE'}->{$self->semFeaturesIndex->{$tmp}->{'ROOT'}}->{'CORRESP'}->{$t2[$#t2-1]}; |
929
|
0
|
|
|
|
|
0
|
$str .= "/" . $t2[$#t2]; |
930
|
0
|
|
|
|
|
0
|
$self->_addSubjectLine($line2, $str); |
931
|
0
|
|
|
|
|
0
|
$self->_printVerbose("done - $str\n",2); |
932
|
|
|
|
|
|
|
} |
933
|
|
|
|
|
|
|
} |
934
|
|
|
|
|
|
|
} |
935
|
|
|
|
|
|
|
} |
936
|
|
|
|
|
|
|
} |
937
|
|
|
|
|
|
|
} |
938
|
|
|
|
|
|
|
} |
939
|
|
|
|
|
|
|
|
940
|
|
|
|
|
|
|
|
941
|
|
|
|
|
|
|
# DOC |
942
|
|
|
|
|
|
|
sub queryGeneration { |
943
|
9
|
|
|
9
|
1
|
18
|
my $self = shift; |
944
|
|
|
|
|
|
|
# my $format = shift; |
945
|
|
|
|
|
|
|
|
946
|
9
|
|
|
|
|
15
|
my $sentence; |
947
|
|
|
|
|
|
|
my $docId; |
948
|
0
|
|
|
|
|
0
|
my $docHeadId; |
949
|
|
|
|
|
|
|
|
950
|
9
|
|
|
|
|
201
|
$self->docId =~ /\-([\d\w]+)$/; |
951
|
9
|
|
|
|
|
37
|
$docId = $1; |
952
|
9
|
|
|
|
|
23
|
$docHeadId = $`; |
953
|
|
|
|
|
|
|
|
954
|
|
|
|
|
|
|
# if ($format eq "XML") { |
955
|
|
|
|
|
|
|
# print $fh '' . "\n"; |
956
|
|
|
|
|
|
|
# print $fh '' . "\n"; |
957
|
9
|
|
|
|
|
62
|
$self->_addQueryXMLString('' . "\n"); |
958
|
|
|
|
|
|
|
# } |
959
|
|
|
|
|
|
|
# if ($format eq "SPARQL") { |
960
|
9
|
|
|
|
|
41
|
$self->_printSPARQLComment(""); |
961
|
9
|
|
|
|
|
38
|
$self->_printSPARQLComment($self->docId); |
962
|
|
|
|
|
|
|
# } |
963
|
9
|
|
|
|
|
18
|
foreach $sentence (@{$self->sentences}) { |
|
9
|
|
|
|
|
53
|
|
964
|
|
|
|
|
|
|
# if ($format eq "XML") { |
965
|
9
|
|
|
|
|
77
|
$self->_addQueryXMLString('' . "\n"); |
966
|
9
|
|
|
|
|
36
|
$self->_addQueryXMLString('
|
967
|
|
|
|
|
|
|
# } |
968
|
|
|
|
|
|
|
# if ($format eq "SPARQL") { |
969
|
9
|
|
|
|
|
27
|
$self->_printSPARQLComment($sentence); |
970
|
|
|
|
|
|
|
# } |
971
|
9
|
|
|
|
|
28
|
$self->_printVerbose("\n************************************************************\n"); |
972
|
9
|
|
|
|
|
34
|
$self->_printVerbose($sentence . "\n"); |
973
|
|
|
|
|
|
|
} |
974
|
|
|
|
|
|
|
|
975
|
|
|
|
|
|
|
######################################################################## |
976
|
|
|
|
|
|
|
|
977
|
9
|
|
|
|
|
36
|
$self->_printSPARQLQueryWithPREFIX; |
978
|
9
|
|
|
|
|
36
|
$self->_addQueryXMLString($self->queryString); |
979
|
|
|
|
|
|
|
######################################################################## |
980
|
|
|
|
|
|
|
# if ($format eq "XML") { |
981
|
9
|
|
|
|
|
30
|
$self->_addQueryXMLString(']]>' . "\n"); |
982
|
9
|
|
|
|
|
30
|
$self->_addQueryXMLString('' . "\n\n"); |
983
|
|
|
|
|
|
|
# warn $self->queryXMLString; |
984
|
|
|
|
|
|
|
# } |
985
|
|
|
|
|
|
|
# if ($format eq "XML") { |
986
|
|
|
|
|
|
|
# $outStr .= '' . "\n"; |
987
|
|
|
|
|
|
|
# } |
988
|
|
|
|
|
|
|
|
989
|
|
|
|
|
|
|
} |
990
|
|
|
|
|
|
|
|
991
|
|
|
|
|
|
|
sub _printSPARQLComment { |
992
|
27
|
|
|
27
|
|
48
|
my ($self, $string) = @_; |
993
|
|
|
|
|
|
|
|
994
|
|
|
|
|
|
|
# warn "-- $string\n"; |
995
|
27
|
|
|
|
|
109
|
$self->_addQueryString("# $string\n"); |
996
|
|
|
|
|
|
|
} |
997
|
|
|
|
|
|
|
|
998
|
|
|
|
|
|
|
sub _printSPARQLQueryWithPREFIX { |
999
|
9
|
|
|
9
|
|
23
|
my ($self) = @_; |
1000
|
9
|
|
|
|
|
12
|
my $query; |
1001
|
|
|
|
|
|
|
|
1002
|
|
|
|
|
|
|
# if (!defined $fh) { |
1003
|
|
|
|
|
|
|
# $fh = *STDOUT; |
1004
|
|
|
|
|
|
|
# } |
1005
|
|
|
|
|
|
|
|
1006
|
9
|
|
|
|
|
31
|
$self->_addQueryString("PREFIX rdfs: \n"); |
1007
|
9
|
|
|
|
|
27
|
$self->_addQueryString("PREFIX rdf: \n"); |
1008
|
|
|
|
|
|
|
|
1009
|
9
|
|
|
|
|
59
|
($query,) = $self->_printSPARQLQuery($self->wherePart, $self->aggregation, 0); |
1010
|
9
|
|
|
|
|
31
|
$self->_addQueryString($query); |
1011
|
|
|
|
|
|
|
} |
1012
|
|
|
|
|
|
|
|
1013
|
|
|
|
|
|
|
sub _printSPARQLQuery { |
1014
|
9
|
|
|
9
|
|
21
|
my ($self, $wherePart, $aggregation, $embeded) = @_; |
1015
|
|
|
|
|
|
|
|
1016
|
9
|
|
|
|
|
17
|
my $line; |
1017
|
|
|
|
|
|
|
my $str; |
1018
|
9
|
|
|
|
|
19
|
my $query = ""; |
1019
|
9
|
|
|
|
|
15
|
my $varAggreg; |
1020
|
|
|
|
|
|
|
my $i; |
1021
|
|
|
|
|
|
|
|
1022
|
|
|
|
|
|
|
# warn "\t in _printSPARQLQuery (" . scalar(@$wherePart) . ")\n"; |
1023
|
9
|
50
|
|
|
|
37
|
if ($aggregation->{'ASK'} == 1) { |
1024
|
0
|
|
|
|
|
0
|
$query .= "ASK \n"; |
1025
|
0
|
|
|
|
|
0
|
$query .= $self->_printWherePart($wherePart, $aggregation, $embeded); |
1026
|
|
|
|
|
|
|
|
1027
|
|
|
|
|
|
|
} else { |
1028
|
9
|
50
|
|
|
|
64
|
if (scalar(@{$self->selectPart}) >= 1) { |
|
9
|
|
|
|
|
51
|
|
1029
|
9
|
50
|
|
|
|
32
|
if (scalar(@$wherePart) != 0) { |
1030
|
|
|
|
|
|
|
# warn "AGGREG: " .join(':', keys %{$aggregation->{'PREDICATE'}}) . " (1a)\n"; |
1031
|
|
|
|
|
|
|
# warn "AGGREG: " .join(':', keys %{$aggregation->{'QTVAR'}}) . " (1b)\n"; |
1032
|
9
|
|
|
|
|
20
|
$query .= "SELECT "; |
1033
|
9
|
50
|
33
|
|
|
55
|
if ((exists $aggregation->{'QTVAR'}->{'count'}) && (exists $aggregation->{'QTVAR'}->{'count'}->{$self->selectPart->[0]})) { |
1034
|
|
|
|
|
|
|
# warn "in COUNT\n"; |
1035
|
0
|
|
|
|
|
0
|
$str = "(COUNT("; |
1036
|
0
|
0
|
0
|
|
|
0
|
if ((exists $aggregation->{'QTVAR'}->{'distinct'}->{$self->selectPart->[0]}) && |
1037
|
|
|
|
|
|
|
(!exists $aggregation->{'QTVAR'}->{'per'}->{$self->selectPart->[0]})) { |
1038
|
0
|
|
|
|
|
0
|
$str .= "DISTINCT "; |
1039
|
|
|
|
|
|
|
} else { |
1040
|
0
|
0
|
|
|
|
0
|
if ($embeded == 1) { |
1041
|
0
|
|
|
|
|
0
|
$str = "DISTINCT " . $self->selectPart->[0] . " $str"; |
1042
|
|
|
|
|
|
|
} else { |
1043
|
0
|
|
|
|
|
0
|
$str = "DISTINCT $str "; |
1044
|
|
|
|
|
|
|
} |
1045
|
|
|
|
|
|
|
} |
1046
|
0
|
|
|
|
|
0
|
$varAggreg = $self->selectPart->[0] ."count"; |
1047
|
0
|
|
|
|
|
0
|
$str .= $self->selectPart->[0] . ") as $varAggreg)"; |
1048
|
0
|
|
|
|
|
0
|
$query .= "$str\n"; |
1049
|
|
|
|
|
|
|
# } elsif ((exists $aggregation->{'QTVAR'}->{'max'}->{$self->selectPart->[0]}) || |
1050
|
|
|
|
|
|
|
# (exists $aggregation->{'QTVAR'}->{'min'}->{$self->selectPart->[0]})) { |
1051
|
|
|
|
|
|
|
# $self-> |
1052
|
|
|
|
|
|
|
} else { |
1053
|
9
|
|
|
|
|
45
|
$query .= "DISTINCT " . $self->selectPart->[0] . "\n"; |
1054
|
|
|
|
|
|
|
} |
1055
|
9
|
|
|
|
|
19
|
$query .= "WHERE "; |
1056
|
9
|
50
|
|
|
|
15
|
if (scalar(@{$self->union}) == 0) { |
|
9
|
|
|
|
|
50
|
|
1057
|
9
|
|
|
|
|
42
|
$query .= $self->_printWherePart($wherePart, $aggregation, $embeded); |
1058
|
|
|
|
|
|
|
} else { |
1059
|
0
|
|
|
|
|
0
|
$query .= "{\n"; |
1060
|
0
|
|
|
|
|
0
|
my @wherePart1; |
1061
|
0
|
|
|
|
|
0
|
for($i=scalar(@{$self->union}) -1 ; $i >= 0; $i--) { |
|
0
|
|
|
|
|
0
|
|
1062
|
0
|
|
|
|
|
0
|
push @wherePart1, $wherePart->[$self->union->[$i]]; |
1063
|
|
|
|
|
|
|
} |
1064
|
0
|
|
|
|
|
0
|
$query .= $self->_printWherePart(\@wherePart1, $aggregation, $embeded); |
1065
|
0
|
|
|
|
|
0
|
$query.="UNION\n"; |
1066
|
0
|
|
|
|
|
0
|
my @wherePart2; |
1067
|
0
|
|
|
|
|
0
|
for($i=$self->union->[0]+1;$i < scalar(@$wherePart);$i++) { |
1068
|
0
|
|
|
|
|
0
|
push @wherePart2, $wherePart->[$i]; |
1069
|
|
|
|
|
|
|
} |
1070
|
0
|
|
|
|
|
0
|
$query .= $self->_printWherePart(\@wherePart2, $aggregation, $embeded); |
1071
|
0
|
|
|
|
|
0
|
$query .= "}\n"; |
1072
|
|
|
|
|
|
|
|
1073
|
|
|
|
|
|
|
} |
1074
|
|
|
|
|
|
|
# warn "AGGREG: " .join(':', keys %{$aggregation->{'PREDICATE'}}) . " (3a)\n"; |
1075
|
|
|
|
|
|
|
# warn "AGGREG: " .join(':', keys %{$aggregation->{'QTVAR'}}) . " (3b)\n"; |
1076
|
9
|
0
|
0
|
|
|
72
|
if ((exists $aggregation->{'QTVAR'}->{'count'}->{$self->selectPart->[0]}) && |
|
|
|
33
|
|
|
|
|
1077
|
|
|
|
|
|
|
((!exists $aggregation->{'QTVAR'}->{'distinct'}->{$self->selectPart->[0]}) || |
1078
|
|
|
|
|
|
|
(exists $aggregation->{'QTVAR'}->{'per'}->{$self->selectPart->[0]}))) { |
1079
|
0
|
|
|
|
|
0
|
$query .= "GROUP BY " .$self->selectPart->[0] . " \n"; |
1080
|
|
|
|
|
|
|
} |
1081
|
|
|
|
|
|
|
} else { |
1082
|
0
|
|
|
|
|
0
|
$self->_printVerbose("Error in wherePart - empty\n"); |
1083
|
|
|
|
|
|
|
} |
1084
|
|
|
|
|
|
|
} else { |
1085
|
0
|
|
|
|
|
0
|
$self->_printVerbose("*** ERROR IN selectPart ***\n"); |
1086
|
|
|
|
|
|
|
} |
1087
|
|
|
|
|
|
|
} |
1088
|
|
|
|
|
|
|
# warn "\t out _printSPARQLQuery\n"; |
1089
|
9
|
|
|
|
|
33
|
return($query, $varAggreg); |
1090
|
|
|
|
|
|
|
} |
1091
|
|
|
|
|
|
|
|
1092
|
|
|
|
|
|
|
sub _printWherePart { |
1093
|
9
|
|
|
9
|
|
18
|
my ($self, $wherePart, $aggregation, $embeded) = @_; |
1094
|
|
|
|
|
|
|
|
1095
|
9
|
|
|
|
|
19
|
my $line; |
1096
|
|
|
|
|
|
|
my $lineNb; |
1097
|
0
|
|
|
|
|
0
|
my @addlines; |
1098
|
0
|
|
|
|
|
0
|
my $query; |
1099
|
0
|
|
|
|
|
0
|
my $query2; |
1100
|
0
|
|
|
|
|
0
|
my $varAggreg; |
1101
|
0
|
|
|
|
|
0
|
my %regexvar; |
1102
|
|
|
|
|
|
|
|
1103
|
9
|
|
|
|
|
22
|
$query .= "{\n"; |
1104
|
9
|
|
|
|
|
38
|
for($lineNb=0;$lineNb < scalar(@$wherePart);$lineNb++){ |
1105
|
12
|
|
|
|
|
24
|
$line = $wherePart->[$lineNb]; |
1106
|
12
|
50
|
|
|
|
94
|
if (exists $aggregation->{'PREDICATE'}->{$line->{'PREDICATE'}->[0]}) { |
1107
|
0
|
|
|
|
|
0
|
$self->_printVerbose("AGGREG: " . $aggregation->{'PREDICATE'}->{$line->{'PREDICATE'}->[0]} . " (2)\n",2); |
1108
|
0
|
|
|
|
|
0
|
($query2, $varAggreg) = $self->_printAggregateLine($wherePart, $aggregation, $line, $aggregation->{'PREDICATE'}->{$line->{'PREDICATE'}->[0]}, \@addlines, \%regexvar); |
1109
|
0
|
|
|
|
|
0
|
$query .= $query2; |
1110
|
|
|
|
|
|
|
} |
1111
|
|
|
|
|
|
|
# warn "=> addlin size: " . scalar(@addlines) . " (a)\n"; |
1112
|
12
|
50
|
|
|
|
44
|
if ($line->{'NEGATION'} == 1) { |
1113
|
0
|
|
|
|
|
0
|
$query .= " FILTER NOT EXISTS {\n"; |
1114
|
|
|
|
|
|
|
} |
1115
|
12
|
|
|
|
|
52
|
$query .= $self->_printSPARQLSelectLine($line, \@addlines, \%regexvar); |
1116
|
|
|
|
|
|
|
# warn "=> addlin size: " . scalar(@addlines) . " (b)\n"; |
1117
|
12
|
50
|
|
|
|
67
|
if ($line->{'NEGATION'} == 1) { |
1118
|
0
|
|
|
|
|
0
|
$query .= "\n }\n"; |
1119
|
|
|
|
|
|
|
} |
1120
|
|
|
|
|
|
|
} |
1121
|
9
|
|
|
|
|
23
|
$query .= join("\n", @addlines); |
1122
|
9
|
|
|
|
|
25
|
$query .= "\n}\n"; |
1123
|
9
|
|
|
|
|
39
|
return($query); |
1124
|
|
|
|
|
|
|
} |
1125
|
|
|
|
|
|
|
|
1126
|
|
|
|
|
|
|
|
1127
|
|
|
|
|
|
|
sub _printAggregateLine { |
1128
|
0
|
|
|
0
|
|
0
|
my ($self, $wherePart, $aggregation, $line, $aggregOp, $addlines, $regexvar) = @_; |
1129
|
|
|
|
|
|
|
|
1130
|
0
|
|
|
|
|
0
|
my $variable; |
1131
|
|
|
|
|
|
|
my $aggregRole; |
1132
|
0
|
|
|
|
|
0
|
my $query = ""; |
1133
|
|
|
|
|
|
|
# my %aggregationOp2; |
1134
|
0
|
|
|
|
|
0
|
my $query2; |
1135
|
|
|
|
|
|
|
my $varAggreg; |
1136
|
0
|
|
|
|
|
0
|
my $varAggregOp; |
1137
|
0
|
|
|
|
|
0
|
my $query3; |
1138
|
|
|
|
|
|
|
|
1139
|
|
|
|
|
|
|
# warn "in _printAggregateLine ($aggregOp)\n"; |
1140
|
0
|
0
|
0
|
|
|
0
|
if (($aggregOp ne 'count') && ($aggregOp ne 'distinct')) { |
1141
|
0
|
0
|
0
|
|
|
0
|
if ((exists $self->semanticCorrespondance->{$self->language}->{'VARIABLE'}->{$line->{'PREDICATE'}->[0]}) && |
1142
|
|
|
|
|
|
|
($self->semanticCorrespondance->{$self->language}->{'VARIABLE'}->{$line->{'PREDICATE'}->[0]} eq "INT")) { |
1143
|
0
|
|
|
|
|
0
|
$query .= " {\n"; |
1144
|
0
|
0
|
|
|
|
0
|
if ($line->{'SUBJECT'}->[0] eq "INT") { |
|
|
0
|
|
|
|
|
|
1145
|
0
|
|
|
|
|
0
|
$aggregRole = "SUBJECT"; |
1146
|
|
|
|
|
|
|
} elsif ($line->{'OBJECT'}->[0] eq "INT") { |
1147
|
0
|
|
|
|
|
0
|
$aggregRole = "OBJECT"; |
1148
|
|
|
|
|
|
|
} else { |
1149
|
0
|
|
|
|
|
0
|
warn "** error in the aggregated variable identification\n"; |
1150
|
0
|
|
|
|
|
0
|
return("",undef); |
1151
|
|
|
|
|
|
|
} |
1152
|
|
|
|
|
|
|
|
1153
|
0
|
|
|
|
|
0
|
$variable = "?$aggregOp" . $line->{'PREDICATE'}->[0]; |
1154
|
|
|
|
|
|
|
|
1155
|
0
|
|
|
|
|
0
|
$query .= " SELECT (" . lc($aggregOp) . "(" . $line->{$aggregRole}->[1] . ") as $variable)\n"; |
1156
|
0
|
|
|
|
|
0
|
$query .= " WHERE {\n"; |
1157
|
0
|
|
|
|
|
0
|
$query .= $self->_printSPARQLSelectLine($line, $addlines, $regexvar); |
1158
|
0
|
|
|
|
|
0
|
$query .= " }\n"; |
1159
|
0
|
0
|
|
|
|
0
|
if ($line->{$aggregRole}->[0] eq "INT") { |
1160
|
0
|
|
|
|
|
0
|
$line->{$aggregRole}->[1] = $variable; |
1161
|
|
|
|
|
|
|
} |
1162
|
0
|
|
|
|
|
0
|
$query .= " }\n"; |
1163
|
|
|
|
|
|
|
} else { |
1164
|
0
|
|
|
|
|
0
|
$self->_printVerbose("AGGREG: $aggregOp (3)\n", 2); |
1165
|
0
|
|
|
|
|
0
|
my $aggregation2 = dclone($aggregation); |
1166
|
|
|
|
|
|
|
# $self->_duplicateAggregationOp($aggregation, %aggregationOp2); |
1167
|
|
|
|
|
|
|
|
1168
|
0
|
|
|
|
|
0
|
$aggregation2->{'QTVAR'}->{'count'}->{$self->selectPart->[0]} = $aggregation2->{'QTVAR'}->{$aggregOp}->{$self->selectPart->[0]}; |
1169
|
0
|
|
|
|
|
0
|
delete $aggregation2->{'QTVAR'}->{$aggregOp}->{$self->selectPart->[0]}; |
1170
|
0
|
|
|
|
|
0
|
delete $aggregation2->{'PREDICATE'}->{$line->{'PREDICATE'}->[0]}; |
1171
|
0
|
|
|
|
|
0
|
($query2, $variable) = $self->_printSPARQLQuery($wherePart, $aggregation2, 1); |
1172
|
0
|
|
|
|
|
0
|
$query3 = " {\n$query2 }\n"; |
1173
|
0
|
0
|
0
|
|
|
0
|
if (($aggregOp eq "min") || ($aggregOp eq "max")) { |
1174
|
0
|
|
|
|
|
0
|
$varAggregOp = "$variable$aggregOp"; |
1175
|
0
|
|
|
|
|
0
|
$query .= "{\n" . "SELECT DISTINCT ($aggregOp($variable) as $varAggregOp)\n"; |
1176
|
0
|
|
|
|
|
0
|
$query .= "WHERE {\n"; |
1177
|
0
|
|
|
|
|
0
|
$query .= $self->_printSPARQLSelectLine($line, $addlines, $regexvar); # , $union); |
1178
|
0
|
|
|
|
|
0
|
$query .= $query3; |
1179
|
0
|
|
|
|
|
0
|
$query .= "}\n}\n$query3", |
1180
|
|
|
|
|
|
|
$query .= "FILTER ($varAggregOp = $variable).\n"; |
1181
|
|
|
|
|
|
|
} |
1182
|
|
|
|
|
|
|
|
1183
|
|
|
|
|
|
|
# $query .= $query2; |
1184
|
|
|
|
|
|
|
} |
1185
|
|
|
|
|
|
|
} |
1186
|
|
|
|
|
|
|
# warn "out _printAggregateLine ($aggregOp)\n"; |
1187
|
0
|
|
|
|
|
0
|
return($query, $variable); |
1188
|
|
|
|
|
|
|
} |
1189
|
|
|
|
|
|
|
|
1190
|
|
|
|
|
|
|
# sub _duplicateAggregationOp { |
1191
|
|
|
|
|
|
|
# my ($self, $aggregation, $aggregation2) = @_; |
1192
|
|
|
|
|
|
|
|
1193
|
|
|
|
|
|
|
# my $infoType; |
1194
|
|
|
|
|
|
|
# foreach $infoType () { |
1195
|
|
|
|
|
|
|
|
1196
|
|
|
|
|
|
|
|
1197
|
|
|
|
|
|
|
# } |
1198
|
|
|
|
|
|
|
|
1199
|
|
|
|
|
|
|
# } |
1200
|
|
|
|
|
|
|
|
1201
|
|
|
|
|
|
|
sub _printSPARQLSelectLine { |
1202
|
12
|
|
|
12
|
|
22
|
my ($self, $line, $addlines, $regexvar) = @_; |
1203
|
12
|
|
|
|
|
22
|
my $query = ""; |
1204
|
|
|
|
|
|
|
|
1205
|
12
|
|
|
|
|
56
|
$query .= " "; |
1206
|
12
|
50
|
|
|
|
44
|
if (defined ($line->{'SUBJECT'})) { |
1207
|
12
|
|
|
|
|
49
|
$query .= $self->_printSPARQLQUERYElement($line->{'SUBJECT'}, $addlines, $regexvar); |
1208
|
12
|
|
|
|
|
23
|
$query .= " "; |
1209
|
|
|
|
|
|
|
} |
1210
|
12
|
50
|
|
|
|
41
|
if (defined ($line->{'PREDICATE'})) { |
1211
|
12
|
|
|
|
|
33
|
$query .= $self->_printSPARQLQUERYElement($line->{'PREDICATE'}, $addlines, $regexvar); |
1212
|
12
|
|
|
|
|
27
|
$query .= " "; |
1213
|
|
|
|
|
|
|
} |
1214
|
12
|
50
|
|
|
|
39
|
if (defined ($line->{'OBJECT'})) { |
1215
|
12
|
|
|
|
|
35
|
$query .= $self->_printSPARQLQUERYElement($line->{'OBJECT'}, $addlines, $regexvar); |
1216
|
|
|
|
|
|
|
} |
1217
|
12
|
|
|
|
|
27
|
$query .= ".\n"; |
1218
|
12
|
|
|
|
|
32
|
return($query); |
1219
|
|
|
|
|
|
|
} |
1220
|
|
|
|
|
|
|
|
1221
|
|
|
|
|
|
|
sub _printSPARQLQUERYElement { |
1222
|
36
|
|
|
36
|
|
66
|
my ($self, $queryElement, $addlines, $regexvar) = @_; |
1223
|
|
|
|
|
|
|
|
1224
|
36
|
|
|
|
|
47
|
my $variable; |
1225
|
|
|
|
|
|
|
my $regex; |
1226
|
36
|
|
|
|
|
49
|
my $query = ""; |
1227
|
|
|
|
|
|
|
|
1228
|
36
|
50
|
|
|
|
359
|
if ($queryElement->[1] =~ /:NODEREGEX:/) { |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
1229
|
0
|
|
|
|
|
0
|
$regex=$'; # ' |
1230
|
0
|
|
|
|
|
0
|
$self->_printVerbose("NODEREGEX: $regexvar\n", 2); |
1231
|
0
|
0
|
|
|
|
0
|
if (!exists $regexvar->{$queryElement->[1]}) { |
1232
|
0
|
|
|
|
|
0
|
$variable=$self->varPrefix . $self->variableCounter; |
1233
|
|
|
|
|
|
|
# warn "\t==> $variable (Subj/Subj)\n"; |
1234
|
0
|
|
|
|
|
0
|
$self->_IncrVariableCounter; |
1235
|
0
|
|
|
|
|
0
|
$query .= $variable; |
1236
|
0
|
|
|
|
|
0
|
push @$addlines, " $variable rdfs:label ?l" . $self->variableCounter . ".\n FILTER(REGEX(?l" . $self->variableCounter . ",'$regex','i'))."; |
1237
|
0
|
|
|
|
|
0
|
$regexvar->{$queryElement->[1]} = $variable; |
1238
|
|
|
|
|
|
|
} else { |
1239
|
0
|
|
|
|
|
0
|
$query .= $regexvar->{$queryElement->[1]}; |
1240
|
|
|
|
|
|
|
} |
1241
|
|
|
|
|
|
|
} elsif ($queryElement->[1] =~ /:LABELREGEX:/) { |
1242
|
1
|
|
|
|
|
3
|
$regex=$'; # ' |
1243
|
1
|
|
|
|
|
6
|
$self->_printVerbose("LABELREGEX: $regexvar\n",2);; |
1244
|
1
|
50
|
|
|
|
4
|
if (!exists $regexvar->{$queryElement->[1]}) { |
1245
|
1
|
|
|
|
|
5
|
$variable=$self->varPrefix . $self->variableCounter; |
1246
|
|
|
|
|
|
|
# warn "\t==> $variable (Subj/Subj)\n"; |
1247
|
1
|
|
|
|
|
2
|
$self->_IncrVariableCounter; |
1248
|
1
|
|
|
|
|
2
|
$query .= $variable; |
1249
|
1
|
|
|
|
|
4
|
push @$addlines, " FILTER(REGEX($variable,'$regex','i'))."; |
1250
|
1
|
|
|
|
|
3
|
$regexvar->{$queryElement->[1]} = $variable; |
1251
|
|
|
|
|
|
|
} else { |
1252
|
0
|
|
|
|
|
0
|
$query .= $regexvar->{$queryElement->[1]}; |
1253
|
|
|
|
|
|
|
} |
1254
|
|
|
|
|
|
|
} elsif ($queryElement->[1] =~ /^http:/) { |
1255
|
20
|
|
|
|
|
78
|
$query .= "<" . $queryElement->[1] . ">"; |
1256
|
|
|
|
|
|
|
} elsif ($queryElement->[1] =~ /^const\/(?.*)/) { |
1257
|
0
|
|
|
|
|
0
|
$query .= '"' . $+{type} . '"^^<' . $self->semanticCorrespondance->{$self->language}->{'CONST'}->{$queryElement->[0]} .">"; |
1258
|
|
|
|
|
|
|
} elsif ($queryElement->[1] =~ /^\?/) { |
1259
|
14
|
|
|
|
|
32
|
$query .= $queryElement->[1]; |
1260
|
|
|
|
|
|
|
} elsif ($queryElement->[1] =~ /^rdf/) { |
1261
|
0
|
|
|
|
|
0
|
$query .= $queryElement->[1]; |
1262
|
|
|
|
|
|
|
} elsif ($queryElement->[1] =~ /^STRING/) { |
1263
|
1
|
|
|
|
|
7
|
$queryElement->[1] =~ s/STRING\///; |
1264
|
1
|
|
|
|
|
4
|
$query .= "\"" . $queryElement->[1] . "\""; |
1265
|
|
|
|
|
|
|
} elsif ($queryElement->[1] =~ /^\"/) { |
1266
|
0
|
|
|
|
|
0
|
$query .= $queryElement->[1]; |
1267
|
|
|
|
|
|
|
} else { |
1268
|
0
|
|
|
|
|
0
|
$query .= "\"" . $queryElement->[1] . "\""; |
1269
|
|
|
|
|
|
|
} |
1270
|
36
|
|
|
|
|
98
|
return($query); |
1271
|
|
|
|
|
|
|
} |
1272
|
|
|
|
|
|
|
|
1273
|
|
|
|
|
|
|
sub _printVerbose { |
1274
|
224
|
|
|
224
|
|
351
|
my($self, $msg, $level) = @_; |
1275
|
|
|
|
|
|
|
|
1276
|
224
|
100
|
|
|
|
496
|
if (!defined $level) { |
1277
|
148
|
|
|
|
|
244
|
$level = 1; |
1278
|
|
|
|
|
|
|
} |
1279
|
|
|
|
|
|
|
|
1280
|
224
|
50
|
33
|
|
|
829
|
if (($self->verbose > 0) && ($self->verbose >= $level)) { |
1281
|
0
|
|
|
|
|
0
|
warn "$msg"; |
1282
|
|
|
|
|
|
|
} |
1283
|
|
|
|
|
|
|
|
1284
|
|
|
|
|
|
|
} |
1285
|
|
|
|
|
|
|
|
1286
|
|
|
|
|
|
|
sub getQueryAnswers { |
1287
|
2
|
|
|
2
|
1
|
5
|
my ($self) = @_; |
1288
|
|
|
|
|
|
|
|
1289
|
|
|
|
|
|
|
# my $prefix = "http://vtentacle.techfak.uni-bielefeld.de:443/sparql?default-graph-uri=&query="; |
1290
|
|
|
|
|
|
|
# my $suffix = "&format=text%2Ftab-separated-values&timeout=0&verbose=on"; |
1291
|
|
|
|
|
|
|
|
1292
|
2
|
|
|
|
|
14
|
my $encod_str = URL::Encode::url_encode_utf8($self->queryString); |
1293
|
2
|
|
|
|
|
201
|
my $webPage = ""; |
1294
|
2
|
|
|
|
|
3
|
my $answer; |
1295
|
|
|
|
|
|
|
my @answers; |
1296
|
|
|
|
|
|
|
|
1297
|
2
|
|
|
|
|
17
|
$self->_printVerbose("get question " . $self->docId . "\n"); |
1298
|
|
|
|
|
|
|
|
1299
|
|
|
|
|
|
|
# my $url = "$prefix$encod_str$suffix"; |
1300
|
2
|
|
|
|
|
27
|
my $url = $self->config->{'NLQUESTION'}->{'language="' . uc($self->language) . '"'}->{'URL_PREFIX'}; |
1301
|
2
|
|
|
|
|
7
|
$url .= $encod_str; |
1302
|
2
|
|
|
|
|
20
|
$url .= $self->config->{'NLQUESTION'}->{'language="' . uc($self->language) . '"'}->{'URL_SUFFIX'}; |
1303
|
|
|
|
|
|
|
|
1304
|
2
|
|
|
|
|
13
|
$self->_printVerbose("\t$url\n"); |
1305
|
|
|
|
|
|
|
|
1306
|
2
|
|
|
|
|
24
|
my $request = HTTP::Request->new(GET => $url); |
1307
|
2
|
|
|
|
|
20484
|
my $ua = LWP::UserAgent->new; |
1308
|
2
|
|
|
|
|
121167
|
my $response = $ua->request($request); |
1309
|
|
|
|
|
|
|
|
1310
|
2
|
50
|
|
|
|
240621
|
if ($response->is_success) { |
1311
|
0
|
|
|
|
|
0
|
$self->_printVerbose("\tSuccess\n",2); |
1312
|
0
|
|
|
|
|
0
|
$webPage = $response->decoded_content; |
1313
|
|
|
|
|
|
|
} else { |
1314
|
2
|
|
|
|
|
47
|
warn $self->docId . ": " . $response->status_line . "\n"; |
1315
|
|
|
|
|
|
|
# $self->_printVerbose($response->status_line . "\n"); |
1316
|
|
|
|
|
|
|
} |
1317
|
|
|
|
|
|
|
|
1318
|
|
|
|
|
|
|
# CSV |
1319
|
2
|
|
|
|
|
332
|
@answers = split /\n/, $webPage; |
1320
|
2
|
|
|
|
|
5
|
shift @answers; |
1321
|
2
|
|
|
|
|
121
|
foreach $answer (@answers) { |
1322
|
0
|
|
|
|
|
|
$answer =~ s/\"//go; |
1323
|
0
|
|
|
|
|
|
$self->_printVerbose("\t=>$answer",2); |
1324
|
0
|
|
|
|
|
|
$self->queryAnswers->{$answer} = 0; |
1325
|
|
|
|
|
|
|
} |
1326
|
|
|
|
|
|
|
|
1327
|
|
|
|
|
|
|
# XML/SPARQL |
1328
|
|
|
|
|
|
|
# $self->_printVerbose($webPage, 2); |
1329
|
|
|
|
|
|
|
# my $xs = XML::Simple->new(); |
1330
|
|
|
|
|
|
|
# my $webPage_struct = $xs->XMLin($webPage); |
1331
|
|
|
|
|
|
|
# warn Dumper($webPage_struct); |
1332
|
|
|
|
|
|
|
} |
1333
|
|
|
|
|
|
|
|
1334
|
|
|
|
|
|
|
|
1335
|
|
|
|
|
|
|
1; |
1336
|
|
|
|
|
|
|
|
1337
|
|
|
|
|
|
|
__END__ |