Working nlg i ogólne poprawki
This commit is contained in:
parent
2abc5bed1a
commit
887f6249ce
@ -14,10 +14,8 @@ class Dp:
|
|||||||
'wagonType': "carrige_class",
|
'wagonType': "carrige_class",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def identify(self):
|
def identify(self):
|
||||||
req = self.answers.get(self.act)
|
req = self.answers.get(self.act)
|
||||||
response = req.get(self.param[0]) if not req is None else "null"
|
response = req.get(self.param[0]) if req is not None else "null"
|
||||||
return response if not response is None else "null"
|
return response if response is not None else "null"
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
|
class Dst:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
class Dst:
|
|
||||||
self.messages = []
|
self.messages = []
|
||||||
self.checklist = {
|
self.checklist = {
|
||||||
"from": None,
|
"from": None,
|
||||||
@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
def save_answer(self, slots):
|
def save_answer(self, slots):
|
||||||
for slot in slots:
|
for slot in slots:
|
||||||
self.checklist[slot[0]] = slot[1]
|
if slot[1] is not None:
|
||||||
|
self.checklist[slot[0]] = slot[1]
|
||||||
|
|
||||||
self.messages.append(slots)
|
self.messages.append(slots)
|
||||||
|
@ -6,7 +6,16 @@ class Nlg:
|
|||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
self.responses = {
|
self.responses = {
|
||||||
"welcomemsg": ["I AM TRAIlMinATor!", "Cześć, jestem TrailMinator"],
|
"welcomemsg": ["I AM TRAIlMinATor!", "Cześć, jestem TrailMinator"],
|
||||||
"null": ["Can't hear you"]}
|
"from": ["Podaj stację poczatkową i końcową",
|
||||||
|
"Podaj stację początkową i końcową zaczynając zdanie od 'chciałbym kupić bilet'"],
|
||||||
|
"to": ["Podaj stację kocową"],
|
||||||
|
"time": ["Podaj w jaki dzień chcesz odbyć podróż"],
|
||||||
|
"passangerCount": ["Podaj ile biletów chcesz kupić"],
|
||||||
|
"discountedCount": ["Podaj ile z tych biletów będzie biletami ze zniżką i jaka zniżka będzie przysługiwała"],
|
||||||
|
"seatType": ["Podaj miejsce jakie chcesz mieć w pociągu: pod oknem/w środku/w przejściu"],
|
||||||
|
"wagonType": ["Podaj klasę wagonu w jakim chcesz kupić bilety: 1 albo 2 klasa"],
|
||||||
|
"null": ["Can't hear you"]
|
||||||
|
}
|
||||||
|
|
||||||
def response(self, response_type: str) -> str:
|
def response(self, response_type: str) -> str:
|
||||||
avail_resps = self.responses.get(response_type)
|
avail_resps = self.responses.get(response_type)
|
||||||
|
@ -20,7 +20,7 @@ public <podaj_liczbe> = (<liczba>+){number};
|
|||||||
public <passanger> = [<liczba>]{passangerCount} bilet[y | ów];
|
public <passanger> = [<liczba>]{passangerCount} bilet[y | ów];
|
||||||
|
|
||||||
//discount count
|
//discount count
|
||||||
public <discount> = [<liczba>]{discountedCount} bilet[y] (z ulgą | ze zniżką) <discount_type>{discount_type};
|
public <discount> = [<liczba>]{discountedCount} bilet[y | ów] (z ulgą | ze zniżką) <discount_type>{discount_type};
|
||||||
<discount_type> = studencką | seniorską | uczniowską;
|
<discount_type> = studencką | seniorską | uczniowską;
|
||||||
|
|
||||||
//seatType
|
//seatType
|
||||||
|
@ -8,13 +8,14 @@ if __name__ == "__main__":
|
|||||||
nlu = nlu.Nlu()
|
nlu = nlu.Nlu()
|
||||||
dst = dst.Dst()
|
dst = dst.Dst()
|
||||||
|
|
||||||
next_question = dst.get_next_question()
|
response_type = dst.get_next_question()
|
||||||
while (next_question):
|
while response_type:
|
||||||
|
next_question = nlg.response(response_type)
|
||||||
print(next_question)
|
print(next_question)
|
||||||
response = input()
|
response = input()
|
||||||
res_tokenized = nlu.tokenize(response)
|
res_tokenized = nlu.tokenize(response)
|
||||||
dst.save_answer(res_tokenized['slots'])
|
dst.save_answer(res_tokenized['slots'])
|
||||||
next_question = dst.get_next_question()
|
response_type = dst.get_next_question()
|
||||||
|
|
||||||
print(dst.checklist)
|
print(dst.checklist)
|
||||||
# print(dp_params)
|
# print(dp_params)
|
||||||
|
Loading…
Reference in New Issue
Block a user