avy-replace.pl 1.71 KB
Newer Older
priyank's avatar
priyank committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
#!/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 "Telugu Generator  - Generator Version 0.91\n(9th Sep 2008 )\n\n";
	print "usage : perl ./tel_gen.pl --path=/home/tel_gen [-i inputfile|--input=\"input_file\"] [-o outputfile|--output=\"output_file\"] \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";

open(ROOTDICT,"$vibh_home/Avy");
@ROOTS = <ROOTDICT>;
chomp(@ROOTS);

%root_hash = ();
foreach $root_1 (@ROOTS)
{
	($root,$pdgm) = split(/\,/,$root_1);
	$key = $root;
	$root_hash{ $key } = $pdgm;
}


sub tel_gen
{
	&read($input);
	@nodes=&get_leaves();
	foreach $node (@nodes)
	{
		$fsSt = &get_field($node,4);
		$fs_array = &read_FS($fsSt);
		@lex = &get_values("lex", $fs_array);
		@cats = &get_values("cat", $fs_array);
		@tams = &get_values("vib", $fs_array);

		@gens = &get_values("gen", $fs_array);
		@nums = &get_values("num", $fs_array);
		@pers = &get_values("per", $fs_array);

		$root = $lex[0];
		$lcat = $cats[0];
		$tam = $tams[0];
		$gen = $gens[0];

		if( $lcat eq "Avy")
		{
		$key = $lex[0];
		$root = $root_hash{$key};
		if($root) {
		#$root= "\@".$root;
		$lex[0]=$root; 
		}
		else { $root=$lex[0]; }	
			&modify_field($node,4,"<fs af='$root,avy,,,,,,'>");
			}
		&modify_field($node,2,$root);
				

	}
}
&tel_gen();
if($output eq "")
{
	&print_tree();
}
else
{
	&print_tree_file($output);
}