#!/usr/bin/perl use Getopt::Long; GetOptions("help!"=>\$help,"path=s"=>\$transfer_home,"resource=s"=>\$rule_file,"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 "Transfer Grammar Engine - Transfer Grammar Engine 1.0\n(29th June 2008)\n\n"; print "usage : ./run-transfer.pl --path=/home/Transfer_Engine-1.0 --resource=Rules [-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($transfer_home eq "") { print "Please Specify the Path as defined in --help\n"; exit(0); } if($rule_file eq "") { print "Please Specify the Path of the RULE FILE as in --help\n"; exit(0); } my $src=$transfer_home . "/src"; require "$src/load.pl"; require "$src/transfer_grammar.pl"; require "$src/modify.pl"; require "$transfer_home/API/shakti_tree_api.pl"; require "$transfer_home/API/feature_filter.pl"; sub main { undef (@_RULE_TREE_); open(ERR,">log"); my $ref_RULE_TREE_=&load($rule_file,\@_RULE_TREE_); # @_RULE_TREE_=@$ref_RULE_TREE_; if ($input eq "") { $input="/dev/stdin"; } # print "tree->",$_RULE_TREE_[0]->[0]->[0]->{"fs"}->[1]{"word"},"\n"; &read_story($input); $numBody = &get_bodycount(); for(my($bodyNum)=1;$bodyNum<=$numBody;$bodyNum++) { $body = &get_body($bodyNum,$body); # Count the number of Paragraphs in the story my($numPara) = &get_paracount($body); #print STDERR "Paras : $numPara\n"; # Iterate through paragraphs in the story for(my($i)=1;$i<=$numPara;$i++) { my($para); # Read Paragraph $para = &get_para($i); # Count the number of sentences in this paragraph my($numSent) = &get_sentcount($para); # print STDERR "\n $i no.of sent $numSent"; #print STDERR "Para Number $i, Num Sentences $numSent\n"; #print $numSent."\n"; # Iterate through sentences in the paragraph for(my($j)=1;$j<=$numSent;$j++) { #print " ... Processing sent $j\n"; # Read the sentence which is in SSF format my($sent) = &get_sent($para,$j); #print STDERR "$sent"; &transfer_grammar($sent,$ref_RULE_TREE_); } } } if($output eq "") { #&print_tree(); &printstory(); } if($output ne "") { #&print_tree_file("$output1"); &printstory_file("$output"); } } &main;