Skip to content

Commit

Permalink
create a list of all coref mentions for the document
Browse files Browse the repository at this point in the history
  • Loading branch information
J38 authored and Stanford NLP committed Nov 1, 2017
1 parent b74d6bb commit cc4b6b6
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/edu/stanford/nlp/pipeline/MentionAnnotator.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package edu.stanford.nlp.pipeline;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
Expand Down Expand Up @@ -98,11 +99,13 @@ public void annotate(Annotation annotation) {
corefProperties.setProperty("removeNestedMentions", "true");
}
List<List<Mention>> mentions = md.findMentions(annotation, dictionaries, corefProperties);
annotation.set(CorefCoreAnnotations.CorefMentionsAnnotation.class , new ArrayList<Mention>());
int mentionIndex = 0;
int currIndex = 0;
for (CoreMap sentence : sentences) {
List<Mention> mentionsForThisSentence = mentions.get(currIndex);
sentence.set(CorefCoreAnnotations.CorefMentionsAnnotation.class, mentionsForThisSentence);
annotation.get(CorefCoreAnnotations.CorefMentionsAnnotation.class).addAll(mentionsForThisSentence);
// increment to next list of mentions
currIndex++;
// assign latest mentionID
Expand Down

0 comments on commit cc4b6b6

Please sign in to comment.