fix and start interaction

This commit is contained in:
s459312 2023-06-15 19:50:31 +02:00
parent a1b0d7a8eb
commit 031fdff757

View File

@ -102,7 +102,7 @@ class NLU:
def __init__(self): def __init__(self):
pass pass
def extract_acts_and_slots(text): def extract_acts_and_slots(self, text):
doc = nlp(text) doc = nlp(text)
acts = [] acts = []
@ -131,14 +131,14 @@ class NLU:
return acts return acts
def find_product_type(product): def find_product_type(self, product):
for product_type, products in product_type_rules.items(): for product_type, products in product_type_rules.items():
if product in products: if product in products:
return product_type, product return product_type, product
return None, None return None, None
text = "Cześć, chciałbym kupić mleko, sok oraz chleb" text = "Cześć, chciałbym kupić mleko, płatki oraz owoce"
nlu = NLU() nlu = NLU()
acts = nlu.extract_acts_and_slots(text) acts = nlu.extract_acts_and_slots(text)
for act in acts: for act in acts:
@ -149,7 +149,7 @@ for act in acts:
dst = DialogStateTracker() dst = DialogStateTracker()
text = "Cześć, chciałbym kupić mleko, sok oraz chleb" text = "Cześć, chciałbym kupić mleko, płatki oraz owoce"
acts = nlu.extract_acts_and_slots(text) acts = nlu.extract_acts_and_slots(text)
@ -159,4 +159,6 @@ dst.update_state(acts)
dialog_state = dst.get_state() dialog_state = dst.get_state()
print("Dialog State:") print("Dialog State:")
print(dialog_state) print(dialog_state)
dm = DialogManager(nlu ,dst)
dm.start_dialog()