Skip to content

Instantly share code, notes, and snippets.

@Nectarineimp
Created November 15, 2012 18:38
Show Gist options
  • Select an option

  • Save Nectarineimp/4080357 to your computer and use it in GitHub Desktop.

Select an option

Save Nectarineimp/4080357 to your computer and use it in GitHub Desktop.
exploring coreferences from Stanford CoreNLP
Map<Integer, CorefChain> graph = document.get(CorefChainAnnotation.class);
for (Map.Entry<Integer, CorefChain> entry : graph.entrySet()) {
CorefChain c = entry.getValue();
System.out.println("\nClusterID: " + entry.getKey());
CorefMention cm = c.getRepresentativeMention();
if (cm != null) {
System.out.println("Representative Mention: " + cm.mentionSpan + " @" + cm.position.elems()[0] + " H:" + cm.position.elems()[1] + " [ " + cm.startIndex + ", " + cm.endIndex + "]");
List<CorefMention> cms = c.getCorefMentions();
System.out.print("Mentions:\n");
for (CorefMention mention : cms) {
System.out.print("\t" + mention.mentionSpan + " @" + mention.sentNum + " [" + mention.startIndex + ", " + mention.endIndex + "]");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment