Merge remote-tracking branch 'origin/master'
# Conflicts: # trailminator/nlu.py
This commit is contained in:
commit
2abc5bed1a
@ -3,7 +3,16 @@ class Dp:
|
||||
self.act = act
|
||||
self.param = param
|
||||
self.answers = {
|
||||
'request': {'imie': "welcomemsg"}
|
||||
'request': {
|
||||
'imie': "welcomemsg",
|
||||
'from': "from",
|
||||
'to': "to",
|
||||
'time': "date",
|
||||
'passangerCount': "travelers_count",
|
||||
'discountCount': "travelers_discount_count",
|
||||
'seatType': "seat_type",
|
||||
'wagonType': "carrige_class",
|
||||
}
|
||||
}
|
||||
|
||||
def identify(self):
|
||||
|
@ -1,5 +1,5 @@
|
||||
class Dst:
|
||||
def __init__(self):
|
||||
class Dst:
|
||||
self.messages = []
|
||||
self.checklist = {
|
||||
"from": None,
|
||||
@ -22,3 +22,9 @@ class Dst:
|
||||
for key, value in self.checklist.items():
|
||||
if value == None:
|
||||
return key
|
||||
|
||||
def save_answer(self, slots):
|
||||
for slot in slots:
|
||||
self.checklist[slot[0]] = slot[1]
|
||||
|
||||
self.messages.append(slots)
|
||||
|
@ -1,14 +1,13 @@
|
||||
import random
|
||||
from urllib import response
|
||||
|
||||
from scipy import rand
|
||||
|
||||
class Nlg:
|
||||
def __init__(self, response_type: str) -> None:
|
||||
self._response_type = response_type
|
||||
self.responses = {"welcomemsg": ["I AM TRAIlMinATor!", "Cześć, jestem TrailMinator"],
|
||||
"null": "Can't hear you"}
|
||||
|
||||
def response(self) -> str:
|
||||
avail_resps = self.responses.get(self._response_type)
|
||||
def __init__(self) -> None:
|
||||
self.responses = {
|
||||
"welcomemsg": ["I AM TRAIlMinATor!", "Cześć, jestem TrailMinator"],
|
||||
"null": ["Can't hear you"]}
|
||||
|
||||
def response(self, response_type: str) -> str:
|
||||
avail_resps = self.responses.get(response_type)
|
||||
return avail_resps[random.randint(0, len(avail_resps)-1)]
|
||||
|
@ -58,10 +58,4 @@ class Nlu:
|
||||
return (act, param)
|
||||
|
||||
nlu = Nlu()
|
||||
print(nlu.tokenize('chciałbym kupić bilet do Krakow'))
|
||||
print(nlu.tokenize('chciałbym kupić bilet z Poznan'))
|
||||
print(nlu.tokenize('w piątek'))
|
||||
print(nlu.tokenize('4 bilety'))
|
||||
print(nlu.tokenize('2 bilety z ulgą studencką'))
|
||||
print(nlu.tokenize('miejsce pod oknem'))
|
||||
print(nlu.tokenize('druga klasa'))
|
||||
print(nlu.tokenize('chciałbym kupić bilet na pociąg z Poznan do Krakow'))
|
||||
|
@ -4,12 +4,23 @@ import dp
|
||||
import nlg
|
||||
|
||||
if __name__ == "__main__":
|
||||
msg = "Jak masz na imie?"
|
||||
dp_params = nlu.Nlu().parse(msg)
|
||||
# print(dp_params)
|
||||
nlg_params = dp.Dp(*dp_params).identify()
|
||||
# print(nlg_params)
|
||||
print(f"{msg}\n{nlg.Nlg(nlg_params).response()}")
|
||||
nlg = nlg.Nlg()
|
||||
nlu = nlu.Nlu()
|
||||
dst = dst.Dst()
|
||||
|
||||
d = dst.Dst()
|
||||
print(d.get_next_question())
|
||||
next_question = dst.get_next_question()
|
||||
while (next_question):
|
||||
print(next_question)
|
||||
response = input()
|
||||
res_tokenized = nlu.tokenize(response)
|
||||
dst.save_answer(res_tokenized['slots'])
|
||||
next_question = dst.get_next_question()
|
||||
|
||||
print(dst.checklist)
|
||||
# print(dp_params)
|
||||
# nlg_params = dp.Dp(*dp_params).identify()
|
||||
# print(nlg_params)
|
||||
#print(f"{msg}\n{nlg.Nlg(nlg_params).response()}")
|
||||
|
||||
#d = dst.Dst()
|
||||
#print(d.get_next_question())
|
||||
|
Loading…
Reference in New Issue
Block a user