I am trying to run a tagger through batch file for different files. This is my code:
String runap1="cd spt1"+"\n"+"java -Xss8192K -Xms128m -Xmx640m -classpath stanford-postagger.jar edu.stanford.nlp.tagger.maxent.MaxentTagger -model models/bidirectional-wsj-0-18.tagger -textFile "+fff[g]+">tag\\"+r1+"\nexit" ;
FileWriter fw1 = new FileWriter("ac.bat");
BufferedWriter bw1 = new BufferedWriter(fw1);
bw1.write(runap1);
bw1.close();
Runtime rx = Runtime.getRuntime();
Process p = null;
try {
p = rx.exec("cmd.exe /c start ac.bat");
} catch(Exception e) {
System.out.println("Error");
} // TODO
try {
Thread.sleep(15000);
} catch (InterruptedException e) {
System.out.println("Thread interrupted");
}
This takes a long time to process, and my PC hangs several times. I want to make a shared memory for the tagger to load it only once and all batch files will use that shared tagger; they should not load the tagger each time. How can I do this?