Skip to content

Instantly share code, notes, and snippets.

@forslund
Created May 30, 2018 13:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save forslund/5c98b3e64482e8b16694211f700c2ca5 to your computer and use it in GitHub Desktop.
Save forslund/5c98b3e64482e8b16694211f700c2ca5 to your computer and use it in GitHub Desktop.
Demonstration of changing confidence when adding extra regexes
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",
100000, include_tags=True))
check_for_location(best_intent)
print('Confidence: {}'.format(best_intent['confidence']))
print('\nRegistering additional regexes...')
# Register additonal regexes
e.register_regex_entity('(is) (?P<Test>.+)')
#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",
100000, include_tags=True))
check_for_location(best_intent)
print('Confidence: {}'.format(best_intent['confidence']))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment