/* author: date started: date finished: description: */ //the tagger uses classes (Hashtable, StringTokenizer) from this package import java.util.*; class LexiconBasedTagger{ static String LEX_FILE = "lexicon.txt"; static String GRAM_FILE = "grammar.txt"; static String TAB="\t"; static String SPACE = " "; static String MESSAGE_PREFIX_PARSE = "The tagged sentence is \n"; static String MESSAGE_PREFIX_TRANS = "The translated sentence is \n"; public static void main(String args[]){ String parsedSentence = ""; String translatedSentence = ""; StringTokenizer st_base = null; StringTokenizer st_paradigm = null; StringTokenizer st_form = null; //read lexicon LexiconReader lr = new LexiconReader(LEX_FILE); //read grammar GrammarReader gr = new GrammarReader(GRAM_FILE); Hashtable lf = gr.getForms(); Hashtable lex = lr.getLexiconData(); Object[] lfa = lf.values().toArray();//collection of all the forms //create empty variable for storing value String target_value_tagged = ""; String target_value_translated = ""; String translation = ""; String translated_verb = ""; //create variable for storing final sentence that we make from the inputs //System.out.println("hello i am here 1"); //String inputSentence = args[2]; //System.out.println("hello i am here 2"); //read arguments for(int i=0;i 0) translated_verb = translation; } }//while }// inner for }//catch if ( target_value_tagged.equals("") ) target_value_tagged = "cant tag"; parsedSentence = parsedSentence + args[i]+":"+target_value_tagged + "\n"; //re-ordering process according to Indian languages if (target_value_translated.indexOf("VERB") < 0) translatedSentence = translatedSentence + " "+target_value_translated; //translatedSentence = translatedSentence + " "+translated_verb; }// outer for //add the verb in the last translatedSentence = translatedSentence + " "+translated_verb; //System.out.println(MESSAGE_PREFIX_PARSE+"{"+parsedSentence+"}"); //System.out.println(MESSAGE_PREFIX_TRANS+translatedSentence); System.out.println( printMessage( 0, "{"+parsedSentence+"}" ) ) ; System.out.println( printMessage( 1, translatedSentence ) ); } public static String printMessage(int opt, String mess) { if (opt==0) return MESSAGE_PREFIX_PARSE + mess; else return MESSAGE_PREFIX_TRANS + mess; } }