Closed funderburkjim closed 6 years ago
Good question. That one works just fine. An even more general version,
which works with the lower level pywrapfst
layer, is:
compose(s, sheep).start() == NO_STATE_ID
The built-in function matches
is a two-argument function that does
exactly this.
Also just FYI, you can pass a string in place of an acceptor and Pynini will implicitly compile it into an acceptor for you.
On Fri, Aug 3, 2018, 4:33 PM funderburkjim notifications@github.com wrote:
This question based on the 'sheep' example:
sheep = acceptor("b") + acceptor("a").plus sheep.optimize(True)
Is there an 'official' programmatic way to test whether a given string 's' matches the 'regular expression' specified by 'sheep'? By trial and error, my candidate expression is:
compose(s,sheep).num_states() != 0
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/kylebgorman/Pynini/issues/6, or mute the thread https://github.com/notifications/unsubscribe-auth/AAJuOflx8Sv_MLDrZkzvISKzG9-K3OLqks5uNLO2gaJpZM4VulEM .
What would be the appropriate matches() function for version >= 2.1.3
?
I'm currently using the python.lib.rewrite.matches()
function this way
from pynini.lib.rewrite import matches
fst = pynini.accep('abc')
input_string = 'abc '
matches(input_string, input_string, fst) # True
input_string = 'abcd '
matches(input_string, input_string, fst) # False
Does this look okay?
I think you want:
matches(input_string, input_string, fst)
The rule is supposed to be the third argument.
On Sat, May 1, 2021 at 12:48 PM Taufiquzzaman Peyash < @.***> wrote:
What would be the appropriate match() function for version >= 2.1.3 ? I'm currently using the python.lib.rewrite.matches() function this way
from pynini.lib.rewrite import matches fst = pynini.accep('abc') input_string = 'abc 'matches(input_string, fst, input_string) # True input_string = 'abcd 'matches(input_string, fst, input_string) # False
Does this look okay?
— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/kylebgorman/pynini/issues/6#issuecomment-830660368, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABG4OLOAIGMYIDUBYNVUA3TLQWFLANCNFSM4FN2KEGA .
Yeah, you're right! My bad! Thanks so much for the clarification.
This question based on the 'sheep' example:
Is there an 'official' programmatic way to test whether a given string 's' matches the 'regular expression' specified by 'sheep'? By trial and error, my candidate expression is: