Exemple #1
0
    def _suggestions(self, text, maxdist, prefix):
        from whoosh.automata.lev import levenshtein_automaton
        from whoosh.automata.fsa import find_all_matches

        seen = set()
        for i in range(1, maxdist + 1):
            dfa = levenshtein_automaton(text, maxdist, prefix).to_dfa()
            sk = self.Skipper(self.wordlist)
            for sug in find_all_matches(dfa, sk):
                if sug not in seen:
                    seen.add(sug)
                    yield (0 - maxdist), sug
Exemple #2
0
    def _suggestions(self, text, maxdist, prefix):
        from whoosh.automata.lev import levenshtein_automaton
        from whoosh.automata.fsa import find_all_matches

        seen = set()
        for i in xrange(1, maxdist + 1):
            dfa = levenshtein_automaton(text, maxdist, prefix).to_dfa()
            sk = self.Skipper(self.wordlist)
            for sug in find_all_matches(dfa, sk):
                if sug not in seen:
                    seen.add(sug)
                    yield (0 - maxdist), sug
 def find_auto(target, k):
     dfa = lev.levenshtein_automaton(target, k, prefix=prefixlen).to_dfa()
     sk = Skipper(words)
     return fsa.find_all_matches(dfa, sk)
Exemple #4
0
 def find_auto(target, k):
     dfa = lev.levenshtein_automaton(target, k, prefix=prefixlen).to_dfa()
     sk = Skipper(words)
     return fsa.find_all_matches(dfa, sk)