-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Repetition with CompoundRule #239
Comments
Not currently. There has been some discussion of it in the past on Gitter (most of which I'm afraid I have forgotten). The question of how to design it is non trivial. It is definitely worth discussing here, as it is a pain point currently! |
Could you give an example of what you're trying to do? |
I'm trying to create a compound rule where certain words can be repeated. For my use case, the syntax that I would most prefer is |
Ahh I see. You can obviously use a
|
Oh you can specify it as an extra already? Is there some documentation for this that I missed? I specifically need it to work with a Choice extra, if that's possible. Thanks for the help. |
Ah yeah you're right, there is a docstring for it but I can't find it in the docs. Basically it's just another extra you can wrap around others, couple of example usages:
It will return a list of the matched elements, and you can specify a default as normal if it's going to be optional. Docs: https://github.com/dictation-toolbox/dragonfly/blob/master/dragonfly/grammar/elements_basic.py#L563 |
I got it to work based on the examples you provided, so thanks for that. At this point, the only question here is whether the CompoundRule should provide syntax support for |
Use of @mrob95 Would you mind if your examples were included in the docstring for the
As @daanzu said, this has come up in the past and has unfortunately been forgotten about. I would be in support of adding this syntax to |
I think this could come in handy fairly often. The main design question is how to handle the |
I've already implemented this in an application I'm writing: https://github.com/osprey-voice/osprey/blob/master/osprey/voice.py#L138, and the way I've implemented it is both |
Is it possible to have an unbounded number of repetitions? Otherwise we are going to have to put a limit on the number of repetitions for |
For engines that support it (I think Kaldi and natlink), the |
That didn't work for me unfortunately. It still checks |
Most regex languages support using {min,max} or {,max} notation for bounded repetitions, in the short term that fits the model already in place. As for dragonfly, unbounded wouldnt be hard to add to repetition. Alternatively, there is a natural bound on repetitions, namely the number of recognized words (except in the trivial repetition of empty element). Thus we dont need to worry about infinite loops while decoding. Perhaps this should be a separate issue, but I should also point out that the dfly convention of making min inclusive and max exclusive in repetitions is both nonstandard compared to regex languages and very confusing. Reading the documentation saying the default is max=min+1 hurts my head :( |
Is it possible to use repetition within the CompoundRule? Is there some syntax that can be used in the spec to achieve this? Is there any documentation for this that i missed? Thanks!
The text was updated successfully, but these errors were encountered: