I am trying to set several options for the StanfordDependencyParser that I am using with NLTK:
from nltk.parse.stanford import StanfordDependencyParser
os.environ['CLASSPATH'] = "path/to/stanford-parser-3.9.1-models.jar"
sdp = StanfordDependencyParser('path/to/stanford-parser-3.9.1-models.jar', corenlp_options=['-retainTmpSubcategories', '-originalDependencies'])
However, I get
raise OSError('Java command failed : ' + str(cmd))
OSError: Java command failed : ['C:\\Program Files\\Java\\jdk-11\\bin\\java.exe', '-mx1000m', '-cp', '\\stanford-parser.jar', 'edu.stanford.nlp.parser.lexparser.LexicalizedParser', '-model', 'edu/stanford/nlp/models/lexparser/englishPCFG.ser.gz', '-sentences', 'newline', '-outputFormat', 'conll2007', '-encoding', 'utf8', ['-retainTmpSubcategories', '-originalDependencies'], 'C:\\Users\\...']
(I removed some of the paths to make it clearer.)
If I only use
sdp = StanfordDependencyParser('path/to/stanford-parser-3.9.1-models.jar', corenlp_options=['-retainTmpSubcategories'])
or
sdp = StanfordDependencyParser('path/to/stanford-parser-3.9.1-models.jar', corenlp_options=['-originalDependencies'])
it works well...
I also looked at the nltk code, the _execute function which is used to compute the commande line
def _execute(self, cmd, input_, verbose=False):
encoding = self._encoding
cmd.extend(['-encoding', encoding])
if self.corenlp_options:
cmd.append(self.corenlp_options)
Does this mean that I can only put 1 single option in the corenlp_options argument??
Thank you for your help!!