Alvis-NLPPlatform

 view release on metacpan or  search on metacpan

lib/Alvis/NLPPlatform/ParseConstituents.yp  view on Meta::CPAN

#
# ParseConstituents.yp
# 
#  used to generate Alvis::NLPPlatform::ParseConstituents.pm
#
#  Use: yapp -m 'Alvis::NLPPlatform::ParseConstituents' -o lib/Alvis/NLPPlatform/ParseConstituents.pm lib/Alvis/NLPPlatform/ParseConstituents.yp
#
# Parse::Yapp input grammar for parsing the constituents of bioLG
#
#
#
%{
    use Alvis::NLPPlatform;
    use Data::Dumper;
    use warnings;


    our $VERSION=$Alvis::NLPPlatform::VERSION;

    my $doc_hash;
    my $decal_phrase_idx;

    my $debug_mode=0;
    my $lconst = 0;
    my $nconst;

    my @tab_nconst;
#     my @tab_type;
#     my @tab_string;
    my $tab_type_ref;
    my $tab_string_ref;

    my $lastword="";

    my $word_id_np_ref;

    my $word_count;

%}
%%

input: #empty
       | input line { push(@{$_[1]},$_[2]); $_[1] }
;

line:     '\n' { $_[1] }  
        | constituent '\n' 
	|  error '\nline: ' { $_[0]->YYErrok }
;

constituent: open constituent_content close 
	   |  error '\nconstituents: ' { $_[0]->YYErrok }

;

constituent_content: chunk {$_[1];}
                   | constituent
                   | constituent_content constituent_content
	   |  error '\nconstituent_content: ' { $_[0]->YYErrok }
;


open: OPEN {
	    # open constituent
	    if($lconst>0){
		push @{$$tab_string_ref[$tab_nconst[$lconst]]} , "phrase" . ($decal_phrase_idx+$$nconst+1) ;
	    }
	    $lconst++;
	    $$nconst++;
	    $tab_nconst[$lconst]=$$nconst;

	    # get type
	    $$tab_type_ref[$tab_nconst[$lconst]]=$_[1];



( run in 1.715 second using v1.01-cache-2.11-cpan-f56aa216473 )