Java Reference
In-Depth Information
The Annotation class' get method, when used with an argument of Core-
fChainAnnotation.class , will return a Map instance of the CorefChain ob-
jects, as shown here. These objects contain information about the coreferences found in
the sentence:
Map<Integer, CorefChain> corefChainMap =
annotation.get(CorefChainAnnotation.class);
The set of the CorefChain objects is indexed using integers. We can iterate over these
objects as shown here. The key set is obtained and then each CorefChain object is dis-
played:
Set<Integer> set = corefChainMap.keySet();
Iterator<Integer> setIterator = set.iterator();
while(setIterator.hasNext()) {
CorefChain corefChain =
corefChainMap.get(setIterator.next());
System.out.println("CorefChain: " + corefChain);
}
The following output is generated:
CorefChain: CHAIN1-["He" in sentence 1, "his" in sentence 1]
CorefChain: CHAIN2-["his cash" in sentence 1]
CorefChain: CHAIN4-["she" in sentence 1, "her" in sentence
1]
CorefChain: CHAIN5-["her change" in sentence 1]
CorefChain: CHAIN7-["they" in sentence 1, "their" in
sentence 1]
CorefChain: CHAIN8-["their lunch" in sentence 1]
We get more detailed information using methods of the CorefChain and CorefMen-
tion classes. The latter class contains information about a specific coreference found in
the sentence.
Add the following code sequence to the body of the previous while loop to obtain and dis-
play this information. The startIndex and endIndex fields of the class refer to the
position of the words in the sentence:
Search WWH ::




Custom Search