#Natural Language Understanding class NLU: #Text analysys def __init__(self, acts, arguments): self.acts = acts self.arguments = arguments def analyze(self, text): #Turn text into frame #return vector for further use act = "(hello()&request(name))" vector = [[0],[1,0]] return vector #Dialogue policy class DP: #Module decide what act takes next def __init__(self, acts, arguments): self.acts = acts self.arguments = arguments def tacticChoice(self, frame_list): actVector = [0, 0] return actVector #Dialogue State Tracker class DST: #Contain informations about state of the dialogue and data taken from user def __init__(self, acts, arguments): self.acts = acts self.arguments = arguments self.frameList= [] #store new act into frame def store(self, frame): self.frameList.append(frame) def transfer(self): return self.frameList #Natural Language Generator class NLG: def __init__(self, acts, arguments): self.acts = acts self.arguments = arguments def vectorToText(self, actVector): if(actVector == [0, 0]): return "Witaj, nazywam się Mateusz." else: return "Przykro mi, nie zrozumiałem Cię" class Run: def __init__(self): self.acts={ 0: "hello", 1: "request", } self.arguments={ 0: "name" } self.nlu = NLU(self.acts, self.arguments) self.dp = DP(self.acts, self.arguments) self.nlg = NLG(self.acts, self.arguments) self.dst = DST(self.acts, self.arguments) def inputProcessing(self, command): act = self.nlu.analyze(command) self.dst.store(act) basic_act = self.dp.tacticChoice(self.dst.transfer()) return self.nlg.vectorToText(basic_act) run = Run() while(1): message = input("Napisz coś: ") print(run.inputProcessing(message))