CorrectOCR.dictionary module

class CorrectOCR.dictionary.Dictionary(path=None, ignoreCase=False)[source]

Bases: set, typing.Generic

Set of words to use for determining correctness of Tokens and suggestions.

Parameters
  • path (Optional[Path]) – A path for loading a previously saved dictionary.

  • ignoreCase (bool) – Whether the dictionary is case sensitive.

clear()[source]

Remove all elements from this set.

add(word, nowarn=False)[source]

Add a new word to the dictionary. Silently drops non-alpha strings.

Parameters
  • word (str) – The word to add.

  • nowarn (bool) – Don’t warn about long words (>15 letters).

save(path=None)[source]

Save the dictionary.

Parameters

path (Optional[Path]) – Optional new path to save to.