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
if __name__ == "__main__":
nlu = NLU()
dst = DST()
2021-05-31 13:52:01 +02:00
dp = DP(dst)
2021-06-03 17:48:12 +02:00
nlg = NLG(dst)
2021-04-26 09:57:03 +02:00
while(1):
user_input = input("Wpisz 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-05-31 13:52:01 +02:00
print('------ rozpoznany user frame ------')
2021-05-30 12:55:49 +02:00
print(user_frame)
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()
2021-06-18 15:26:21 +02:00
system_act = dp.choose_tactic()
2021-06-03 17:48:12 +02:00
2021-05-31 13:52:01 +02:00
print('------ stan ------')
print(state, last_user_act, last_system_act)
print('------ przechowywane sloty ------')
print(slots)
print('------ wybrana akcja systemu ------')
print(system_act)
2021-06-18 15:26:21 +02:00
system_response = nlg.generate_response(system_act)
2021-06-03 17:48:12 +02:00
print('------ wygenerowana odpowiedź systemu ------')
print(system_response)
2021-05-31 13:52:01 +02:00
print('-----------------------------------')
print('-----------------------------------')
2021-05-31 14:53:20 +02:00
if system_act.getActType() == SystemActType.BYE:
break