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:

  • dependency.gov(): 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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.