public void start() throws LiveIOProgramExecutionException { if (OS.isWindows()) { // C&C's craziness on Windows... this.modelsDir = this.modelsDir.replaceAll("\\\\", "\\\\\\\\"); } System.out.println("["+this.getClass().getName()+"] models directory = " +this.modelsDir); LinkedList<String> programAndArgs = new LinkedList<String>(); programAndArgs.add(this.programName); programAndArgs.add("--models"); programAndArgs.add(this.modelsDir); execution = new LiveIOProgramExecution(programAndArgs); execution.start(); converter = new TextToPennTreeBankConverter(); }
/** * After you are done with this converter, call this method * to clean up. * Don't call any other method of this converter later. */ public void end() { if (!finalizationDone) { if (execution!=null) { try{execution.endIO();}catch(Exception e){} try{convertionFile.delete();}catch(Exception e){} execution = null; convertionFile = null; finalizationDone = true; } } }
/** * Does the conversion. * @throws PennTreeBankConverterException */ public void convert() throws PennTreeBankConverterException { if (null==sentences) throw new PennTreeBankConverterException("sentences are null. Call setSentences() before calling this method."); try { start(); convertedSentences = new ArrayList<String>(this.sentences.size()); for (String sentence : this.sentences) { execution.putLine(sentence); String convertedLine = execution.getLine(TIME_OUT); convertedSentences.add(convertedLine); } } catch(LiveIOProgramExecutionException e) { throw new PennTreeBankConverterException("Cannot run the script. See nested exception",e); } }
ex.printStackTrace(); System.out.println("finalizing"); try{execution.endIO();}catch(Exception x){} if (liveIoProgramExecutionExceptionThrown) execution.destroyProcess(); try{converter.end();}catch(Exception x){}
try{execution.endIO();}catch(Exception e){} if (liveIoProgramExecutionExceptionThrown) execution.destroyProcess(); try{converter.end();}catch(Exception e){}
/** * Parser initializations. * @throws LiveIOProgramExecutionException */ private void start() throws LiveIOProgramExecutionException { if (OS.isWindows()) { // C&C's craziness on Windows... this.modelsDir = this.modelsDir.replaceAll("\\\\", "\\\\\\\\"); } System.out.println("["+this.getClass().getName()+"] models directory = " +this.modelsDir); LinkedList<String> programAndArgs = new LinkedList<String>(); programAndArgs.add(this.exec); programAndArgs.add(MODELS_ARG_SPECIFIER); programAndArgs.add(this.modelsDir); //execution = new LiveIOProgramExecution(programAndArgs,Charset.forName(C_AND_C_CHARSET),true); execution = new LiveIOProgramExecution(programAndArgs,java.nio.charset.Charset.forName(C_AND_C_CHARSET),false,false,true); //execution = new LiveIOProgramExecution(programAndArgs,null,true,false,true); //execution = new LiveIOProgramExecution(programAndArgs); execution.start(); converter = new eu.excitementproject.eop.lap.biu.en.tokenizer.TextToPennTreeBankConverter(); }
public void windowClosing(WindowEvent e) { System.out.println("window closing"); try{execution.endIO();}catch(Exception x){} try{converter.end();}catch(Exception x){} System.exit(0); } }
protected void start() throws LiveIOProgramExecutionException, PennTreeBankConverterException { if (execution!=null) ; else { try { createConvertionScript(); LinkedList<String> programAndArguments = new LinkedList<String>(); programAndArguments.add(CONVERTER_PROGRAM); programAndArguments.addAll(Utils.arrayToCollection(CONVERTER_PARAMS, new ArrayList<String>(CONVERTER_PARAMS.length))); programAndArguments.add(CONVERTER_SCRIPT_NAME_SPECIFIER_PARAM); programAndArguments.add(convertionFile.getAbsolutePath()); execution = new LiveIOProgramExecution(programAndArguments); execution.start(); } catch(IOException e) { throw new PennTreeBankConverterException("script creation failure. See nested exception",e); } } }