示例#1
0
 def next(self):
     # Try to get the next sub-token from word currently being split.
     # If unavailable, move on to the next word and try again.
     while True:
         try:
             (word, pos) = next(self._curtok)
             return (word, pos + self._curpos)
         except StopIteration:
             (word, pos) = next(self._tokenizer)
             while self._skip(self._to_string(word)):
                 (word, pos) = next(self._tokenizer)
             self._curword = word
             self._curpos = pos
             self._curtok = self._split(word)
示例#2
0
 def next(self):
     # Try to get the next sub-token from word currently being split.
     # If unavailable, move on to the next word and try again.
     try:
         (word,pos) = next(self._curtok)
         return (word,pos + self._curpos)
     except StopIteration:
         (word,pos) = next(self._tokenizer)
         while self._skip(word):
             (word,pos) = next(self._tokenizer)
         self._curword = word
         self._curpos = pos
         self._curtok = self._split(word)
         return self.next()
示例#3
0
    def next(self):
        """Process text up to the next spelling error.
        
        This method is designed to support the iterator protocol.
        Each time it is called, it will advance the 'word' attribute
        to the next spelling error in the text.  When no more errors
        are found, it will raise StopIteration.
        
        The method will always return self, so that it can be used
        sensibly in common idioms such as:

            for err in checker:
                err.do_something()
        
        """
        # Find the next spelling error.
        # The uncaught StopIteration from next(self._tokens)
        # will provide the StopIteration for this method
        while True:
            (word,pos) = next(self._tokens)
            # decode back to a regular string
            word = self._array_to_string(word)
            if self.dict.check(word):
                continue
            if word in self._ignore_words:
                continue
            self.word = word
            self.wordpos = pos
            if word in self._replace_words:
                self.replace(self._replace_words[word])
                continue
            break
        return self
示例#4
0
    def next(self):
        """Process text up to the next spelling error.
        
        This method is designed to support the iterator protocol.
        Each time it is called, it will advance the 'word' attribute
        to the next spelling error in the text.  When no more errors
        are found, it will raise StopIteration.
        
        The method will always return self, so that it can be used
        sensibly in common idioms such as:

            for err in checker:
                err.do_something()
        
        """
        # Find the next spelling error.
        # The uncaught StopIteration from next(self._tokens)
        # will provide the StopIteration for this method
        while True:
            (word, pos) = next(self._tokens)
            # decode back to a regular string
            word = self._array_to_string(word)
            if self.dict.check(word):
                continue
            if word in self._ignore_words:
                continue
            self.word = word
            self.wordpos = pos
            if word in self._replace_words:
                self.replace(self._replace_words[word])
                continue
            break
        return self