From 3e68490ab54dc4362426c56a4173a397200bb416 Mon Sep 17 00:00:00 2001 From: Adrian Charkiewicz Date: Wed, 20 Apr 2022 12:02:13 +0200 Subject: [PATCH] changed input to be dict of list of tuples --- src/components/DST.py | 16 +++++++++++----- src/components/NLU.py | 6 +++++- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/components/DST.py b/src/components/DST.py index f046e91..302504d 100644 --- a/src/components/DST.py +++ b/src/components/DST.py @@ -9,16 +9,22 @@ class DST: def getDialogueState(self, userActs): # iterate over speech acts - for k, v in userActs['inform'].items(): + """for k, v in userActs['inform'].items(): for slot in self.slots: if slot == k: self.slots['name'] = v - print(self.slots) + print(self.slots)""" + if userActs['act']=='book': + for (k,v) in userActs['slots']: + print(k) + if k in self.slots: + self.slots[k]=v # returns all slots - pass + return self.slots dst = DST() -userActs = {'inform': {'name': 'edyta', 'age': 18}, 'reqmore': {'date', 'time'}} -dst.getDialogueState(userActs) +#userActs = {'inform': {'name': 'edyta', 'age': 18}, 'reqmore': {'date', 'time'}} +ivona_acts={'act':'book','slots':[('name','ewa'), ('hour','dziesiąta'), ('size','trzech')]} +print(dst.getDialogueState(ivona_acts)) diff --git a/src/components/NLU.py b/src/components/NLU.py index f28aa54..29bb65f 100644 --- a/src/components/NLU.py +++ b/src/components/NLU.py @@ -24,4 +24,8 @@ class NLU: if matched: return NLU.getDialogAct(matched[0]) else: - return {'act': 'null', 'slots': []} \ No newline at end of file + return {'act': 'null', 'slots': []} + + + +print(nlu.nlu("Cześć, jak masz na imię?")) \ No newline at end of file