AutoCorrect module

class AutoCorrect.AutoCorrect[source]

Bases: object

classmethod auto_correct(input_string)[source]

Takes in argument input_string, splits by spaces to create word tokens, and replaces each token with closest match in the class’ correction_dict. Returns string of tokens joined by spaces (preserves order).

Parameters

input_string – string

Returns

string

classmethod input(prompt='')[source]

Input method used by autocorrect class. Takes in input using builtin input method and returns corrected input. Supports input prompt.

Parameters

prompt

Returns

input_reference()

Read a string from standard input. The trailing newline is stripped.

The prompt string, if given, is printed to standard output without a trailing newline before reading input.

If the user hits EOF (*nix: Ctrl-D, Windows: Ctrl-Z+Return), raise EOFError. On *nix systems, readline is used if available.

classmethod override_input()[source]

Overrides builtin input method with class input method.

Returns

classmethod register(category, words)[source]

Registers new autocorrection categories and words.

Parameters
  • category

  • words

Returns

classmethod restore_input()[source]

Restores builtin input method.

Returns

classmethod switch_input()[source]

Switches between builtin input method and class input method, depending on which is currently being used.

Returns

correction_dict = {}
cutoff = 0.6