pynini | Read-only unofficial mirror of Pynini | Wiki library
kandi X-RAY | pynini Summary
kandi X-RAY | pynini Summary
This is a read-only unofficial mirror of Pynini. This is simply a mirror of recent Pynini releases, for convenience. Pynini was not developed here, the project is not active here, it does not accept pull requests here, and there is no issue tracker or wiki here. For all of these things, the official Pynini page is the best place to go.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of pynini
pynini Key Features
pynini Examples and Code Snippets
Community Discussions
Trending Discussions on pynini
QUESTION
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:
- 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
(hi01
and friend001100
). - 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:05If 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:
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).
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.
QUESTION
I'm having issues installing Pynini for python.
I tried doing it with using pip. From the command line it seems to work, but once I start testing functions, there is nothing, basically.
I tried downloading the tar.gz in http://www.openfst.org/twiki/bin/view/GRM/PyniniDownload
and from then, pip it, but it fails to build the 'wheel'.
It doesn't really tell me much more than this. I looked into the prereqs, but I'm now wondering if it is somehow related to python version.
I'm using python 3...
Any help would be much appreciated.
ANSWER
Answered 2017-Apr-07 at 18:03a standard-complying C++ 11 compiler is in system requirements (see openfst.org/twiki/pub/GRM/PyniniDownload/README.rst ). try mingW64
https://wiki.python.org/moin/WindowsCompilers#GCC_-MinGW.28x86.29
Windows C++ compiler with full C++11 support (should work with Qt)
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install pynini
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page