Package io.outofprintmagazine.nlp.utils
Class CoreNlpUtils
- java.lang.Object
-
- io.outofprintmagazine.nlp.utils.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 Summary
Fields Modifier and Type Field Description static List<String>coreNlpAnnotatorAliases
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description StringgetCanonicalEntityNameFromCorefChain(edu.stanford.nlp.pipeline.CoreDocument document, edu.stanford.nlp.coref.data.CorefChain corefChain)List<edu.stanford.nlp.pipeline.CoreEntityMention>getCoreEntityMentionFromCorefMention(edu.stanford.nlp.pipeline.CoreDocument document, edu.stanford.nlp.coref.data.CorefChain.CorefMention corefMention)List<edu.stanford.nlp.pipeline.CoreEntityMention>getCoreEntityMentionFromToken(edu.stanford.nlp.pipeline.CoreDocument document, edu.stanford.nlp.ling.CoreLabel token)edu.stanford.nlp.coref.data.CorefChaingetCorefChainFromCoreEntityMention(edu.stanford.nlp.pipeline.CoreDocument document, edu.stanford.nlp.pipeline.CoreEntityMention entityMention)edu.stanford.nlp.coref.data.CorefChaingetCorefChainFromCorefMention(edu.stanford.nlp.pipeline.CoreDocument document, edu.stanford.nlp.coref.data.CorefChain.CorefMention corefMention)StringgetCoreNlpGenderNameFromCoreEntityMention(edu.stanford.nlp.pipeline.CoreDocument document, edu.stanford.nlp.pipeline.CoreEntityMention entityMention)StringgetGenderNameFromCorefChain(edu.stanford.nlp.pipeline.CoreDocument document, edu.stanford.nlp.coref.data.CorefChain corefChain)static CoreNlpUtilsgetInstance(IParameterStore parameterStore)StringgetOOPGenderNameFromCoreEntityMention(edu.stanford.nlp.pipeline.CoreDocument document, edu.stanford.nlp.pipeline.CoreEntityMention entityMention)edu.stanford.nlp.pipeline.StanfordCoreNLPgetPipeline()PropertiesgetPipelineProps()edu.stanford.nlp.pipeline.CoreSentencegetSentenceFromCoreEntityMention(edu.stanford.nlp.pipeline.CoreDocument document, edu.stanford.nlp.pipeline.CoreEntityMention entityMention)edu.stanford.nlp.pipeline.CoreSentencegetSentenceFromCorefMention(edu.stanford.nlp.pipeline.CoreDocument document, edu.stanford.nlp.coref.data.CorefChain.CorefMention corefMention)edu.stanford.nlp.pipeline.CoreSentencegetSentenceFromToken(edu.stanford.nlp.pipeline.CoreDocument document, edu.stanford.nlp.ling.CoreLabel token)intgetSentenceIdFromSentence(edu.stanford.nlp.pipeline.CoreDocument document, edu.stanford.nlp.pipeline.CoreSentence sentence)edu.stanford.nlp.ling.CoreLabelgetTokenFromIndexedWord(edu.stanford.nlp.pipeline.CoreDocument document, edu.stanford.nlp.ling.IndexedWord word)List<edu.stanford.nlp.ling.CoreLabel>getTokensFromCoreEntityMention(edu.stanford.nlp.pipeline.CoreDocument document, edu.stanford.nlp.pipeline.CoreEntityMention entityMention)List<edu.stanford.nlp.ling.CoreLabel>getTokensFromCorefChain(edu.stanford.nlp.pipeline.CoreDocument document, edu.stanford.nlp.coref.data.CorefChain corefChain)List<edu.stanford.nlp.ling.CoreLabel>getTokensFromCorefMention(edu.stanford.nlp.pipeline.CoreDocument document, edu.stanford.nlp.coref.data.CorefChain.CorefMention corefMention)List<edu.stanford.nlp.trees.TypedDependency>getTypedDependencyDepFromToken(edu.stanford.nlp.pipeline.CoreDocument document, edu.stanford.nlp.ling.CoreLabel token)List<edu.stanford.nlp.trees.TypedDependency>getTypedDependencyGovFromToken(edu.stanford.nlp.pipeline.CoreDocument document, edu.stanford.nlp.ling.CoreLabel token)booleanisCoreEntityMentionForCanonicalEntityName(edu.stanford.nlp.pipeline.CoreDocument document, edu.stanford.nlp.pipeline.CoreEntityMention entityMention, String canonicalEntityName)booleanisCoreEntityMentionInAnyCorefChain(edu.stanford.nlp.pipeline.CoreDocument document, edu.stanford.nlp.pipeline.CoreEntityMention entityMention)booleanisCorefChainForCanonicalEntityName(edu.stanford.nlp.pipeline.CoreDocument document, edu.stanford.nlp.coref.data.CorefChain corefChain, String canonicalEntityName)
-
-
-
Method Detail
-
getInstance
public static CoreNlpUtils getInstance(IParameterStore parameterStore) throws IOException
- Throws:
IOException
-
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)
-
-