How can I call this jar from python and also capture the results:
c:> java -cp "C:\mallet-2.0.7\class;C:\mallet-2.0.7\lib\mallet-deps.jar" cc.mallet.fst.SimpleTagger --model-file nouncrf sample.txt
How can I call this jar from python and also capture the results:
c:> java -cp "C:\mallet-2.0.7\class;C:\mallet-2.0.7\lib\mallet-deps.jar" cc.mallet.fst.SimpleTagger --model-file nouncrf sample.txt
Use subprocess:
from subprocess import call
call(["java", "-jar", "foo.jar"])
You could also add other arguments like -cp
to the list:
call(["java", "-cp", "<yourclasspath>", "-jar", "foo.jar"])