public class StanfordNLPConnector extends Object
| Modifier and Type | Field and Description |
|---|---|
private static org.slf4j.Logger |
log |
private int |
nodeNumber |
static StringBuilder |
out |
private static String |
STANFORD_IP |
private static int |
STANFORD_PORT |
private edu.stanford.nlp.pipeline.StanfordCoreNLPClient |
stanfordPipe |
private static int |
USED_CORES |
private Set<edu.stanford.nlp.ling.IndexedWord> |
visitedNodes |
| Constructor and Description |
|---|
StanfordNLPConnector()
Initializes CoreNLP with default Annotators.
|
StanfordNLPConnector(String annotators)
Initializes the StanfordNLP with given Annotators.Complete Annotator list
at http://stanfordnlp.github.io/CoreNLP/annotators.html}
|
| Modifier and Type | Method and Description |
|---|---|
private void |
convertGraphStanford(MutableTreeNode parentMutableNode,
edu.stanford.nlp.ling.IndexedWord parentGraphWord,
edu.stanford.nlp.semgraph.SemanticGraph graph)
The recursive Function to convert a Semantic Graph into MutableTree
|
Map<String,String> |
generatePOSTags(edu.stanford.nlp.pipeline.Annotation document)
Generates POS tags with StanfordCoreNLP.
|
static String |
getStanfordIp() |
static int |
getStanfordPort() |
MutableTree |
parseTree(HAWKQuestion q,
UnitController numberToDigit)
Runs Stanford Pipeline on given question.
|
String |
postprocessStringForStanford(edu.stanford.nlp.ling.IndexedWord node)
Deals with the problem of Stanford splitting by "(" and ")" in a previous
step, we replace this by "////" This method regexes it back to normal.
|
String |
preprocessStringForStanford(String input)
Stanford splits by sentences with "(" and ")" in them.
|
MutableTree |
process(edu.stanford.nlp.pipeline.Annotation document)
Extracts dependency Graph from processed Annotation.
|
edu.stanford.nlp.pipeline.Annotation |
runAnnotation(HAWKQuestion q)
Runs StanfordNLP on given HawkQuestion`s question in
English and returns processed Annotation
|
edu.stanford.nlp.pipeline.Annotation |
runAnnotation(String s)
Runs StanfordNLP on given bare String and returns processed Annotation
|
private MutableTree |
semanticGraphToMutableTree(edu.stanford.nlp.semgraph.SemanticGraph graph,
HAWKQuestion q)
Converts a SemanticGraph from StanfordNLP to a Mutable tree recursively
with DFS.
|
private edu.stanford.nlp.pipeline.StanfordCoreNLPClient stanfordPipe
private int nodeNumber
private Set<edu.stanford.nlp.ling.IndexedWord> visitedNodes
public static StringBuilder out
private static org.slf4j.Logger log
private static final String STANFORD_IP
private static final int STANFORD_PORT
private static final int USED_CORES
public StanfordNLPConnector(String annotators)
annotators - Annotators to runpublic StanfordNLPConnector()
public edu.stanford.nlp.pipeline.Annotation runAnnotation(String s)
s - The String to be processed.preprocessStringForStanford(String)public edu.stanford.nlp.pipeline.Annotation runAnnotation(HAWKQuestion q)
q - The HAWKQuestion to be processed.public MutableTree process(edu.stanford.nlp.pipeline.Annotation document)
document - an Processed Annotationpublic MutableTree parseTree(HAWKQuestion q, UnitController numberToDigit)
Note: Extracted MutableTree will be set in HAWKQuestion>Note:
q - Question to process.public Map<String,String> generatePOSTags(edu.stanford.nlp.pipeline.Annotation document)
private MutableTree semanticGraphToMutableTree(edu.stanford.nlp.semgraph.SemanticGraph graph, HAWKQuestion q)
public String preprocessStringForStanford(String input)
http://dbpedia.org/page/Pound_(mass) http://dbpedia.org/page/Pound_(band)So we replace round brackets with "////"
public String postprocessStringForStanford(edu.stanford.nlp.ling.IndexedWord node)
preprocessStringForStanford(String)private void convertGraphStanford(MutableTreeNode parentMutableNode, edu.stanford.nlp.ling.IndexedWord parentGraphWord, edu.stanford.nlp.semgraph.SemanticGraph graph)
public static String getStanfordIp()
public static int getStanfordPort()
Copyright © 2016–2017 Pivotal Software, Inc.. All rights reserved.