Package: adapt-parser
Adapt Intent ParserThe 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 StartedTo take a dependency on Adapt, it's recommended to use virtualenv and pip to install source from github.$virtualenvmyvirtualenv
$.myvirtualenv/bin/activate
$pipinstall-egit+https://github.com/mycroftai/adapt#egg=adapt-parserExamplesExecutable examples can be found in theexamples folder.Intent ModellingIn 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.EntitiesEntities are a named value. Examples include:Blink 182is anArtistThe Big Bang Theoryis aTelevision ShowPlayis aListen CommandSong(s)is aMusic KeywordFor 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.defregister_vocab(entity_type,entity_value):pass# a tiny bit of codedefregister_pandora_vocab(emitter):forvin["stations"]:register_vocab('Browse Music Command',v)forvin["play","listen","hear"]:register_vocab('Listen Command',v)forvin["music","radio"]:register_vocab('Music Keyword',v)forvin["Pandora"]:register_vocab('Plugin Name',v)station_name_regex=re.compile(r"(.*) Radio")p=get_pandora()forstationinp.stations:m=station_name_regex.match(station.get('stationName'))ifnotm:continueformatchinm.groups():register_vocab('Pandora Station',match)DevelopmentGlad you'd like to help!To install test and development requirements runpip install -r test-requirements.txtThis will install the test-requirements as well as the runtime requirements for adapt.To test any changes before submitting them run./run_tests.shThis will run the same checks as the Github actions and verify that your code should pass with flying colours.Reporting IssuesIt'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.fromadapt.engineimportIntentDeterminationEngineengine=IntentDeterminationEngine()# Load engine with vocabulary and parsersimportadapt.tools.debugasatdatd.dump(engine,'debug.adapt')Learn MoreFurther documentation can be found athttps://mycroft-ai.gitbook.io/docs/mycroft-technologies/adapt