public static void main ( String [ ] args ) throws IOException { if ( args . length == 0 ) { System . err . println ( "Usage: Dictionary dictionary_file" ) ; System . exit ( 0 ) ; } Dictionary dict = new Dictionary ( args [ 0 ] ) ; BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String line ; while ( null != ( line = in . readLine ( ) ) ) { String [ ] words = line . split ( " " ) ; if ( dict . contains ( words ) ) { System . out . println ( "Dictionary contains: " + line ) ; } else { System . out . println ( "Dictionary does not contain: " + line ) ; } } /* for (Iterator di = dict.iterator();di.hasNext();) { System.out.println(di.next()); } */ }
Allows a dictionery to be queried for specific n - grams from the command - line from statndard in using space delimited n - grams on a single line .