https://github.com/mycroftai/adapt
Adapt Intent Parser
https://github.com/mycroftai/adapt
intent-parser intents open-source opensource speech-recognition speech-to-text
Last synced: 11 days ago
JSON representation
Adapt Intent Parser
- Host: GitHub
- URL: https://github.com/mycroftai/adapt
- Owner: MycroftAI
- License: apache-2.0
- Created: 2015-09-08T01:28:48.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2024-07-21T21:46:45.000Z (9 months ago)
- Last Synced: 2025-04-03T23:07:59.345Z (18 days ago)
- Topics: intent-parser, intents, open-source, opensource, speech-recognition, speech-to-text
- Language: Python
- Size: 361 KB
- Stars: 714
- Watchers: 75
- Forks: 155
- Open Issues: 12
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
- Code of conduct: CODE_OF_CONDUCT.md
- Support: SUPPORT.md
Awesome Lists containing this project
README
[](LICENSE.md) [](https://mycroft.ai/cla) [](https://github.com/MycroftAI/contributors/blob/master/team/Mycroft%20Core.md) 
[](https://travis-ci.org/MycroftAI/adapt) [](https://coveralls.io/github/MycroftAI/adapt?branch=master)
[](http://makeapullrequest.com)
[](https://chat.mycroft.ai)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.[](https://www.youtube.com/watch?v=zR9xvPtM6Ro)
Getting Started
===============
To take a dependency on Adapt, it's recommended to use virtualenv and pip to install source from github.```bash
$ 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](https://github.com/MycroftAI/adapt/tree/master/examples).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:
```Python
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.
```Python
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.
```Python
def register_vocab(entity_type, entity_value):
pass
# a tiny bit of codedef 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.```python
from adapt.engine import IntentDeterminationEngine
engine = IntentDeterminationEngine()
# Load engine with vocabulary and parsersimport 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