Closed mortommy closed 7 years ago
Hi, the regex looks good and I believe it should work. What does the code building the intent using the regex look like?
Hi, thank you for your answer. The code is:
dimmer_status_intent = IntentBuilder("Dimmer_StatusIntent").require("DimmerStatusKeyword").require("Command").require("Item").build()
self.register_intent(dimmer_status_intent, self.handle_dimmer_status_intent)
the DimmerStatusKeyword file is:
dim
brighten
the other intents I developed before are still working, just this new one is not.
Thank you.
Not sure here...I've tested it and there's something fishy going on.
I think you can move forward by using the regexp (dim|brighten) (?P<Item>.*)
and getting the command from DimmerStatusKeyword
value in your handler
using the following intent
IntentBuilder("Dimmer_StatusIntent").require("DimmerStatusKeyword").require("Item").build()
I'll have to look into this more
Ok, I've spent the morning checking this. As far as I can understand it works as intended.
I can get it working in the following two ways for the sentence dim the desktop lamp
:
IntentBuilder("Dimmer_StatusIntent").require("Command").require("Item").build()
and
IntentBuilder("Dimmer_StatusIntent").require("DimmerStatusKeyword").require("Item").build()
but now with this:
IntentBuilder("Dimmer_StatusIntent").require("DimmerStatusKeyword").require("Command").require("Item").build()
I think what is happening is that dim or brighten is required twice and sure enough:
dim dim desktop lamp
works for above intent.
The thing is that the words in the sentence can only be matched to a single require()
statement. In your case both DimmerStatusKeyword
and Command
requires the same dim or brighten and since there is only a single dim
in dim the desktop lamp
.
I think the correct way is to do as I suggested in my previous post.
Thank you for the explanation. I'm looking for an example about the way you explained in the previous post. Do you mean using Message.metadata? Thank you
Yes,
metadata
is simply called data
now.
for you it would look something like:
def handle_dimmer_status_intent(self, message):
command = message.data.get('DimmerStatusKeyword')
Then command would be either 'dim'
or 'brighten'
@mortommy Did you get it working? Can we close the issue?
Hi, I got it working right now using your example. Thank you for your support.
Great to hear you got it working! Closing this issue.
Hi, I'm trying to extend one skill I have developed adding new regex expression and I decided to create a new file. With the expression:
(?P<Command>dim|brighten) (?P<Item>.*)
when in cli I type:
dim something
orbright something
I always get:
If, in the file, I define the expression as
dim (?P<Item>.*)
it works. Is it not possible to start a regex with a group?
As additional information, I have another regex file where I also use Command and Item as group name.
Thank you.
Regards.