Skip to main content

License CLA Team Status

Build Status Coverage Status PRs Welcome Join chat

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.

Introducing the Adapt Intent Parser

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)

Learn More

Further documentation can be found at https://mycroft-ai.gitbook.io/docs/mycroft-technologies/adapt

Metadata

Release files for adapt-parser 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for adapt-parser 0.4.0
File Size Uploaded
adapt-parser-0.4.0.tar.gz 19.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for adapt-parser 0.4.0
File Interpreter ABI Platform
adapt_parser-0.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 48.3 kB

Release files / adapt-parser-0.4.0.tar.gz

Download URL adapt-parser-0.4.0.tar.gz
Size 19.5 kB
Tags Source
SHA-256 checksum
How to use checksums
f5fbd73d586d9c70055bc45a58dafd186b0200655c8495d655f20f6f0a6a8831
BLAKE2b-256 checksum
How to use checksums
27163c1d88d6336f437e7433f58361d6ea7543c6a9758849351fee1dd34fefcf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.21.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.7.3

Release files / adapt_parser-0.4.0-py3-none-any.whl

Download URL adapt_parser-0.4.0-py3-none-any.whl
Size 28.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
16cc3cd1f3f2fc78bfb1a14ed8c1177f2e29b7a38929e7e5231fbfe5782b2c7e
BLAKE2b-256 checksum
How to use checksums
f63854bc1a3e23f18678030efc1a98134de1d10323ce1f619d6a1e341db10399
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.21.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.7.3

Release history Release notifications | RSS feed

1.0.0

2 release files

0.6.2

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.1

2 release files

0.4.3

2 release files

0.4.1

2 release files

This release

0.4.0 This release

2 release files

0.3.7

1 release file

0.3.6

1 release file

0.3.5

1 release file

0.3.4

1 release file

0.3.3

1 release file

0.3.2

1 release file

0.3.0

1 release file

0.2.8

1 release file

0.2.7

1 release file

0.2.6

1 release file

0.2.5

1 release file

0.2.4

1 release file

0.2.3

1 release file

0.2.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page