public abstract class StanfordNLPPostProcessor extends Object implements IntentPostProcessor
IntentPostProcessor
using Stanford NLP library to extract information from the user input.
This class should be extended by any IntentPostProcessor
relying on the StanfordNLPService
. It
provides a default implementation of the init()
methods that warms-up the NLP pipeline with a fake input,
and provides the getAnnotation(String, XatkitSession)
helpers that allows to retrieve an
Annotation
from a given input by looking in the XatkitSession
.
StanfordNLPService
Modifier and Type | Field and Description |
---|---|
protected static String |
NLP_ANNOTATION_SESSION_KEY
The
XatkitSession key used to store the last annotation. |
protected static String |
NLP_CONTEXT_KEY
The context key used to store Stanford NLP information.
|
protected static String |
NLP_INPUT_SESSION_KEY
The
XatkitSession key used to store the last annotated input. |
Constructor and Description |
---|
StanfordNLPPostProcessor() |
Modifier and Type | Method and Description |
---|---|
protected edu.stanford.nlp.pipeline.Annotation |
getAnnotation(String input,
XatkitSession session)
Computes the
Annotation for the provided input . |
void |
init()
Initialize the underlying
StanfordNLPService and performs a warm-up annotation on it. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
process
protected static final String NLP_CONTEXT_KEY
protected static final String NLP_INPUT_SESSION_KEY
XatkitSession
key used to store the last annotated input.
This value is stored in the XatkitSession
to let multiple post-processors access it to compute
specific metrics.
protected static final String NLP_ANNOTATION_SESSION_KEY
XatkitSession
key used to store the last annotation.
This value is stored in the XatkitSession
to let multiple post-processors access it to compute
specific metrics.
public void init()
StanfordNLPService
and performs a warm-up annotation on it.
This method is used to avoid delays on the first query performed on a deployed chatbot.
init
in interface IntentPostProcessor
StanfordNLPService.init()
protected final edu.stanford.nlp.pipeline.Annotation getAnnotation(String input, XatkitSession session)
Annotation
for the provided input
.
This method looks in the provided session
if an Annotation
has been already computed for the
provided input
and returns it. If it is not the case a new Annotation
is computed using
StanfordNLPService.annotate(String)
and stored in the session
.
input
- the textual input to annotatesession
- the XatkitSession
corresponding to the provided input
Annotation
corresponding to the provided input
Copyright © 2020 SOM Research Lab. All rights reserved.