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 String
getCanonicalEntityNameFromCorefChain(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.CorefChain
getCorefChainFromCoreEntityMention(edu.stanford.nlp.pipeline.CoreDocument document, edu.stanford.nlp.pipeline.CoreEntityMention entityMention)
edu.stanford.nlp.coref.data.CorefChain
getCorefChainFromCorefMention(edu.stanford.nlp.pipeline.CoreDocument document, edu.stanford.nlp.coref.data.CorefChain.CorefMention corefMention)
String
getCoreNlpGenderNameFromCoreEntityMention(edu.stanford.nlp.pipeline.CoreDocument document, edu.stanford.nlp.pipeline.CoreEntityMention entityMention)
String
getGenderNameFromCorefChain(edu.stanford.nlp.pipeline.CoreDocument document, edu.stanford.nlp.coref.data.CorefChain corefChain)
static CoreNlpUtils
getInstance(IParameterStore parameterStore)
String
getOOPGenderNameFromCoreEntityMention(edu.stanford.nlp.pipeline.CoreDocument document, edu.stanford.nlp.pipeline.CoreEntityMention entityMention)
edu.stanford.nlp.pipeline.StanfordCoreNLP
getPipeline()
Properties
getPipelineProps()
edu.stanford.nlp.pipeline.CoreSentence
getSentenceFromCoreEntityMention(edu.stanford.nlp.pipeline.CoreDocument document, edu.stanford.nlp.pipeline.CoreEntityMention entityMention)
edu.stanford.nlp.pipeline.CoreSentence
getSentenceFromCorefMention(edu.stanford.nlp.pipeline.CoreDocument document, edu.stanford.nlp.coref.data.CorefChain.CorefMention corefMention)
edu.stanford.nlp.pipeline.CoreSentence
getSentenceFromToken(edu.stanford.nlp.pipeline.CoreDocument document, edu.stanford.nlp.ling.CoreLabel token)
int
getSentenceIdFromSentence(edu.stanford.nlp.pipeline.CoreDocument document, edu.stanford.nlp.pipeline.CoreSentence sentence)
edu.stanford.nlp.ling.CoreLabel
getTokenFromIndexedWord(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)
boolean
isCoreEntityMentionForCanonicalEntityName(edu.stanford.nlp.pipeline.CoreDocument document, edu.stanford.nlp.pipeline.CoreEntityMention entityMention, String canonicalEntityName)
boolean
isCoreEntityMentionInAnyCorefChain(edu.stanford.nlp.pipeline.CoreDocument document, edu.stanford.nlp.pipeline.CoreEntityMention entityMention)
boolean
isCorefChainForCanonicalEntityName(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)
-
-