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.act = act
|
||||||
self.param = param
|
self.param = param
|
||||||
self.answers = {
|
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):
|
def identify(self):
|
||||||
|
@ -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,
|
||||||
@ -22,3 +22,9 @@ class Dst:
|
|||||||
for key, value in self.checklist.items():
|
for key, value in self.checklist.items():
|
||||||
if value == None:
|
if value == None:
|
||||||
return key
|
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
|
import random
|
||||||
from urllib import response
|
from urllib import response
|
||||||
|
|
||||||
from scipy import rand
|
|
||||||
|
|
||||||
class Nlg:
|
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:
|
def __init__(self) -> None:
|
||||||
avail_resps = self.responses.get(self._response_type)
|
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)]
|
return avail_resps[random.randint(0, len(avail_resps)-1)]
|
||||||
|
@ -58,10 +58,4 @@ class Nlu:
|
|||||||
return (act, param)
|
return (act, param)
|
||||||
|
|
||||||
nlu = Nlu()
|
nlu = Nlu()
|
||||||
print(nlu.tokenize('chciałbym kupić bilet do Krakow'))
|
print(nlu.tokenize('chciałbym kupić bilet na pociąg z Poznan 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'))
|
|
||||||
|
@ -4,12 +4,23 @@ import dp
|
|||||||
import nlg
|
import nlg
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
msg = "Jak masz na imie?"
|
nlg = nlg.Nlg()
|
||||||
dp_params = nlu.Nlu().parse(msg)
|
nlu = nlu.Nlu()
|
||||||
# print(dp_params)
|
dst = dst.Dst()
|
||||||
nlg_params = dp.Dp(*dp_params).identify()
|
|
||||||
# print(nlg_params)
|
|
||||||
print(f"{msg}\n{nlg.Nlg(nlg_params).response()}")
|
|
||||||
|
|
||||||
d = dst.Dst()
|
next_question = dst.get_next_question()
|
||||||
print(d.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