How to use the pynini.string_map 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
def __init__(self,
               alphabet,
               lexicon,
               insert_cost=DEFAULT_INSERT_COST,
               delete_cost=DEFAULT_DELETE_COST,
               substitute_cost=DEFAULT_SUBSTITUTE_COST):
    super(LevenshteinAutomaton, self).__init__(alphabet, insert_cost,
                                               delete_cost, substitute_cost)
    # Compiles lexicon and composes the right factor with it.
    compiled_lexicon = string_map(lexicon)
    self._l_o = self._e_o @ compiled_lexicon
    self._l_o.optimize(True)

pynini

Finite-state grammar compilation

MIT
Latest version published 5 months ago

Package Health Score

82 / 100
Full package analysis