From 887f6249ce0e2726d87c773ebef0e6da932126f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cezary=20Ga=C5=82=C4=85zkiewicz?= Date: Tue, 7 Jun 2022 23:11:29 +0200 Subject: [PATCH] =?UTF-8?q?Working=20nlg=20i=20og=C3=B3lne=20poprawki?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- trailminator/dp.py | 8 +++----- trailminator/dst.py | 5 +++-- trailminator/nlg.py | 11 ++++++++++- trailminator/rules.jsgf | 2 +- trailminator/trailminator.py | 7 ++++--- 5 files changed, 21 insertions(+), 12 deletions(-) diff --git a/trailminator/dp.py b/trailminator/dp.py index cad33e9..3e08d3e 100644 --- a/trailminator/dp.py +++ b/trailminator/dp.py @@ -14,10 +14,8 @@ class Dp: 'wagonType': "carrige_class", } } - + def identify(self): req = self.answers.get(self.act) - response = req.get(self.param[0]) if not req is None else "null" - return response if not response is None else "null" - - + response = req.get(self.param[0]) if req is not None else "null" + return response if response is not None else "null" diff --git a/trailminator/dst.py b/trailminator/dst.py index 31ab0ec..df60a46 100644 --- a/trailminator/dst.py +++ b/trailminator/dst.py @@ -1,5 +1,5 @@ +class Dst: def __init__(self): - class Dst: self.messages = [] self.checklist = { "from": None, @@ -25,6 +25,7 @@ def save_answer(self, slots): for slot in slots: - self.checklist[slot[0]] = slot[1] + if slot[1] is not None: + self.checklist[slot[0]] = slot[1] self.messages.append(slots) diff --git a/trailminator/nlg.py b/trailminator/nlg.py index 08cb638..c385a4f 100644 --- a/trailminator/nlg.py +++ b/trailminator/nlg.py @@ -6,7 +6,16 @@ class Nlg: def __init__(self) -> None: self.responses = { "welcomemsg": ["I AM TRAIlMinATor!", "Cześć, jestem TrailMinator"], - "null": ["Can't hear you"]} + "from": ["Podaj stację poczatkową i końcową", + "Podaj stację początkową i końcową zaczynając zdanie od 'chciałbym kupić bilet'"], + "to": ["Podaj stację kocową"], + "time": ["Podaj w jaki dzień chcesz odbyć podróż"], + "passangerCount": ["Podaj ile biletów chcesz kupić"], + "discountedCount": ["Podaj ile z tych biletów będzie biletami ze zniżką i jaka zniżka będzie przysługiwała"], + "seatType": ["Podaj miejsce jakie chcesz mieć w pociągu: pod oknem/w środku/w przejściu"], + "wagonType": ["Podaj klasę wagonu w jakim chcesz kupić bilety: 1 albo 2 klasa"], + "null": ["Can't hear you"] + } def response(self, response_type: str) -> str: avail_resps = self.responses.get(response_type) diff --git a/trailminator/rules.jsgf b/trailminator/rules.jsgf index ad48d0f..94c1473 100644 --- a/trailminator/rules.jsgf +++ b/trailminator/rules.jsgf @@ -20,7 +20,7 @@ public = (+){number}; public = []{passangerCount} bilet[y | ów]; //discount count -public = []{discountedCount} bilet[y] (z ulgą | ze zniżką) {discount_type}; +public = []{discountedCount} bilet[y | ów] (z ulgą | ze zniżką) {discount_type}; = studencką | seniorską | uczniowską; //seatType diff --git a/trailminator/trailminator.py b/trailminator/trailminator.py index 93d539f..6e39e1a 100644 --- a/trailminator/trailminator.py +++ b/trailminator/trailminator.py @@ -8,13 +8,14 @@ if __name__ == "__main__": nlu = nlu.Nlu() dst = dst.Dst() - next_question = dst.get_next_question() - while (next_question): + response_type = dst.get_next_question() + while response_type: + next_question = nlg.response(response_type) print(next_question) response = input() res_tokenized = nlu.tokenize(response) dst.save_answer(res_tokenized['slots']) - next_question = dst.get_next_question() + response_type = dst.get_next_question() print(dst.checklist) # print(dp_params)