How to use the pynini.shortestdistance function in pynini

To help you get started, we’ve selected a few pynini examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github kylebgorman / EditTransducer / edit_transducer / edit_transducer.py View on Github external
"""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()])

pynini

Finite-state grammar compilation

MIT
Latest version published 4 months ago

Package Health Score

79 / 100
Full package analysis