module StanfordCoreNLP # @private Annotations = { 'nlp.trees.international.pennchinese.ChineseGrammaticalRelations' => [ 'AdjectivalModifierGRAnnotation', 'AdverbialModifierGRAnnotation', 'ArgumentGRAnnotation', 'AspectMarkerGRAnnotation', 'AssociativeMarkerGRAnnotation', 'AssociativeModifierGRAnnotation', 'AttributiveGRAnnotation', 'AuxModifierGRAnnotation', 'AuxPassiveGRAnnotation', 'BaGRAnnotation', 'ClausalComplementGRAnnotation', 'ClausalSubjectGRAnnotation', 'ClauseModifierGRAnnotation', 'ComplementGRAnnotation', 'ComplementizerGRAnnotation', 'ControllingSubjectGRAnnotation', 'CoordinationGRAnnotation', 'DeterminerGRAnnotation', 'DirectObjectGRAnnotation', 'DvpMarkerGRAnnotation', 'DvpModifierGRAnnotation', 'EtcGRAnnotation', 'LocalizerComplementGRAnnotation', 'ModalGRAnnotation', 'ModifierGRAnnotation', 'NegationModifierGRAnnotation', 'NominalPassiveSubjectGRAnnotation', 'NominalSubjectGRAnnotation', 'NounCompoundModifierGRAnnotation', 'NumberModifierGRAnnotation', 'NumericModifierGRAnnotation', 'ObjectGRAnnotation', 'OrdNumberGRAnnotation', 'ParentheticalGRAnnotation', 'ParticipialModifierGRAnnotation', 'PreconjunctGRAnnotation', 'PrepositionalLocalizerModifierGRAnnotation', 'PrepositionalModifierGRAnnotation', 'PrepositionalObjectGRAnnotation', 'PunctuationGRAnnotation', 'RangeGRAnnotation', 'RelativeClauseModifierGRAnnotation', 'ResultativeComplementGRAnnotation', 'SemanticDependentGRAnnotation', 'SubjectGRAnnotation', 'TemporalClauseGRAnnotation', 'TemporalGRAnnotation', 'TimePostpositionGRAnnotation', 'TopicGRAnnotation', 'VerbCompoundGRAnnotation', 'VerbModifierGRAnnotation', 'XClausalComplementGRAnnotation' ], 'nlp.dcoref.CoNLL2011DocumentReader' => [ 'CorefMentionAnnotation', 'NamedEntityAnnotation' ], 'nlp.ling.CoreAnnotations' => [ 'AbbrAnnotation', 'AbgeneAnnotation', 'AbstrAnnotation', 'AfterAnnotation', 'AnswerAnnotation', 'AnswerObjectAnnotation', 'AntecedentAnnotation', 'ArgDescendentAnnotation', 'ArgumentAnnotation', 'BagOfWordsAnnotation', 'BeAnnotation', 'BeforeAnnotation', 'BeginIndexAnnotation', 'BestCliquesAnnotation', 'BestFullAnnotation', 'CalendarAnnotation', 'CategoryAnnotation', 'CategoryFunctionalTagAnnotation', 'CharacterOffsetBeginAnnotation', 'CharacterOffsetEndAnnotation', 'CharAnnotation', 'ChineseCharAnnotation', 'ChineseIsSegmentedAnnotation', 'ChineseOrigSegAnnotation', 'ChineseSegAnnotation', 'ChunkAnnotation', 'CoarseTagAnnotation', 'CommonWordsAnnotation', 'CoNLLDepAnnotation', 'CoNLLDepParentIndexAnnotation', 'CoNLLDepTypeAnnotation', 'CoNLLPredicateAnnotation', 'CoNLLSRLAnnotation', 'ContextsAnnotation', 'CopyAnnotation', 'CostMagnificationAnnotation', 'CovertIDAnnotation', 'D2_LBeginAnnotation', 'D2_LEndAnnotation', 'D2_LMiddleAnnotation', 'DayAnnotation', 'DependentsAnnotation', 'DictAnnotation', 'DistSimAnnotation', 'DoAnnotation', 'DocDateAnnotation', 'DocIDAnnotation', 'DomainAnnotation', 'EndIndexAnnotation', 'EntityClassAnnotation', 'EntityRuleAnnotation', 'EntityTypeAnnotation', 'FeaturesAnnotation', 'FemaleGazAnnotation', 'FirstChildAnnotation', 'ForcedSentenceEndAnnotation', 'FreqAnnotation', 'GazAnnotation', 'GazetteerAnnotation', 'GenericTokensAnnotation', 'GeniaAnnotation', 'GoldAnswerAnnotation', 'GovernorAnnotation', 'GrandparentAnnotation', 'HaveAnnotation', 'HeadWordStringAnnotation', 'HeightAnnotation', 'IDAnnotation', 'IDFAnnotation', 'INAnnotation', 'IndexAnnotation', 'InterpretationAnnotation', 'IsDateRangeAnnotation', 'IsURLAnnotation', 'LabelAnnotation', 'LastGazAnnotation', 'LastTaggedAnnotation', 'LBeginAnnotation', 'LeftChildrenNodeAnnotation', 'LeftTermAnnotation', 'LemmaAnnotation', 'LEndAnnotation', 'LengthAnnotation', 'LMiddleAnnotation', 'MaleGazAnnotation', 'MarkingAnnotation', 'MonthAnnotation', 'MorphoCaseAnnotation', 'MorphoGenAnnotation', 'MorphoNumAnnotation', 'MorphoPersAnnotation', 'NamedEntityTagAnnotation', 'NeighborsAnnotation', 'NERIDAnnotation', 'NormalizedNamedEntityTagAnnotation', 'NotAnnotation', 'NumericCompositeObjectAnnotation', 'NumericCompositeTypeAnnotation', 'NumericCompositeValueAnnotation', 'NumericObjectAnnotation', 'NumericTypeAnnotation', 'NumericValueAnnotation', 'NumerizedTokensAnnotation', 'NumTxtSentencesAnnotation', 'OriginalAnswerAnnotation', 'OriginalCharAnnotation', 'OriginalTextAnnotation', 'ParagraphAnnotation', 'ParagraphsAnnotation', 'ParaPositionAnnotation', 'ParentAnnotation', 'PartOfSpeechAnnotation', 'PercentAnnotation', 'PhraseWordsAnnotation', 'PhraseWordsTagAnnotation', 'PolarityAnnotation', 'PositionAnnotation', 'PossibleAnswersAnnotation', 'PredictedAnswerAnnotation', 'PrevChildAnnotation', 'PriorAnnotation', 'ProjectedCategoryAnnotation', 'ProtoAnnotation', 'RoleAnnotation', 'SectionAnnotation', 'SemanticHeadTagAnnotation', 'SemanticHeadWordAnnotation', 'SemanticTagAnnotation', 'SemanticWordAnnotation', 'SentenceIDAnnotation', 'SentenceIndexAnnotation', 'SentencePositionAnnotation', 'SentencesAnnotation', 'ShapeAnnotation', 'SpaceBeforeAnnotation', 'SpanAnnotation', 'SpeakerAnnotation', 'SRL_ID', 'SRLIDAnnotation', 'SRLInstancesAnnotation', 'StackedNamedEntityTagAnnotation', 'StateAnnotation', 'StemAnnotation', 'SubcategorizationAnnotation', 'TagLabelAnnotation', 'TextAnnotation', 'TokenBeginAnnotation', 'TokenEndAnnotation', 'TokensAnnotation', 'TopicAnnotation', 'TrueCaseAnnotation', 'TrueCaseTextAnnotation', 'TrueTagAnnotation', 'UBlockAnnotation', 'UnaryAnnotation', 'UnknownAnnotation', 'UtteranceAnnotation', 'UTypeAnnotation', 'ValueAnnotation', 'VerbSenseAnnotation', 'WebAnnotation', 'WordFormAnnotation', 'WordnetSynAnnotation', 'WordPositionAnnotation', 'WordSenseAnnotation', 'XmlContextAnnotation', 'XmlElementAnnotation', 'YearAnnotation' ], 'nlp.dcoref.CorefCoreAnnotations' => [ 'CorefAnnotation', 'CorefChainAnnotation', 'CorefClusterAnnotation', 'CorefClusterIdAnnotation', 'CorefDestAnnotation', 'CorefGraphAnnotation' ], 'nlp.ling.CoreLabel' => [ 'GenericAnnotation' ], 'nlp.trees.EnglishGrammaticalRelations' => [ 'AbbreviationModifierGRAnnotation', 'AdjectivalComplementGRAnnotation', 'AdjectivalModifierGRAnnotation', 'AdvClauseModifierGRAnnotation', 'AdverbialModifierGRAnnotation', 'AgentGRAnnotation', 'AppositionalModifierGRAnnotation', 'ArgumentGRAnnotation', 'AttributiveGRAnnotation', 'AuxModifierGRAnnotation', 'AuxPassiveGRAnnotation', 'ClausalComplementGRAnnotation', 'ClausalPassiveSubjectGRAnnotation', 'ClausalSubjectGRAnnotation', 'ComplementGRAnnotation', 'ComplementizerGRAnnotation', 'ConjunctGRAnnotation', 'ControllingSubjectGRAnnotation', 'CoordinationGRAnnotation', 'CopulaGRAnnotation', 'DeterminerGRAnnotation', 'DirectObjectGRAnnotation', 'ExpletiveGRAnnotation', 'IndirectObjectGRAnnotation', 'InfinitivalModifierGRAnnotation', 'MarkerGRAnnotation', 'ModifierGRAnnotation', 'MultiWordExpressionGRAnnotation', 'NegationModifierGRAnnotation', 'NominalPassiveSubjectGRAnnotation', 'NominalSubjectGRAnnotation', 'NounCompoundModifierGRAnnotation', 'NpAdverbialModifierGRAnnotation', 'NumberModifierGRAnnotation', 'NumericModifierGRAnnotation', 'ObjectGRAnnotation', 'ParataxisGRAnnotation', 'ParticipialModifierGRAnnotation', 'PhrasalVerbParticleGRAnnotation', 'PossessionModifierGRAnnotation', 'PossessiveModifierGRAnnotation', 'PreconjunctGRAnnotation', 'PredeterminerGRAnnotation', 'PredicateGRAnnotation', 'PrepositionalComplementGRAnnotation', 'PrepositionalModifierGRAnnotation', 'PrepositionalObjectGRAnnotation', 'PunctuationGRAnnotation', 'PurposeClauseModifierGRAnnotation', 'QuantifierModifierGRAnnotation', 'ReferentGRAnnotation', 'RelativeClauseModifierGRAnnotation', 'RelativeGRAnnotation', 'SemanticDependentGRAnnotation', 'SubjectGRAnnotation', 'TemporalModifierGRAnnotation', 'XClausalComplementGRAnnotation' ], 'nlp.trees.GrammaticalRelation' => [ 'DependentGRAnnotation', 'GovernorGRAnnotation', 'GrammaticalRelationAnnotation', 'KillGRAnnotation', 'Language', 'RootGRAnnotation' ], 'nlp.ie.machinereading.structure.MachineReadingAnnotations' => [ 'DependencyAnnotation', 'DocumentDirectoryAnnotation', 'DocumentIdAnnotation', 'EntityMentionsAnnotation', 'EventMentionsAnnotation', 'GenderAnnotation', 'RelationMentionsAnnotation', 'TriggerAnnotation' ], 'nlp.parser.lexparser.ParserAnnotations' => [ 'ConstraintAnnotation' ], 'nlp.trees.semgraph.SemanticGraphCoreAnnotations' => [ 'BasicDependenciesAnnotation', 'CollapsedCCProcessedDependenciesAnnotation', 'CollapsedDependenciesAnnotation' ], 'nlp.time.TimeAnnotations' => [ 'TimexAnnotation', 'TimexAnnotations' ], 'nlp.time.TimeExpression' => [ 'Annotation', 'ChildrenAnnotation' ], 'nlp.trees.TreeCoreAnnotations' => [ 'TreeHeadTagAnnotation', 'TreeHeadWordAnnotation', 'TreeAnnotation' ] } annotations_by_name = {} Annotations.each do |base_class, annotation_classes| annotation_classes.each do |annotation_class| annotations_by_name[annotation_class] ||= [] annotations_by_name[annotation_class] << base_class end end AnnotationsByName = annotations_by_name # Modify the Rjb JavaProxy class to add our own method to get annotations. Rjb::Rjb_JavaProxy.class_eval do # Dynamically defined on all proxied annotation classes. # Get an annotation using the annotation bridge. def get(annotation, anno_base = nil) if !java_methods.include?('get(Ljava.lang.Class;)') raise'No annotation can be retrieved on this object.' else anno_class = "#{StanfordCoreNLP.camel_case(annotation)}Annotation" if anno_base raise "The path #{anno_base} doesn't exist." unless Annotations[anno_base] anno_bases = [anno_base] else anno_bases = AnnotationsByName[anno_class] raise "The annotation #{anno_class} doesn't exist." unless anno_bases end if anno_bases.size > 1 msg = "There are many different annotations bearing the name #{anno_class}. " msg << "Please specify one of the following base classes as second parameter to disambiguate: " msg << anno_bases.join(',') raise msg else base_class = anno_bases[0] end url = "edu.stanford.#{base_class}$#{anno_class}" AnnotationBridge.getAnnotation(self, url) end end end end