Beispiel #1
0
 def process_word(self, word):
     """
     Check the word. Return None if the word is properly spelled.
     Otherwise, return a list of alternatives.
     """
     d = self.d
     if not d:
         return None
     if d.check(word):
         return None
     # Speed doesn't matter here. The more we find, the more convenient.
     # Remove all digits.
     word = ''.join([i for i in word if not i.isdigit()])
     if d.check(word) or d.check(word.lower()):
         return None
     if word.find('_') > -1:
         # Snake case.
         words = word.split('_')
         for word2 in words:
             if not d.check(word2) and not d.check(word2.lower()):
                 return d.suggest(word)
         return None
     words = g.unCamel(word)
     if words:
         for word2 in words:
             if not d.check(word2) and not d.check(word2.lower()):
                 return d.suggest(word)
         return None
     return d.suggest(word)
Beispiel #2
0
 def processWord(self, word):
     """
     Check the word. Return None if the word is properly spelled.
     Otherwise, return a list of alternatives.
     """
     d = self.d
     if not d:
         return None
     elif d.check(word):
         return None
     # Speed doesn't matter here. The more we find, the more convenient.
     word = ''.join([i for i in word if not i.isdigit()])
         # Remove all digits.
     if d.check(word) or d.check(word.lower()):
         return None
     if word.find('_') > -1:
         # Snake case.
         words = word.split('_')
         for word2 in words:
             if not d.check(word2) and not d.check(word2.lower()):
                 return d.suggest(word)
         return None
     words = g.unCamel(word)
     if words:
         for word2 in words:
             if not d.check(word2) and not d.check(word2.lower()):
                 return d.suggest(word)
         return None
     else:
         return d.suggest(word)