Created
May 30, 2018 06:15
Failing optionally adapt test case
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from adapt.intent import IntentBuilder | |
from adapt.engine import IntentDeterminationEngine | |
def check_for_location(intent): | |
if 'Location' in intent: | |
print('Location: {}'.format(intent['Location'])) | |
else: | |
print('Location: Not found') | |
e = IntentDeterminationEngine() | |
print('Registering weather skill entities') | |
# Weather Keywords | |
e.register_entity('what is', 'Query', None) | |
e.register_entity('weather', 'Weather', None) | |
e.register_regex_entity('(at|in) (?P<Location>.+)') | |
print('Registering Current weather intent') | |
# Registering current weather intent | |
i = IntentBuilder("CurrentWeatherIntent").require( | |
"Weather").optionally("Location").build() | |
e.register_intent_parser(i) | |
print('TESTING "what is the weather like in stockholm"') | |
best_intent = next(e.determine_intent("what is the weather like in stockholm", | |
100, include_tags=True)) | |
check_for_location(best_intent) | |
print('\nRegistering additional regexes...') | |
# Register additonal regexes | |
e.register_regex_entity('(read (out )?)?((status|state|value|sensor) )?(?P<Entity>.*)') | |
print('TESTING "what is the weather like in stockholm"') | |
best_intent = next(e.determine_intent("what is the weather like in stockholm", | |
100, include_tags=True)) | |
check_for_location(best_intent) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment