-
Notifications
You must be signed in to change notification settings - Fork 155
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
Regex entities with optional words #157
Comments
Not sure if I've understood it correctly but it may be the way regexes work. They match as much as possible. (atleast from what I've gathered messing around on https://pythex.org/ A workaround may be to do something like: Edit: (literally 5 min later) |
Thanks @forslund for looking into my issue. search for the moon still matches the the article, It is possible to do an or statement in the regex with ( for| a| an) but I can't believe there is no way to match just nothing. If no article matches, it should just match the whole rest of the sentence. I played a bit around on regex101 and with this pattern I do have some workarounds in my project, like making a new intent for this case but it would be nice to have a cleaner solution. |
Did some digging tonight, the issue is (I think) the iterative approach adapt uses with regexes... and adapt chooses to report back "the" as the match... However using negative lookahead:
should not match against "tell me about the", but should work with "tell me about the moon", however for some reason this doesn't result in any match...I see that "moon" is matched but somehow not used as a result. will need to dig some more... |
|
Indeed this works on my end too. It also works with several words Something like With this solution I can hardcode something in my code to have an easier matching. Anyway, thank you very much for your help! |
Partially it's caused by how adapts runs multiple passes over subsets of the utterance but partially something seems slightly wrong (or I don't quite understand it). I will look into it some more and see if I can understand the internals better but I'm not sure I'll be able to improve things. |
Not sure if this is a bug, a missing feature or that I just don't know how it works...
Is there a possibility to have an optional word what can or cannot be there, for example:
both sentences should match only moon.
I can match both sentence with:
engine.register_regex_entity("(for|about) (?P<search>.*)")
but with the second phrase, I will match the moon
I played around with
(|the)
,(|the)?
,(the)?
and a lot of other regex patterns...I also looked into other mycroft-skills to find a hint, but no luck...Isn't there some kind of wildcard for this case or a regex pattern I missed?
Thanks in advance.
The text was updated successfully, but these errors were encountered: