Java Reference
In-Depth Information
gsf.newGrammaticalStructure(parseTree);
List<TypedDependency> tdl =
gs.typedDependenciesCCprocessed();
We can simply display the list as shown here:
System.out.println(tdl);
The output is as follows:
[det(cow-2, The-1), nsubj(jumped-3, cow-2), root(ROOT-0,
jumped-3), det(moon-6, the-5), prep_over(jumped-3, moon-6)]
This information can also be extracted using the gov , reln , and dep methods, which re-
turn the governor word, the relationship, and the dependent element, respectively, as illus-
trated here:
for(TypedDependency dependency : tdl) {
System.out.println("Governor Word: [" +
dependency.gov()
+ "] Relation: [" + dependency.reln().getLongName()
+ "] Dependent Word: [" + dependency.dep() + "]");
}
The output is as follows:
Governor Word: [cow/NN] Relation: [determiner] Dependent
Word: [The/DT]
Governor Word: [jumped/VBD] Relation: [nominal subject]
Dependent Word: [cow/NN]
Governor Word: [ROOT] Relation: [root] Dependent Word:
[jumped/VBD]
Governor Word: [moon/NN] Relation: [determiner] Dependent
Word: [the/DT]
Governor Word: [jumped/VBD] Relation: [prep_collapsed]
Dependent Word: [moon/NN]
From this, we can gleam the relationships within a sentence and the elements of the rela-
tionship.
Search WWH ::




Custom Search