Add 'nlu.py'

This commit is contained in:
Patryk Gałka 2023-04-20 21:24:58 +02:00
parent c11e6ea284
commit b6411ae7d0

14
nlu.py Normal file
View File

@ -0,0 +1,14 @@
import jsgf
order_grammar = jsgf.parse_grammar_file('order.jsgf')
order_grammar
utterance = 'chciałbym zamowic pizze vesuvio XXL na dwie osoby'
matched = order_grammar.find_matching_rules(utterance)
def get_dialog_act(rule):
slots = []
get_slots(rule.expansion, slots)
return {'act': rule.grammar.name, 'slots': slots}