pynini | Read-only mirror of Pynini

 by   kylebgorman Python Version: Current License: Apache-2.0

kandi X-RAY | pynini Summary

kandi X-RAY | pynini Summary

pynini is a Python library. pynini has no bugs, it has no vulnerabilities, it has build file available, it has a Permissive License and it has low support. You can download it from GitHub.

Pynini is a Python extension module which allows the user to compile, optimize, and apply grammar rules. Rules can be compiled into weighted finite state transducers, pushdown transducers, or multi-pushdown transducers. For general information and a detailed tutorial, see pynini.opengrm.org.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              pynini has a low active ecosystem.
              It has 55 star(s) with 9 fork(s). There are 7 watchers for this library.
              OutlinedDot
              It had no major release in the last 6 months.
              There are 3 open issues and 41 have been closed. On average issues are closed in 54 days. There are 1 open pull requests and 0 closed requests.
              It has a neutral sentiment in the developer community.
              The latest version of pynini is current.

            kandi-Quality Quality

              pynini has 0 bugs and 0 code smells.

            kandi-Security Security

              pynini has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              pynini code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              pynini is licensed under the Apache-2.0 License. This license is Permissive.
              Permissive licenses have the least restrictions, and you can use them in most projects.

            kandi-Reuse Reuse

              pynini releases are not available. You will need to build from source code and install.
              Build file is available. You can build the component from source.
              Installation instructions, examples and code snippets are available.

            Top functions reviewed by kandi - BETA

            kandi has reviewed pynini and discovered the below as its top functions. This is intended to give you an instant insight into pynini implemented functionality, and help decide if they suit your requirements.
            • Run the generator
            • Generate a mapping of target designator
            • Close the FST file
            • Check if ostring matches a given rule
            • Rewrite the lattice
            • Checks if the input matches the given string
            • Return the top - level rewrite
            • Convert a lattice to the shortest shortest path
            • Convert a lattice to a list of strings
            • Find optimal rewrite for a string
            • Convert a lattice to fst
            • Transform a sentence into a string
            • Rewrite a string
            • Transform a string into one - top - top - top - level rewriting
            • Return a list of possible rewrite rules
            • Rewrites the given string
            • Return a list of strings representing the top - left transformation
            • Rewrite a top - level string
            • Create a new Fst with the given weight
            • Rewrite the input string
            • Delete a cross expression
            • Reduce a rule
            • Generate markdown
            • Returns a fst with zero padding
            • Tag a word
            • Get the version string
            Get all kandi verified functions for this library.

            pynini Key Features

            No Key Features are available at this moment for pynini.

            pynini Examples and Code Snippets

            No Code Snippets are available at this moment for pynini.

            Community Discussions

            QUESTION

            How to restrict the sequence prediction in an LSTM model to match a specific pattern?
            Asked 2020-Apr-12 at 17:40

            I have created a word-level text generator using an LSTM model. But in my case, not every word is suitable to be selected. I want them to match additional conditions:

            1. Each word has a map: if a character is a vowel then it will write 1 if not, it will write 0 (for instance, overflow would be 10100010). Then, the sentence generated needs to meet a given structure, for instance, 01001100 (hi 01 and friend 001100).
            2. The last vowel of the last word must be the one provided. Let's say is e. (friend will do the job, then).

            Thus, to handle this scenario, I've created a pandas dataframe with the following structure:

            ...

            ANSWER

            Answered 2020-Apr-12 at 02:05

            If you are happy with your approach, the easiest way might be if you'd be able to train your LSTM on the reversed sequences as to train it to give the weight of the previous word, rather than the next one. In such a case, you can use the method you already employ, except that the first subset of words would be satisfying the last vowel constraint. I don't believe that this is guaranteed to produce the best result.

            Now, if that reversal is not possible or if, after reading my answer further, you find that this doesn't find the best solution, then I suggest using a pathfinding algorithm, similar to reinforcement learning, but not statistical as the weights computed by the trained LSTM are deterministic. What you currently use is essentially a depth first greedy search which, depending on the LSTM output, might be even optimal. Say if LSTM is giving you a guaranteed monotonous increase in the sum which doesn't vary much between the acceptable consequent words (as the difference between N-1 and N sequence is much larger than the difference between the different options of the Nth word). In the general case, when there is no clear heuristic to help you, you will have to perform an exhaustive search. If you can come up with an admissible heuristic, you can use A* instead of Dijkstra's algorithm in the first option below, and it will do the faster, the better you heuristic is.

            I suppose it is clear, but just in case, your graph connectivity is defined by your constraint sequence. The initial node (0-length sequence with no words) is connected with any word in your data frame that matches the beginning of your constraint sequence. So you do not have the graph as a data structure, just it's the compressed description as this constraint.

            EDIT As per request in the comment here are additional details. Here are a couple of options though:

            1. Apply Dijkstra's algorithm multiple times. Dijkstra's search finds the shortest path between 2 known nodes, while in your case we only have the initial node (0-length sequence with no words) and the final words are unknown.

              • Find all acceptable last words (those that satisfy both the pattern and vowel constraints).
              • Apply Dijkstra's search for each one of those, finding the largest word sequence weight sum for each of them.
              • Dijkstra's algorithm is tailored to the searching of the shortest path, so to apply it directly you will have to negate the weights on each step and pick the smallest one of those that haven't been visited yet.
              • After finding all solutions (sentences that end with one of those last words that you identified initially), select the smallest solution (this is going to be exactly the largest weight sum among all solutions).
            2. Modify your existing depth-first search to do an exhaustive search.

              • Perform the search operation as you described in OP and find a solution if the last step gives one (if the last word with a correct vowel is available at all), record the weight
              • Rollback one step to the previous word and pick the second-best option among previous words. You might be able to discard all the words of the same length on the previous step if there was no solution at all. If there was a solution, it depends on whether your LSTM provides different weights depending on the previous word. Likely it does and in that case, you have to perform that operation for all the words in the previous step.
              • When you run out of the words on the previous step, move one step up and restart down from there.
              • You keep the current winner all the time as well as the list of unvisited nodes on every step and perform exhaustive search. Eventually, you will find the best solution.

            Source https://stackoverflow.com/questions/61055924

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install pynini

            Users can either install using conda-forge, or can compile the extensions and their dependencies from scratch.
            Linux (x86) and Mac OS X users who already have conda can install Pynini and all dependencies with the following command.
            Once these are installed, issue the following command:. To confirm successful installation, run python test/pynini_test.py; if all tests pass, the final line will read OK. Pynini source installation for the current version has been tested on Debian Linux 5.7.17-1 on x86_64, GCC 10.2.0, and Python 3.8.5.
            A standards-compliant C++17 compiler (GCC >= 7 or Clang >= 700)
            The compatible recent version of OpenFst (see NEWS for this) built with the far, pdt, mpdt, and script extensions (i.e., built with ./configure --enable-grm) and headers
            Python 3.6+ and headers

            Support

            Pynini 2.0.0 and onward support Python 3. The Pynini 2.1 versions (onward) drop Python 2 support.
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/kylebgorman/pynini.git

          • CLI

            gh repo clone kylebgorman/pynini

          • sshUrl

            git@github.com:kylebgorman/pynini.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link