SystemyDialogowe/main.py

39 lines
1.2 KiB
Python
Raw Permalink Normal View History

2021-05-31 14:53:20 +02:00
from SystemActType import SystemActType
2021-04-26 00:29:07 +02:00
from NaturalLanguageUnderstanding import NLU
2021-04-26 09:57:03 +02:00
from NaturalLanguageGeneration import NLG
2021-04-26 00:29:07 +02:00
from DialogueStateTracker import DST
from DialoguePolicy import DP
2021-06-14 17:27:27 +02:00
from DBManager import calender_db
2021-04-26 00:29:07 +02:00
if __name__ == "__main__":
2021-06-14 17:27:27 +02:00
db = calender_db()
2021-04-26 00:29:07 +02:00
nlu = NLU()
dst = DST()
2021-06-14 17:27:27 +02:00
dp = DP(dst, db)
2021-06-03 17:48:12 +02:00
nlg = NLG(dst)
2021-04-26 09:57:03 +02:00
while(1):
2021-06-14 17:27:27 +02:00
user_input = input("\nWpisz tekst: ")
2021-04-26 00:29:07 +02:00
2021-05-16 16:56:37 +02:00
user_frame = nlu.parse_user_input(user_input)
2021-06-15 10:05:49 +02:00
# print('\n------ rozpoznany user frame ------')
# print(user_frame)
2021-06-14 17:27:27 +02:00
2021-05-31 13:52:01 +02:00
dst.user_update(user_frame)
state, last_user_act, last_system_act = dst.get_dialogue_state()
slots = dst.get_dialogue_slots()
system_act = dp.chooseTactic()
2021-06-03 17:48:12 +02:00
2021-06-15 10:05:49 +02:00
# print('\n------ stan ------')
# print(state, last_user_act, last_system_act)
# print('\n------ przechowywane sloty ------')
# print(slots)
2021-06-14 17:27:27 +02:00
print('\n------ wybrana akcja systemu ------')
2021-05-31 13:52:01 +02:00
print(system_act)
2021-06-03 17:48:12 +02:00
system_response = nlg.generateResponse(system_act)
2021-06-14 17:27:27 +02:00
print('\n------ wygenerowana odpowiedź systemu ------')
2021-06-03 17:48:12 +02:00
print(system_response)
2021-05-31 14:53:20 +02:00
if system_act.getActType() == SystemActType.BYE:
break