Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
in the lexicon according to the underlying edit transducer. In the case of
a tie (i.e., where there are multiple closest strings), only one will be
returned; tie breaking is deterministic but difficult to reason about and
thus should be considered unspecified.) The `closest_matches` method can be
used to enumerate all the ties.
Args:
query: input string or acceptor.
Returns:
The closest string in the lexicon.
"""
lattice = self._create_levenshtein_automaton_lattice(query)
# For implementation reasons, the shortest path (when k = 1) is in reverse
# state order, so we perform a topological sort ahead of time.
return shortestpath(lattice).topsort().stringify()