#!/usr/bin/perl use Getopt::Long; GetOptions("help!"=>\$help,"path=s"=>\$vibh_home,"input=s"=>\$input,"output=s",\$output); print "Unprocessed by Getopt::Long\n" if $ARGV[0]; foreach (@ARGV) { print "$_\n"; exit(0); } if($help eq 1) { print "Failsafe System Version 1.0\n(22th Oct 2009 )\n\n"; print "usage : perl ./failsafe.pl --path=\$PWD [-i inputfile|--input=\"input_file\"] [-o outputfile|--output=\"output_file\"] -rule hin/rule.rl\n"; print "\tIf the output file is not mentioned then the output will be printed to STDOUT\n"; exit(0); } if($vibh_home eq "") { print "Please Specify the Path as defined in --help\n"; exit(0); } require "$vibh_home/API/shakti_tree_api.pl"; require "$vibh_home/API/feature_filter.pl"; &read_story($input); $numBody = &get_bodycount(); for(my($bodyNum)=1;$bodyNum<=$numBody;$bodyNum++) { $body = &get_body($bodyNum,$body); my($numPara) = &get_paracount($body); for(my($i1)=1;$i1<=$numPara;$i1++) { my($para); $para = &get_para($i1); my($numSent) = &get_sentcount($para); for(my($j1)=1;$j1<=$numSent;$j1++) { $flag = 0; my($sent) = &get_sent($para,$j1); #Read All the heads my @all_childrennp =&get_nodes(3,"NP",$sent); my @all_childrenvgf =&get_nodes(3,"VGF",$sent); my @all_childrenvgnf =&get_nodes(3,"VGNF",$sent); my @all_childrenvgnn =&get_nodes(3,"VGNN",$sent); my @all_childrenjj =&get_nodes(3,"JJP",$sent); my @all_childrencc =&get_nodes(3,"CCP",$sent); my @all_childrenblk =&get_nodes(3,"BLK",$sent); my @all_childrenneg =&get_nodes(3,"NEGP",$sent); my @all_childrenrb =&get_nodes(3,"RBP",$sent); my @all_childrenfrag =&get_nodes(3,"FRAGP",$sent); @all_children=(@all_childrennp,@all_childrenvgf,@all_childrenvgnf,@all_childrenvgnn,@all_childrenjj,@all_childrencc,@all_childrenblk,@all_childrenneg,@all_childrenrb,@all_childrenfrag); $num = @all_children; for($i = 0; $i < $num; $i++) { my @all_childrennp =&get_nodes(3,"NP",$sent); my @all_childrenvgf =&get_nodes(3,"VGF",$sent); my @all_childrenvgnf =&get_nodes(3,"VGNF",$sent); my @all_childrenvgnn =&get_nodes(3,"VGNN",$sent); my @all_childrenjj =&get_nodes(3,"JJP",$sent); my @all_childrencc =&get_nodes(3,"CCP",$sent); my @all_childrenblk =&get_nodes(3,"BLK",$sent); my @all_childrenneg =&get_nodes(3,"NEGP",$sent); my @all_childrenrb =&get_nodes(3,"RBP",$sent); my @all_childrenfrag =&get_nodes(3,"FRAGP",$sent); @all_children=(@all_childrennp,@all_childrenvgf,@all_childrenvgnf,@all_childrenvgnn,@all_childrenjj,@all_childrencc,@all_childrenblk,@all_childrenneg,@all_childrenrb,@all_childrenfrag); $node = $all_children[$i]; #processing on the Head my $posh = &get_field($node, 3,$sent); my $val_fsh=&get_field($node, 4,$sent); $fs_arrayh = &read_FS($val_fsh,$sent); @lcath = &get_values("cat", $fs_arrayh,$sent); if(($lcath[0] eq "unk")&&($posh=~/^V/)) { $new_lcath[0]="v"; } elsif(($lcath[0] eq "unk")&&($posh=~/^NP/)) { $new_lcath[0]="n"; } elsif(($lcath[0] eq "unk")&&($posh=~/^J/)) { $new_lcath[0]="adj"; } elsif(($lcath[0] eq "unk")&&($posh=~/^C/)) { $new_lcath[0]="avy"; } elsif(($lcath[0] eq "unk")&&($posh=~/^RB/)) { $new_lcath[0]="adv"; } elsif(($lcath[0] eq "unk")&&($posh=~/^NE/)) { $new_lcath[0]="v"; } else{$new_lcath[0]=$lcath[0];} &update_attr_val("cat",\@new_lcath,$fs_arrayh,$sent); my $ret_string = &make_string($fs_arrayh,$sent); &modify_field($node,4,$ret_string,$sent); @new_lcath=""; my(@childs) = &get_children($node,$sent); $num_child = @childs; #Child are been read here foreach $child (@childs) { my $pos = &get_field($child, 3,$sent); my $val_fs=&get_field($child, 4,$sent); $fs_array = &read_FS($val_fs,$sent); my @lcat = &get_values("cat", $fs_array,$sent); #Processing on childrens of Heads if(($lcat[0] eq "unk")&&($pos=~/NN/)) { $new_lcat[0]="n";} elsif(($lcat[0] eq "unk")&&($pos=~/NNP/)) { $new_lcat[0]="n"; } elsif(($lcat[0] eq "unk")&&($pos=~/CL/)) { $new_lcat[0]="avy"; } elsif(($lcat[0] eq "unk")&&($pos=~/VM/)) { $new_lcat[0]="v"; } elsif(($lcat[0] eq "unk")&&($pos=~/VAUX/)) { $new_lcat[0]="v"; } elsif(($lcat[0] eq "unk")&&($pos=~/UT/)) { $new_lcat[0]="v"; } elsif(($lcat[0] eq "unk")&&($pos=~/NEG/)) { $new_lcat[0]="v"; } elsif(($lcat[0] eq "unk")&&($pos=~/JJ/)) { $new_lcat[0]="adj"; } elsif(($lcat[0] eq "unk")&&($pos=~/INTF/)) { $new_lcat[0]="avy"; } elsif(($lcat[0] eq "unk")&&($pos=~/RB/)) { $new_lcat[0]="adv"; } elsif(($lcat[0] eq "unk")&&($pos=~/PRP/)) { $new_lcat[0]="pn"; } elsif(($lcat[0] eq "unk")&&($pos=~/QF/)) { $new_lcat[0]="avy"; } elsif(($lcat[0] eq "unk")&&($pos=~/WQ/)) { $new_lcat[0]="pn"; } elsif(($lcat[0] eq "unk")&&($pos=~/PSP/)) { $new_lcat[0]="psp"; } elsif(($lcat[0] eq "unk")&&($pos=~/QC/)) { $new_lcat[0]="num"; } elsif(($lcat[0] eq "unk")&&($pos=~/QO/)) { $new_lcat[0]="num"; } elsif(($lcat[0] eq "unk")&&($pos=~/QF/)) { $new_lcat[0]="avy"; } elsif(($lcat[0] eq "unk")&&($pos=~/DEM/)) { $new_lcat[0]="avy"; } elsif(($lcat[0] eq "unk")&&($pos=~/RP/)) { $new_lcat[0]="avy"; } elsif(($lcat[0] eq "unk")&&($pos=~/CC/)) { $new_lcat[0]="avy"; } elsif(($lcat[0] eq "unk")&&($pos=~/INJ/)) { $new_lcat[0]="avy"; } elsif(($lcat[0] eq "unk")&&($pos=~/NST/)) { $new_lcat[0]="nst"; } else { $new_lcat[0]=$lcat[0]; } &update_attr_val("cat",\@new_lcat,$fs_array,$sent); my $string = &make_string($fs_array,$sent); &modify_field($child,4,$string,$sent); @new_lcat=""; } } } } } if($output eq "" ) { &printstory(); } else { &printstory_file("$output"); }