-
Notifications
You must be signed in to change notification settings - Fork 22
Processors
Xatkit embeds processors, that are additional pieces of logic that can be plugged to tune the intent recognition process. Pre-processors operate on the user input to optimize it before intent extraction (e.g. by adding a question mark at the end of a sentence that is obviously a question). On the other hand, post-processors are designed to operate after the intent recognition process, usually to set additional context parameters (e.g. perform some sentiment analysis, set whether the input is a yes/no question, etc).
Unless explicitly stated in the documentation, Xatkit processors can be used with any intent recognition engine. To integrate Xatkit processors in your bot you need to add the following lines in your bot configuration:
xatkit.recognition.preprocessors = PreProcessor1, PreProcessor2
xatkit.recognition.postprocessors = PostProcessor1, PostProcessor2
Processors are set using their name (see the table below for the list of processors embedded in Xatkit). Note that each property accepts a list of comma-separated processor names.
📚 You can also directly use the processor class to configure your bot programmatically:
import static com.xatkit.core.recognition.IntentRecognitionProviderFactoryConfiguration.*; [...] configuration.addProperty(RECOGNITION_PREPROCESSORS_KEY, EnglishSentimentPostProcessor.class.getSimpleName());
Name | Description | Requirements |
---|---|---|
SpacePunctuationPreProcessor |
Adds spaces around punctuation when needed (e.g. from "?" to " ?"). This processor is enabled by default when using the NlpjsIntentRecognitionProvider . |
Name | Description | Requirements |
---|---|---|
RemoveEnglishStopWords |
Removes English stop words from recognized intent's parameter values that have been extracted from any entities. This processor helps normalizing DialogFlow values when using any entities. |
|
IsEnglishYesNoQuestion |
Sets the context parameter nlp.isYesNo to true if the user input is a yes/no question, and false otherwise |
See Stanford CoreNLP configuration |
EnglishSentiment |
Sets the context parameter nlp.sentiment to a value in ["Very Negative", "Negative", "Neutral", "Positive", "Very Positive"] corresponding to the sentiment extracted from the user input. |
See Stanford CoreNLP configuration |
TrimParameterValuesPostProcessor |
Removes leading/trailing spaces in extracted parameter values (e.g. from "Barcelona " to "Barcelona"). This processor is enabled by default when using the NlpjsIntentRecognitionProvider . |
|
TrimPunctuationPostProcessor |
Removes punctuation in extracted parameter values (e.g. from "Barcelona!" to "Barcelona"). This processor is enabled by default when using the NlpjsIntentRecognitionProvider . |
Stanford CoreNLP is not embedded by default in Xatkit. This means that you need to manually add the following dependency in your bot's pom.xml
:
<dependency>
<groupId>edu.stanford.nlp</groupId>
<artifactId>stanford-corenlp</artifactId>
<version>3.9.2</version>
<exclusions>
<exclusion>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
</exclusion>
</exclusions>
</dependency>
📚 The exclusion rule avoids a dependency conflict with other libraries used in Xatkit with different versions of protobuf.
You also need to download the jar containing the Stanford CoreNLP models and add it to your classpath.
❗ Xatkit currently works with CoreNLP
3.9.2
, make sure you select the language model for this specific version to avoid compatibility issues.
- Getting Started
- Configuring your bot
- Integrating an Intent Recognition Provider
- Adding a bot to your website
- Deploying on Slack
- Basic concepts
- Intents and Entities
- States, Transitions, and Context
- Default and Local Fallbacks
- Core Library