intent#

class besser.bot.core.intent.intent.Intent(name, training_sentences=None, parameters=None, description=None)[source]#

Bases: object

The Intent core component of a bot.

Intents define a set of training sentences representing the different ways a user could express an intention (e.g. “Hi”, “Hello” for a Greetings intent).

Intents can also define parameters that are filled with information extracted from the user input using entities.

Parameters:
  • name (str) – the intent’s name

  • training_sentences (list[str] or None) – the intent’s training sentences

  • parameters (list[IntentParameter] or None) – the intent’s parameters

  • description (str or None) – a description of the intent, optional

name#

The intent’s name

Type:

str

training_sentences#

The intent’s training sentences

Type:

list[str]

processed_training_sentences#

Processed training sentences are stored for intent prediction

Type:

list[str] or None

parameters#

The intent’s parameters

Type:

list[IntentParameter]

description#

a description of the intent, optional

Type:

str or None

parameter(name, fragment, entity)[source]#

Add a parameter to the list of intent parameters.

This method creates an IntentParameter instance with the provided name, fragment, and entity, and appends it to the list of parameters associated with the intent.

Parameters:
  • name (str) – The name of the parameter.

  • fragment (str) – A description or fragment associated with the parameter.

  • entity (Entity) – The entity that this parameter is related to.

Returns:

Returns the instance of Intent it was called on (i.e., self).

Return type:

Intent

process_training_sentences(nlp_engine)[source]#

Process the training sentences of the intent.

Parameters:

nlp_engine (NPLEngine) – the NLPEngine that handles the NLP processes of the bot

to_json()[source]#

Returns the intent content in a JSON format.

Returns:

The intent content.

Return type:

dict