当我使用此处的示例时,出现错误
AttributeError: 'Tree' object has no attribute 'triples'
我使用的 nltk 版本是 3.2.4,python 2.7。任何关于如何解决它的想法都非常感谢!
from nltk.parse.stanford import StanfordDependencyParser
path_to_jar = 'path_to/stanford-parser-full-2014-08-27/stanford-parser.jar'
path_to_models_jar = 'path_to/stanford-parser-full-2014-08-27/stanford-parser-3.4.1-models.jar'
dependency_parser = StanfordDependencyParser(path_to_jar=path_to_jar, path_to_models_jar=path_to_models_jar)
result = dependency_parser.raw_parse('I shot an elephant in my sleep')
dep = result.next()
print list(dep.triples())