public class RegExIntentRecognitionProvider extends IntentRecognitionProvider
IntentRecognitionProvider
that relies on RegExp to match user inputs.
This intent provider is designed to handle bot prototyping with a minimal support to match user inputs using
RegExp Pattern
s. This provider should not be used if advanced input extraction capabilities are required.
Note: this class uses strict patterns that perform exact matches of the input. This exact
matching is case sensitive. You can check alternative IntentRecognitionProvider
s if you need to
support advanced features such as partial matches.
Note: the RegExIntentRecognitionProvider
translates EntityType
s into single-word
patterns. This means that the any
entity will match "test", but not "test test", you can check
alternative IntentRecognitionProvider
s if you need to support such features.
The RegExIntentRecognitionProvider
will be used by Xatkit if the application's Configuration
file does not contain specific IntentRecognitionProvider
properties (see
IntentRecognitionProviderFactory.getIntentRecognitionProvider(XatkitCore, Configuration)
).
IntentRecognitionProviderFactory
Modifier and Type | Field and Description |
---|---|
static com.xatkit.intent.IntentDefinition |
DEFAULT_FALLBACK_INTENT
The Default Fallback Intent that is returned when the user input does not match any registered Intent.
|
protected EntityMapper |
entityMapper
The
EntityMapper used to store system and dynamic entity mappings. |
protected static String |
FOLLOW_CONTEXT_NAME_SUFFIX
The context name suffix used to identify follow-up contexts.
|
protected Map<com.xatkit.intent.IntentDefinition,List<Pattern>> |
intentPatterns
|
Constructor and Description |
---|
RegExIntentRecognitionProvider(Configuration configuration)
Constructs a
RegExIntentRecognitionProvider with the provided Configuration . |
RegExIntentRecognitionProvider(Configuration configuration,
RecognitionMonitor recognitionMonitor)
Constructs a
RegExIntentRecognitionProvider with the provided configuration . |
Modifier and Type | Method and Description |
---|---|
XatkitSession |
createSession(String sessionId)
Creates a new
XatkitSession from the provided sessionId . |
void |
deleteEntityDefinition(com.xatkit.intent.EntityDefinition entityDefinition)
Deletes the provided
entityDefinition . |
void |
deleteIntentDefinition(com.xatkit.intent.IntentDefinition intentDefinition)
Deletes the provided
intentDefinition . |
com.xatkit.intent.RecognizedIntent |
getIntentInternal(String input,
XatkitSession session)
Computes the
RecognizedIntent associated to the provided input . |
RecognitionMonitor |
getRecognitionMonitor()
Returns the
RecognitionMonitor associated to this intent recognition provider. |
boolean |
isShutdown()
Returns whether the intent recognition provider client is shutdown.
|
void |
registerEntityDefinition(com.xatkit.intent.EntityDefinition entityDefinition)
Registers the provided
entityDefinition . |
void |
registerIntentDefinition(com.xatkit.intent.IntentDefinition intentDefinition)
Registers the provided
IntentDefinition . |
void |
shutdown()
Shuts down the intent recognition provider client and invalidates the remaining sessions.
|
void |
trainMLEngine()
This method is not implemented and throws an
UnsupportedOperationException . |
getIntent, setPostProcessors, setPreProcessors
public static com.xatkit.intent.IntentDefinition DEFAULT_FALLBACK_INTENT
protected static String FOLLOW_CONTEXT_NAME_SUFFIX
protected EntityMapper entityMapper
EntityMapper
used to store system and dynamic entity mappings.public RegExIntentRecognitionProvider(Configuration configuration)
RegExIntentRecognitionProvider
with the provided Configuration
.
This constructor is a placeholder for
RegExIntentRecognitionProvider(Configuration, RecognitionMonitor)
with a null
RecognitionMonitor
.
configuration
- the Configuration
the Configuration
used to customize the created
XatkitSession
sNullPointerException
- if the provided configuration
is null
RegExIntentRecognitionProvider(Configuration, RecognitionMonitor)
public RegExIntentRecognitionProvider(Configuration configuration, @Nullable RecognitionMonitor recognitionMonitor)
RegExIntentRecognitionProvider
with the provided configuration
.configuration
- the Configuration
used to customize the created XatkitSession
s
* @param recognitionMonitor the RecognitionMonitor
instance storing intent
matching informationNullPointerException
- if the provided configuration
is null
public void registerEntityDefinition(com.xatkit.intent.EntityDefinition entityDefinition)
entityDefinition
.
Registered EntityDefinition
are reused when registering intents to produce RegExp Pattern
s that
are matched against user inputs.
registerEntityDefinition
in class IntentRecognitionProvider
entityDefinition
- the EntityDefinition
to register to the underlying intent recognition providerregisterIntentDefinition(IntentDefinition)
public void registerIntentDefinition(com.xatkit.intent.IntentDefinition intentDefinition)
IntentDefinition
.
This method creates a set of RegExp patterns that can be matched against user inputs. Note that
CustomEntityDefinition
used in the provided intentDefinition
must have been registered using
registerEntityDefinition(EntityDefinition)
.
registerIntentDefinition
in class IntentRecognitionProvider
intentDefinition
- the IntentDefinition
to register to the underlying intent recognition providerregisterEntityDefinition(EntityDefinition)
public void deleteEntityDefinition(com.xatkit.intent.EntityDefinition entityDefinition)
entityDefinition
.deleteEntityDefinition
in class IntentRecognitionProvider
entityDefinition
- the EntityDefinition
to delete from the underlying intent recognition providerIntentRecognitionProvider.trainMLEngine()
public void deleteIntentDefinition(com.xatkit.intent.IntentDefinition intentDefinition)
intentDefinition
.
This method deletes the RegExp Pattern
s associated to the provided intentDefinition
, meaning
that the intent won't be matched by the provider anymore.
deleteIntentDefinition
in class IntentRecognitionProvider
intentDefinition
- the IntentDefinition
to delete from the underlying intent recognition providerIntentRecognitionProvider.trainMLEngine()
public void trainMLEngine()
UnsupportedOperationException
.
Use valid IntentRecognitionProvider
s to enable ML training.
trainMLEngine
in class IntentRecognitionProvider
UnsupportedOperationException
- when calledpublic XatkitSession createSession(String sessionId)
XatkitSession
from the provided sessionId
.createSession
in class IntentRecognitionProvider
sessionId
- the identifier to create a session fromXatkitSession
for the provided sessionId
@Nullable public RecognitionMonitor getRecognitionMonitor()
RecognitionMonitor
associated to this intent recognition provider.getRecognitionMonitor
in class IntentRecognitionProvider
RecognitionMonitor
, or null
if analytics monitoring is disabled.public void shutdown()
Note: calling this method invalidates the intent recognition provider client connection, and thus this class cannot be used to access the intent recognition provider anymore.
shutdown
in class IntentRecognitionProvider
public boolean isShutdown()
isShutdown
in class IntentRecognitionProvider
true
if the intent recognition provider client is shutdown, false
otherwisepublic com.xatkit.intent.RecognizedIntent getIntentInternal(String input, XatkitSession session)
RecognizedIntent
associated to the provided input
.
This method relies on the RegExp patterns created when calling
registerIntentDefinition(IntentDefinition)
to match the provided input. The provided session
is used to retrieve the intents that can be matched according to the current contexts.
If the RegExIntentRecognitionProvider
cannot find a valid IntentDefinition
for the provided
input
the returned RecognizedIntent
's definition will be the DEFAULT_FALLBACK_INTENT
.
Note: this class uses strict patterns that perform exact matches of the input. This exact
matching is case sensitive. You can check alternative IntentRecognitionProvider
s if you need to
support advanced features such as partial matches.
Note: the RegExIntentRecognitionProvider
translates EntityType
s into single-word
patterns. This means that the any
entity will match "test", but not "test test", you can check
alternative IntentRecognitionProvider
s if you need to support such features.
getIntentInternal
in class IntentRecognitionProvider
input
- the String
representing the textual input to process and extract the intent fromsession
- the XatkitSession
used to access context informationRecognizedIntent
matched from the provided input
Copyright © 2020 SOM Research Lab. All rights reserved.