| 1 | #################################################################### | ||
| 2 | # | ||
| 3 | # This file was generated using Parse::Yapp version 1.05. | ||
| 4 | # | ||
| 5 | # Don't edit this file, use source file instead. | ||
| 6 | # | ||
| 7 | # ANY CHANGE MADE HERE WILL BE LOST ! | ||
| 8 | # | ||
| 9 | #################################################################### | ||
| 10 | package Lingua::Ogmios::NLPWrappers::PatternParser; | ||
| 11 | use vars qw ( @ISA ); | ||
| 12 | use strict; | ||
| 13 | |||
| 14 | @ISA= qw ( Parse::Yapp::Driver ); | ||
| 15 | use Parse::Yapp::Driver; | ||
| 16 | |||
| 17 | #line 12 "lib/Lingua/Ogmios/NLPWrappers/PatternParser.yp" | ||
| 18 | |||
| 19 | use Lingua::Ogmios::NLPWrappers::I2B2; | ||
| 20 | use Data::Dumper; | ||
| 21 | use warnings; | ||
| 22 | |||
| 23 | my $node_set = []; | ||
| 24 | my $node; | ||
| 25 | my @node_stack; | ||
| 26 | my @uncomplete; | ||
| 27 | my @parse; | ||
| 28 | |||
| 29 | my $action; | ||
| 30 | |||
| 31 | |||
| 32 | my $num_content_words; | ||
| 33 | my @pos_sequence; | ||
| 34 | my $priority; | ||
| 35 | |||
| 36 | my $distance; | ||
| 37 | |||
| 38 | my $pos_sequence; | ||
| 39 | my $pattern; | ||
| 40 | my $parse; | ||
| 41 | my $num_line = 1; | ||
| 42 | |||
| 43 | |||
| 44 | sub new { | ||
| 45 | my($class)=shift; | ||
| 46 | ref($class) | ||
| 47 | and $class=ref($class); | ||
| 48 | |||
| 49 | my($self)=$class->SUPER::new( yyversion => '1.05', | ||
| 50 | yystates => | ||
| 51 | [ | ||
| 52 | {#State 0 | ||
| 53 | DEFAULT => -1, | ||
| 54 | GOTOS => { | ||
| 55 | 'input' => 1 | ||
| 56 | } | ||
| 57 | }, | ||
| 58 | {#State 1 | ||
| 59 | ACTIONS => { | ||
| 60 | 'REGEXP_SEQ' => -8, | ||
| 61 | '' => 2, | ||
| 62 | 'SYNDEP_SEQ' => -5, | ||
| 63 | 'SEMTYPE_TAG' => -8, | ||
| 64 | 'TERMCONTENT_SEQ' => -8, | ||
| 65 | "\n" => 5, | ||
| 66 | 'TERM_SEQ' => -8, | ||
| 67 | 'WORD_SEQ' => -8, | ||
| 68 | 'POSTAG_TAG' => -8, | ||
| 69 | 'OPEN_CHUNK' => -8, | ||
| 70 | 'DISTANCE_SEQ' => -8, | ||
| 71 | 'error' => 6 | ||
| 72 | }, | ||
| 73 | GOTOS => { | ||
| 74 | 'pattern' => 3, | ||
| 75 | '@1-0' => 4, | ||
| 76 | 'line' => 7 | ||
| 77 | } | ||
| 78 | }, | ||
| 79 | {#State 2 | ||
| 80 | DEFAULT => 0 | ||
| 81 | }, | ||
| 82 | {#State 3 | ||
| 83 | ACTIONS => { | ||
| 84 | 'REGEXP_SEQ' => 16, | ||
| 85 | 'WORD_SEQ' => 22, | ||
| 86 | 'POSTAG_TAG' => 12, | ||
| 87 | 'SEMTYPE_TAG' => 18, | ||
| 88 | 'OPEN_CHUNK' => 13, | ||
| 89 | 'TERMCONTENT_SEQ' => 10, | ||
| 90 | 'DISTANCE_SEQ' => 15, | ||
| 91 | 'error' => 14, | ||
| 92 | 'TERM_SEQ' => 20 | ||
| 93 | }, | ||
| 94 | GOTOS => { | ||
| 95 | 'REGEXP' => 21, | ||
| 96 | 'POSTAG' => 9, | ||
| 97 | 'WORD' => 8, | ||
| 98 | 'CHUNK' => 17, | ||
| 99 | 'TERM' => 23, | ||
| 100 | 'DISTANCE' => 11, | ||
| 101 | 'SEMTYPE' => 24, | ||
| 102 | 'TERMCONTENT' => 19 | ||
| 103 | } | ||
| 104 | }, | ||
| 105 | {#State 4 | ||
| 106 | ACTIONS => { | ||
| 107 | 'SYNDEP_SEQ' => 25, | ||
| 108 | 'error' => 26 | ||
| 109 | }, | ||
| 110 | GOTOS => { | ||
| 111 | 'SYN_DEP' => 27 | ||
| 112 | } | ||
| 113 | }, | ||
| 114 | {#State 5 | ||
| 115 | DEFAULT => -3 | ||
| 116 | }, | ||
| 117 | {#State 6 | ||
| 118 | ACTIONS => { | ||
| 119 | "\npattern: " => 29, | ||
| 120 | "\nline:" => 28 | ||
| 121 | } | ||
| 122 | }, | ||
| 123 | {#State 7 | ||
| 124 | DEFAULT => -2 | ||
| 125 | }, | ||
| 126 | {#State 8 | ||
| 127 | DEFAULT => -15 | ||
| 128 | }, | ||
| 129 | {#State 9 | ||
| 130 | DEFAULT => -12 | ||
| 131 | }, | ||
| 132 | {#State 10 | ||
| 133 | DEFAULT => -31 | ||
| 134 | }, | ||
| 135 | {#State 11 | ||
| 136 | ACTIONS => { | ||
| 137 | 'error' => 30, | ||
| 138 | 'ACTION_SEQ' => 32 | ||
| 139 | }, | ||
| 140 | GOTOS => { | ||
| 141 | 'ACTION' => 31 | ||
| 142 | } | ||
| 143 | }, | ||
| 144 | {#State 12 | ||
| 145 | DEFAULT => -23 | ||
| 146 | }, | ||
| 147 | {#State 13 | ||
| 148 | DEFAULT => -35, | ||
| 149 | GOTOS => { | ||
| 150 | '@2-1' => 33 | ||
| 151 | } | ||
| 152 | }, | ||
| 153 | {#State 14 | ||
| 154 | ACTIONS => { | ||
| 155 | "\nTERM_CONTENT: " => 37, | ||
| 156 | "\nCHUNK: " => 36, | ||
| 157 | "\nWORD: " => 38, | ||
| 158 | "\nDISTANCE: " => 35, | ||
| 159 | "\nTERM: " => 34, | ||
| 160 | "\nREGEXP: " => 39, | ||
| 161 | "\nPOSTAG: " => 41, | ||
| 162 | "\nSEMTYPE: " => 40 | ||
| 163 | } | ||
| 164 | }, | ||
| 165 | {#State 15 | ||
| 166 | DEFAULT => -19 | ||
| 167 | }, | ||
| 168 | {#State 16 | ||
| 169 | DEFAULT => -25 | ||
| 170 | }, | ||
| 171 | {#State 17 | ||
| 172 | DEFAULT => -10 | ||
| 173 | }, | ||
| 174 | {#State 18 | ||
| 175 | DEFAULT => -21 | ||
| 176 | }, | ||
| 177 | {#State 19 | ||
| 178 | DEFAULT => -14 | ||
| 179 | }, | ||
| 180 | {#State 20 | ||
| 181 | DEFAULT => -29 | ||
| 182 | }, | ||
| 183 | {#State 21 | ||
| 184 | DEFAULT => -11 | ||
| 185 | }, | ||
| 186 | {#State 22 | ||
| 187 | DEFAULT => -27 | ||
| 188 | }, | ||
| 189 | {#State 23 | ||
| 190 | DEFAULT => -13 | ||
| 191 | }, | ||
| 192 | {#State 24 | ||
| 193 | DEFAULT => -9 | ||
| 194 | }, | ||
| 195 | {#State 25 | ||
| 196 | DEFAULT => -33 | ||
| 197 | }, | ||
| 198 | {#State 26 | ||
| 199 | ACTIONS => { | ||
| 200 | "\nSYNDEP: " => 42 | ||
| 201 | } | ||
| 202 | }, | ||
| 203 | {#State 27 | ||
| 204 | ACTIONS => { | ||
| 205 | 'REGEXP_SEQ' => -38, | ||
| 206 | 'WORD_SEQ' => -38, | ||
| 207 | 'POSTAG_TAG' => -38, | ||
| 208 | 'SEMTYPE_TAG' => -38, | ||
| 209 | 'TERMCONTENT_SEQ' => -38, | ||
| 210 | 'DISTANCE_SEQ' => -38, | ||
| 211 | 'error' => 43, | ||
| 212 | 'TERM_SEQ' => -38 | ||
| 213 | }, | ||
| 214 | GOTOS => { | ||
| 215 | 'phrase' => 44 | ||
| 216 | } | ||
| 217 | }, | ||
| 218 | {#State 28 | ||
| 219 | DEFAULT => -7 | ||
| 220 | }, | ||
| 221 | {#State 29 | ||
| 222 | DEFAULT => -16 | ||
| 223 | }, | ||
| 224 | {#State 30 | ||
| 225 | ACTIONS => { | ||
| 226 | "\nACTION: " => 45 | ||
| 227 | } | ||
| 228 | }, | ||
| 229 | {#State 31 | ||
| 230 | ACTIONS => { | ||
| 231 | "\n" => 46 | ||
| 232 | } | ||
| 233 | }, | ||
| 234 | {#State 32 | ||
| 235 | DEFAULT => -17 | ||
| 236 | }, | ||
| 237 | {#State 33 | ||
| 238 | ACTIONS => { | ||
| 239 | 'SYNDEP_SEQ' => 25, | ||
| 240 | 'error' => 26 | ||
| 241 | }, | ||
| 242 | GOTOS => { | ||
| 243 | 'SYN_DEP' => 47 | ||
| 244 | } | ||
| 245 | }, | ||
| 246 | {#State 34 | ||
| 247 | DEFAULT => -30 | ||
| 248 | }, | ||
| 249 | {#State 35 | ||
| 250 | DEFAULT => -20 | ||
| 251 | }, | ||
| 252 | {#State 36 | ||
| 253 | DEFAULT => -37 | ||
| 254 | }, | ||
| 255 | {#State 37 | ||
| 256 | DEFAULT => -32 | ||
| 257 | }, | ||
| 258 | {#State 38 | ||
| 259 | DEFAULT => -28 | ||
| 260 | }, | ||
| 261 | {#State 39 | ||
| 262 | DEFAULT => -26 | ||
| 263 | }, | ||
| 264 | {#State 40 | ||
| 265 | DEFAULT => -22 | ||
| 266 | }, | ||
| 267 | {#State 41 | ||
| 268 | DEFAULT => -24 | ||
| 269 | }, | ||
| 270 | {#State 42 | ||
| 271 | DEFAULT => -34 | ||
| 272 | }, | ||
| 273 | {#State 43 | ||
| 274 | ACTIONS => { | ||
| 275 | "\nphrase: " => 48 | ||
| 276 | } | ||
| 277 | }, | ||
| 278 | {#State 44 | ||
| 279 | ACTIONS => { | ||
| 280 | 'REGEXP_SEQ' => 16, | ||
| 281 | 'WORD_SEQ' => 22, | ||
| 282 | 'POSTAG_TAG' => 12, | ||
| 283 | 'SEMTYPE_TAG' => 18, | ||
| 284 | 'TERMCONTENT_SEQ' => 10, | ||
| 285 | 'DISTANCE_SEQ' => 15, | ||
| 286 | 'error' => 52, | ||
| 287 | 'TERM_SEQ' => 20 | ||
| 288 | }, | ||
| 289 | GOTOS => { | ||
| 290 | 'REGEXP' => 54, | ||
| 291 | 'POSTAG' => 50, | ||
| 292 | 'WORD' => 49, | ||
| 293 | 'TERM' => 55, | ||
| 294 | 'DISTANCE' => 51, | ||
| 295 | 'SEMTYPE' => 56, | ||
| 296 | 'TERMCONTENT' => 53 | ||
| 297 | } | ||
| 298 | }, | ||
| 299 | {#State 45 | ||
| 300 | DEFAULT => -18 | ||
| 301 | }, | ||
| 302 | {#State 46 | ||
| 303 | DEFAULT => -4 | ||
| 304 | }, | ||
| 305 | {#State 47 | ||
| 306 | ACTIONS => { | ||
| 307 | 'REGEXP_SEQ' => -38, | ||
| 308 | 'CLOSE_CHUNK' => -38, | ||
| 309 | 'SEMTYPE_TAG' => -38, | ||
| 310 | 'TERMCONTENT_SEQ' => -38, | ||
| 311 | 'TERM_SEQ' => -38, | ||
| 312 | 'WORD_SEQ' => -38, | ||
| 313 | 'POSTAG_TAG' => -38, | ||
| 314 | 'error' => 43 | ||
| 315 | }, | ||
| 316 | GOTOS => { | ||
| 317 | 'phrase' => 57 | ||
| 318 | } | ||
| 319 | }, | ||
| 320 | {#State 48 | ||
| 321 | DEFAULT => -45 | ||
| 322 | }, | ||
| 323 | {#State 49 | ||
| 324 | DEFAULT => -44 | ||
| 325 | }, | ||
| 326 | {#State 50 | ||
| 327 | DEFAULT => -41 | ||
| 328 | }, | ||
| 329 | {#State 51 | ||
| 330 | ACTIONS => { | ||
| 331 | 'error' => 30, | ||
| 332 | 'ACTION_SEQ' => 32 | ||
| 333 | }, | ||
| 334 | GOTOS => { | ||
| 335 | 'ACTION' => 58 | ||
| 336 | } | ||
| 337 | }, | ||
| 338 | {#State 52 | ||
| 339 | ACTIONS => { | ||
| 340 | "\nTERM_CONTENT: " => 37, | ||
| 341 | "\nWORD: " => 38, | ||
| 342 | "\nDISTANCE: " => 35, | ||
| 343 | "\nTERM: " => 34, | ||
| 344 | "\nREGEXP: " => 39, | ||
| 345 | "\nPOSTAG: " => 41, | ||
| 346 | "\nSEMTYPE: " => 40 | ||
| 347 | } | ||
| 348 | }, | ||
| 349 | {#State 53 | ||
| 350 | DEFAULT => -43 | ||
| 351 | }, | ||
| 352 | {#State 54 | ||
| 353 | DEFAULT => -39 | ||
| 354 | }, | ||
| 355 | {#State 55 | ||
| 356 | DEFAULT => -42 | ||
| 357 | }, | ||
| 358 | {#State 56 | ||
| 359 | DEFAULT => -40 | ||
| 360 | }, | ||
| 361 | {#State 57 | ||
| 362 | ACTIONS => { | ||
| 363 | 'REGEXP_SEQ' => 16, | ||
| 364 | 'CLOSE_CHUNK' => 60, | ||
| 365 | 'SEMTYPE_TAG' => 18, | ||
| 366 | 'TERMCONTENT_SEQ' => 10, | ||
| 367 | 'TERM_SEQ' => 20, | ||
| 368 | 'WORD_SEQ' => 22, | ||
| 369 | 'POSTAG_TAG' => 12, | ||
| 370 | 'error' => 59 | ||
| 371 | }, | ||
| 372 | GOTOS => { | ||
| 373 | 'REGEXP' => 54, | ||
| 374 | 'POSTAG' => 50, | ||
| 375 | 'WORD' => 49, | ||
| 376 | 'TERM' => 55, | ||
| 377 | 'SEMTYPE' => 56, | ||
| 378 | 'TERMCONTENT' => 53 | ||
| 379 | } | ||
| 380 | }, | ||
| 381 | {#State 58 | ||
| 382 | ACTIONS => { | ||
| 383 | "\n" => 61 | ||
| 384 | } | ||
| 385 | }, | ||
| 386 | {#State 59 | ||
| 387 | ACTIONS => { | ||
| 388 | "\nTERM_CONTENT: " => 37, | ||
| 389 | "\nWORD: " => 38, | ||
| 390 | "\nTERM: " => 34, | ||
| 391 | "\nREGEXP: " => 39, | ||
| 392 | "\nPOSTAG: " => 41, | ||
| 393 | "\nSEMTYPE: " => 40 | ||
| 394 | } | ||
| 395 | }, | ||
| 396 | {#State 60 | ||
| 397 | DEFAULT => -36 | ||
| 398 | }, | ||
| 399 | {#State 61 | ||
| 400 | DEFAULT => -6 | ||
| 401 | } | ||
| 402 | ], | ||
| 403 | yyrules => | ||
| 404 | [ | ||
| 405 | [#Rule 0 | ||
| 406 | '$start', 2, undef | ||
| 407 | ], | ||
| 408 | [#Rule 1 | ||
| 409 | 'input', 0, undef | ||
| 410 | ], | ||
| 411 | [#Rule 2 | ||
| 412 | 'input', 2, | ||
| 413 | sub | ||
| 414 | #line 41 "lib/Lingua/Ogmios/NLPWrappers/PatternParser.yp" | ||
| 415 | { # print STDERR "INPUT $_[2] \n"; | ||
| 416 | } | ||
| 417 | ], | ||
| 418 | [#Rule 3 | ||
| 419 | 'line', 1, | ||
| 420 | sub | ||
| 421 | #line 45 "lib/Lingua/Ogmios/NLPWrappers/PatternParser.yp" | ||
| 422 | { $_[1] } | ||
| 423 | ], | ||
| 424 | [#Rule 4 | ||
| 425 | 'line', 4, | ||
| 426 | sub | ||
| 427 | #line 46 "lib/Lingua/Ogmios/NLPWrappers/PatternParser.yp" | ||
| 428 | { | ||
| 429 | # print STDERR "=>$_[1] ($action)\n"; | ||
| 430 | $_[0]->YYData->{PPRS}->addSynPattern($node_set, $action, $distance); | ||
| 431 | @$node_set = (); | ||
| 432 | } | ||
| 433 | ], | ||
| 434 | [#Rule 5 | ||
| 435 | '@1-0', 0, | ||
| 436 | sub | ||
| 437 | #line 51 "lib/Lingua/Ogmios/NLPWrappers/PatternParser.yp" | ||
| 438 | { #print STDERR "START\n"; | ||
| 439 | $node = $node_set; | ||
| 440 | } | ||
| 441 | ], | ||
| 442 | [#Rule 6 | ||
| 443 | 'line', 6, | ||
| 444 | sub | ||
| 445 | #line 53 "lib/Lingua/Ogmios/NLPWrappers/PatternParser.yp" | ||
| 446 | { | ||
| 447 | push @$node, shift @$node; | ||
| 448 | # print "++>$_[1] ($action)\n"; | ||
| 449 | $_[0]->YYData->{PPRS}->addSynPattern($node_set, $action, $distance); | ||
| 450 | @$node_set = (); | ||
| 451 | } | ||
| 452 | ], | ||
| 453 | [#Rule 7 | ||
| 454 | 'line', 2, | ||
| 455 | sub | ||
| 456 | #line 59 "lib/Lingua/Ogmios/NLPWrappers/PatternParser.yp" | ||
| 457 | { $_[0]->YYErrok } | ||
| 458 | ], | ||
| 459 | [#Rule 8 | ||
| 460 | 'pattern', 0, | ||
| 461 | sub | ||
| 462 | #line 68 "lib/Lingua/Ogmios/NLPWrappers/PatternParser.yp" | ||
| 463 | { #print STDERR "START\n"; | ||
| 464 | $node = $node_set; | ||
| 465 | } | ||
| 466 | ], | ||
| 467 | [#Rule 9 | ||
| 468 | 'pattern', 2, undef | ||
| 469 | ], | ||
| 470 | [#Rule 10 | ||
| 471 | 'pattern', 2, undef | ||
| 472 | ], | ||
| 473 | [#Rule 11 | ||
| 474 | 'pattern', 2, undef | ||
| 475 | ], | ||
| 476 | [#Rule 12 | ||
| 477 | 'pattern', 2, undef | ||
| 478 | ], | ||
| 479 | [#Rule 13 | ||
| 480 | 'pattern', 2, undef | ||
| 481 | ], | ||
| 482 | [#Rule 14 | ||
| 483 | 'pattern', 2, undef | ||
| 484 | ], | ||
| 485 | [#Rule 15 | ||
| 486 | 'pattern', 2, undef | ||
| 487 | ], | ||
| 488 | [#Rule 16 | ||
| 489 | 'pattern', 2, | ||
| 490 | sub | ||
| 491 | #line 78 "lib/Lingua/Ogmios/NLPWrappers/PatternParser.yp" | ||
| 492 | { $_[0]->YYErrok } | ||
| 493 | ], | ||
| 494 | [#Rule 17 | ||
| 495 | 'ACTION', 1, | ||
| 496 | sub | ||
| 497 | #line 81 "lib/Lingua/Ogmios/NLPWrappers/PatternParser.yp" | ||
| 498 | { | ||
| 499 | $action = $_[1]; | ||
| 500 | # print STDERR "ACTION: $action\n"; | ||
| 501 | } | ||
| 502 | ], | ||
| 503 | [#Rule 18 | ||
| 504 | 'ACTION', 2, | ||
| 505 | sub | ||
| 506 | #line 85 "lib/Lingua/Ogmios/NLPWrappers/PatternParser.yp" | ||
| 507 | { $_[0]->YYErrok } | ||
| 508 | ], | ||
| 509 | [#Rule 19 | ||
| 510 | 'DISTANCE', 1, | ||
| 511 | sub | ||
| 512 | #line 88 "lib/Lingua/Ogmios/NLPWrappers/PatternParser.yp" | ||
| 513 | { | ||
| 514 | $distance = $_[1]; | ||
| 515 | # print STDERR "DISTANCE: $distance\n"; | ||
| 516 | } | ||
| 517 | ], | ||
| 518 | [#Rule 20 | ||
| 519 | 'DISTANCE', 2, | ||
| 520 | sub | ||
| 521 | #line 92 "lib/Lingua/Ogmios/NLPWrappers/PatternParser.yp" | ||
| 522 | { $_[0]->YYErrok } | ||
| 523 | ], | ||
| 524 | [#Rule 21 | ||
| 525 | 'SEMTYPE', 1, | ||
| 526 | sub | ||
| 527 | #line 95 "lib/Lingua/Ogmios/NLPWrappers/PatternParser.yp" | ||
| 528 | { | ||
| 529 | # print STDERR "SEMTYPE $_[1]\n"; | ||
| 530 | push @$node, {'type' => 'semtype', | ||
| 531 | 'semtype' => $_[1]}; | ||
| 532 | } | ||
| 533 | ], | ||
| 534 | [#Rule 22 | ||
| 535 | 'SEMTYPE', 2, | ||
| 536 | sub | ||
| 537 | #line 100 "lib/Lingua/Ogmios/NLPWrappers/PatternParser.yp" | ||
| 538 | { $_[0]->YYErrok } | ||
| 539 | ], | ||
| 540 | [#Rule 23 | ||
| 541 | 'POSTAG', 1, | ||
| 542 | sub | ||
| 543 | #line 103 "lib/Lingua/Ogmios/NLPWrappers/PatternParser.yp" | ||
| 544 | { | ||
| 545 | # print STDERR "POSTAG $_[1]\n"; | ||
| 546 | push @$node, {'type' => 'postag', | ||
| 547 | 'postag' => $_[1]}; | ||
| 548 | } | ||
| 549 | ], | ||
| 550 | [#Rule 24 | ||
| 551 | 'POSTAG', 2, | ||
| 552 | sub | ||
| 553 | #line 108 "lib/Lingua/Ogmios/NLPWrappers/PatternParser.yp" | ||
| 554 | { $_[0]->YYErrok } | ||
| 555 | ], | ||
| 556 | [#Rule 25 | ||
| 557 | 'REGEXP', 1, | ||
| 558 | sub | ||
| 559 | #line 111 "lib/Lingua/Ogmios/NLPWrappers/PatternParser.yp" | ||
| 560 | { | ||
| 561 | # print STDERR "REGEXP $_[1]\n"; | ||
| 562 | push @$node, {'type' => 'word_re', | ||
| 563 | 'word_re' => $_[1]}; | ||
| 564 | } | ||
| 565 | ], | ||
| 566 | [#Rule 26 | ||
| 567 | 'REGEXP', 2, | ||
| 568 | sub | ||
| 569 | #line 116 "lib/Lingua/Ogmios/NLPWrappers/PatternParser.yp" | ||
| 570 | { $_[0]->YYErrok } | ||
| 571 | ], | ||
| 572 | [#Rule 27 | ||
| 573 | 'WORD', 1, | ||
| 574 | sub | ||
| 575 | #line 119 "lib/Lingua/Ogmios/NLPWrappers/PatternParser.yp" | ||
| 576 | { | ||
| 577 | # print STDERR "WORD $_[1]\n"; | ||
| 578 | push @$node, {'type' => 'word', | ||
| 579 | 'word' => $_[1]}; | ||
| 580 | } | ||
| 581 | ], | ||
| 582 | [#Rule 28 | ||
| 583 | 'WORD', 2, | ||
| 584 | sub | ||
| 585 | #line 124 "lib/Lingua/Ogmios/NLPWrappers/PatternParser.yp" | ||
| 586 | { $_[0]->YYErrok } | ||
| 587 | ], | ||
| 588 | [#Rule 29 | ||
| 589 | 'TERM', 1, | ||
| 590 | sub | ||
| 591 | #line 127 "lib/Lingua/Ogmios/NLPWrappers/PatternParser.yp" | ||
| 592 | { | ||
| 593 | # print STDERR "TERM $_[1]\n"; | ||
| 594 | push @$node, {'type' => 'term', | ||
| 595 | 'term' => $_[1]}; | ||
| 596 | } | ||
| 597 | ], | ||
| 598 | [#Rule 30 | ||
| 599 | 'TERM', 2, | ||
| 600 | sub | ||
| 601 | #line 132 "lib/Lingua/Ogmios/NLPWrappers/PatternParser.yp" | ||
| 602 | { $_[0]->YYErrok } | ||
| 603 | ], | ||
| 604 | [#Rule 31 | ||
| 605 | 'TERMCONTENT', 1, | ||
| 606 | sub | ||
| 607 | #line 135 "lib/Lingua/Ogmios/NLPWrappers/PatternParser.yp" | ||
| 608 | { | ||
| 609 | # print STDERR "TERMCONTENT $_[1]\n"; | ||
| 610 | push @$node, {'type' => 'termContent', | ||
| 611 | 'termContent' => $_[1]}; | ||
| 612 | } | ||
| 613 | ], | ||
| 614 | [#Rule 32 | ||
| 615 | 'TERMCONTENT', 2, | ||
| 616 | sub | ||
| 617 | #line 140 "lib/Lingua/Ogmios/NLPWrappers/PatternParser.yp" | ||
| 618 | { $_[0]->YYErrok } | ||
| 619 | ], | ||
| 620 | [#Rule 33 | ||
| 621 | 'SYN_DEP', 1, | ||
| 622 | sub | ||
| 623 | #line 143 "lib/Lingua/Ogmios/NLPWrappers/PatternParser.yp" | ||
| 624 | { | ||
| 625 | # print STDERR "SYNDEP $_[1]\n"; | ||
| 626 | push @$node, {'type' => 'syndep', | ||
| 627 | 'syndep' => $_[1]}; | ||
| 628 | } | ||
| 629 | ], | ||
| 630 | [#Rule 34 | ||
| 631 | 'SYN_DEP', 2, | ||
| 632 | sub | ||
| 633 | #line 148 "lib/Lingua/Ogmios/NLPWrappers/PatternParser.yp" | ||
| 634 | { $_[0]->YYErrok } | ||
| 635 | ], | ||
| 636 | [#Rule 35 | ||
| 637 | '@2-1', 0, | ||
| 638 | sub | ||
| 639 | #line 153 "lib/Lingua/Ogmios/NLPWrappers/PatternParser.yp" | ||
| 640 | { my $nodetmp = []; | ||
| 641 | push @node_stack, $node; | ||
| 642 | push @$node, {'type' => 'chunk', | ||
| 643 | 'chunk' => $nodetmp }; | ||
| 644 | $node = $nodetmp; | ||
| 645 | } | ||
| 646 | ], | ||
| 647 | [#Rule 36 | ||
| 648 | 'CHUNK', 5, | ||
| 649 | sub | ||
| 650 | #line 158 "lib/Lingua/Ogmios/NLPWrappers/PatternParser.yp" | ||
| 651 | { | ||
| 652 | # print STDERR "CHUNK $_[3]\n"; | ||
| 653 | push @$node, shift @$node; | ||
| 654 | $node = pop @node_stack; | ||
| 655 | } | ||
| 656 | ], | ||
| 657 | [#Rule 37 | ||
| 658 | 'CHUNK', 2, | ||
| 659 | sub | ||
| 660 | #line 163 "lib/Lingua/Ogmios/NLPWrappers/PatternParser.yp" | ||
| 661 | { $_[0]->YYErrok } | ||
| 662 | ], | ||
| 663 | [#Rule 38 | ||
| 664 | 'phrase', 0, | ||
| 665 | sub | ||
| 666 | #line 167 "lib/Lingua/Ogmios/NLPWrappers/PatternParser.yp" | ||
| 667 | {# print STDERR "phrase\n"; | ||
| 668 | } | ||
| 669 | ], | ||
| 670 | [#Rule 39 | ||
| 671 | 'phrase', 2, undef | ||
| 672 | ], | ||
| 673 | [#Rule 40 | ||
| 674 | 'phrase', 2, undef | ||
| 675 | ], | ||
| 676 | [#Rule 41 | ||
| 677 | 'phrase', 2, undef | ||
| 678 | ], | ||
| 679 | [#Rule 42 | ||
| 680 | 'phrase', 2, undef | ||
| 681 | ], | ||
| 682 | [#Rule 43 | ||
| 683 | 'phrase', 2, undef | ||
| 684 | ], | ||
| 685 | [#Rule 44 | ||
| 686 | 'phrase', 2, undef | ||
| 687 | ], | ||
| 688 | [#Rule 45 | ||
| 689 | 'phrase', 2, | ||
| 690 | sub | ||
| 691 | #line 175 "lib/Lingua/Ogmios/NLPWrappers/PatternParser.yp" | ||
| 692 | { $_[0]->YYErrok } | ||
| 693 | ] | ||
| 694 | ], | ||
| 695 | @_); | ||
| 696 | bless($self,$class); | ||
| 697 | } | ||
| 698 | |||
| 699 | #line 178 "lib/Lingua/Ogmios/NLPWrappers/PatternParser.yp" | ||
| 700 | |||
| 701 | |||
| 702 | |||
| 703 | |||
| 704 | sub _Error { | ||
| 705 | exists $_[0]->YYData->{ERRMSG} | ||
| 706 | and do { | ||
| 707 | print $_[0]->YYData->{ERRMSG}; | ||
| 708 | delete $_[0]->YYData->{ERRMSG}; | ||
| 709 | return; | ||
| 710 | }; | ||
| 711 | print STDERR "Syntax error.\n"; | ||
| 712 | print "Syntax error.\n"; | ||
| 713 | } | ||
| 714 | |||
| 715 | sub _Lexer { | ||
| 716 | my($parser)=shift; | ||
| 717 | |||
| 718 | my $fh = $parser->YYData->{FH}; | ||
| 719 | |||
| 720 | my $semtype = '(@semtype\(([^\)]+)\))'; | ||
| 721 | my $openchunk = '(\[)'; | ||
| 722 | my $closechunk = '(\])'; | ||
| 723 | my $syn_dep = '(@syndep\(([^\)]+)\))'; | ||
| 724 | my $postag = '(@postag\(([^\)]+)\))'; | ||
| 725 | # my $regexp = '(@re_begin(.*?)@re_end)'; | ||
| 726 | my $regexp = '(@word_re(\(.*?\))@)'; | ||
| 727 | my $termcontent = '(@term\(([^\)]+)\))'; | ||
| 728 | my $term = '(@term@)'; | ||
| 729 | my $word = '([^ \|\n\]]+)'; | ||
| 730 | my $action = '(\|\|\s*([^\n]+))'; | ||
| 731 | my $distance = '(\|\|\s*([0-9]+))'; | ||
| 732 | |||
| 733 | $parser->YYData->{INPUT} | ||
| 734 | or $parser->YYData->{INPUT} = <$fh> | ||
| 735 | or return('', undef); | ||
| 736 | |||
| 737 | $parser->YYData->{INPUT} =~ s/^[ \t]*#.*//; | ||
| 738 | $parser->YYData->{INPUT} =~ s/^[ \t]*//; | ||
| 739 | |||
| 740 | # warn "==>" . $parser->YYData->{INPUT} . ";\n"; | ||
| 741 | # print "==>" . $parser->YYData->{INPUT} . ";\n"; | ||
| 742 | |||
| 743 | for ($parser->YYData->{INPUT}) { | ||
| 744 | s/^$semtype\s*// and return ('SEMTYPE_TAG', $2); | ||
| 745 | s/^$openchunk\s*// and return ('OPEN_CHUNK', $1); | ||
| 746 | s/^$closechunk// and return('CLOSE_CHUNK', $1); | ||
| 747 | s/^$syn_dep// and return('SYNDEP_SEQ', $2); | ||
| 748 | s/^$postag// and return('POSTAG_TAG', $2); | ||
| 749 | s/^$regexp// and return('REGEXP_SEQ', $2); | ||
| 750 | s/^$termcontent// and return('TERMCONTENT_SEQ', $2); | ||
| 751 | s/^$term// and return('TERM_SEQ', $1); | ||
| 752 | s/^$distance// and return('DISTANCE_SEQ', $2); | ||
| 753 | s/^$action// and return('ACTION_SEQ', $2); | ||
| 754 | s/^$word// and return('WORD_SEQ', $1); | ||
| 755 | s/^(.)//s and return($1,$1); | ||
| 756 | } | ||
| 757 | } | ||
| 758 | |||
| 759 | # sub Run { | ||
| 760 | # my($self)=shift; | ||
| 761 | # $self->YYParse( yylex => \&_Lexer, yyerror => \&_Error ); | ||
| 762 | # } | ||
| 763 | |||
| 764 | # my($parsingpattern)=new ParsingPatternParser; | ||
| 765 | # $parsingpattern->Run; | ||
| 766 | |||
| 767 | |||
| 768 | __END__ |