edu.stanford.nlp.ling.AnnotationLookup Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of stanford-parser Show documentation
Show all versions of stanford-parser Show documentation
Stanford Parser processes raw text in English, Chinese, German, Arabic, and French, and extracts constituency parse trees.
package edu.stanford.nlp.ling;
import java.util.Map;
import edu.stanford.nlp.ling.CoreLabel.GenericAnnotation;
import edu.stanford.nlp.util.ErasureUtils;
import edu.stanford.nlp.util.Generics;
/** @author Anna Rafferty */
public class AnnotationLookup {
private AnnotationLookup() {}
public enum KeyLookup {
VALUE_KEY(CoreAnnotations.ValueAnnotation.class, OldFeatureLabelKeys.VALUE_KEY),
TAG_KEY(CoreAnnotations.PartOfSpeechAnnotation.class, OldFeatureLabelKeys.TAG_KEY),
WORD_KEY(CoreAnnotations.TextAnnotation.class, OldFeatureLabelKeys.WORD_KEY),
LEMMA_KEY(CoreAnnotations.LemmaAnnotation.class, OldFeatureLabelKeys.LEMMA_KEY),
CATEGORY_KEY(CoreAnnotations.CategoryAnnotation.class, OldFeatureLabelKeys.CATEGORY_KEY),
//PROJ_CAT_KEY(CoreAnnotations.ProjectedCategoryAnnotation.class, OldFeatureLabelKeys.PROJ_CAT_KEY),
//HEAD_WORD_KEY("edu.stanford.nlp.ling.TreeCoreAnnotations.HeadWordAnnotation", OldFeatureLabelKeys.HEAD_WORD_KEY),
//HEAD_TAG_KEY("edu.stanford.nlp.ling.TreeCoreAnnotations.HeadTagAnnotation", OldFeatureLabelKeys.HEAD_TAG_KEY),
INDEX_KEY(CoreAnnotations.IndexAnnotation.class, OldFeatureLabelKeys.INDEX_KEY),
ARG_KEY(CoreAnnotations.ArgumentAnnotation.class, OldFeatureLabelKeys.ARG_KEY),
MARKING_KEY(CoreAnnotations.MarkingAnnotation.class, OldFeatureLabelKeys.MARKING_KEY),
SEMANTIC_HEAD_WORD_KEY(CoreAnnotations.SemanticHeadWordAnnotation.class, OldFeatureLabelKeys.SEMANTIC_HEAD_WORD_KEY),
SEMANTIC_HEAD_POS_KEY(CoreAnnotations.SemanticHeadTagAnnotation.class, OldFeatureLabelKeys.SEMANTIC_HEAD_POS_KEY),
VERB_SENSE_KEY(CoreAnnotations.VerbSenseAnnotation.class, OldFeatureLabelKeys.VERB_SENSE_KEY),
CATEGORY_FUNCTIONAL_TAG_KEY(CoreAnnotations.CategoryFunctionalTagAnnotation.class, OldFeatureLabelKeys.CATEGORY_FUNCTIONAL_TAG_KEY),
NER_KEY(CoreAnnotations.NamedEntityTagAnnotation.class, OldFeatureLabelKeys.NER_KEY),
SHAPE_KEY(CoreAnnotations.ShapeAnnotation.class, OldFeatureLabelKeys.SHAPE_KEY),
LEFT_TERM_KEY(CoreAnnotations.LeftTermAnnotation.class, OldFeatureLabelKeys.LEFT_TERM_KEY),
PARENT_KEY(CoreAnnotations.ParentAnnotation.class, OldFeatureLabelKeys.PARENT_KEY),
SPAN_KEY(CoreAnnotations.SpanAnnotation.class, OldFeatureLabelKeys.SPAN_KEY),
BEFORE_KEY(CoreAnnotations.BeforeAnnotation.class, OldFeatureLabelKeys.BEFORE_KEY),
AFTER_KEY(CoreAnnotations.AfterAnnotation.class, OldFeatureLabelKeys.AFTER_KEY),
CURRENT_KEY(CoreAnnotations.OriginalTextAnnotation.class, OldFeatureLabelKeys.CURRENT_KEY),
ANSWER_KEY(CoreAnnotations.AnswerAnnotation.class, OldFeatureLabelKeys.ANSWER_KEY),
GOLDANSWER_Key(CoreAnnotations.GoldAnswerAnnotation.class, OldFeatureLabelKeys.GOLDANSWER_KEY),
FEATURES_KEY(CoreAnnotations.FeaturesAnnotation.class, OldFeatureLabelKeys.FEATURES_KEY),
INTERPRETATION_KEY(CoreAnnotations.InterpretationAnnotation.class, OldFeatureLabelKeys.INTERPRETATION_KEY),
ROLE_KEY(CoreAnnotations.RoleAnnotation.class, OldFeatureLabelKeys.ROLE_KEY),
GAZETTEER_KEY(CoreAnnotations.GazetteerAnnotation.class, OldFeatureLabelKeys.GAZETTEER_KEY),
STEM_KEY(CoreAnnotations.StemAnnotation.class, OldFeatureLabelKeys.STEM_KEY),
POLARITY_KEY(CoreAnnotations.PolarityAnnotation.class, OldFeatureLabelKeys.POLARITY_KEY),
CH_CHAR_KEY(CoreAnnotations.ChineseCharAnnotation.class, OldFeatureLabelKeys.CH_CHAR_KEY),
CH_ORIG_SEG_KEY(CoreAnnotations.ChineseOrigSegAnnotation.class, OldFeatureLabelKeys.CH_ORIG_SEG_KEY),
CH_SEG_KEY(CoreAnnotations.ChineseSegAnnotation.class, OldFeatureLabelKeys.CH_SEG_KEY),
BEGIN_POSITION_KEY(CoreAnnotations.CharacterOffsetBeginAnnotation.class, OldFeatureLabelKeys.BEGIN_POSITION_KEY),
END_POSITION_KEY(CoreAnnotations.CharacterOffsetEndAnnotation.class, OldFeatureLabelKeys.END_POSITION_KEY),
DOCID_KEY(CoreAnnotations.DocIDAnnotation.class, OldFeatureLabelKeys.DOCID_KEY),
SENTINDEX_KEY(CoreAnnotations.SentenceIndexAnnotation.class, OldFeatureLabelKeys.SENTINDEX_KEY),
IDF_KEY(CoreAnnotations.IDFAnnotation.class, "idf"),
END_POSITION_KEY2(CoreAnnotations.CharacterOffsetEndAnnotation.class, "endPosition"),
CHUNK_KEY(CoreAnnotations.ChunkAnnotation.class, "chunk"),
NORMALIZED_NER_KEY(CoreAnnotations.NormalizedNamedEntityTagAnnotation.class, "normalized"),
MORPHO_NUM_KEY(CoreAnnotations.MorphoNumAnnotation.class,"num"),
MORPHO_PERS_KEY(CoreAnnotations.MorphoPersAnnotation.class,"pers"),
MORPHO_GEN_KEY(CoreAnnotations.MorphoGenAnnotation.class,"gen"),
MORPHO_CASE_KEY(CoreAnnotations.MorphoCaseAnnotation.class,"case"),
WORDNET_SYN_KEY(CoreAnnotations.WordnetSynAnnotation.class,"wordnetsyn"),
PROTO_SYN_KEY(CoreAnnotations.ProtoAnnotation.class,"proto"),
DOCTITLE_KEY(CoreAnnotations.DocTitleAnnotation.class,"doctitle"),
DOCTYPE_KEY(CoreAnnotations.DocTypeAnnotation.class,"doctype"),
DOCDATE_KEY(CoreAnnotations.DocDateAnnotation.class,"docdate"),
DOCSOURCETYPE_KEY(CoreAnnotations.DocSourceTypeAnnotation.class,"docsourcetype"),
LINK_KEY(CoreAnnotations.LinkAnnotation.class,"link"),
SPEAKER_KEY(CoreAnnotations.SpeakerAnnotation.class,"speaker"),
AUTHOR_KEY(CoreAnnotations.AuthorAnnotation.class,"author"),
SECTION_KEY(CoreAnnotations.SectionAnnotation.class,"section"),
SECTIONID_KEY(CoreAnnotations.SectionIDAnnotation.class,"sectionID"),
SECTIONDATE_KEY(CoreAnnotations.SectionDateAnnotation.class,"sectionDate"),
// Thang Sep13: for Genia NER
HEAD_KEY(CoreAnnotations.HeadWordStringAnnotation.class, "head"),
GOVERNOR_KEY(CoreAnnotations.GovernorAnnotation.class, "governor"),
GAZ_KEY(CoreAnnotations.GazAnnotation.class, "gaz"),
ABBR_KEY(CoreAnnotations.AbbrAnnotation.class, "abbr"),
ABSTR_KEY(CoreAnnotations.AbstrAnnotation.class, "abstr"),
FREQ_KEY(CoreAnnotations.FreqAnnotation.class, "freq"),
WEB_KEY(CoreAnnotations.WebAnnotation.class, "web"),
// Also have "pos" for PartOfTag (POS is also the TAG_KEY - "tag", but "pos" makes more sense)
// Still keep "tag" for POS tag so we don't break anything
POS_TAG_KEY(CoreAnnotations.PartOfSpeechAnnotation.class, "pos");
public final Class coreKey;
public final String oldKey;
private KeyLookup(Class extends CoreAnnotation> coreKey, String oldKey) {
this.coreKey = coreKey;
this.oldKey = oldKey;
}
/**
* This constructor allows us to use reflection for loading old class keys.
* This is useful because we can then create distributions that do not have
* all of the classes required for all the old keys (such as trees package classes).
*/
private KeyLookup(String className, String oldKey) {
Class> keyClass;
try {
keyClass = Class.forName(className);
} catch(ClassNotFoundException e) {
GenericAnnotation