sugaroid.brain package

Submodules

sugaroid.brain.about module

class sugaroid.brain.about.AboutAdapter(chatbot, **kwargs)[source]

Bases: sugaroid.core.base_adapters.SugaroidLogicAdapter

Defines the personality of sugaroid. About Adapter sets the basic parameters of personality. These include questions like ‘Who is your brother?’, or “What is your Hobby?”

Warning

This adapter is incomplete and requires additional clauses.

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

Checks if the provided statement is a statement which matches a similarity to “What is your <insert token>

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

Override this method and implement your logic for selecting a response to an input statement.

A confidence value and the selected response statement should be returned. The confidence value represents a rating of how accurate the logic adapter expects the selected response to be. Confidence scores are used to select the best response from multiple logic adapters.

The confidence value should be a number between 0 and 1 where 0 is the lowest confidence level and 1 is the highest.

Parameters
  • statement (Statement) – An input statement to be processed by the logic adapter.

  • additional_response_selection_parameters (dict) – Parameters to be used when filtering results to choose a response from.

Return type

Statement

sugaroid.brain.about.about_process_en(statement: sugaroid.core.statement.SugaroidStatement) Tuple[bool, str, str, str][source]

sugaroid.brain.aki module

This module in Sugaroid uses a licensed term ‘Akinator’. Sugaroid and its developer attributes its author here Elokence.com – SARL a limited liability company with a share capital of 80,000€, whose head office is 8, rue Jules Vallès – 28 300 Mainvilliers – France, and registered with the Chartres Register of Companies under the number 501 030 316. The design and contents of the Website constitute a protected work under current intellectual property laws, of which Elokence is the rightholder. The Publications Director is Mr Arnaud MÉGRET, manager of Elokence.com.

The author takes no right over the information provided by Akinator and is solely provided by the WebAPI Akinator.com. All rights reserved to Akinator.

The creator of Akinator.py NinjaSnails is also attributed. The Akinator wrapper for python is provided under OpenSource License (MIT)

class sugaroid.brain.aki.AkinatorAdapter(chatbot, **kwargs)[source]

Bases: sugaroid.core.base_adapters.SugaroidLogicAdapter

Adapter which ports the wrapper of the Akinator game to Sugaroid

can_process(statement)[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

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

Override this method and implement your logic for selecting a response to an input statement.

A confidence value and the selected response statement should be returned. The confidence value represents a rating of how accurate the logic adapter expects the selected response to be. Confidence scores are used to select the best response from multiple logic adapters.

The confidence value should be a number between 0 and 1 where 0 is the lowest confidence level and 1 is the highest.

Parameters
  • statement (Statement) – An input statement to be processed by the logic adapter.

  • additional_response_selection_parameters (dict) – Parameters to be used when filtering results to choose a response from.

Return type

Statement

class sugaroid.brain.aki.SugaroidAkinator(chatbot: sugaroid.core.bot.SugaroidBot)[source]

Bases: object

check_ans(statement)[source]
game_over()[source]
progression(statement)[source]
start_check()[source]
start_game()[source]
win()[source]

sugaroid.brain.areyou module

class sugaroid.brain.areyou.AreYouAdapter(chatbot, **kwargs)[source]

Bases: sugaroid.core.base_adapters.SugaroidLogicAdapter

Adapter to process statements beginning with ‘are you’

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

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

Override this method and implement your logic for selecting a response to an input statement.

A confidence value and the selected response statement should be returned. The confidence value represents a rating of how accurate the logic adapter expects the selected response to be. Confidence scores are used to select the best response from multiple logic adapters.

The confidence value should be a number between 0 and 1 where 0 is the lowest confidence level and 1 is the highest.

Parameters
  • statement (Statement) – An input statement to be processed by the logic adapter.

  • additional_response_selection_parameters (dict) – Parameters to be used when filtering results to choose a response from.

Return type

Statement

sugaroid.brain.assertive module

class sugaroid.brain.assertive.AssertiveAdapter(chatbot, **kwargs)[source]

Bases: sugaroid.core.base_adapters.SugaroidLogicAdapter

Handles assertive and imperative statements

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

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

Override this method and implement your logic for selecting a response to an input statement.

A confidence value and the selected response statement should be returned. The confidence value represents a rating of how accurate the logic adapter expects the selected response to be. Confidence scores are used to select the best response from multiple logic adapters.

The confidence value should be a number between 0 and 1 where 0 is the lowest confidence level and 1 is the highest.

Parameters
  • statement (Statement) – An input statement to be processed by the logic adapter.

  • additional_response_selection_parameters (dict) – Parameters to be used when filtering results to choose a response from.

Return type

Statement

sugaroid.brain.because module

class sugaroid.brain.because.BecauseAdapter(chatbot, **kwargs)[source]

Bases: sugaroid.core.base_adapters.SugaroidLogicAdapter

Processes statements which starts with Because or gives a reason

can_process(statement: sugaroid.core.statement.SugaroidStatement)[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

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

Override this method and implement your logic for selecting a response to an input statement.

A confidence value and the selected response statement should be returned. The confidence value represents a rating of how accurate the logic adapter expects the selected response to be. Confidence scores are used to select the best response from multiple logic adapters.

The confidence value should be a number between 0 and 1 where 0 is the lowest confidence level and 1 is the highest.

Parameters
  • statement (Statement) – An input statement to be processed by the logic adapter.

  • additional_response_selection_parameters (dict) – Parameters to be used when filtering results to choose a response from.

Return type

Statement

sugaroid.brain.because.pos_tag(statement: sugaroid.core.statement.SugaroidStatement)[source]

sugaroid.brain.brain module

Sugaroid Neuron preprocesses the text and fixes user input problems so that it is easier for the other adapters to process. Sugaroid Neuron replaces spellings (when spell checker is enabled) and prefers the Arithemetic operator to process the statements when necessary

class sugaroid.brain.brain.Neuron(bot)[source]

Bases: object

Main processing object. sugaroid.brain.Neuron classifies texts initially

alu(var)[source]

Puts spaces between arithemetic operators

gen_arithmetic(parsed: str)[source]

Parse a arithemetic statement using the MathematicalEvaluation Adapter

gen_best_match(parsed) sugaroid.core.statement.SugaroidStatement[source]

Returns the best match of parsed object in the the list of stored data

:return The closed match to parsed

static gen_time() str[source]

Returns the current local time, formatted by strftime

Returns

The current local time

Return type

str

static normalize(text: str) str[source]

Normalize a text using WordPunctTokenizer

Parameters

text (str) – The text to be normalized

Returns

The normalized text

Return type

str

parse(var)[source]

Ask sugaroid to parse a statement. Neuron.parse processes the statement with different adapters and returns a SugaroidStatement, Statement, or a string object on every instance processed.

>>> neuron = Neuron(bot)
>>> neuron.parse("Hello World")
Hi There!
time()[source]

Returns the current time

sugaroid.brain.bye module

class sugaroid.brain.bye.ByeAdapter(chatbot, **kwargs)[source]

Bases: chatterbot.logic.logic_adapter.LogicAdapter

Destroys Sugaroid on bye

can_process(statement)[source]

A preliminary check that is called to determine if a logic adapter can process a given statement. By default, this method returns true but it can be overridden in child classes as needed.

Return type

bool

process(statement, additional_response_selection_parameters=None)[source]

Override this method and implement your logic for selecting a response to an input statement.

A confidence value and the selected response statement should be returned. The confidence value represents a rating of how accurate the logic adapter expects the selected response to be. Confidence scores are used to select the best response from multiple logic adapters.

The confidence value should be a number between 0 and 1 where 0 is the lowest confidence level and 1 is the highest.

Parameters
  • statement (Statement) – An input statement to be processed by the logic adapter.

  • additional_response_selection_parameters (dict) – Parameters to be used when filtering results to choose a response from.

Return type

Statement

sugaroid.brain.canmay module

class sugaroid.brain.canmay.CanAdapter(chatbot, **kwargs)[source]

Bases: chatterbot.logic.logic_adapter.LogicAdapter

Processes statements which features a Modal question (can, may)

can_process(statement)[source]

A preliminary check that is called to determine if a logic adapter can process a given statement. By default, this method returns true but it can be overridden in child classes as needed.

Return type

bool

process(statement, additional_response_selection_parameters=None)[source]

Override this method and implement your logic for selecting a response to an input statement.

A confidence value and the selected response statement should be returned. The confidence value represents a rating of how accurate the logic adapter expects the selected response to be. Confidence scores are used to select the best response from multiple logic adapters.

The confidence value should be a number between 0 and 1 where 0 is the lowest confidence level and 1 is the highest.

Parameters
  • statement (Statement) – An input statement to be processed by the logic adapter.

  • additional_response_selection_parameters (dict) – Parameters to be used when filtering results to choose a response from.

Return type

Statement

sugaroid.brain.constants module

sugaroid.brain.convert module

class sugaroid.brain.convert.CurrencyAdapter(chatbot, **kwargs)[source]

Bases: chatterbot.logic.logic_adapter.LogicAdapter

Gives a random response, because Sugaroid tries not to say I don’t know

can_process(statement)[source]

A preliminary check that is called to determine if a logic adapter can process a given statement. By default, this method returns true but it can be overridden in child classes as needed.

Return type

bool

process(statement, additional_response_selection_parameters=None)[source]

Override this method and implement your logic for selecting a response to an input statement.

A confidence value and the selected response statement should be returned. The confidence value represents a rating of how accurate the logic adapter expects the selected response to be. Confidence scores are used to select the best response from multiple logic adapters.

The confidence value should be a number between 0 and 1 where 0 is the lowest confidence level and 1 is the highest.

Parameters
  • statement (Statement) – An input statement to be processed by the logic adapter.

  • additional_response_selection_parameters (dict) – Parameters to be used when filtering results to choose a response from.

Return type

Statement

class sugaroid.brain.convert.SugaroidCurrency[source]

Bases: object

convert(src: str, dest: str, amount: float)[source]

sugaroid.brain.covid module

class sugaroid.brain.covid.CovidAdapter(chatbot, **kwargs)[source]

Bases: chatterbot.logic.logic_adapter.LogicAdapter

A COVID-19 dedicated Adapter In the memory of cancelled Google Code In, Grand Prize Winner’s trip, 2019-2020 :

can_process(statement)[source]

A preliminary check that is called to determine if a logic adapter can process a given statement. By default, this method returns true but it can be overridden in child classes as needed.

Return type

bool

process(statement, additional_response_selection_parameters=None)[source]

Override this method and implement your logic for selecting a response to an input statement.

A confidence value and the selected response statement should be returned. The confidence value represents a rating of how accurate the logic adapter expects the selected response to be. Confidence scores are used to select the best response from multiple logic adapters.

The confidence value should be a number between 0 and 1 where 0 is the lowest confidence level and 1 is the highest.

Parameters
  • statement (Statement) – An input statement to be processed by the logic adapter.

  • additional_response_selection_parameters (dict) – Parameters to be used when filtering results to choose a response from.

Return type

Statement

sugaroid.brain.debug module

class sugaroid.brain.debug.DebugAdapter(chatbot, **kwargs)[source]

Bases: chatterbot.logic.logic_adapter.LogicAdapter

Internal Admin feature to debug Sugaroid statements

can_process(statement)[source]

A preliminary check that is called to determine if a logic adapter can process a given statement. By default, this method returns true but it can be overridden in child classes as needed.

Return type

bool

gen_num()[source]
help()[source]
process(statement, additional_response_selection_parameters=None)[source]

Override this method and implement your logic for selecting a response to an input statement.

A confidence value and the selected response statement should be returned. The confidence value represents a rating of how accurate the logic adapter expects the selected response to be. Confidence scores are used to select the best response from multiple logic adapters.

The confidence value should be a number between 0 and 1 where 0 is the lowest confidence level and 1 is the highest.

Parameters
  • statement (Statement) – An input statement to be processed by the logic adapter.

  • additional_response_selection_parameters (dict) – Parameters to be used when filtering results to choose a response from.

Return type

Statement

track(number, number_out=None)[source]

sugaroid.brain.dis module

class sugaroid.brain.dis.DisAdapter(chatbot, **kwargs)[source]

Bases: chatterbot.logic.logic_adapter.LogicAdapter

A complex algorithm sorting the words beginning with negative based on the probability. and achieving a similar confidence ratio of the word percentage. The DisAdapter keeps the confidence below 0.5 so that the BestAdapter may find some other answer similar to

can_process(statement)[source]

A preliminary check that is called to determine if a logic adapter can process a given statement. By default, this method returns true but it can be overridden in child classes as needed.

Return type

bool

process(statement, additional_response_selection_parameters=None)[source]

Override this method and implement your logic for selecting a response to an input statement.

A confidence value and the selected response statement should be returned. The confidence value represents a rating of how accurate the logic adapter expects the selected response to be. Confidence scores are used to select the best response from multiple logic adapters.

The confidence value should be a number between 0 and 1 where 0 is the lowest confidence level and 1 is the highest.

Parameters
  • statement (Statement) – An input statement to be processed by the logic adapter.

  • additional_response_selection_parameters (dict) – Parameters to be used when filtering results to choose a response from.

Return type

Statement

sugaroid.brain.do module

MIT License

Sugaroid Artificial Intelligence Chatbot Core Copyright (c) 2020-2021 Srevin Saju Copyright (c) 2021 The Sugaroid Project

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

class sugaroid.brain.do.DoAdapter(chatbot, **kwargs)[source]

Bases: chatterbot.logic.logic_adapter.LogicAdapter

Processes statements beginning with ‘Do’ and ‘know’

can_process(statement)[source]

A preliminary check that is called to determine if a logic adapter can process a given statement. By default, this method returns true but it can be overridden in child classes as needed.

Return type

bool

process(statement, additional_response_selection_parameters=None)[source]

Override this method and implement your logic for selecting a response to an input statement.

A confidence value and the selected response statement should be returned. The confidence value represents a rating of how accurate the logic adapter expects the selected response to be. Confidence scores are used to select the best response from multiple logic adapters.

The confidence value should be a number between 0 and 1 where 0 is the lowest confidence level and 1 is the highest.

Parameters
  • statement (Statement) – An input statement to be processed by the logic adapter.

  • additional_response_selection_parameters (dict) – Parameters to be used when filtering results to choose a response from.

Return type

Statement

sugaroid.brain.dolike module

class sugaroid.brain.dolike.DoLikeAdapter(chatbot, **kwargs)[source]

Bases: chatterbot.logic.logic_adapter.LogicAdapter

Handles likes of Sugaroid

can_process(statement)[source]

A preliminary check that is called to determine if a logic adapter can process a given statement. By default, this method returns true but it can be overridden in child classes as needed.

Return type

bool

process(statement, additional_response_selection_parameters=None)[source]

Override this method and implement your logic for selecting a response to an input statement.

A confidence value and the selected response statement should be returned. The confidence value represents a rating of how accurate the logic adapter expects the selected response to be. Confidence scores are used to select the best response from multiple logic adapters.

The confidence value should be a number between 0 and 1 where 0 is the lowest confidence level and 1 is the highest.

Parameters
  • statement (Statement) – An input statement to be processed by the logic adapter.

  • additional_response_selection_parameters (dict) – Parameters to be used when filtering results to choose a response from.

Return type

Statement

sugaroid.brain.either module

class sugaroid.brain.either.OrAdapter(chatbot, **kwargs)[source]

Bases: chatterbot.logic.logic_adapter.LogicAdapter

Selects a random operand of the provided statement

can_process(statement)[source]

A preliminary check that is called to determine if a logic adapter can process a given statement. By default, this method returns true but it can be overridden in child classes as needed.

Return type

bool

process(statement, additional_response_selection_parameters=None)[source]

Override this method and implement your logic for selecting a response to an input statement.

A confidence value and the selected response statement should be returned. The confidence value represents a rating of how accurate the logic adapter expects the selected response to be. Confidence scores are used to select the best response from multiple logic adapters.

The confidence value should be a number between 0 and 1 where 0 is the lowest confidence level and 1 is the highest.

Parameters
  • statement (Statement) – An input statement to be processed by the logic adapter.

  • additional_response_selection_parameters (dict) – Parameters to be used when filtering results to choose a response from.

Return type

Statement

sugaroid.brain.emotion module

class sugaroid.brain.emotion.EmotionAdapter(chatbot, **kwargs)[source]

Bases: sugaroid.core.base_adapters.SugaroidLogicAdapter

Handles positive and negative emotional statements

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

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

Override this method and implement your logic for selecting a response to an input statement.

A confidence value and the selected response statement should be returned. The confidence value represents a rating of how accurate the logic adapter expects the selected response to be. Confidence scores are used to select the best response from multiple logic adapters.

The confidence value should be a number between 0 and 1 where 0 is the lowest confidence level and 1 is the highest.

Parameters
  • statement (Statement) – An input statement to be processed by the logic adapter.

  • additional_response_selection_parameters (dict) – Parameters to be used when filtering results to choose a response from.

Return type

Statement

sugaroid.brain.emotion.handle_dead_statements(statement: sugaroid.core.statement.SugaroidStatement) Tuple[str, int][source]

Handles those statements which contains words like dead some people dead, everyone dead.

>>> statement = SugaroidStatement("Everyone is dead. Sed indeed")
>>> response, _ = handle_dead_statements(statement)
>>> print(response)
Very sed
Parameters

statement (SugaroidStatement) – the statement to process

sugaroid.brain.emotion.handle_give_consolation(_: sugaroid.core.statement.SugaroidStatement) Tuple[str, int][source]

Give consolation to the user when the user is depressed :param _: :type _: :return: :rtype:

sugaroid.brain.emotion.handle_thanks(_: sugaroid.core.statement.SugaroidStatement) Tuple[str, int][source]

Say welcome when the user says thank you! :param _: :type _: :return: :rtype:

sugaroid.brain.feel module

class sugaroid.brain.feel.FeelAdapter(chatbot, **kwargs)[source]

Bases: chatterbot.logic.logic_adapter.LogicAdapter

Handles sentences containing the word feel

can_process(statement)[source]

A preliminary check that is called to determine if a logic adapter can process a given statement. By default, this method returns true but it can be overridden in child classes as needed.

Return type

bool

process(statement, additional_response_selection_parameters=None)[source]

Override this method and implement your logic for selecting a response to an input statement.

A confidence value and the selected response statement should be returned. The confidence value represents a rating of how accurate the logic adapter expects the selected response to be. Confidence scores are used to select the best response from multiple logic adapters.

The confidence value should be a number between 0 and 1 where 0 is the lowest confidence level and 1 is the highest.

Parameters
  • statement (Statement) – An input statement to be processed by the logic adapter.

  • additional_response_selection_parameters (dict) – Parameters to be used when filtering results to choose a response from.

Return type

Statement

sugaroid.brain.fun module

class sugaroid.brain.fun.FunAdapter(chatbot, **kwargs)[source]

Bases: chatterbot.logic.logic_adapter.LogicAdapter

Gives a random response, because Sugaroid tries not to say I don’t know

can_process(statement)[source]

A preliminary check that is called to determine if a logic adapter can process a given statement. By default, this method returns true but it can be overridden in child classes as needed.

Return type

bool

process(statement, additional_response_selection_parameters=None)[source]

Override this method and implement your logic for selecting a response to an input statement.

A confidence value and the selected response statement should be returned. The confidence value represents a rating of how accurate the logic adapter expects the selected response to be. Confidence scores are used to select the best response from multiple logic adapters.

The confidence value should be a number between 0 and 1 where 0 is the lowest confidence level and 1 is the highest.

Parameters
  • statement (Statement) – An input statement to be processed by the logic adapter.

  • additional_response_selection_parameters (dict) – Parameters to be used when filtering results to choose a response from.

Return type

Statement

sugaroid.brain.hangman module

class sugaroid.brain.hangman.Hangman(chatbot: sugaroid.core.bot.SugaroidBot, is_marvel=False, is_hp=False)[source]

Bases: object

game_over()[source]

Congratulation message as response at the end of the game :return:

gen_dash()[source]
get_remaining_life()[source]
get_results()[source]

Generates the results after a series of attempts :return: Boolean. True for User Win, False for lost

process(statement)[source]
class sugaroid.brain.hangman.HangmanAdapter(chatbot, **kwargs)[source]

Bases: sugaroid.core.base_adapters.SugaroidLogicAdapter

Plays hangman with you

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

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

Override this method and implement your logic for selecting a response to an input statement.

A confidence value and the selected response statement should be returned. The confidence value represents a rating of how accurate the logic adapter expects the selected response to be. Confidence scores are used to select the best response from multiple logic adapters.

The confidence value should be a number between 0 and 1 where 0 is the lowest confidence level and 1 is the highest.

Parameters
  • statement (Statement) – An input statement to be processed by the logic adapter.

  • additional_response_selection_parameters (dict) – Parameters to be used when filtering results to choose a response from.

Return type

Statement

sugaroid.brain.iam module

class sugaroid.brain.iam.MeAdapter(chatbot, **kwargs)[source]

Bases: chatterbot.logic.logic_adapter.LogicAdapter

Processes the statements showing possessive

can_process(statement)[source]

A preliminary check that is called to determine if a logic adapter can process a given statement. By default, this method returns true but it can be overridden in child classes as needed.

Return type

bool

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

Override this method and implement your logic for selecting a response to an input statement.

A confidence value and the selected response statement should be returned. The confidence value represents a rating of how accurate the logic adapter expects the selected response to be. Confidence scores are used to select the best response from multiple logic adapters.

The confidence value should be a number between 0 and 1 where 0 is the lowest confidence level and 1 is the highest.

Parameters
  • statement (Statement) – An input statement to be processed by the logic adapter.

  • additional_response_selection_parameters (dict) – Parameters to be used when filtering results to choose a response from.

Return type

Statement

sugaroid.brain.idk module

sugaroid.brain.imitate module

class sugaroid.brain.imitate.ImitateAdapter(chatbot, **kwargs)[source]

Bases: chatterbot.logic.logic_adapter.LogicAdapter

Handles statements involving imitations of some sentences

can_process(statement)[source]

A preliminary check that is called to determine if a logic adapter can process a given statement. By default, this method returns true but it can be overridden in child classes as needed.

Return type

bool

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

Override this method and implement your logic for selecting a response to an input statement.

A confidence value and the selected response statement should be returned. The confidence value represents a rating of how accurate the logic adapter expects the selected response to be. Confidence scores are used to select the best response from multiple logic adapters.

The confidence value should be a number between 0 and 1 where 0 is the lowest confidence level and 1 is the highest.

Parameters
  • statement (Statement) – An input statement to be processed by the logic adapter.

  • additional_response_selection_parameters (dict) – Parameters to be used when filtering results to choose a response from.

Return type

Statement

sugaroid.brain.interrupt module

class sugaroid.brain.interrupt.InterruptAdapter(chatbot, **kwargs)[source]

Bases: chatterbot.logic.logic_adapter.LogicAdapter

can_process(statement)[source]

A preliminary check that is called to determine if a logic adapter can process a given statement. By default, this method returns true but it can be overridden in child classes as needed.

Return type

bool

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

Override this method and implement your logic for selecting a response to an input statement.

A confidence value and the selected response statement should be returned. The confidence value represents a rating of how accurate the logic adapter expects the selected response to be. Confidence scores are used to select the best response from multiple logic adapters.

The confidence value should be a number between 0 and 1 where 0 is the lowest confidence level and 1 is the highest.

Parameters
  • statement (Statement) – An input statement to be processed by the logic adapter.

  • additional_response_selection_parameters (dict) – Parameters to be used when filtering results to choose a response from.

Return type

Statement

sugaroid.brain.joke module

class sugaroid.brain.joke.JokeAdapter(chatbot, **kwargs)[source]

Bases: sugaroid.core.base_adapters.SugaroidLogicAdapter

Gets a random joke from the v2.joke api

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

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

Override this method and implement your logic for selecting a response to an input statement.

A confidence value and the selected response statement should be returned. The confidence value represents a rating of how accurate the logic adapter expects the selected response to be. Confidence scores are used to select the best response from multiple logic adapters.

The confidence value should be a number between 0 and 1 where 0 is the lowest confidence level and 1 is the highest.

Parameters
  • statement (Statement) – An input statement to be processed by the logic adapter.

  • additional_response_selection_parameters (dict) – Parameters to be used when filtering results to choose a response from.

Return type

Statement

sugaroid.brain.learn module

class sugaroid.brain.learn.LearnAdapter(chatbot, **kwargs)[source]

Bases: chatterbot.logic.logic_adapter.LogicAdapter

a specific adapter for learning responses

can_process(statement)[source]

A preliminary check that is called to determine if a logic adapter can process a given statement. By default, this method returns true but it can be overridden in child classes as needed.

Return type

bool

process(statement, additional_response_selection_parameters=None)[source]

Override this method and implement your logic for selecting a response to an input statement.

A confidence value and the selected response statement should be returned. The confidence value represents a rating of how accurate the logic adapter expects the selected response to be. Confidence scores are used to select the best response from multiple logic adapters.

The confidence value should be a number between 0 and 1 where 0 is the lowest confidence level and 1 is the highest.

Parameters
  • statement (Statement) – An input statement to be processed by the logic adapter.

  • additional_response_selection_parameters (dict) – Parameters to be used when filtering results to choose a response from.

Return type

Statement

sugaroid.brain.let module

class sugaroid.brain.let.LetAdapter(chatbot, **kwargs)[source]

Bases: chatterbot.logic.logic_adapter.LogicAdapter

Takes care of assuming statements. Eg: Let a = 1

can_process(statement)[source]

A preliminary check that is called to determine if a logic adapter can process a given statement. By default, this method returns true but it can be overridden in child classes as needed.

Return type

bool

process(statement, additional_response_selection_parameters=None)[source]

Override this method and implement your logic for selecting a response to an input statement.

A confidence value and the selected response statement should be returned. The confidence value represents a rating of how accurate the logic adapter expects the selected response to be. Confidence scores are used to select the best response from multiple logic adapters.

The confidence value should be a number between 0 and 1 where 0 is the lowest confidence level and 1 is the highest.

Parameters
  • statement (Statement) – An input statement to be processed by the logic adapter.

  • additional_response_selection_parameters (dict) – Parameters to be used when filtering results to choose a response from.

Return type

Statement

sugaroid.brain.myname module

class sugaroid.brain.myname.MyNameAdapter(chatbot, **kwargs)[source]

Bases: chatterbot.logic.logic_adapter.LogicAdapter

Handles sentences featuring ‘my’ and ‘name’

can_process(statement)[source]

A preliminary check that is called to determine if a logic adapter can process a given statement. By default, this method returns true but it can be overridden in child classes as needed.

Return type

bool

process(statement, additional_response_selection_parameters=None)[source]

Override this method and implement your logic for selecting a response to an input statement.

A confidence value and the selected response statement should be returned. The confidence value represents a rating of how accurate the logic adapter expects the selected response to be. Confidence scores are used to select the best response from multiple logic adapters.

The confidence value should be a number between 0 and 1 where 0 is the lowest confidence level and 1 is the highest.

Parameters
  • statement (Statement) – An input statement to be processed by the logic adapter.

  • additional_response_selection_parameters (dict) – Parameters to be used when filtering results to choose a response from.

Return type

Statement

sugaroid.brain.news module

News headlines provided by NewsAPI

class sugaroid.brain.news.NewsAdapter(chatbot, **kwargs)[source]

Bases: chatterbot.logic.logic_adapter.LogicAdapter

Ports the SugaroidNews Wrapper for easier access by the SugaroidChatbot Class

can_process(statement)[source]

Checks if the statement has a cosine similarity of any of the words mentioned here :param statement: SugaroidStatement Class Object :return: bool,

process(statement, additional_response_selection_parameters=None)[source]

Override this method and implement your logic for selecting a response to an input statement.

A confidence value and the selected response statement should be returned. The confidence value represents a rating of how accurate the logic adapter expects the selected response to be. Confidence scores are used to select the best response from multiple logic adapters.

The confidence value should be a number between 0 and 1 where 0 is the lowest confidence level and 1 is the highest.

Parameters
  • statement (Statement) – An input statement to be processed by the logic adapter.

  • additional_response_selection_parameters (dict) – Parameters to be used when filtering results to choose a response from.

Return type

Statement

class sugaroid.brain.news.SugaroidNews(chatbot=None)[source]

Bases: object

A dedicated class for processing news from the API

get_news_keyword(keyword)[source]
get_top_headlines(country=None)[source]

Get the top news items of the country if provided. Otherwise give international news :param country: :return:

process(response)[source]

Convert the raw JSON Response to Human Readable News bullets :param response: :return: array of news headlines

sugaroid.brain.ok module

class sugaroid.brain.ok.OkayAdapter(chatbot, **kwargs)[source]

Bases: chatterbot.logic.logic_adapter.LogicAdapter

Handles statements with a plain old okay

can_process(statement)[source]

A preliminary check that is called to determine if a logic adapter can process a given statement. By default, this method returns true but it can be overridden in child classes as needed.

Return type

bool

process(statement, additional_response_selection_parameters=None)[source]

Override this method and implement your logic for selecting a response to an input statement.

A confidence value and the selected response statement should be returned. The confidence value represents a rating of how accurate the logic adapter expects the selected response to be. Confidence scores are used to select the best response from multiple logic adapters.

The confidence value should be a number between 0 and 1 where 0 is the lowest confidence level and 1 is the highest.

Parameters
  • statement (Statement) – An input statement to be processed by the logic adapter.

  • additional_response_selection_parameters (dict) – Parameters to be used when filtering results to choose a response from.

Return type

Statement

sugaroid.brain.oneword module

class sugaroid.brain.oneword.OneWordAdapter(chatbot, **kwargs)[source]

Bases: sugaroid.core.base_adapters.SugaroidLogicAdapter

Logical adapter for processing data with one words

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

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

Override this method and implement your logic for selecting a response to an input statement.

A confidence value and the selected response statement should be returned. The confidence value represents a rating of how accurate the logic adapter expects the selected response to be. Confidence scores are used to select the best response from multiple logic adapters.

The confidence value should be a number between 0 and 1 where 0 is the lowest confidence level and 1 is the highest.

Parameters
  • statement (Statement) – An input statement to be processed by the logic adapter.

  • additional_response_selection_parameters (dict) – Parameters to be used when filtering results to choose a response from.

Return type

Statement

sugaroid.brain.ooo module

class sugaroid.brain.ooo.Emotion[source]

Bases: object

Defines a variety of Sugaroid compatible Emotion

adorable = 6
angel = 12
angry = 11
angry_non_expressive = 13
blush = 3
cry = 5
cry_overflow = 10
dead = 15
depressed = 55
fun = 2
genie = 70
github = 14
lol = 8
negative = 50
neutral = 0
non_expressive = 53
non_expressive_left = 52
o = 4
positive = 1
rich = 2
seriously = 54
sleep = 57
smirking = 51
vomit = 15
wink = 4

sugaroid.brain.play module

class sugaroid.brain.play.PlayAdapter(chatbot, **kwargs)[source]

Bases: chatterbot.logic.logic_adapter.LogicAdapter

[DEPRECATED] Plays a game on desktops only

can_process(statement)[source]

A preliminary check that is called to determine if a logic adapter can process a given statement. By default, this method returns true but it can be overridden in child classes as needed.

Return type

bool

process(statement, additional_response_selection_parameters=None)[source]

Override this method and implement your logic for selecting a response to an input statement.

A confidence value and the selected response statement should be returned. The confidence value represents a rating of how accurate the logic adapter expects the selected response to be. Confidence scores are used to select the best response from multiple logic adapters.

The confidence value should be a number between 0 and 1 where 0 is the lowest confidence level and 1 is the highest.

Parameters
  • statement (Statement) – An input statement to be processed by the logic adapter.

  • additional_response_selection_parameters (dict) – Parameters to be used when filtering results to choose a response from.

Return type

Statement

sugaroid.brain.postprocessor module

sugaroid.brain.postprocessor.any_in(arg1: list, string1: list)[source]

Advanced in operator Checks any of the list item exists in in the string :param arg1: :param string1: :return:

sugaroid.brain.postprocessor.cosine_similarity(X_list, Y_list)[source]
sugaroid.brain.postprocessor.difference(lst1, lst2)[source]
sugaroid.brain.postprocessor.lemma_in(arg, spacy_tokenized)[source]
sugaroid.brain.postprocessor.pos_in(arg, spacy_tokenized)[source]
sugaroid.brain.postprocessor.random_response(iterable=())[source]

Selects a random response from the given set of iterable types :param iterable: :return: a selected value of the iterable

sugaroid.brain.postprocessor.raw_in(arg, spacy_tokenized)[source]
sugaroid.brain.postprocessor.raw_lower_in(arg, spacy_tokenized)[source]
sugaroid.brain.postprocessor.reverse(token)[source]

Reverses the first person pronouns to second person pronouns and vice versa :param token: a nltk.word_tokenize type list :return: a list similar to nltk.word_tokenize

sugaroid.brain.postprocessor.sigmaSimilarity(src, dest)[source]
Parameters
  • src – a list of literals

  • dest – a list of final literals

Returns

Probability

sugaroid.brain.postprocessor.text2int(textnum, numwords={})[source]

Converts words to numbers from https://stackoverflow.com/questions/493174/is-there-a-way-to-convert-number-words-to-integers :param textnum: :param numwords: :return:

sugaroid.brain.preprocessors module

sugaroid.brain.preprocessors.current_time()[source]

Returns a tuple containing (hour, minute) for current local time.

sugaroid.brain.preprocessors.non_punkt_normalize(txt)[source]
sugaroid.brain.preprocessors.normalize(text)[source]
sugaroid.brain.preprocessors.preprocess(string_arg: str, should_expand=True)[source]

EXPERIMENTAL Testing Required

Remove unwanted characters, expand words, replace short forms and fix capitalization for certain pronouns :param string_arg: String argument which you would like to process :return: String stype containing expanded texts :return_type: <class ‘str’>

sugaroid.brain.preprocessors.purify(tokenized, args, lemma=False)[source]

Scans tokenized text removes any common words in args :param tokenized: :param args: :return:

sugaroid.brain.preprocessors.spac_token(statement, chatbot=False)[source]
sugaroid.brain.preprocessors.tokenize(txt)[source]

sugaroid.brain.reader module

class sugaroid.brain.reader.ReaderAdapter(chatbot, **kwargs)[source]

Bases: chatterbot.logic.logic_adapter.LogicAdapter

Logical adapter for processing data with one words

can_process(statement)[source]

A preliminary check that is called to determine if a logic adapter can process a given statement. By default, this method returns true but it can be overridden in child classes as needed.

Return type

bool

process(statement, additional_response_selection_parameters=None)[source]

Override this method and implement your logic for selecting a response to an input statement.

A confidence value and the selected response statement should be returned. The confidence value represents a rating of how accurate the logic adapter expects the selected response to be. Confidence scores are used to select the best response from multiple logic adapters.

The confidence value should be a number between 0 and 1 where 0 is the lowest confidence level and 1 is the highest.

Parameters
  • statement (Statement) – An input statement to be processed by the logic adapter.

  • additional_response_selection_parameters (dict) – Parameters to be used when filtering results to choose a response from.

Return type

Statement

sugaroid.brain.rereversei module

class sugaroid.brain.rereversei.ReReverseAdapter(chatbot, **kwargs)[source]

Bases: chatterbot.logic.logic_adapter.LogicAdapter

Processes statements featuring conversational flow. It scans the previous statements and takes a cosine similarity of the statemnts, and TFiD Vector cross product to get the most probable answer

can_process(statement)[source]

A preliminary check that is called to determine if a logic adapter can process a given statement. By default, this method returns true but it can be overridden in child classes as needed.

Return type

bool

process(statement, additional_response_selection_parameters=None)[source]

Override this method and implement your logic for selecting a response to an input statement.

A confidence value and the selected response statement should be returned. The confidence value represents a rating of how accurate the logic adapter expects the selected response to be. Confidence scores are used to select the best response from multiple logic adapters.

The confidence value should be a number between 0 and 1 where 0 is the lowest confidence level and 1 is the highest.

Parameters
  • statement (Statement) – An input statement to be processed by the logic adapter.

  • additional_response_selection_parameters (dict) – Parameters to be used when filtering results to choose a response from.

Return type

Statement

sugaroid.brain.rereversei.reset_reverse(self)[source]

sugaroid.brain.reset module

class sugaroid.brain.reset.ResetAdapter(chatbot, **kwargs)[source]

Bases: chatterbot.logic.logic_adapter.LogicAdapter

Resets the Sugaroid global variables

can_process(statement)[source]

A preliminary check that is called to determine if a logic adapter can process a given statement. By default, this method returns true but it can be overridden in child classes as needed.

Return type

bool

process(statement, additional_response_selection_parameters=None)[source]

Override this method and implement your logic for selecting a response to an input statement.

A confidence value and the selected response statement should be returned. The confidence value represents a rating of how accurate the logic adapter expects the selected response to be. Confidence scores are used to select the best response from multiple logic adapters.

The confidence value should be a number between 0 and 1 where 0 is the lowest confidence level and 1 is the highest.

Parameters
  • statement (Statement) – An input statement to be processed by the logic adapter.

  • additional_response_selection_parameters (dict) – Parameters to be used when filtering results to choose a response from.

Return type

Statement

sugaroid.brain.reset_trivia module

class sugaroid.brain.reset_trivia.TriviaAdapter(chatbot, **kwargs)[source]

Bases: chatterbot.logic.logic_adapter.LogicAdapter

Resets the game of a trivia game

can_process(statement)[source]

A preliminary check that is called to determine if a logic adapter can process a given statement. By default, this method returns true but it can be overridden in child classes as needed.

Return type

bool

process(statement, additional_response_selection_parameters=None)[source]

Override this method and implement your logic for selecting a response to an input statement.

A confidence value and the selected response statement should be returned. The confidence value represents a rating of how accurate the logic adapter expects the selected response to be. Confidence scores are used to select the best response from multiple logic adapters.

The confidence value should be a number between 0 and 1 where 0 is the lowest confidence level and 1 is the highest.

Parameters
  • statement (Statement) – An input statement to be processed by the logic adapter.

  • additional_response_selection_parameters (dict) – Parameters to be used when filtering results to choose a response from.

Return type

Statement

sugaroid.brain.reversethink module

class sugaroid.brain.reversethink.ReverseAdapter(chatbot, **kwargs)[source]

Bases: chatterbot.logic.logic_adapter.LogicAdapter

A random adapter. Top Secret

can_process(statement)[source]

A preliminary check that is called to determine if a logic adapter can process a given statement. By default, this method returns true but it can be overridden in child classes as needed.

Return type

bool

process(statement, additional_response_selection_parameters=None)[source]

Override this method and implement your logic for selecting a response to an input statement.

A confidence value and the selected response statement should be returned. The confidence value represents a rating of how accurate the logic adapter expects the selected response to be. Confidence scores are used to select the best response from multiple logic adapters.

The confidence value should be a number between 0 and 1 where 0 is the lowest confidence level and 1 is the highest.

Parameters
  • statement (Statement) – An input statement to be processed by the logic adapter.

  • additional_response_selection_parameters (dict) – Parameters to be used when filtering results to choose a response from.

Return type

Statement

sugaroid.brain.saypls module

class sugaroid.brain.saypls.JokeAdapter(chatbot, **kwargs)[source]

Bases: chatterbot.logic.logic_adapter.LogicAdapter

Gets a random joke from the Chuck Norris Database

can_process(statement)[source]

A preliminary check that is called to determine if a logic adapter can process a given statement. By default, this method returns true but it can be overridden in child classes as needed.

Return type

bool

process(statement, additional_response_selection_parameters=None)[source]

Override this method and implement your logic for selecting a response to an input statement.

A confidence value and the selected response statement should be returned. The confidence value represents a rating of how accurate the logic adapter expects the selected response to be. Confidence scores are used to select the best response from multiple logic adapters.

The confidence value should be a number between 0 and 1 where 0 is the lowest confidence level and 1 is the highest.

Parameters
  • statement (Statement) – An input statement to be processed by the logic adapter.

  • additional_response_selection_parameters (dict) – Parameters to be used when filtering results to choose a response from.

Return type

Statement

sugaroid.brain.swaglyrics module

exception sugaroid.brain.swaglyrics.LyricsNotFound[source]

Bases: Exception

Exception raised when the lyrics has not been found in Genius through Swaglyrics

class sugaroid.brain.swaglyrics.SwagLyricsAdapter(chatbot, **kwargs)[source]

Bases: chatterbot.logic.logic_adapter.LogicAdapter

Get the lyrics for a song using Swaglyrics

can_process(statement)[source]

A preliminary check that is called to determine if a logic adapter can process a given statement. By default, this method returns true but it can be overridden in child classes as needed.

Return type

bool

process(statement, additional_response_selection_parameters=None)[source]

Override this method and implement your logic for selecting a response to an input statement.

A confidence value and the selected response statement should be returned. The confidence value represents a rating of how accurate the logic adapter expects the selected response to be. Confidence scores are used to select the best response from multiple logic adapters.

The confidence value should be a number between 0 and 1 where 0 is the lowest confidence level and 1 is the highest.

Parameters
  • statement (Statement) – An input statement to be processed by the logic adapter.

  • additional_response_selection_parameters (dict) – Parameters to be used when filtering results to choose a response from.

Return type

Statement

sugaroid.brain.time module

class sugaroid.brain.time.TimeAdapter(chatbot, **kwargs)[source]

Bases: chatterbot.logic.logic_adapter.LogicAdapter

Provides time and time related functions except time conversion

can_process(statement)[source]

A preliminary check that is called to determine if a logic adapter can process a given statement. By default, this method returns true but it can be overridden in child classes as needed.

Return type

bool

process(statement, additional_response_selection_parameters=None)[source]

Override this method and implement your logic for selecting a response to an input statement.

A confidence value and the selected response statement should be returned. The confidence value represents a rating of how accurate the logic adapter expects the selected response to be. Confidence scores are used to select the best response from multiple logic adapters.

The confidence value should be a number between 0 and 1 where 0 is the lowest confidence level and 1 is the highest.

Parameters
  • statement (Statement) – An input statement to be processed by the logic adapter.

  • additional_response_selection_parameters (dict) – Parameters to be used when filtering results to choose a response from.

Return type

Statement

sugaroid.brain.trivia module

class sugaroid.brain.trivia.TriviaAdapter(chatbot, **kwargs)[source]

Bases: sugaroid.core.base_adapters.SugaroidLogicAdapter

Plays a short game of trivia

can_process(statement: sugaroid.core.statement.SugaroidStatement)[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

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

Override this method and implement your logic for selecting a response to an input statement.

A confidence value and the selected response statement should be returned. The confidence value represents a rating of how accurate the logic adapter expects the selected response to be. Confidence scores are used to select the best response from multiple logic adapters.

The confidence value should be a number between 0 and 1 where 0 is the lowest confidence level and 1 is the highest.

Parameters
  • statement (Statement) – An input statement to be processed by the logic adapter.

  • additional_response_selection_parameters (dict) – Parameters to be used when filtering results to choose a response from.

Return type

Statement

sugaroid.brain.twoword module

class sugaroid.brain.twoword.TwoWordAdapter(chatbot, **kwargs)[source]

Bases: chatterbot.logic.logic_adapter.LogicAdapter

Hanfles sentences having two wrods

can_process(statement)[source]

A preliminary check that is called to determine if a logic adapter can process a given statement. By default, this method returns true but it can be overridden in child classes as needed.

Return type

bool

process(statement, additional_response_selection_parameters=None)[source]

Override this method and implement your logic for selecting a response to an input statement.

A confidence value and the selected response statement should be returned. The confidence value represents a rating of how accurate the logic adapter expects the selected response to be. Confidence scores are used to select the best response from multiple logic adapters.

The confidence value should be a number between 0 and 1 where 0 is the lowest confidence level and 1 is the highest.

Parameters
  • statement (Statement) – An input statement to be processed by the logic adapter.

  • additional_response_selection_parameters (dict) – Parameters to be used when filtering results to choose a response from.

Return type

Statement

sugaroid.brain.update module

class sugaroid.brain.update.UpdateAdapter(chatbot, **kwargs)[source]

Bases: chatterbot.logic.logic_adapter.LogicAdapter

[DO NOT CONNECT] a specific adapter for updating the sugaroid bot

can_process(statement)[source]

A preliminary check that is called to determine if a logic adapter can process a given statement. By default, this method returns true but it can be overridden in child classes as needed.

Return type

bool

process(statement, additional_response_selection_parameters=None)[source]

Override this method and implement your logic for selecting a response to an input statement.

A confidence value and the selected response statement should be returned. The confidence value represents a rating of how accurate the logic adapter expects the selected response to be. Confidence scores are used to select the best response from multiple logic adapters.

The confidence value should be a number between 0 and 1 where 0 is the lowest confidence level and 1 is the highest.

Parameters
  • statement (Statement) – An input statement to be processed by the logic adapter.

  • additional_response_selection_parameters (dict) – Parameters to be used when filtering results to choose a response from.

Return type

Statement

sugaroid.brain.utils module

class sugaroid.brain.utils.LanguageProcessor[source]

Bases: object

lemma(arg)[source]
lp()[source]
similarity(arg1, arg2)[source]
tokenize(arg)[source]

sugaroid.brain.waitwhat module

class sugaroid.brain.waitwhat.WaitWhatAdapter(chatbot, **kwargs)[source]

Bases: chatterbot.logic.logic_adapter.LogicAdapter

Handles statements that ask for a re-clarification. Compare WhatWhatAdapter

can_process(statement)[source]

A preliminary check that is called to determine if a logic adapter can process a given statement. By default, this method returns true but it can be overridden in child classes as needed.

Return type

bool

process(statement, additional_response_selection_parameters=None)[source]

Override this method and implement your logic for selecting a response to an input statement.

A confidence value and the selected response statement should be returned. The confidence value represents a rating of how accurate the logic adapter expects the selected response to be. Confidence scores are used to select the best response from multiple logic adapters.

The confidence value should be a number between 0 and 1 where 0 is the lowest confidence level and 1 is the highest.

Parameters
  • statement (Statement) – An input statement to be processed by the logic adapter.

  • additional_response_selection_parameters (dict) – Parameters to be used when filtering results to choose a response from.

Return type

Statement

sugaroid.brain.whatamidoing module

sugaroid.brain.whatamidoing.process_what_ami_doing(statement: sugaroid.core.statement.SugaroidStatement)[source]

sugaroid.brain.whatwhat module

class sugaroid.brain.whatwhat.WhatWhatAdapter(chatbot, **kwargs)[source]

Bases: chatterbot.logic.logic_adapter.LogicAdapter

Handles statements that ask for a clarification. Wait what?

can_process(statement)[source]

A preliminary check that is called to determine if a logic adapter can process a given statement. By default, this method returns true but it can be overridden in child classes as needed.

Return type

bool

process(statement, additional_response_selection_parameters=None)[source]

Override this method and implement your logic for selecting a response to an input statement.

A confidence value and the selected response statement should be returned. The confidence value represents a rating of how accurate the logic adapter expects the selected response to be. Confidence scores are used to select the best response from multiple logic adapters.

The confidence value should be a number between 0 and 1 where 0 is the lowest confidence level and 1 is the highest.

Parameters
  • statement (Statement) – An input statement to be processed by the logic adapter.

  • additional_response_selection_parameters (dict) – Parameters to be used when filtering results to choose a response from.

Return type

Statement

sugaroid.brain.whoami module

class sugaroid.brain.whoami.WhoAdapter(chatbot, **kwargs)[source]

Bases: chatterbot.logic.logic_adapter.LogicAdapter

Handles statements with ‘who’ as one of the tokens

can_process(statement)[source]

A preliminary check that is called to determine if a logic adapter can process a given statement. By default, this method returns true but it can be overridden in child classes as needed.

Return type

bool

process(statement, additional_response_selection_parameters=None)[source]

Override this method and implement your logic for selecting a response to an input statement.

A confidence value and the selected response statement should be returned. The confidence value represents a rating of how accurate the logic adapter expects the selected response to be. Confidence scores are used to select the best response from multiple logic adapters.

The confidence value should be a number between 0 and 1 where 0 is the lowest confidence level and 1 is the highest.

Parameters
  • statement (Statement) – An input statement to be processed by the logic adapter.

  • additional_response_selection_parameters (dict) – Parameters to be used when filtering results to choose a response from.

Return type

Statement

sugaroid.brain.why module

class sugaroid.brain.why.WhyWhenAdapter(chatbot, **kwargs)[source]

Bases: sugaroid.core.base_adapters.SugaroidLogicAdapter

Processes wh-adverbs

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

process(statement: sugaroid.core.statement.SugaroidStatement, additional_response_selection_parameters=None)[source]
Parameters
  • statement

  • additional_response_selection_parameters

Returns

sugaroid.brain.why.get_age() str[source]

sugaroid.brain.wiki module

class sugaroid.brain.wiki.WikiAdapter(chatbot, **kwargs)[source]

Bases: chatterbot.logic.logic_adapter.LogicAdapter

Handles Wikipedia based questions

can_process(statement) bool[source]

A preliminary check that is called to determine if a logic adapter can process a given statement. By default, this method returns true but it can be overridden in child classes as needed.

Return type

bool

process(statement, additional_response_selection_parameters=None)[source]

Override this method and implement your logic for selecting a response to an input statement.

A confidence value and the selected response statement should be returned. The confidence value represents a rating of how accurate the logic adapter expects the selected response to be. Confidence scores are used to select the best response from multiple logic adapters.

The confidence value should be a number between 0 and 1 where 0 is the lowest confidence level and 1 is the highest.

Parameters
  • statement (Statement) – An input statement to be processed by the logic adapter.

  • additional_response_selection_parameters (dict) – Parameters to be used when filtering results to choose a response from.

Return type

Statement

Parameters
  • self – self object where chatbot object is also located

  • question

Returns

A tuple of values:

(response, confidence, stat) stat = Found or not found

sugaroid.brain.wolfalpha module

Wolfram|Alpha Adapter is an adapter which is used to fetch results from the Wolfram ALpha server

MARKS LICENSE AND ATTRIBUTION”Wolfram|Alpha Marks” means the trade names, trademarks, service marks, logos, domain names and other distinctive marks of Wolfram|Alpha. Wolfram|Alpha grants You a non-exclusive license to use the Wolfram|Alpha Marks solely in connection with their display on or through the API Client as delivered by Wolfram|Alpha. Your API Client shall provide proper attribution to Wolfram|Alpha whenever such content is displayed or accessed by providing the end user with a direct link to the specific Wolfram|Alpha result page from which the content was derived. Wolfram|Alpha may terminate Your license

to use the Wolfram|Alpha Marks at any time for any or no reason. You shall not at
any time challenge or assist others to challenge Wolfram|Alpha Marks or their

registration (except to the extent You cannot give up that right by law) or to register any trademarks, marks, domains or trade names obviously similar, in

Wolfram|Alpha’s discretion, to those of Wolfram|Alpha. This prohibition survives any termination or expiration of this Agreement.

LINKINGUnless part of a written agreement to the contrary, You are required to provide a conspicuous hyperlink directly to the corresponding results page of the Wolfram|Alpha website (http://www.wolframalpha.com) on every page with Results.

class sugaroid.brain.wolfalpha.WolframAlphaAdapter(chatbot, **kwargs)[source]

Bases: sugaroid.core.base_adapters.SugaroidLogicAdapter

Wolfram Alpha Adapter for Sugaroid

can_process(statement: sugaroid.core.statement.SugaroidStatement)[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

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

Override this method and implement your logic for selecting a response to an input statement.

A confidence value and the selected response statement should be returned. The confidence value represents a rating of how accurate the logic adapter expects the selected response to be. Confidence scores are used to select the best response from multiple logic adapters.

The confidence value should be a number between 0 and 1 where 0 is the lowest confidence level and 1 is the highest.

Parameters
  • statement (Statement) – An input statement to be processed by the logic adapter.

  • additional_response_selection_parameters (dict) – Parameters to be used when filtering results to choose a response from.

Return type

Statement

sugaroid.brain.yesno module

class sugaroid.brain.yesno.BoolAdapter(chatbot, **kwargs)[source]

Bases: sugaroid.core.base_adapters.SugaroidLogicAdapter

Processes Boolean based answers

can_process(statement: sugaroid.core.statement.SugaroidStatement)[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

process(statement, additional_response_selection_parameters=None)[source]

Override this method and implement your logic for selecting a response to an input statement.

A confidence value and the selected response statement should be returned. The confidence value represents a rating of how accurate the logic adapter expects the selected response to be. Confidence scores are used to select the best response from multiple logic adapters.

The confidence value should be a number between 0 and 1 where 0 is the lowest confidence level and 1 is the highest.

Parameters
  • statement (Statement) – An input statement to be processed by the logic adapter.

  • additional_response_selection_parameters (dict) – Parameters to be used when filtering results to choose a response from.

Return type

Statement

Module contents