code: def test_levenshtein_prefix():
      path = os.path.join(
          os.path.dirname(__file__), "english-words.10.gz"
      )
      wordfile = gzip.open(path, "rb")
      words = sorted(
          line.decode("latin1").strip().lower() for line in wordfile
      )
      prefixlen = 1
  
      def find_brute(target, k):
          for w in words:
              d = levenshtein(w, target, k)
              if d <= k and w[:prefixlen] == target[:prefixlen]:
                  yield w
  
      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)
  
      assert set(find_brute("look", 2)) == set(find_auto("look", 2))
      assert set(find_brute("bend", 1)) == set(find_auto("bend", 1))
      assert set(find_brute("puck", 1)) == set(find_auto("puck", 1))
      assert set(find_brute("zero", 1)) == set(find_auto("zero", 1))
  
imports: import gzip
  import os.path
  from bisect import bisect_left
  from whoosh.compat import permutations
  from whoosh.compat import xrange
  from whoosh.automata import fsa, glob, lev
  from whoosh.support.levenshtein import levenshtein
label_desc: Use image node_id 10 for calling a global function with example usage: test_levenshtein_prefix() and returns: fsa