package ILMT::TEL::HIN::Repair::failsafe; use Dir::Self; use Exporter qw(import); use ILMT::TEL::HIN::SSFAPI::feature_filter; use ILMT::TEL::HIN::SSFAPI::shakti_tree_api; our @EXPORT = qw(failsafe); my $cwd = __DIR__; my %root_hash = (); my %vgnf_hash = (); sub preprocess { open(ROOTDICT,"$cwd/failsafe/data/suffix"); @ROOTS = ; chomp(@ROOTS); open(VGNFTAM,"$cwd/failsafe/data/vgnf-tam"); @VGNFT = ; chomp(@VGNFT); foreach my $root_1 (@ROOTS) { my ($root,$pdgm) = split(/\,/,$root_1); my $key = $root; $root_hash{ $key } = $pdgm; } foreach my $vgnftam (@VGNFT) { my ($root,$pdgm) = split(/\,/,$vgnftam); my $key = $root; $vgnf_hash{ $key } = $pdgm; } } sub failsafe { my %par = @_; my $input = $par{'data'}; read_story(\$input); my $result; my $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/)&&($posh!~/VGNF/))) { $new_lcath[0]="v"; } elsif(($lcath[0] eq "unk")&&(($posh=~/^NP/)||($posh=~/VGNF/))) { $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"; } ### #elsif(($lcath[0] eq "unk")&&($posh=~/BLK/)&&($pos eq "PSP")) { ### 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; #Children are been read here foreach $child (@childs) { my $pos = &get_field($child, 3,$sent); my $npos = &get_field($child-1, 3,$sent); my $token = &get_field($child, 2,$sent); my $val_fs=&get_field($child, 4,$sent); $fs_array = &read_FS($val_fs,$sent); #if($val_fs=~/[0-9],[0-9][^_']/){ # $val_fs=~s/([0-9]),([0-9])/$1\,$2/g; # &modify_field($child,4,$val_fs,$sent); #} my @lcat = &get_values("cat", $fs_array,$sent); my @root = &get_values("lex", $fs_array,$sent); if(($npos=~/Q/)&&($token=~/^sAr[lAiuUeo]/)){ $root[0]="sAri"; &update_attr_val("lex",\@root,$fs_array,$sent); my $string1 = &make_string($fs_array,$sent); &modify_field($child,4,$string1,$sent); } my @new_vib = &get_values("vib", $fs_array,$sent); # some one blocked this, can i know why- chris-261112 ##my @new_vib = &get_values("vib", $fs_array,$sent); #Processing on childrens of Heads if they are unk $key=$new_vib[0]; $pdgm=$vgnf_hash{$key}; chomp($pdgm); if(($posh eq "VGF")&&($pos eq "VM")&&($pdgm eq "yes")){ $newposh="VGNF"; &modify_field($node,3,$newposh,$sent); } if(($pos=~/VM/)&&($lcat[0]=~/n/)&&($val_fs=~/deri/)){ my @new_lcat; $new_lcat[0]="v"; &update_attr_val("cat",\@new_lcat,$fs_array,$sent); my $string = &make_string($fs_array,$sent); &modify_field($child,4,$string,$sent); } if(($pos=~/RB/)&&($lcat[0]=~/avy/)){ my @new_lcat; $new_lcat[0]="adv"; &update_attr_val("cat",\@new_lcat,$fs_array,$sent); my $string = &make_string($fs_array,$sent); &modify_field($child,4,$string,$sent); } if(($lcat[0]=~/^v/)&&($new_vib[0]=~/wU_uMdu_wU_uMdu_A/)){ #print "Imhere\n"; # my @new_lcat; $new_vib[0]="wU_uMdu_wA"; &update_attr_val("vib",\@new_vib,$fs_array,$sent); &update_attr_val("tam",\@new_vib,$fs_array,$sent); #&update_attr_val("cat",\@new_lcat,$fs_array,$sent); my $string = &make_string($fs_array,$sent); &modify_field($child,4,$string,$sent); } if($lcat[0] eq "unk") { if(($lcat[0] eq "unk")&&($pos eq "RB")){ $new_lcat[0]="adv"; if($root[0]=~/gA$/) { $root[0]=~s/gA$//g; $new_vib[0]="gA"; } &update_attr_val("lex",\@root,$fs_array,$sent); &update_attr_val("vib",\@new_vib,$fs_array,$sent); my $string1 = &make_string($fs_array,$sent); &modify_field($child,4,$string1,$sent); } elsif(($lcat[0] eq "unk")&&(($pos=~/NN/)||($posh=~/VGNF/))) { $new_lcat[0]="n"; $new_gen[0]="n"; $new_num[0]="sg"; $new_per[0]="3"; $new_vib[0]=~s/.*/0/; #print "iam here with $pdgm $key \n"; if($root[0]=~/lone$/) { $root[0]=~s/lone$//g; $new_vib[0]="lone"; } if($root[0]=~/nenA$/) { ##harinenA => hariwAnYA $root[0]=~s/nenA$//g; $new_vib[0]="nenA"; } if($root[0]=~/loki$/) { $root[0]=~s/loki$//g; $new_vib[0]="loki"; } if($root[0]=~/lo$|lopal[A-z]*$/) { $root[0]=~s/lo.*$//g; $new_vib[0]="lo"; ##print "new_vib=$new_vib[0]\n"; } if($root[0]=~/guriwo$/) { ##Aruguriwo $root[0]=~s/guriwo$/guru/g; $new_vib[0]="wo"; ##print "new_vib=$new_vib[0]\n"; } if($root[0]=~/([0-9]+)lak[iu]$/) { #$root[0]=~s/k[iu]$//g; $root[0]=~s/([0-9]+)lak[iu]$/$1/g; #$new_gen[0]="n"; ##$new_num[0]="pl"; $new_num[0]="sg"; $new_lcat[0]="num"; $new_vib[0]="ki"; } if($root[0]=~/([0-9]+)k[iu]$/) { #$root[0]=~s/k[iu]$//g; $root[0]=~s/([0-9]+)k[iu]$/$1/g; #$new_gen[0]="n"; ##$new_num[0]="pl"; $new_num[0]="sg"; $new_lcat[0]="num"; $new_vib[0]="ki"; } if($root[0]=~/Aniki$/) { ##SawAbxAniki $root[0]=~s/Aniki$/aM/g; $new_vib[0]="ki"; } if($root[0]=~/([A-z]+)k[iu]$/) { $root[0]=~s/k[iu]$//g; $new_vib[0]="ki"; } if($root[0]=~/[^BGCJN][AIUEVO]n[iu]$/) { $root[0]=~s/n[iu]$//g; $new_vib[0]="nu"; } if($root[0]=~/loni$/) { $root[0]=~s/loni$//g; $new_vib[0]="loni"; } if($root[0]=~/[^aAe]n[iu]$/) { $root[0]=~s/n[iu]$//g; $new_vib[0]="nu"; } if($root[0]=~/([0-9]+)(la)*n[iu]$/) { #$root[0]=~s/k[iu]$//g; ### $root[0]=~s/([0-9]+)(la)*n[iu]$/$1/g; $new_num[0]="pl"; $new_vib[0]="ni"; } if($root[0]=~/([A-z])lanu$/) { $root[0]=~s/lanu//g; $new_num[0]="pl"; $new_vib[0]="ni"; } if($root[0]=~/elYlanuMdI$/) { #elYlanuMdI $root[0]=~s/elYlanuMdI/edu/g; $new_num[0]="pl"; $new_vib[0]="nuMdI"; } if($root[0]=~/[^aAiIuUooeEV]xi$/) { $root[0]=~s/xi//g; $new_vib[0]="xi"; } if($root[0]=~/wo$/) { $root[0]=~s/wo//g; $new_vib[0]="wo"; } if($root[0]=~/wobAtu$/) { $root[0]=~s/wobAtu//g; $new_vib[0]="wobAtu"; } if($root[0]=~/n[ui]M[cd]i$/) { $root[0]=~s/n[iu]M[cd]i$//; $new_vib[0]="nuMdi"; } if($root[0]=~/kosaM$|karaku$/) { $root[0]=~s/kosaM$|karaku$//g; $new_vib[0]="kosaM"; } if($root[0]=~/kiMx[A-z]*$/) { $root[0]=~s/kiMx[A-z]*$//g; $new_vib[0]="kiMxa"; } if($root[0]=~/([A-z]+)pE[A-z]*$/) { $root[0]=~s/pE[A-z]*$//g; $new_vib[0]="pEna"; } #PARAMESH 17_02_10 word like "raMXramani" if($root[0]=~/amani$/) { $root[0]=~s/amani/aM/g; $new_vib[0]="ani"; } if($root[0]=~/lu$/) { $root[0]=~s/lu//g; $new_vib[0]="0"; $new_num[0]="pl"; } if($root[0]=~/vu$/) { $root[0]=~s/vu//g; $new_vib[0]="0"; $new_num[0]="sg"; $new_gen[0]="any"; $new_per[0]="2"; } if($root[0]=~/Mcabadina$/) { ##'nirmiMcabadina $root[0]=~s/Mcabadina/Mcu/g; $new_lcat[0]="v"; $new_vib[0]="a_badu_ina"; $new_num[0]="any"; $new_gen[0]="any"; $new_per[0]="any"; } # if($root[0] ne "") { # $new_vib[0]="0"; # } #else{$new_vib[0]="0"; } &update_attr_val("lex",\@root,$fs_array,$sent); &update_attr_val("tam",\@new_vib,$fs_array,$sent); &update_attr_val("gen",\@new_gen,$fs_array,$sent); &update_attr_val("num",\@new_num,$fs_array,$sent); &update_attr_val("per",\@new_per,$fs_array,$sent); &update_attr_val("vib",\@new_vib,$fs_array,$sent); my $string1 = &make_string($fs_array,$sent); &modify_field($child,4,$string1,$sent); } 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 "pn")&&($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=~/Q[C|O]/)) { $new_lcat[0]="num"; if($root[0]=~/([A-z]*)/) { $root[0]=~/([0-9]*)(.*)/; $new_root[0]=$1; $new_vib[0]=$2; &update_attr_val("lex",\@new_root,$fs_array,$sent); &update_attr_val("vib",\@new_vib,$fs_array,$sent); my $string1 = &make_string($fs_array,$sent); &modify_field($child,4,$string1,$sent); } } 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=""; } #The chunk change takes place. ############################################################################################# #Blocked by PARAMESH 210111,since the following VGNN is chnged in2 NP #4 (( VGNN #4.1 addukovadaM VM #4.2 valla PSP # )) # if(($posh ne "NP")&&($lcat[0] eq "n")&&($pos=~/NN|UT|JJ|CC|PSP|Q[CF]|VM/)) { if(($posh=~/BLK|GNN/)) { $posh="NP"; &modify_field($node,3,$posh,$sent); if(($pos=~/V/)&&($lcat[0] eq "n")){$pos="NN"; &modify_field($child,3,$pos,$sent); } } } if(($posh eq "NP")&&($lcat[0] eq "adj")&&($pos=~/NN|UT|CC|PSP|Q[CF]|VM/)) { if(($pos=~/N|V|P/)&&($lcat[0] eq "adj")){$pos="JJ"; &modify_field($child,3,$pos,$sent); } } ############################################################################################## #elsif(($posh ne "VGF" or $posh ne "VGNF" or $posh ne "VGNN")&&($lcat[0] eq "v" or $lcat[0] eq "pn")&&($pos=~/VM|VAUX|RB/)) { #$new_posh="VGF"; } # #elsif(($posh ne "JJP")&&($lcat[0] eq "adj")&&($pos=~/NN|JJ/)) { #$new_posh="JJP"; } #elsif(($posh ne "CCP")&&($lcat[0] eq "avy")&&($pos=~/CC/)) { #$new_posh="CCP"; } else { $new_posh=$posh; } ##if($new_posh ne ""){ ##&modify_field($node,3,$new_posh,$sent);} $posh=""; $pos=""; } } } } } open OUTFILE, '>', \$result or die $!; select(OUTFILE); printstory(); select(STDOUT); return $result; } preprocess(); 1;