Skip to content

Instantly share code, notes, and snippets.

@MatthewScholefield
Last active July 6, 2018 13:21
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MatthewScholefield/fe8f2db52bdbab8b14c1721c7bd5e3d3 to your computer and use it in GitHub Desktop.
Save MatthewScholefield/fe8f2db52bdbab8b14c1721c7bd5e3d3 to your computer and use it in GitHub Desktop.
Adapt vs Padatious

Adapt

Provide specific groups of vocab that can be said anywhere in a sentence.

__init__.py:

from mycroft import MycroftSkill, intent_handler, AdaptIntent  # AdaptIntent == IntentBuilder

class HelloSkill(MycroftSkill):
    @intent_handler(AdaptIntent().require('Hello').require('Person'))
    def handle_hello(self, message):
        self.speak('Hello, ' + message.data['Person'])

vocab/en-us/Hello.voc:

Hi
Hello

vocab/en-us/Person.voc:

Bob
Joe
Sue

test/intent/hello.intent.json:

{
  "utterance": "Hi Joe",
  "intent_type": "handle_hello",
  "intent": {
    "Hello": "Hi",
    "Person": "Joe"
  }
}

Padatious

Describe a list of example utterances with possible extracted entities.

__init__.py:

from mycroft import MycroftSkill, intent_file_handler

class HelloSkill(MycroftSkill):
    def initialize(self):
        self.register_entity_file('person.entity')

    @intent_file_handler('hello.intent')
    def handle_hello(self, message):
        self.speak('Hello, ' + message.data['person'])

vocab/en-us/hello.intent:

Hi {person}
Hello {person}

vocab/en-us/person.entity:

Bob
Joe
Sue

test/intent/hello.intent.json:

{
  "utterance": "Hi Joe",
  "intent_type": "hello.intent",
  "intent": {
    "person": "Joe"
  }
}
@KathyReid
Copy link

Apologies, I'm just getting to this on my list now. Really appreciate you putting this together. These are some great examples of how Adapt and Padatious work, however I'd also like to provide some guidance on scenarios where it makes more sense to use Adapt over Padatious or vice-versa. My guess is that you would use Adapt where your Intent has some very specific phrasing, and you have a clear list of entities, but it makes more sense to use Padatious where the Intent might be a little "fuzzy" or where more slang / informal language would be used. What do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment