DST module
This commit is contained in:
parent
d1dbd09a15
commit
a798e3ec39
100
Modules.py
100
Modules.py
@ -79,7 +79,7 @@ class DP(Policy):
|
||||
if value != ""
|
||||
]
|
||||
self.db.dbs = {
|
||||
"book": [
|
||||
"books": [
|
||||
{
|
||||
"author": "autor",
|
||||
"title": "krew",
|
||||
@ -177,10 +177,37 @@ class SDST(DST):
|
||||
"card": {"semi": {"lost": "", "destroyed": "", "new": ""}},
|
||||
"date": {"semi": {"day": "", "month": "", "year": ""}},
|
||||
},
|
||||
"request_state": {},
|
||||
"request_state": {
|
||||
"reserve": {"reservation": []},
|
||||
},
|
||||
"reqmore_state": {
|
||||
"books": {
|
||||
"reserve": {"reservation": []},
|
||||
"semi": {
|
||||
"title": "",
|
||||
"author": "",
|
||||
"genre": "",
|
||||
"publisher": "",
|
||||
"edition": "",
|
||||
"lang": "",
|
||||
},
|
||||
},
|
||||
"library": {
|
||||
"semi": {
|
||||
"location": "",
|
||||
"status": "",
|
||||
"events": "",
|
||||
"days": "",
|
||||
"phone number": "",
|
||||
}
|
||||
},
|
||||
"card": {"semi": {"lost": "", "destroyed": "", "new": ""}},
|
||||
"date": {"semi": {"day": "", "month": "", "year": ""}},
|
||||
},
|
||||
"terminated": False,
|
||||
"history": [],
|
||||
}
|
||||
|
||||
self.ref = {
|
||||
"Books": {
|
||||
"Title": "title",
|
||||
@ -214,7 +241,7 @@ class SDST(DST):
|
||||
domain = domain.lower()
|
||||
intent = intent.lower()
|
||||
|
||||
if domain in ["unk", "general", "booking"]:
|
||||
if domain in ["bye", "thankyou", "hello"]:
|
||||
continue
|
||||
|
||||
if intent == "inform":
|
||||
@ -227,22 +254,75 @@ class SDST(DST):
|
||||
|
||||
if k in domain_dic["semi"]:
|
||||
nvalue = normalize_value(self.value_dict, domain, k, value)
|
||||
self.state["belief_state"][domain]["semi"][k] = nvalue
|
||||
elif k in domain_dic["book"]:
|
||||
self.state["belief_state"][domain]["book"][k] = value
|
||||
elif k.lower() in domain_dic["book"]:
|
||||
self.state["belief_state"][domain]["book"][k.lower()] = value
|
||||
self.state["belief_state"][domain]["semi"][k] = value
|
||||
elif k in domain_dic["books"]:
|
||||
self.state["belief_state"][domain]["books"][k] = value
|
||||
elif k.lower() in domain_dic["books"]:
|
||||
self.state["belief_state"][domain]["books"][k.lower()] = value
|
||||
|
||||
elif intent == "request":
|
||||
k = self.ref[domain.capitalize()].get(slot, slot)
|
||||
|
||||
if k is None:
|
||||
continue
|
||||
|
||||
if domain not in self.state["request_state"]:
|
||||
self.state["request_state"][domain] = {}
|
||||
self.state["request_state"]["reserve"]["reservation"].append(value)
|
||||
else:
|
||||
if (
|
||||
value
|
||||
not in self.state["request_state"]["reserve"]["reservation"]
|
||||
):
|
||||
self.state["request_state"]["reserve"]["reservation"].append(
|
||||
value
|
||||
)
|
||||
|
||||
if k not in self.state["request_state"][domain]:
|
||||
self.state["request_state"][domain][k] = 0
|
||||
self.state["request_state"][domain][k] = value
|
||||
else:
|
||||
self.state["request_state"][domain][k] = value
|
||||
|
||||
self.state["history"].append(
|
||||
self.state["request_state"]["reserve"]["reservation"][-1]
|
||||
)
|
||||
|
||||
elif intent == "reqmore":
|
||||
k = self.ref[domain.capitalize()].get(slot, slot)
|
||||
|
||||
if k is None:
|
||||
continue
|
||||
|
||||
domain_dic = self.state["reqmore_state"][domain]
|
||||
|
||||
if k in domain_dic["semi"]:
|
||||
nvalue = normalize_value(self.value_dict, domain, k, value)
|
||||
self.state["reqmore_state"][domain]["semi"][k] = value
|
||||
elif k in domain_dic["books"]:
|
||||
self.state["reqmore_state"][domain]["books"][k] = value
|
||||
elif k.lower() in domain_dic["books"]:
|
||||
self.state["reqmore_state"][domain]["books"][k.lower()] = value
|
||||
|
||||
elif intent == "negate":
|
||||
try:
|
||||
self.state["request_state"]["reserve"]["reservation"].remove(
|
||||
self.state["history"][-1]
|
||||
)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
elif intent == "affirm":
|
||||
self.state["belief_state"]["books"]["reserve"][
|
||||
"reservation"
|
||||
] = self.state["request_state"]["reserve"]["reservation"]
|
||||
|
||||
else:
|
||||
continue
|
||||
|
||||
return self.state
|
||||
|
||||
def init_session(self):
|
||||
self.state = self_state
|
||||
self.state = self.state
|
||||
|
||||
|
||||
# Natural Language Generator
|
||||
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
"book":{
|
||||
"books":{
|
||||
"title": [
|
||||
"Bezsenność w Tokio",
|
||||
"Sapiens Od zwierząt do bogów",
|
||||
|
Loading…
Reference in New Issue
Block a user