1

When I am using the example from here I am getting the error

AttributeError: 'Tree' object has no attribute 'triples'

The version of the nltk I am using is 3.2.4, python 2.7. Any ideas of how to solve it are highly appreciated!

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())
student
  • 511
  • 1
  • 5
  • 20
  • The help string for `StanfordDependencyParser` mentions `parse.triples()` and `parse.trees()`, suggesting that the result should be a special parse object that can be viewed in different ways. In fact, `raw_parse()` returns a sequence of `Tree()` objects, not triples. Do you _need_ the triples for some reason? If not, just change your code to `print(dep)`. – alexis Jun 17 '17 at 13:06
  • Thank you for your response! I am really interested in the triples or something similar to Open IE https://nlp.stanford.edu/software/openie.html – student Jun 18 '17 at 16:25

0 Answers0