| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# |
|
2
|
|
|
|
|
|
|
# ParsingPatternParser.yp |
|
3
|
|
|
|
|
|
|
# |
|
4
|
|
|
|
|
|
|
# used to generate Lingua::YaTeA::ParsingPatternParser.pm |
|
5
|
|
|
|
|
|
|
# |
|
6
|
|
|
|
|
|
|
# Use: yapp -m 'Lingua::YaTeA::ParsingPatternParser' -o lib/Lingua/YaTeA/ParsingPatternParser.pm lib/Lingua/YaTeA/ParsingPatternParser.yp |
|
7
|
|
|
|
|
|
|
# |
|
8
|
|
|
|
|
|
|
# Parse::Yapp input grammar for parsing the yatea PArsint patterns |
|
9
|
|
|
|
|
|
|
# |
|
10
|
|
|
|
|
|
|
# |
|
11
|
|
|
|
|
|
|
# |
|
12
|
|
|
|
|
|
|
%{ |
|
13
|
5
|
|
|
5
|
|
1426
|
use Lingua::YaTeA; |
|
|
5
|
|
|
|
|
13
|
|
|
|
5
|
|
|
|
|
55
|
|
|
14
|
|
|
|
|
|
|
# use Data::Dumper; |
|
15
|
5
|
|
|
5
|
|
152
|
use warnings; |
|
|
5
|
|
|
|
|
109
|
|
|
|
5
|
|
|
|
|
9875
|
|
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
my $node_set; |
|
18
|
|
|
|
|
|
|
my $level = 0; |
|
19
|
|
|
|
|
|
|
my $node; |
|
20
|
|
|
|
|
|
|
my @uncomplete; |
|
21
|
|
|
|
|
|
|
my @parse; |
|
22
|
|
|
|
|
|
|
my $edge; |
|
23
|
|
|
|
|
|
|
my $num_content_words; |
|
24
|
|
|
|
|
|
|
my @pos_sequence; |
|
25
|
|
|
|
|
|
|
my $priority; |
|
26
|
|
|
|
|
|
|
my $direction; |
|
27
|
|
|
|
|
|
|
my $pos_sequence; |
|
28
|
|
|
|
|
|
|
my $pattern; |
|
29
|
|
|
|
|
|
|
my $parse; |
|
30
|
|
|
|
|
|
|
my $num_line = 1; |
|
31
|
|
|
|
|
|
|
%} |
|
32
|
|
|
|
|
|
|
%% |
|
33
|
|
|
|
|
|
|
input: #empty |
|
34
|
4
|
|
|
672
|
0
|
16
|
| input line { # print STDERR "INPUT $_[1] \n"; |
|
|
|
|
|
4
|
|
|
|
|
35
|
4
|
50
|
|
|
|
16
|
} |
|
36
|
|
|
|
|
|
|
; |
|
37
|
|
|
|
|
|
|
|
|
38
|
392
|
|
|
392
|
|
14008
|
line: '\n' { $_[1] } |
|
39
|
|
|
|
|
|
|
| parsingpattern '\n' { |
|
40
|
|
|
|
|
|
|
# print STDERR "=>$_[1]\n"; |
|
41
|
|
|
|
|
|
|
|
|
42
|
280
|
|
|
280
|
|
10362
|
$pos_sequence = join(" ",@pos_sequence); |
|
43
|
280
|
|
|
|
|
600
|
$parse = join(" ",@parse); |
|
44
|
|
|
|
|
|
|
# print STDERR "parse = $parse\n"; |
|
45
|
280
|
|
|
|
|
842
|
$node_set->setRoot; |
|
46
|
280
|
|
|
|
|
939
|
$pattern = Lingua::YaTeA::ParsingPattern->new($parse,$pos_sequence,$node_set,$priority,$direction,$num_content_words,$num_line); |
|
47
|
|
|
|
|
|
|
|
|
48
|
280
|
|
|
|
|
617
|
$_[0]->YYData->{PPRS}->addPattern($pattern); |
|
49
|
280
|
|
|
|
|
549
|
@pos_sequence = (); |
|
50
|
280
|
|
|
|
|
394
|
@uncomplete = (); |
|
51
|
280
|
|
|
|
|
410
|
@parse = (); |
|
52
|
280
|
|
|
|
|
343
|
$level = 0; |
|
53
|
280
|
|
|
|
|
578
|
$_[0]->YYData->{PPRS}->checkContentWords($num_content_words,$num_line); |
|
54
|
|
|
|
|
|
|
|
|
55
|
280
|
100
|
|
|
|
527
|
if ($num_content_words > $Lingua::YaTeA::ParsingPatternRecordSet::max_content_words) |
|
56
|
|
|
|
|
|
|
{ |
|
57
|
8
|
|
|
|
|
15
|
$Lingua::YaTeA::ParsingPatternRecordSet::max_content_words = $num_content_words; |
|
58
|
|
|
|
|
|
|
} |
|
59
|
280
|
|
|
|
|
356
|
$num_content_words = 0; |
|
60
|
280
|
|
|
|
|
518
|
$num_line++; |
|
61
|
|
|
|
|
|
|
} |
|
62
|
0
|
|
|
0
|
|
0
|
| error '\n' { $_[0]->YYErrok } |
|
63
|
|
|
|
|
|
|
; |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
parsingpattern: { # print STDERR "START\n"; |
|
66
|
|
|
|
|
|
|
|
|
67
|
280
|
|
|
280
|
|
7225
|
$node_set = Lingua::YaTeA::NodeSet->new; |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
} OPEN pattern END priority direction |
|
70
|
0
|
|
|
0
|
|
0
|
| error 'parsingpattern' { $_[0]->YYErrok } |
|
71
|
|
|
|
|
|
|
; |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
pattern: CANDIDATE PREP DET CANDIDATE |
|
75
|
|
|
|
|
|
|
| CANDIDATE PREP CANDIDATE |
|
76
|
|
|
|
|
|
|
| CANDIDATE PREP PREP CANDIDATE |
|
77
|
|
|
|
|
|
|
| CANDIDATE DET CANDIDATE |
|
78
|
|
|
|
|
|
|
| CANDIDATE CANDIDATE |
|
79
|
0
|
|
|
0
|
|
0
|
| error '\nnew_pattern: ' { $_[0]->YYErrok } |
|
80
|
|
|
|
|
|
|
; |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
OPEN: OPEN_TAG {# print STDERR "OPEN $_[1]\n"; |
|
83
|
|
|
|
|
|
|
|
|
84
|
300
|
100
|
|
300
|
|
14740
|
if ($level == 0) |
|
85
|
|
|
|
|
|
|
{ |
|
86
|
280
|
|
|
|
|
749
|
$node = Lingua::YaTeA::RootNode->new($level); |
|
87
|
|
|
|
|
|
|
} |
|
88
|
|
|
|
|
|
|
else |
|
89
|
|
|
|
|
|
|
{ |
|
90
|
20
|
|
|
|
|
123
|
$node = Lingua::YaTeA::InternalNode->new($level); |
|
91
|
|
|
|
|
|
|
} |
|
92
|
300
|
|
|
|
|
804
|
$node_set->addNode($node); |
|
93
|
300
|
|
|
|
|
587
|
push @uncomplete, $node; |
|
94
|
300
|
|
|
|
|
400
|
$level++; |
|
95
|
300
|
|
|
|
|
695
|
push @parse, $_[1]; |
|
96
|
|
|
|
|
|
|
} |
|
97
|
0
|
|
|
0
|
|
0
|
| error '\nOPEN: ' { $_[0]->YYErrok } |
|
98
|
|
|
|
|
|
|
; |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
CANDIDATE: CANDIDATE_TAG POSITION_TAG { |
|
101
|
|
|
|
|
|
|
# print STDERR "CANDIDATE $_[1] $_[2]\n"; |
|
102
|
|
|
|
|
|
|
|
|
103
|
580
|
|
|
580
|
|
22134
|
$edge = Lingua::YaTeA::PatternLeaf->new($_[1],$node); |
|
104
|
580
|
|
|
|
|
1552
|
$node->addEdge($edge,$_[2]); |
|
105
|
580
|
|
|
|
|
750
|
$num_content_words++; |
|
106
|
580
|
|
|
|
|
1034
|
push @pos_sequence,$_[1]; |
|
107
|
580
|
|
|
|
|
1488
|
push @parse, "$_[1]<=$_[2]>"; |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
} |
|
110
|
|
|
|
|
|
|
| OPEN pattern CLOSE |
|
111
|
0
|
|
|
0
|
|
0
|
| error '\nCANDIDATE: ' { $_[0]->YYErrok } |
|
112
|
|
|
|
|
|
|
; |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
PREP: PREP_TAG {# print STDERR "PREP $_[1]\n"; |
|
115
|
108
|
|
|
108
|
|
3964
|
$node->{"PREP"} = $_[1]; |
|
116
|
108
|
|
|
|
|
171
|
push @pos_sequence, $_[1]; |
|
117
|
108
|
|
|
|
|
196
|
push @parse, $_[1]; |
|
118
|
|
|
|
|
|
|
} |
|
119
|
0
|
|
|
0
|
|
0
|
| error '\nPREP: ' { $_[0]->YYErrok } |
|
120
|
|
|
|
|
|
|
; |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
DET: DET_TAG {# print STDERR "DET $_[1]\n"; |
|
124
|
52
|
|
|
52
|
|
1884
|
$node->{"DET"} = $_[1]; |
|
125
|
52
|
|
|
|
|
90
|
push @pos_sequence, $_[1]; |
|
126
|
52
|
|
|
|
|
109
|
push @parse, $_[1]; |
|
127
|
|
|
|
|
|
|
} |
|
128
|
0
|
|
|
0
|
|
0
|
| error '\nDET: ' { $_[0]->YYErrok } |
|
129
|
|
|
|
|
|
|
; |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
CLOSE: CLOSE_TAG {# print STDERR "CLOSE_TAG $_[1]\n"; |
|
132
|
20
|
|
|
20
|
|
752
|
pop @uncomplete; |
|
133
|
20
|
|
|
|
|
102
|
$node->linkToFather(\@uncomplete,$_[1]); |
|
134
|
20
|
|
|
|
|
39
|
$node = $uncomplete[$#uncomplete]; |
|
135
|
20
|
|
|
|
|
30
|
$level--; |
|
136
|
20
|
|
|
|
|
47
|
push @parse, ')'; |
|
137
|
|
|
|
|
|
|
} |
|
138
|
0
|
|
|
0
|
|
0
|
| error '\nCLOSE: ' { $_[0]->YYErrok } |
|
139
|
|
|
|
|
|
|
; |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
END: END_TAG {# print STDERR "END $_[1]\n"; |
|
142
|
280
|
|
|
280
|
|
9881
|
push @parse, $_[1]; |
|
143
|
280
|
|
|
|
|
549
|
$_[1]; |
|
144
|
|
|
|
|
|
|
} |
|
145
|
0
|
|
|
0
|
|
0
|
| error '\nEND: ' { $_[0]->YYErrok }; |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
priority: PRIORITY_TAG {# print STDERR "PRIORITY\n"; |
|
148
|
280
|
|
|
280
|
|
10484
|
$priority = $_[1]; |
|
149
|
|
|
|
|
|
|
} |
|
150
|
0
|
|
|
0
|
|
0
|
| error '\npriority: ' { $_[0]->YYErrok } |
|
151
|
|
|
|
|
|
|
; |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
direction: DIRECTION_TAG {# print STDERR "DIRECTION $_[1]\n"; |
|
154
|
280
|
|
|
280
|
|
9948
|
$direction = $_[1]; |
|
155
|
|
|
|
|
|
|
} |
|
156
|
0
|
|
|
0
|
|
0
|
| error '\ndirection: ' { $_[0]->YYErrok } |
|
157
|
4
|
|
|
|
|
766
|
; |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
%% |
|
160
|
4
|
|
|
|
|
377
|
|
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
sub _Error { |
|
164
|
|
|
|
|
|
|
exists $_[0]->YYData->{ERRMSG} |
|
165
|
0
|
0
|
|
0
|
|
0
|
and do { |
|
166
|
0
|
|
|
|
|
0
|
print $_[0]->YYData->{ERRMSG}; |
|
167
|
0
|
|
|
|
|
0
|
delete $_[0]->YYData->{ERRMSG}; |
|
168
|
0
|
|
|
|
|
0
|
return; |
|
169
|
|
|
|
|
|
|
}; |
|
170
|
0
|
|
|
|
|
0
|
print "Syntax error.\n"; |
|
171
|
|
|
|
|
|
|
} |
|
172
|
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
sub _Lexer { |
|
174
|
3156
|
|
|
3156
|
|
82339
|
my($parser)=shift; |
|
175
|
|
|
|
|
|
|
|
|
176
|
3156
|
|
|
|
|
5724
|
my $fh = $parser->YYData->{FH}; |
|
177
|
|
|
|
|
|
|
|
|
178
|
3156
|
|
|
|
|
16554
|
my $open = '(\()'; |
|
179
|
3156
|
|
|
|
|
4917
|
my $det = $parser->YYData->{DETERMINERS}; |
|
180
|
3156
|
|
|
|
|
16911
|
my $prep = $parser->YYData->{PREPOSITIONS}; |
|
181
|
3156
|
|
|
|
|
16476
|
my $candidates = $parser->YYData->{CANDIDATES}; |
|
182
|
3156
|
|
|
|
|
15064
|
my $positions = '<=(([MH])||(C[12]))>'; |
|
183
|
3156
|
|
|
|
|
3585
|
my $close = '\)<=(([MH])||(C[12]))>'; |
|
184
|
3156
|
|
|
|
|
3684
|
my $end = '(\))\t+'; |
|
185
|
3156
|
|
|
|
|
3538
|
my $priority = '([0-9]+)\t+'; |
|
186
|
3156
|
|
|
|
|
3374
|
my $direction = '((LEFT)|(RIGHT))'; |
|
187
|
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
$parser->YYData->{INPUT} |
|
190
|
|
|
|
|
|
|
or $parser->YYData->{INPUT} = <$fh> |
|
191
|
3156
|
100
|
100
|
|
|
5123
|
or return('',undef); |
|
192
|
|
|
|
|
|
|
|
|
193
|
3152
|
|
|
|
|
25078
|
$parser->YYData->{INPUT}=~s/^[ \t]*#.*//; |
|
194
|
3152
|
|
|
|
|
19535
|
$parser->YYData->{INPUT}=~s/^[ \t]*//; |
|
195
|
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
|
|
198
|
3152
|
|
|
|
|
24412
|
for ($parser->YYData->{INPUT}) { |
|
199
|
3152
|
100
|
|
|
|
24131
|
s/^$open\s*// and return ('OPEN_TAG', $1); |
|
200
|
2852
|
100
|
|
|
|
11821
|
s/^$candidates\s*// and return('CANDIDATE_TAG', $1); |
|
201
|
2272
|
100
|
|
|
|
5964
|
s/^$prep// and return('PREP_TAG', $1); |
|
202
|
2164
|
100
|
|
|
|
4809
|
s/^$det// and return('DET_TAG', $1); |
|
203
|
2112
|
100
|
|
|
|
7626
|
s/^$positions\s*// and return('POSITION_TAG', $1); |
|
204
|
1532
|
100
|
|
|
|
3495
|
s/^$close// and return('CLOSE_TAG', $1); |
|
205
|
1512
|
100
|
|
|
|
4610
|
s/^$end// and return('END_TAG', $1); |
|
206
|
1232
|
100
|
|
|
|
4271
|
s/^$priority// and return('PRIORITY_TAG', $1); |
|
207
|
952
|
100
|
|
|
|
3220
|
s/^$direction// and return('DIRECTION_TAG', $1); |
|
208
|
672
|
50
|
|
|
|
4596
|
s/^(.)//s and return($1,$1); |
|
209
|
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
} |
|
211
|
|
|
|
|
|
|
} |
|
212
|
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
# sub Run { |
|
214
|
|
|
|
|
|
|
# my($self)=shift; |
|
215
|
|
|
|
|
|
|
# $self->YYParse( yylex => \&_Lexer, yyerror => \&_Error ); |
|
216
|
|
|
|
|
|
|
# } |
|
217
|
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
# my($parsingpattern)=new ParsingPatternParser; |
|
219
|
|
|
|
|
|
|
# $parsingpattern->Run; |
|
220
|
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
__END__ |