helper module

class helper.Context(operator: helper.Helper)

Bases: object

[Context class for the Strategy Pattern, for helper]

run(*argv)

[runs the helper object]

Returns

[returns the value returned by the helper object]

Return type

  • bool

  • str

  • int

  • float

strategy(operator: helper.Helper)

[setter]

Parameters

operator (Helper) – [sets the helper object]

class helper.Helper

Bases: abc.ABC

[Interface for Helper classes. These classes contain simple methods that support skill classes.

The helper applies the Strategy Pattern]

run(*argv)
class helper.create_pickle_files

Bases: helper.Helper

run(name: str)
[After registration, this method creates three pickle files where user’s details are stored:
  • [SOS contact details]

  • [Personal lists]

  • [Personal settings]]

Parameters

name (str) – [The name of the user in front of the camera and the name of the folder where the pickle files are created]

class helper.delete_pictures

Bases: helper.Helper

run(name: str)

[Method that removes the pictures after registration, but keeps the folder for the user’s personal settings and lists]

Parameters

name (str) – [The name of the folder and the name of the user]

class helper.folder_exists

Bases: helper.Helper

run(folder: str)

[The method checks if a certain path exists or not]

Parameters

folder (str) – [The path that needs to be checked if it exists]

Returns

  • True -> the path exists

  • False -> the path does not exist

Return type

str

class helper.get_last_word

Bases: helper.Helper

run(string: str)

[The method returns the last word from a sentence]

Parameters

string (str) – [The sentence that needs to be parsed]

Returns

[The last word of initial sentence]

Return type

str

class helper.get_request

Bases: helper.Helper

run(link: str)

[Method that performs a request and returns the response of the request in a JSON format]

Parameters

link (str) – [Link to get the response from]

Returns

[Returns the response of the server in a json format]

Return type

[JSON format]

class helper.nice_formatted_long_text

Bases: helper.Helper

run(longString: str)

[Method that formats a long string to multiple rows]

Parameters

longString (str) – [String received, that needs to be formatatted]

splitter(numberOfWords: int, longString: str)

[Method created as a helper for the “nice_formatted_long_text(longString:str)” ]

Parameters
  • numberOfWords (int) – [Denotes how many words are allowed on a single row]

  • longString (str) – [The initial string that needs to be parsed]

class helper.remove_polite_words

Bases: helper.Helper

run(string: str)

[Method removing the polite words from a string, as they are not used by the virtual_assistant to process a request]

Parameters

string (str) – [String that needs to be cleaned from certain words]

class helper.remove_words

Bases: helper.Helper

run(string: str, words: list)

[Method that hat removes certain substrings from a string]

Parameters
  • string (str) – [String that neeeds to be cleaned]

  • words (list) – [The words that the string needs to be cleaned from]

Returns

[The cleaned string]

Return type

str

class helper.substring_after

Bases: helper.Helper

run(string: str, delimiter: str)

[Method returning the next two words after a keyword ]

Parameters
  • string (str) – [Initial string]

  • delimiter (str) – [The key word searched in the string]

class helper.word_after

Bases: helper.Helper

run(string: str, delimiter: str)

[method that returns a certain word, following a particular string]

Parameters
  • string (str) – [Initial string]

  • delimiter (str) – [The word after which the string is required]

Returns

[A certain string]

Return type

[str]

class helper.word_before

Bases: helper.Helper

run(string: str, delimiter: str)

[Method that returns a string found before after a certain word]

Parameters
  • string (str) – [Initial string]

  • delimiter (str) – [The word before the string is required]

Returns

[A certain string]

Return type

[str]