sugaroid.core package

Submodules

sugaroid.core.base_adapters module

class sugaroid.core.base_adapters.SugaroidLogicAdapter(chatbot, **kwargs)[source]

Bases: chatterbot.logic.logic_adapter.LogicAdapter

This is an abstract class that represents the interface that all logic adapters should implement.

Parameters
  • search_algorithm_name – The name of the search algorithm that should be used to search for close matches to the provided input. Defaults to the value of Search.name.

  • maximum_similarity_threshold – The maximum amount of similarity between two statement that is required before the search process is halted. The search for a matching statement will continue until a statement with a greater than or equal similarity is found or the search set is exhausted. Defaults to 0.95

  • response_selection_method (collections.abc.Callable) – The a response selection method. Defaults to get_first_response

  • default_response (str or list or tuple) – The default response returned by this logic adaper if there is no other possible response to return.

Tprocess(statement: sugaroid.core.statement.SugaroidStatement, additional_response_selection_parameters=None) sugaroid.core.statement.SugaroidStatement[source]

Processes the statement in detail :param statement: The statement from the user to process :type statement: SugaroidStatement :param additional_response_selection_parameters: :type additional_response_selection_parameters: :return: The Statement from the logic adapter once its processed :rtype: SugaroidStatement

can_process(statement: sugaroid.core.statement.SugaroidStatement) bool[source]

Checks if Sugaroid can process a statement :param statement: The statement to do prelimnary checks :type statement: SugaroidStatement :return: True, if the statement be processed, else False :rtype: bool

sugaroid.core.bot module

class sugaroid.core.bot.SugaroidBot(name, **kwargs)[source]

Bases: chatterbot.chatterbot.ChatBot

The SugaroidBot inherits the class local variables from the Chat

gen_debug(statement, adapter, confidence, results)[source]

Create a debug dictionary key:value pair for Debug Conversation The Google :param statement: input_statement :param adapter: Adapter __gtype__classname__ :param confidence: SugaroidStatement.confidence :param results: Sugaroid Statement.text :return:

generate_response(input_statement, additional_response_selection_parameters=None) sugaroid.core.statement.SugaroidStatement[source]

Return a response based on a given input statement.

Parameters
  • additional_response_selection_parameters

  • input_statement – The input statement to be processed.

:return the processed final statement :rtype SugaroidStatement

get_emotion() int[source]

Returns the emotion of the chatbot at a particular time :return: The emotion of the bot

get_global(key)[source]

Returns a global constant :param key: :return:

get_response(statement=None, **kwargs)[source]

Return the bot’s response based on the input.

Parameters

statement – An statement object or string.

Returns

A response to the input.

Return type

Statement

get_username() str[source]

The username of the bot :return: The username of sugaroid :rtype: str

reset_variables()[source]
set_emotion(emotion)[source]

Sets the emotion for the chatbot globally. (Deprecated) :param emotion: :return:

set_username() NotImplementedError[source]

Sets the Sugaroid user username :return: None, Exception

toggle_discord()[source]

Toggle Discord Configuration :return:

sugaroid.core.statement module

class sugaroid.core.statement.SugaroidStatement(text: str, in_response_to=None, emotion: Optional[int] = None, **kwargs)[source]

Bases: chatterbot.conversation.Statement

A modified chatterbot Statement with the additional parameters The Chatterbot Statement did not preserve the capabilities to hold fundamental data such as name of the adapter and emotion of the statement passed The emotion was either a <class ‘Emotion’> type or NoneType The Adapter was the generic name of the adapter in string type determined by the __gtype__ variable

confidence
conversation
created_at
property doc: spacy.tokens.doc.Doc

Returns the spacy.tokens.doc.Doc of the statement :return: :rtype:

property emotion: int

Gives the assigned emotion of the statement :return: :rtype:

classmethod from_list_random(statements: list)[source]

Select a random statement from a list of statements :param statements: :type statements: :return: :rtype: SugaroidStatement

classmethod from_statement(statement: chatterbot.conversation.Statement)[source]

Convert chatterbot.Statement to sugaroid.core.statement.Statement :param statement: :type statement: chatterbot.Statement :return: :rtype: SugaroidStatement

id
in_response_to
property lemma: Generator

Returns the normalized words of the statement :return: :rtype:

persona
property pos: Generator

Returns the pos_ generator words of the statement :return: :rtype:

search_in_response_to
search_text
set_adapter(adapter: str)[source]
set_chatbot(is_chatbot: bool)[source]
set_confidence(confidence: float)[source]
set_emotion(emotion: int)[source]
property simple: List[str]

Returns the statement stripped and split into words :return: :rtype:

storage
property tag: Generator

Returns the tag_ generator words of the statement :return: :rtype:

tags
text
property tokens: spacy.tokens.doc.Doc

Alias of self.doc :return: :rtype:

property words: list

Returns the normalized words of the statement :return: :rtype:

Module contents