$search
00001 package instruction.test; 00002 00003 import java.io.File; 00004 import java.util.ArrayList; 00005 import java.util.Iterator; 00006 import instruction.semanticObjects.Instruction; 00007 import instruction.syntaxparser.Parser; 00008 00009 public class TestTrainingSet { 00010 00014 public static void main( String[] args ) { 00015 00016 Parser parser = new Parser(); 00017 // InstructionFactory factory = new InstructionFactory( parser ); 00018 // Disambiguator disambiguator = new Disambiguator(); 00019 // InstructionPostProcessor postProc = new InstructionPostProcessor(); 00020 00021 File howtos = new File( "howtos" ); 00022 00023 if ( howtos.isDirectory() ) { 00024 String[] files = howtos.list(); 00025 for ( int i = 0; i < files.length; i++ ) { 00026 File tmp = new File( files[i] ); 00027 if ( tmp.isDirectory() ) 00028 continue; 00029 00030 parser.setFileToParse( howtos.getName() + File.separator + files[i] ); 00031 00032 ArrayList<Instruction> howto = new ArrayList<Instruction>(); 00033 00034 for ( Iterator<String> iter = parser.iterator(); iter.hasNext(); ) { 00035 String sentence = iter.next(); 00036 // System.out.println( sentence ); 00037 00038 for ( int k = 0; k <= Parser.PRE_PROCESSOR_LOWER_CASE; k += Parser.PRE_PROCESSOR_LOWER_CASE ) { 00039 // parser.usePreProcessor( Parser.PRE_PROCESSOR_QUOTATION_MARKS 00040 // | Parser.PRE_PROCESSOR_USE_CIPHERS_ONLY | k ); 00041 00042 //SyntaxTree tree = 00043 parser.parse( sentence ); 00044 // tree.printTree(); 00045 try { 00046 // List<Instruction> instructions = factory.makeInstructions( tree ); 00047 // factory.findMeaningsForInstructions( instructions ); 00048 // postProc.run( instructions ); 00049 // disambiguator.disambiguateInstructions( instructions ); 00050 // howto.addAll( instructions ); 00051 // if ( ! instructions.isEmpty() ) 00052 // break; 00053 } 00054 catch ( Exception e ) { 00055 System.out.println( e.getMessage() ); 00056 e.printStackTrace(); 00057 continue; 00058 } 00059 } 00060 00061 } 00062 System.out.println( "***************************\nHOW TO " 00063 + files[i].replaceAll( "_", " " ).toUpperCase() ); 00064 for ( int j = 0; j < howto.size(); j++ ) 00065 System.out.println( howto.get( j ) ); 00066 00067 } 00068 } 00069 00070 } 00071 00072 }