Skip to content
Snippets Groups Projects
Commit d69f437a authored by Tomasz Walkowiak's avatar Tomasz Walkowiak
Browse files

fixing typos

parent 7035bd0a
No related merge requests found
Pipeline #9208 failed with stages
in 16 seconds
...@@ -7,20 +7,24 @@ from autocorrect import Speller, Word ...@@ -7,20 +7,24 @@ from autocorrect import Speller, Word
_log = logging.getLogger(__name__) _log = logging.getLogger(__name__)
class SpellerFixed(Speller): class SpellerFixed(Speller):
"""Fixes orginal speller in case of long words""" """Fixes orginal speller in case of long words."""
def __init__(self, lang="en"): def __init__(self, lang="en"):
"""Call superclass."""
super().__init__(lang) super().__init__(lang)
def get_candidates(self, word): def get_candidates(self, word):
"""Returns a list of possible candidate words."""
w = Word(word, self.lang, self.only_replacements) w = Word(word, self.lang, self.only_replacements)
if self.fast or len(word)>15: if self.fast or len(word) > 15:
candidates = self.existing([word]) or self.existing(w.typos()) or [word] candidates = self.existing([word]) or self.existing(w.typos()) or
[word]
else: else:
candidates = ( candidates = (
self.existing([word]) self.existing([word]) or
or self.existing(w.typos()) self.existing(w.typos()) or
or self.existing(w.double_typos()) self.existing(w.double_typos()) or
or [word] [word]
) )
return [(self.nlp_data.get(c, 0), c) for c in candidates] return [(self.nlp_data.get(c, 0), c) for c in candidates]
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment