There's more...

We can use the TypedDependency list to provide more information about the tree. In the following for loop, we iterate over each dependency and display details about each one using the following methods:

  • This returns the governing word. Its originalText method returns a string containing the word and its type. A governing word is one that frequently requires another word to complete its meaning.
  • dependency.reln(): This returns the relationship between the governing word and the dependent word. The getLongName method returns the string representation of the relationship.
  • dependency.dep(): This returns the dependent word and its type.

These methods are then used to display more meaning output. Add the following ...

Get Natural Language Processing with Java Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.