Build an open future with us.

Invest in Mycroft and become a community partner.

How can I parse duration related information using adapt parse


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


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…


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