intent_classifier#

class besser.bot.nlp.intent_classifier.intent_classifier.IntentClassifier(nlp_engine, state)[source]#

Bases: ABC

The Intent Classifier abstract class.

An intent classifier is in charge of determining the intent of a user message. Given a text (a user message) and a set of intents, the intent classifier predicts the probability of each intent to be the actual message’s intent.

The intent classifier belongs to a specific bot state, thus the predicted intent will always be one of the state’s intents. Therefore, the state must have at least 1 intent.

This class serves as a template to implement intent classifiers.

Parameters:
  • nlp_engine (NLPEngine) – the NLPEngine that handles the NLP processes of the bot

  • state (State) – the state the intent classifier belongs to

_nlp_engine#

The NLPEngine that handles the NLP processes of the bot.

Type:

NLPEngine

_state#

The state the intent classifier belongs to.

Type:

State

_abc_impl = <_abc._abc_data object>#
abstract predict(message)[source]#

Predict the intent of a given message.

Instead of returning only the intent with the highest likelihood, return all predictions. Predictions include not only the intent scores but other information extracted from the message.

Parameters:

message (str) – the message to predict the intent

Returns:

the list of predictions made by the intent classifier.

Return type:

list[IntentClassifierPrediction]

abstract train()[source]#

Train the intent classifier.