A text-to-intent parsing framework.
Project description
Adapt Intent Parser
The Adapt Intent Parser is a flexible and extensible intent definition and determination framework. It is intended to parse natural language text into a structured intent that can then be invoked programatically.
Getting Started
To take a dependency on Adapt, it's recommended to use virtualenv and pip to install source from github.
$ virtualenv myvirtualenv
$ . myvirtualenv/bin/activate
$ pip install -e git+https://github.com/mycroftai/adapt#egg=adapt-parser
Examples
Executable examples can be found in the examples folder.
Intent Modelling
In this context, an Intent is an action the system should perform. In the context of Pandora, we’ll define two actions: List Stations, and Select Station (aka start playback)
With the Adapt intent builder:
list_stations_intent = IntentBuilder('pandora:list_stations')\
.require('Browse Music Command')\
.build()
For the above, we are describing a “List Stations” intent, which has a single requirement of a “Browse Music Command” entity.
play_music_command = IntentBuilder('pandora:select_station')\
.require('Listen Command')\
.require('Pandora Station')\
.optionally('Music Keyword')\
.build()
For the above, we are describing a “Select Station” (aka start playback) intent, which requires a “Listen Command” entity, a “Pandora Station”, and optionally a “Music Keyword” entity.
Entities
Entities are a named value. Examples include:
Blink 182
is an Artist
The Big Bang Theory
is a Television Show
Play
is a Listen Command
Song(s)
is a Music Keyword
For my Pandora implementation, there is a static set of vocabulary for the Browse Music Command, Listen Command, and Music Keyword (defined by me, a native english speaker and all-around good guy). Pandora Station entities are populated via a "List Stations" API call to Pandora. Here’s what the vocabulary registration looks like.
def register_vocab(entity_type, entity_value):
pass
# a tiny bit of code
def register_pandora_vocab(emitter):
for v in ["stations"]:
register_vocab('Browse Music Command', v)
for v in ["play", "listen", "hear"]:
register_vocab('Listen Command', v)
for v in ["music", "radio"]:
register_vocab('Music Keyword', v)
for v in ["Pandora"]:
register_vocab('Plugin Name', v)
station_name_regex = re.compile(r"(.*) Radio")
p = get_pandora()
for station in p.stations:
m = station_name_regex.match(station.get('stationName'))
if not m:
continue
for match in m.groups():
register_vocab('Pandora Station', match)
Development
Glad you'd like to help!
To install test and development requirements run
pip install -r test-requirements.txt
This will install the test-requirements as well as the runtime requirements for adapt.
To test any changes before submitting them run
./run_tests.sh
This will run the same checks as the Github actions and verify that your code should pass with flying colours.
Reporting Issues
It's often difficult to debug issues with adapt without a complete context. To facilitate simpler debugging, please include a serialized copy of the intent determination engine using the debug dump utilities.
from adapt.engine import IntentDeterminationEngine
engine = IntentDeterminationEngine()
# Load engine with vocabulary and parsers
import adapt.tools.debug as atd
atd.dump(engine, 'debug.adapt')
Learn More
Further documentation can be found at https://mycroft-ai.gitbook.io/docs/mycroft-technologies/adapt
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file adapt-parser-1.0.0.tar.gz
.
File metadata
- Download URL: adapt-parser-1.0.0.tar.gz
- Upload date:
- Size: 23.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fb9a072e01ce4d2a2eaab791db4159144af1cfeebdec931db0b60ec2f471fd59 |
|
MD5 | 818e041e543339df194781a461470bf7 |
|
BLAKE2b-256 | ff97236a8cf280b789a86a7e5b50d3602e189ecc9726ebbb5b3259bb43761b02 |
File details
Details for the file adapt_parser-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: adapt_parser-1.0.0-py3-none-any.whl
- Upload date:
- Size: 31.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e6839f79c6927ee5c645236420fd07db4a15d9bf2f0fe8e4c4fd28ad58d4e536 |
|
MD5 | ef7f3bb8cd764567fecb351f4bacc41c |
|
BLAKE2b-256 | 13c09f3c286511554628eaacc7080ec69f30e8b2a5e3e078b37c4ed7703924b2 |