From c6d8b14e6e734acaa45922fe021143bebf799506 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20Zab=C5=82o=C5=84ski?= Date: Mon, 30 May 2022 12:00:09 +0200 Subject: [PATCH] fix --- DST_DP_lab_9-10/value_dict.json | 644 +++++++++++++++++++++++++++++++- NLG_lab_11/NLG.py | 90 +++-- 2 files changed, 690 insertions(+), 44 deletions(-) diff --git a/DST_DP_lab_9-10/value_dict.json b/DST_DP_lab_9-10/value_dict.json index 5298f53..20c9598 100644 --- a/DST_DP_lab_9-10/value_dict.json +++ b/DST_DP_lab_9-10/value_dict.json @@ -38,9 +38,6 @@ "15:07", "17:07", "19:07", - "21:07", - "23:07", - "01:07", "05:58", "06:58", "07:58", @@ -206,8 +203,6 @@ "06:52", "08:52", "10:52", - "12:52", - "14:52", "16:52", "18:52", "20:52", @@ -263,9 +258,6 @@ "17:44", "18:44", "19:44", - "20:44", - "21:44", - "22:44", "23:44", "24:44", "01:44", @@ -371,6 +363,366 @@ "broxbourne", "stevenage" ], + "date":[ + "1.01", + "2.01", + "3.01", + "4.01", + "5.01", + "6.01", + "7.01", + "8.01", + "9.01", + "10.01", + "11.01", + "12.01", + "13.01", + "14.01", + "15.01", + "16.01", + "17.01", + "18.01", + "19.01", + "20.01", + "21.01", + "22.01", + "23.01", + "24.01", + "25.01", + "26.01", + "27.01", + "28.01", + "29.01", + "30.01", + "1.02", + "2.02", + "3.02", + "4.02", + "5.02", + "6.02", + "7.02", + "8.02", + "9.02", + "10.02", + "11.02", + "12.02", + "13.02", + "14.02", + "15.02", + "16.02", + "17.02", + "18.02", + "19.02", + "20.02", + "21.02", + "22.02", + "23.02", + "24.02", + "25.02", + "26.02", + "27.02", + "28.02", + "1.03", + "2.03", + "3.03", + "4.03", + "5.03", + "6.03", + "7.03", + "8.03", + "9.03", + "10.03", + "11.03", + "12.03", + "13.03", + "14.03", + "15.03", + "16.03", + "17.03", + "18.03", + "19.03", + "20.03", + "21.03", + "22.03", + "23.03", + "24.03", + "25.03", + "26.03", + "27.03", + "28.03", + "29.03", + "30.03", + "1.04", + "2.04", + "3.04", + "4.04", + "5.04", + "6.04", + "7.04", + "8.04", + "9.04", + "10.04", + "11.04", + "12.04", + "13.04", + "14.04", + "15.04", + "16.04", + "17.04", + "18.04", + "19.04", + "20.04", + "21.04", + "22.04", + "23.04", + "24.04", + "25.04", + "26.04", + "27.04", + "28.04", + "29.04", + "30.04", + "1.05", + "2.05", + "3.05", + "4.05", + "5.05", + "6.05", + "7.05", + "8.05", + "9.05", + "10.05", + "11.05", + "12.05", + "13.05", + "14.05", + "15.05", + "16.05", + "17.05", + "18.05", + "19.05", + "20.05", + "21.05", + "22.05", + "23.05", + "24.05", + "25.05", + "26.05", + "27.05", + "28.05", + "29.05", + "30.05", + "1.06", + "2.06", + "3.06", + "4.06", + "5.06", + "6.06", + "7.06", + "8.06", + "9.06", + "10.06", + "11.06", + "12.06", + "13.06", + "14.06", + "15.06", + "16.06", + "17.06", + "18.06", + "19.06", + "20.06", + "21.06", + "22.06", + "23.06", + "24.06", + "25.06", + "26.06", + "27.06", + "28.06", + "29.06", + "30.06", + "1.07", + "2.07", + "3.07", + "4.07", + "5.07", + "6.07", + "7.07", + "8.07", + "9.07", + "10.07", + "11.07", + "12.07", + "13.07", + "14.07", + "15.07", + "16.07", + "17.07", + "18.07", + "19.07", + "20.07", + "21.07", + "22.07", + "23.07", + "24.07", + "25.07", + "26.07", + "27.07", + "28.07", + "29.07", + "30.07", + "1.08", + "2.08", + "3.08", + "4.08", + "5.08", + "6.08", + "7.08", + "8.08", + "9.08", + "10.08", + "11.08", + "12.08", + "13.08", + "14.08", + "15.08", + "16.08", + "17.08", + "18.08", + "19.08", + "20.08", + "21.08", + "22.08", + "23.08", + "24.08", + "25.08", + "26.08", + "27.08", + "28.08", + "29.08", + "30.08", + "1.09", + "2.09", + "3.09", + "4.09", + "5.09", + "6.09", + "7.09", + "8.09", + "9.09", + "10.09", + "11.09", + "12.09", + "13.09", + "14.09", + "15.09", + "16.09", + "17.09", + "18.09", + "19.09", + "20.09", + "21.09", + "22.09", + "23.09", + "24.09", + "25.09", + "26.09", + "27.09", + "28.09", + "29.09", + "30.09", + "1.10", + "2.10", + "3.10", + "4.10", + "5.10", + "6.10", + "7.10", + "8.10", + "9.10", + "10.10", + "11.10", + "12.10", + "13.10", + "14.10", + "15.10", + "16.10", + "17.10", + "18.10", + "19.10", + "20.10", + "21.10", + "22.10", + "23.10", + "24.10", + "25.10", + "26.10", + "27.10", + "28.10", + "29.10", + "30.10", + "1.11", + "2.11", + "3.11", + "4.11", + "5.11", + "6.11", + "7.11", + "8.11", + "9.11", + "10.11", + "11.11", + "12.11", + "13.11", + "14.11", + "15.11", + "16.11", + "17.11", + "18.11", + "19.11", + "20.11", + "21.11", + "22.11", + "23.11", + "24.11", + "25.11", + "26.11", + "27.11", + "28.11", + "29.11", + "30.11", + "1.12", + "2.12", + "3.12", + "4.12", + "5.12", + "6.12", + "7.12", + "8.12", + "9.12", + "10.12", + "11.12", + "12.12", + "13.12", + "14.12", + "15.12", + "16.12", + "17.12", + "18.12", + "19.12", + "20.12", + "21.12", + "22.12", + "23.12", + "24.12", + "25.12", + "26.12", + "27.12", + "28.12", + "29.12", + "30.12" + ], "movie":[ "Batman", "Batmana", @@ -405,6 +757,281 @@ "broxbourne", "stevenage" ], + "seat":[ + "1,1", + "2,1", + "3,1", + "4,1", + "5,1", + "6,1", + "7,1", + "8,1", + "9,1", + "10,1", + "11,1", + "12,1", + "13,1", + "14,1", + "15,1", + "16,1", + "17,1", + "1,2", + "2,2", + "3,2", + "4,2", + "5,2", + "6,2", + "7,2", + "8,2", + "9,2", + "10,2", + "11,2", + "12,2", + "13,2", + "14,2", + "15,2", + "16,2", + "17,2", + "1,3", + "2,3", + "3,3", + "4,3", + "5,3", + "6,3", + "7,3", + "8,3", + "9,3", + "10,3", + "11,3", + "12,3", + "13,3", + "14,3", + "15,3", + "16,3", + "17,3", + "1,4", + "2,4", + "3,4", + "4,4", + "5,4", + "6,4", + "7,4", + "8,4", + "9,4", + "10,4", + "11,4", + "12,4", + "13,4", + "14,4", + "15,4", + "16,4", + "17,4", + "1,5", + "2,5", + "3,5", + "4,5", + "5,5", + "6,5", + "7,5", + "8,5", + "9,5", + "10,5", + "11,5", + "12,5", + "13,5", + "14,5", + "15,5", + "16,5", + "17,5", + "1,6", + "2,6", + "3,6", + "4,6", + "5,6", + "6,6", + "7,6", + "8,6", + "9,6", + "10,6", + "11,6", + "12,6", + "13,6", + "14,6", + "15,6", + "16,6", + "17,6", + "1,7", + "2,7", + "3,7", + "4,7", + "5,7", + "6,7", + "7,7", + "8,7", + "9,7", + "10,7", + "11,7", + "12,7", + "13,7", + "14,7", + "15,7", + "16,7", + "17,7", + "1,8", + "2,8", + "3,8", + "4,8", + "5,8", + "6,8", + "7,8", + "8,8", + "9,8", + "10,8", + "11,8", + "12,8", + "13,8", + "14,8", + "15,8", + "16,8", + "17,8", + "1,9", + "2,9", + "3,9", + "4,9", + "5,9", + "6,9", + "7,9", + "8,9", + "9,9", + "10,9", + "11,9", + "12,9", + "13,9", + "14,9", + "15,9", + "16,9", + "17,9", + "1,10", + "2,10", + "3,10", + "4,10", + "5,10", + "6,10", + "7,10", + "8,10", + "9,10", + "10,10", + "11,10", + "12,10", + "13,10", + "14,10", + "15,10", + "16,10", + "17,10", + "1,11", + "2,11", + "3,11", + "4,11", + "5,11", + "6,11", + "7,11", + "8,11", + "9,11", + "10,11", + "11,11", + "12,11", + "13,11", + "14,11", + "15,11", + "16,11", + "17,11", + "1,12", + "2,12", + "3,12", + "4,12", + "5,12", + "6,12", + "7,12", + "8,12", + "9,12", + "10,12", + "11,12", + "12,12", + "13,12", + "14,12", + "15,12", + "16,12", + "17,12", + "1,13", + "2,13", + "3,13", + "4,13", + "5,13", + "6,13", + "7,13", + "8,13", + "9,13", + "10,13", + "11,13", + "12,13", + "13,13", + "14,13", + "15,13", + "16,13", + "17,13", + "1,14", + "2,14", + "3,14", + "4,14", + "5,14", + "6,14", + "7,14", + "8,14", + "9,14", + "10,14", + "11,14", + "12,14", + "13,14", + "14,14", + "15,14", + "16,14", + "17,14" + ], + "sear_row": [ + "1", + "2", + "3", + "4", + "5", + "6", + "7", + "8", + "9", + "10", + "11", + "12", + "13", + "14" + ], + "sear_place": [ + "1", + "2", + "3", + "4", + "5", + "6", + "7", + "8", + "9", + "10", + "11", + "12", + "13", + "14", + "15", + "16", + "17" + ], "duration": [ "51 minuty", "88 minuty", @@ -3213,6 +3840,7 @@ "tr5679" ] }, + "police": { "name": [ "parkside police station" diff --git a/NLG_lab_11/NLG.py b/NLG_lab_11/NLG.py index 70a91a3..2e454b6 100644 --- a/NLG_lab_11/NLG.py +++ b/NLG_lab_11/NLG.py @@ -1,40 +1,58 @@ import json value_dict = json.load(open('../DST_DP_lab_9-10/value_dict.json')) -def nlg(system_act): - domain, intent, slot, value = system_act +class NLG: + def __init__(self): + self.answer = '' - if domain == 'Cinema' and intent == 'Inform' and slot == 'Seat': - if value == '': - return f'Nie znalazłem miejsca' - elif value == "top": - return f'Wolne miejsca na górze w rzędzie 10 miejsca od 5 do 10 i od 12 do 14' - elif value <= "bottom": - return f'Wolne miejsca na dole w rzędzie 1 miejsca od 2 do 10 i od 12 do 14' - elif value <= "middle": - return f'Wolne miejsca na środku w rzędzie 6 miejsca od 5 do 10' - elif domain == 'Cinema' and intent == 'Inform' and slot == 'Movie': - if value == None: - return f'Nie znalazłem filmu' - else: - return f'Film {value} będzie wyświetlany jutro o godzinie 21:30' - elif domain == 'Cinema' and intent == 'Offer' and slot == 'Closestscreening': - if value in ['dziś','jutro','pojutrze']: - return f'{value} prezentujemy Batmana o 18 i coś o 20' - elif value in value_dict['train']['day']: - return f'w {value} prezentujemy Batmana o 18 i coś o 20' - elif value in value_dict['train']['day']: - return f'dnia {value} prezentujemy Batmana o 18 i coś o 20'#lista dni 01.01 itd. - elif domain == 'Cinema' and intent == 'Request' and slot == 'e-mail': - if value== '': - return 'podaj e-mail' - else: - pass - elif domain == 'Cinema' and intent == 'Request' and slot == 'name': - if value== '': - return 'podaj imie i nazwisko' - else: - pass + def update(self, system_act): + for domain, intent, slot, value in system_act: + if domain == 'Cinema' and intent == 'Inform' and slot == 'Seat': + if value == '': + self.answer += f'Nie znalazłem miejsca.' + elif value == "top": + self.answer += f'Wolne miejsca na górze w rzędzie 10 miejsca od 5 do 10 i od 12 do 14. ' + elif value <= "bottom": + self.answer += f'Wolne miejsca na dole w rzędzie 1 miejsca od 2 do 10 i od 12 do 14. ' + elif value <= "middle": + self.answer += f'Wolne miejsca na środku w rzędzie 6 miejsca od 5 do 10. ' + elif domain == 'Cinema' and intent == 'Inform' and slot == 'Movie': + if value == None: + self.answer += f'Nie znalazłem filmu. ' + else: + self.answer += f'Film {value} będzie wyświetlany jutro o godzinie 21:30. ' + elif domain == 'Cinema' and intent == 'Offer' and slot == 'Closestscreening': + if value in ['Dziś','Jutro','Pojutrze']: + self.answer += f'{value} prezentujemy Batmana o 18:30 i Ambulans o 21:00. ' + elif value in value_dict['train']['day']: + self.answer += f'W {value} prezentujemy Ambulans o 18:30 i To nie wypanda o 20:00. ' + elif value in value_dict['train']['date']: + self.answer += f'Dnia {value} prezentujemy Batmana o 18:00 i Sing 2 o 20:30. ' + elif domain == 'Cinema' and intent == 'Request' and slot == 'e-mail': + if value== '': + self.answer += 'Prosze podać e-mail. ' + else: + pass + elif domain == 'Cinema' and intent == 'Request' and slot == 'name': + if value== '': + self.answer += 'Prosze podać imie i nazwisko. ' + else: + pass + elif domain == 'Cinema' and intent =='Request' and slot == 'Seat_row': + if value in value_dict['train']['seat_row']: + self.answer += f'W rzędzie {value} są wolne miejsca od 1 do 4 i od 12 do 15. ' + else: + self.answer += f'Nie ma wolnych miejsc. ' + elif domain == 'Cinema' and intent =='Request' and slot == 'Seat_place': + if value in value_dict['train']['seat_place']: + self.answer += f'W rzędzie 4 jest wolne miejsce {value}. ' + else: + self.answer += f'W rzędzie 4 nie ma wolnego miejsce {value}. ' + elif domain == 'Cinema' and intent =='Request' and slot == 'Seat': + if value in value_dict['train']['seat']: + self.answer += f'Miejsce {value} jest wolne. ' + else: + self.answer += f'Miejsce {value} nie jest wolne. ' + return self.answer -print(nlg(['Cinema', 'Offer', 'Closestscreening', "poniedziałek"])) - -# print(value_dict['train']['day']) +nlg = NLG() +print(nlg.update([['Cinema', 'Offer', 'Closestscreening', "1.02"],['Cinema', 'Request', 'name', ""]]))