Class CoreNlpUtils


  • public class CoreNlpUtils
    extends Object

    Main integration point to the CoreNLP pipeline.

    Singleton class: get instance via static getInstance(IParameterStore) call.

    getPipelineProps() returns a Properties object to configure the StanfordCoreNLP pipeline. MODIFY ONLY WITH EXTREME CARE!

    getPipeline() returns a (singleton) StanfordCoreNLP pipeline. NOT THREAD SAFE!

    Most of the rest of the methods are utility functions to integrate Tokens, Sentences, EntityMentions, CorefChains, and TypedDependencies.

    Author:
    Ram Sadasiv
    • Field Detail

      • coreNlpAnnotatorAliases

        public static List<String> coreNlpAnnotatorAliases
    • Method Detail

      • getPipelineProps

        public Properties getPipelineProps()
      • getPipeline

        public edu.stanford.nlp.pipeline.StanfordCoreNLP getPipeline()
      • getCoreEntityMentionFromToken

        public List<edu.stanford.nlp.pipeline.CoreEntityMention> getCoreEntityMentionFromToken​(edu.stanford.nlp.pipeline.CoreDocument document,
                                                                                               edu.stanford.nlp.ling.CoreLabel token)
      • getCoreEntityMentionFromCorefMention

        public List<edu.stanford.nlp.pipeline.CoreEntityMention> getCoreEntityMentionFromCorefMention​(edu.stanford.nlp.pipeline.CoreDocument document,
                                                                                                      edu.stanford.nlp.coref.data.CorefChain.CorefMention corefMention)
      • isCoreEntityMentionInAnyCorefChain

        public boolean isCoreEntityMentionInAnyCorefChain​(edu.stanford.nlp.pipeline.CoreDocument document,
                                                          edu.stanford.nlp.pipeline.CoreEntityMention entityMention)
      • getCorefChainFromCoreEntityMention

        public edu.stanford.nlp.coref.data.CorefChain getCorefChainFromCoreEntityMention​(edu.stanford.nlp.pipeline.CoreDocument document,
                                                                                         edu.stanford.nlp.pipeline.CoreEntityMention entityMention)
      • getTokenFromIndexedWord

        public edu.stanford.nlp.ling.CoreLabel getTokenFromIndexedWord​(edu.stanford.nlp.pipeline.CoreDocument document,
                                                                       edu.stanford.nlp.ling.IndexedWord word)
      • getTypedDependencyDepFromToken

        public List<edu.stanford.nlp.trees.TypedDependency> getTypedDependencyDepFromToken​(edu.stanford.nlp.pipeline.CoreDocument document,
                                                                                           edu.stanford.nlp.ling.CoreLabel token)
      • getTypedDependencyGovFromToken

        public List<edu.stanford.nlp.trees.TypedDependency> getTypedDependencyGovFromToken​(edu.stanford.nlp.pipeline.CoreDocument document,
                                                                                           edu.stanford.nlp.ling.CoreLabel token)
      • getCorefChainFromCorefMention

        public edu.stanford.nlp.coref.data.CorefChain getCorefChainFromCorefMention​(edu.stanford.nlp.pipeline.CoreDocument document,
                                                                                    edu.stanford.nlp.coref.data.CorefChain.CorefMention corefMention)
      • isCorefChainForCanonicalEntityName

        public boolean isCorefChainForCanonicalEntityName​(edu.stanford.nlp.pipeline.CoreDocument document,
                                                          edu.stanford.nlp.coref.data.CorefChain corefChain,
                                                          String canonicalEntityName)
      • isCoreEntityMentionForCanonicalEntityName

        public boolean isCoreEntityMentionForCanonicalEntityName​(edu.stanford.nlp.pipeline.CoreDocument document,
                                                                 edu.stanford.nlp.pipeline.CoreEntityMention entityMention,
                                                                 String canonicalEntityName)
      • getTokensFromCorefChain

        public List<edu.stanford.nlp.ling.CoreLabel> getTokensFromCorefChain​(edu.stanford.nlp.pipeline.CoreDocument document,
                                                                             edu.stanford.nlp.coref.data.CorefChain corefChain)
      • getTokensFromCorefMention

        public List<edu.stanford.nlp.ling.CoreLabel> getTokensFromCorefMention​(edu.stanford.nlp.pipeline.CoreDocument document,
                                                                               edu.stanford.nlp.coref.data.CorefChain.CorefMention corefMention)
      • getSentenceIdFromSentence

        public int getSentenceIdFromSentence​(edu.stanford.nlp.pipeline.CoreDocument document,
                                             edu.stanford.nlp.pipeline.CoreSentence sentence)
      • getSentenceFromToken

        public edu.stanford.nlp.pipeline.CoreSentence getSentenceFromToken​(edu.stanford.nlp.pipeline.CoreDocument document,
                                                                           edu.stanford.nlp.ling.CoreLabel token)
      • getSentenceFromCoreEntityMention

        public edu.stanford.nlp.pipeline.CoreSentence getSentenceFromCoreEntityMention​(edu.stanford.nlp.pipeline.CoreDocument document,
                                                                                       edu.stanford.nlp.pipeline.CoreEntityMention entityMention)
      • getTokensFromCoreEntityMention

        public List<edu.stanford.nlp.ling.CoreLabel> getTokensFromCoreEntityMention​(edu.stanford.nlp.pipeline.CoreDocument document,
                                                                                    edu.stanford.nlp.pipeline.CoreEntityMention entityMention)
      • getSentenceFromCorefMention

        public edu.stanford.nlp.pipeline.CoreSentence getSentenceFromCorefMention​(edu.stanford.nlp.pipeline.CoreDocument document,
                                                                                  edu.stanford.nlp.coref.data.CorefChain.CorefMention corefMention)
      • getCanonicalEntityNameFromCorefChain

        public String getCanonicalEntityNameFromCorefChain​(edu.stanford.nlp.pipeline.CoreDocument document,
                                                           edu.stanford.nlp.coref.data.CorefChain corefChain)
      • getGenderNameFromCorefChain

        public String getGenderNameFromCorefChain​(edu.stanford.nlp.pipeline.CoreDocument document,
                                                  edu.stanford.nlp.coref.data.CorefChain corefChain)
      • getCoreNlpGenderNameFromCoreEntityMention

        public String getCoreNlpGenderNameFromCoreEntityMention​(edu.stanford.nlp.pipeline.CoreDocument document,
                                                                edu.stanford.nlp.pipeline.CoreEntityMention entityMention)
      • getOOPGenderNameFromCoreEntityMention

        public String getOOPGenderNameFromCoreEntityMention​(edu.stanford.nlp.pipeline.CoreDocument document,
                                                            edu.stanford.nlp.pipeline.CoreEntityMention entityMention)