deeppavlov/models/spelling_correction/levenshtein/tabled_trie.py
def words(self):
        """
        Возвращает итератор по словам, содержащимся в боре
        """
        branch, word, indexes = [self.root], [], [0]
        letters_with_children = [self._get_children_and_letters(self.root)]
        while len(branch) > 0:
            if self.is_final(branch[-1]):
                yield "".join(word)
            while indexes[-1] == len(letters_with_children[-1]):
                indexes.pop()
                letters_with_children.pop()
                branch.pop()
                if len(indexes) == 0:
                    raise StopIteration()
                word.pop()
            next_letter, next_child = letters_with_children[-1][indexes[-1]]
            indexes[-1] += 1
            indexes.append(0)
            word.append(next_letter)
            branch.append(next_child)
            letters_with_children.append(self._get_children_and_letters(branch[-1]))
def words(self):
        """
        Возвращает итератор по словам, содержащимся в боре
        """
        branch, word, indexes = [self.root], [], [0]
        letters_with_children = [self._get_children_and_letters(self.root)]
        while len(branch) > 0:
            if self.is_final(branch[-1]):
                yield "".join(word)
            while indexes[-1] == len(letters_with_children[-1]):
                indexes.pop()
                letters_with_children.pop()
                branch.pop()
                if len(indexes) == 0:
                    raise StopIteration()
                word.pop()
            next_letter, next_child = letters_with_children[-1][indexes[-1]]
            indexes[-1] += 1
            indexes.append(0)
            word.append(next_letter)
            branch.append(next_child)
            letters_with_children.append(self._get_children_and_letters(branch[-1]))
def words ( self ) : branch , word , indexes = [ self . root ] , [ ] , [ 0 ] letters_with_children = [ self . _get_children_and_letters ( self . root ) ] while len ( branch ) > 0 : if self . is_final ( branch [ - 1 ] ) : yield "" . join ( word ) while indexes [ - 1 ] == len ( letters_with_children [ - 1 ] ) : indexes . pop ( ) letters_with_children . pop ( ) branch . pop ( ) if len ( indexes ) == 0 : raise StopIteration ( ) word . pop ( ) next_letter , next_child = letters_with_children [ - 1 ] [ indexes [ - 1 ] ] indexes [ - 1 ] += 1 indexes . append ( 0 ) word . append ( next_letter ) branch . append ( next_child ) letters_with_children . append ( self . _get_children_and_letters ( branch [ - 1 ] ) )
Возвращает итератор по словам, содержащимся в боре
Возвращает итератор по словам содержащимся в боре