Ejemplo n.º 1
0
 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]
Ejemplo n.º 2
0
 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)
Ejemplo n.º 3
0
 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]
Ejemplo n.º 4
0
def test_single_typos():
    word = Word("me", "en")
    assert set(word.typos()) == single_typos_me
Ejemplo n.º 5
0
def test_single_typos():
    word = Word('me', 'en')
    assert set(word.typos()) == single_typos_me