import java.util.*; import java.io.*; public class GrammarReader { static String TAB="\t"; BufferedReader fr = null; String line=""; String sourceData =""; String targetData =""; public Hashtable lex = new Hashtable(); String errMsg =""; String grammar_file_name = ""; //class constructor public GrammarReader(String gramfile){ grammar_file_name = gramfile; } //function to read the lexicon data and store it in a hashtable public Hashtable getForms(){ StringTokenizer st = null; errMsg = ""; try { fr = new BufferedReader( new FileReader(grammar_file_name) ); while ( ( line = fr.readLine() ) != null ) { sourceData = ""; targetData = ""; st = new StringTokenizer(line, "="); if( st.hasMoreTokens() ) { sourceData = st.nextToken(); } if( st.hasMoreTokens() ) { targetData = st.nextToken(); } lex.put(sourceData, targetData); }//WHILE } catch (Exception ex) { errMsg = "error in reading file... " + ex.toString() ; try { fr.close(); } catch (Exception cl) { } System.out.println(errMsg); } return lex; } }