edu.stanford.nlp.dcoref.CorefCoreAnnotations Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of stanford-corenlp Show documentation
Show all versions of stanford-corenlp Show documentation
Stanford CoreNLP provides a set of natural language analysis tools which can take raw English language text input and give the base forms of words, their parts of speech, whether they are names of companies, people, etc., normalize dates, times, and numeric quantities, mark up the structure of sentences in terms of phrases and word dependencies, and indicate which noun phrases refer to the same entities. It provides the foundational building blocks for higher level text understanding applications.
package edu.stanford.nlp.dcoref;
import java.util.List;
import java.util.Map;
import java.util.Set;
import edu.stanford.nlp.ling.CoreAnnotation;
import edu.stanford.nlp.ling.CoreLabel;
import edu.stanford.nlp.util.ErasureUtils;
import edu.stanford.nlp.util.IntTuple;
import edu.stanford.nlp.util.Pair;
/**
* Similar to {@link edu.stanford.nlp.ling.CoreAnnotations},
* but this class contains
* annotations made specifically for storing Coref data. This is kept
* separate from CoreAnnotations so that systems which only need
* CoreAnnotations do not depend on Coref classes.
*/
public class CorefCoreAnnotations {
/**
* The standard key for the coref label.
* Not used by the new dcoref system.
*/
public static class CorefAnnotation implements CoreAnnotation {
@Override
public Class getType() {
return String.class;
}
}
/**
* Destination of the coreference link for this word (if any).
* It contains the index of the sentence and the index of the word that
* are the end of this coref link. Both indices start at 1. The
* sentence index is IntTuple.get(0); the token index in the
* sentence is IntTuple.get(1).
*/
public static class CorefDestAnnotation implements CoreAnnotation {
public Class getType() {
return IntTuple.class;
}
}
/**
* This stores the entire set of coreference links for one
* document. Each link is stored as a pair of pointers (source and
* destination), where each pointer stores a sentence offset and a
* token offset. All offsets start at 0.
*/
@Deprecated
public static class CorefGraphAnnotation implements CoreAnnotation>> {
public Class>> getType() {
return ErasureUtils.uncheckedCast(List.class);
}
}
/**
* An integer representing a document-level unique cluster of
* coreferent entities. In other words, if two entities have the
* same CorefClusterIdAnnotation, they are coreferent. This
* annotation is typically attached to tokens (CoreLabel).
*/
public static class CorefClusterIdAnnotation implements CoreAnnotation {
public Class getType() {
return Integer.class;
}
}
/**
* Set of all the CoreLabel objects which are coreferent with a
* CoreLabel. Note that the list includes the CoreLabel that was
* annotated which creates a cycle.
*
* @deprecated This was an original dcoref annotation. You should now use CorefChainAnnotation
*/
@Deprecated
public static class CorefClusterAnnotation implements CoreAnnotation> {
public Class> getType() {
return ErasureUtils.uncheckedCast(Set.class);
}
}
/**
* CorefChainID - CorefChain map.
*/
public static class CorefChainAnnotation implements CoreAnnotation