Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
"""Computes minimum distance.
This method computes, for a pair of input/output strings or acceptors, the
minimum edit distance according to the underlying edit transducer.
Args:
iset: input string or acceptor.
oset: output string or acceptor.
Returns:
Minimum edit distance according to the edit transducer.
"""
lattice = self._create_lattice(iset, oset)
# The shortest cost from all final states to the start state is
# equivalent to the cost of the shortest path.
return float(shortestdistance(lattice, reverse=True)[lattice.start()])