Adapt Tutorial
A step by step tutorial in using Adapt Intent Parser, using the `single_intent_parser.py` file as a starting point.
Prerequisites
To complete this tutorial, you should have some basic knowledge of the Python programming language, and be comfortable executing commands on a Linux command line.
If you are looking to use Adapt in a Mycroft Skill, please see Skill Development > Intents
Step 1 - Sample Intent
This is the sample Intent around which the tutorial is based.
Step 2 - Import Libraries
First, we need to import json
for serializing the Adapt Intent Parser output, and sys
for reading in command line arguments.
Next, we import the IntentBuilder
and `IntentDeterminationEngine.
Next, we instantiate an IntentDeterminationEngine object.
Next, we delcare a collection of weather Keywords, in JSON syntax. These Keywords act as hints to the Adapt Intent Parser about which intent context is being referenced by an Utterance.
Register each Keyword with the engine
.
Next, we declare a collection
of weather types. These act as a query parameter on a Weather Intent.
For example, in the sentence:
Will it rain in Seattle tomorrow?
the collection
of weather types can then be used to determine whether that weather type is occurring in Seattle.
Next, each weather type is registered with the engine
.
Next, a collection
of locations is declared. These also act as a query parameter on a Weather Intent, and can be used in combination with the weather type collection
.
Next, each location is registered with the engine
.
Next, we construct an intent parser
. The intent parser
is named WeatherIntent
and requires both a WeatherKeyword
and Location
, and can optionally include a WeatherType
.
Next, we register the intent parser
with the engine
.
We then declare an entry point for the script. @TODO - need to explain here what an entry point is.
Next, pass the command line arguments to this script as an Utterance into engine.determine_intent()
. This function returns a generator, and we then use the generator to iterate through the results.
If the confidence is >0, this is a valid Intent.
Next, serialize the Intent and print it to stdout
.
Of course, you don't just have to output the Intent to stdout
- you can use it to build all sorts of tools.
Last updated