$search
00001 package instruction.test; 00002 00003 import java.io.IOException; 00004 import java.util.List; 00005 import instruction.disambiguator.Disambiguator; 00006 import instruction.factory.InstructionFactory; 00007 import instruction.postprocessor.InstructionPostProcessor; 00008 import instruction.semanticObjects.Instruction; 00009 import instruction.syntaxparser.Parser; 00010 import instruction.syntaxparser.SyntaxTree; 00011 00012 public class TestCommandLine { 00013 00014 00015 public static boolean ARG_PRINT_PARSER_TREE = true; 00016 00020 public static void main( String[] args ) { 00021 00022 Parser parser = new Parser(); 00023 InstructionFactory factory = new InstructionFactory( parser ); 00024 Disambiguator disambiguator = new Disambiguator(); 00025 InstructionPostProcessor postProc = new InstructionPostProcessor(); 00026 00027 System.out.println( "Initializing OpenCyc..." ); 00028 System.out.println( "Ready for Services" ); 00029 00030 try { 00031 while ( true ) { 00032 System.out.print(">"); 00033 String s = ""; 00034 int r; 00035 do { 00036 r = System.in.read(); 00037 s += (char) r; 00038 } 00039 while ( r != (char) '\n' ); 00040 00041 parser.usePreProcessor( Parser.PRE_PROCESSOR_QUOTATION_MARKS 00042 | Parser.PRE_PROCESSOR_USE_CIPHERS_ONLY ); 00043 SyntaxTree t = parser.parse( s ); 00044 00045 if (ARG_PRINT_PARSER_TREE) 00046 t.printTree(); 00047 00048 try { 00049 00050 System.out.print("Making Instructions..."); 00051 List<Instruction> instructions = factory.makeInstructions( t ); 00052 System.out.println("Done."); 00053 00054 System.out.print("Retrieving Meanings of Words..."); 00055 // factory.findMeaningsForInstructions( instructions ); 00056 System.out.println("Done."); 00057 00058 System.out.print("Running Post-Processor..."); 00059 postProc.run( instructions ); 00060 System.out.println("Done."); 00061 00062 System.out.print("Running Disambiguator..."); 00063 disambiguator.disambiguateInstructions( instructions ); 00064 System.out.println("Done."); 00065 00066 // Print Instructions 00067 for (int i = 0; i < instructions.size(); i++) { 00068 System.out.println(instructions.get( i )); 00069 } 00070 00071 } 00072 catch ( Exception e ) { 00073 System.out.println(e.getMessage()); 00074 e.printStackTrace(); 00075 } 00076 00077 00078 } 00079 } 00080 catch ( IOException e ) { 00081 // TODO Auto-generated catch block 00082 e.printStackTrace(); 00083 } 00084 } 00085 00086 }