added DST, DP and NLG classes

This commit is contained in:
Krzysztof Raczyński 2024-04-21 10:09:03 +02:00
parent 3a6965c2d9
commit d49172230a
4 changed files with 40 additions and 0 deletions

8
DialoguePolicy.py Normal file
View File

@ -0,0 +1,8 @@
class DialoguePolicy:
def policy(self, state):
system_act = None
name = "James"
if state == "what name":
system_act = f"inform(name={name})"
return system_act

7
DialogueStateTracker.py Normal file
View File

@ -0,0 +1,7 @@
class DialogueStateTracker:
def dst(self, user_act):
state = None
if user_act == "request(firstname)":
state = "what name"
return state

17
Main.py
View File

@ -1,7 +1,24 @@
from NaturalLanguageAnalyzer import NaturalLanguageAnalyzer
from DialogueStateTracker import DialogueStateTracker
from DialoguePolicy import DialoguePolicy
from NaturalLanguageGeneration import NaturalLanguageGeneration
if __name__ == "__main__":
text = "Cześć, jak masz na imię?"
nla = NaturalLanguageAnalyzer()
user_act = nla.process(text)
print(user_act)
dst = DialogueStateTracker()
state = dst.dst(user_act)
print(state)
dp = DialoguePolicy()
system_act = dp.policy(state)
print(system_act)
nlg = NaturalLanguageGeneration()
response = nlg.nlg(system_act)
print(response)

View File

@ -0,0 +1,8 @@
class NaturalLanguageGeneration:
def nlg(self, system_act):
response = None
name = "James"
if system_act == f"inform(name={name})":
response = f"Witaj, nazywam się {name}"
return response