Open danpovey opened 4 years ago
Sorry something wrong happened, will try again. from_str has an issue that it cannot read either:
Also it would be nice to have the following clarification to the usage message, if its OK with the style:
'''Create an Fsa from a string in the k2 format.
(See also from_openfst).
... we definitely need to test this for the FSA with no states, and the FSA with no arcs but the final-state could be various values greater than zero, e.g. 1 or 2. Please always keep in mind edge cases like this !
Incidentally, I'm torn on whether the acceptor
arg for from_str
should default to false (as for openfst) or true (which would be more natural for k2 itself). Maybe false for consistency would be easier? Or make it true but also make the openfst one be true or undefined? IDK.
the Fsa with no states or: the Fsa with a start state and final-state but no arcs.
The problem is that from_str
invokes
https://github.com/k2-fsa/k2/blob/72a8768beaf8f55ffecc9de30fa18c05370e9f04/k2/csrc/fsa.h#L204
The vector contains Arc
information. If there are no arcs, it is not possible to keep the state information.
OK, that function was written earlier, when the text format was different (no final-state) and when my plan was to use arrays of arcs to serialize FSAs. Now things have changed. We can give the num-states (== final-state + 1) to this function as an arg, and change it so it no longer attempts to work that out.
@csukuangfj you'll work on this at some point, right?
Yes, I'll start this once k2.index
is finished. Sorry, I am busy this week.
Hi, @csukuangfj . I want to ask if this problem has been solved. If you have not had time to deal with it, would you like to let me try to solve it?
@songmeixu
sure, thank you.