added DST, DP and NLG classes
This commit is contained in:
parent
3a6965c2d9
commit
d49172230a
8
DialoguePolicy.py
Normal file
8
DialoguePolicy.py
Normal 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
7
DialogueStateTracker.py
Normal 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
17
Main.py
@ -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)
|
||||
|
||||
|
||||
|
8
NaturalLanguageGeneration.py
Normal file
8
NaturalLanguageGeneration.py
Normal 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
|
Loading…
Reference in New Issue
Block a user