From 372358b1a2b43496900d0613e84b57946a13485a Mon Sep 17 00:00:00 2001 From: s444417 Date: Wed, 20 Apr 2022 13:13:13 +0200 Subject: [PATCH] add slots --- src/components/DP.py | 7 ++++--- src/components/DST.py | 5 ----- src/components/NLG.py | 4 ++-- src/components/NLU.py | 5 +---- src/dialogue_system.py | 14 ++++++++++++++ 5 files changed, 21 insertions(+), 14 deletions(-) diff --git a/src/components/DP.py b/src/components/DP.py index 826fd80..7f5feed 100644 --- a/src/components/DP.py +++ b/src/components/DP.py @@ -1,9 +1,10 @@ # Martyna class DP: - def __self__(self): - pass + + def __init__(self, slots): + self.slots = slots - def getAct(self, slots): + def getAct(slots): # iterate over slots # find empty # returns system act diff --git a/src/components/DST.py b/src/components/DST.py index 302504d..039ade7 100644 --- a/src/components/DST.py +++ b/src/components/DST.py @@ -1,10 +1,5 @@ # Adrian class DST: - def __self__(self): - pass - - # is it the only one slot that we need? - slots = {'name': None} def getDialogueState(self, userActs): # iterate over speech acts diff --git a/src/components/NLG.py b/src/components/NLG.py index d017344..c142988 100644 --- a/src/components/NLG.py +++ b/src/components/NLG.py @@ -3,5 +3,5 @@ class NLG: def __self__(self): pass - def getResponse(self, systemAct): - return "Witaj, nazywam się Cheddar.\n" \ No newline at end of file + def getResponse(systemAct): + return "Witaj, nazywam się Nachos.\n" \ No newline at end of file diff --git a/src/components/NLU.py b/src/components/NLU.py index 29bb65f..b562355 100644 --- a/src/components/NLU.py +++ b/src/components/NLU.py @@ -2,6 +2,7 @@ from jsgf import PublicRule, Grammar import re class NLU: + def get_str_cleaned(str_dirty): punctuation = '!"#$%&\'()*+,-./:;<=>?@[\\\\]^_`{|}~' new_str = str_dirty.lower() @@ -25,7 +26,3 @@ class NLU: return NLU.getDialogAct(matched[0]) else: return {'act': 'null', 'slots': []} - - - -print(nlu.nlu("Cześć, jak masz na imię?")) \ No newline at end of file diff --git a/src/dialogue_system.py b/src/dialogue_system.py index 5803d13..c4a5e21 100644 --- a/src/dialogue_system.py +++ b/src/dialogue_system.py @@ -1,5 +1,19 @@ from components.NLU import NLU from components.NLG import NLG + +slots = [ + ("title", None), + ("date", None), + ("time", None), + ("quantity", None), + ("location", None), + ("seats", None), + ("reservation_id", None), + ("goal", None), + ("area", None), + ] + + def generate_response(input): result = NLU.nlu(input) return result