I have this file called "lexparser.bat"
:: Runs the English PCFG parser on one or more files, printing trees only
:: usage: lexparser fileToparse
java -mx150m -cp "*;" edu.stanford.nlp.parser.lexparser.LexicalizedParser -outputFormat "penn,typedDependencies" edu/stanford/nlp/models/lexparser/englishPCFG.ser.gz %1
I have a text
Text = ['asdfd', 'ahksja',....]
and I tried to pass a sentence 'asdf' to lexparser.bat but it does not work.
for sentence in Text:
parser = os.popen("lexparser.bat", sentence)
However, if I have my text with .txt format, it works
parser = os.popen("lexparser.bat", "file.txt")
Whether this can be done and how depends on the syntax of this lexparser program, not on Python.
That said, as @RobKennedy suggested, this isn't how you pass an argument to
os.popen(). You probably want
subprocess instead, as
os.popen is deprecated. That would look like