Build an open future with us.

Invest in Mycroft and become a community partner.

How can I parse duration related information using adapt parse


#1

example sentence: “I am planning to sleep for 30 minutes”

I should be able to get the intent of sleeping for the duration of 30 minutes using adapt parse.

I have recently learned using adapt parser with keywords, components and locations, but unsure of how to build intent containing information about duration


#2

One thing you can do is create the intent parsing based on the key words then process the remainder of the utterance with a regex to extract the digits (numeric value) then process that separately.
Something like
strRemainder = str(message.utterance_remainder())
str_numbers = re.findall(’\d+’,strRemainder)
int_duration = int(str_numbers[0])

I did something similar in my pick number skill here…


#3

The mycroft-timer Skill has some great examples of this using the extractNumber() function:

https://github.com/MycroftAI/mycroft-timer/blob/18.02/init.py