Example #1
0
 def known_edits2(self, word):
     #
     words = set(e2 for e1 in edits1(word) for e2 in edits1(e1) if self.lookup(e2))
     v = set()
     for c in words:
         if(spelltools.is_valid(c)):
             v.add(c)
     return words
Example #2
0
 def known_edits2(self, word):
     #
     words = set(e2 for e1 in edits1(word) for e2 in edits1(e1)
                 if self.lookup(e2))
     v = set()
     for c in words:
         if (spelltools.is_valid(c)):
             v.add(c)
     return words
Example #3
0
 def correct(self, word):
     """
     Give suggestion to wrong word
     @param word: input word
     @type  word: unicode
     @return: a list of suggested words
     @rtype: list of unicode
     """
     candidates = self.known([word])
     if not candidates:
         candidates = self.known(edits1(word))
     #ToDo: implement the second error edits
     #if not candidates:
         #candidates =  self.known_edits2(word)
     if not candidates:
         candidates = [word]
     return sorted(candidates, key=lambda x: spelltools.phonetic_distance(word,x))
Example #4
0
 def correct(self, word):
     """
     Give suggestion to wrong word
     @param word: input word
     @type  word: unicode
     @return: a list of suggested words
     @rtype: list of unicode
     """
     candidates = self.known([word])
     if not candidates:
         candidates = self.known(edits1(word))
     #ToDo: implement the second error edits
     #if not candidates:
         #candidates =  self.known_edits2(word)
     if not candidates:
         candidates = [word]
     return sorted(candidates, key=lambda x: spelltools.phonetic_distance(word,x))
Example #5
0
    def known_edits2(self, word):

        return set(e2 for e1 in edits1(word) for e2 in edits1(e1)
                   if self.lookup(e2))
Example #6
0
    def known_edits2(self, word):

        return set(e2 for e1 in edits1(word) for e2 in edits1(e1) if self.lookup(e2))