def get_candidates(word): w = Word(word, self.lang) candidates = (self.existing([word]) or self.existing(w.typos()) or self.existing(w.double_typos()) or [word]) return [(self.nlp_data.get(c), c) for c in candidates]
def autocorrect_word(self, word): """most likely correction for everything up to a double typo""" w = Word(word, self.lang) candidates = (self.existing([word]) or self.existing(w.typos()) or self.existing(w.double_typos()) or [word]) return max(candidates, key=self.nlp_data.get)
def get_candidates(self, word): w = Word(word, self.lang, self.only_replacements) if self.fast: candidates = self.existing([word]) or self.existing( w.typos()) or [word] else: candidates = (self.existing([word]) or self.existing(w.typos()) or self.existing(w.double_typos()) or [word]) return [(self.nlp_data.get(c, 0), c) for c in candidates]
def test_single_typos(): word = Word("me", "en") assert set(word.typos()) == single_typos_me
def test_single_typos(): word = Word('me', 'en') assert set(word.typos()) == single_typos_me