deeppavlov/models/spelling_correction/levenshtein/tabled_trie.py
def find_partitions(self, s, max_count=1):
        """
        Находит все разбиения s = s_1 ... s_m на словарные слова s_1, ..., s_m
        для m <= max_count
        """
        curr_agenda = [(self.root, [], 0)]
        for i, a in enumerate(s):
            next_agenda = []
            for curr, borders, cost in curr_agenda:
                if cost >= max_count:
                    continue
                child = self.graph[curr][self.alphabet_codes[a]]
                # child = self.graph[curr][a]
                if child == Trie.NO_NODE:
                    continue
                next_agenda.append((child, borders, cost))
                if self.is_final(child):
                    next_agenda.append((self.root, borders + [i+1], cost+1))
            curr_agenda = next_agenda
        answer = []
        for curr, borders, cost in curr_agenda:
            if curr == self.root:
                borders = [0] + borders
                answer.append([s[left:borders[i+1]] for i, left in enumerate(borders[:-1])])
        return answer
def find_partitions(self, s, max_count=1):
        """
        Находит все разбиения s = s_1 ... s_m на словарные слова s_1, ..., s_m
        для m <= max_count
        """
        curr_agenda = [(self.root, [], 0)]
        for i, a in enumerate(s):
            next_agenda = []
            for curr, borders, cost in curr_agenda:
                if cost >= max_count:
                    continue
                child = self.graph[curr][self.alphabet_codes[a]]
                # child = self.graph[curr][a]
                if child == Trie.NO_NODE:
                    continue
                next_agenda.append((child, borders, cost))
                if self.is_final(child):
                    next_agenda.append((self.root, borders + [i+1], cost+1))
            curr_agenda = next_agenda
        answer = []
        for curr, borders, cost in curr_agenda:
            if curr == self.root:
                borders = [0] + borders
                answer.append([s[left:borders[i+1]] for i, left in enumerate(borders[:-1])])
        return answer
def find_partitions ( self , s , max_count = 1 ) : curr_agenda = [ ( self . root , [ ] , 0 ) ] for i , a in enumerate ( s ) : next_agenda = [ ] for curr , borders , cost in curr_agenda : if cost >= max_count : continue child = self . graph [ curr ] [ self . alphabet_codes [ a ] ] # child = self.graph[curr][a] if child == Trie . NO_NODE : continue next_agenda . append ( ( child , borders , cost ) ) if self . is_final ( child ) : next_agenda . append ( ( self . root , borders + [ i + 1 ] , cost + 1 ) ) curr_agenda = next_agenda answer = [ ] for curr , borders , cost in curr_agenda : if curr == self . root : borders = [ 0 ] + borders answer . append ( [ s [ left : borders [ i + 1 ] ] for i , left in enumerate ( borders [ : - 1 ] ) ] ) return answer
Находит все разбиения s = s_1 ... s_m на словарные слова s_1, ..., s_m
        для m <= max_count
Находит все разбиения s = s_1 ... s_m на словарные слова s_1 ... s_m для m < = max_count