Merge branch 'trailminator' of https://git.wmi.amu.edu.pl/s478841/SD-project-22 into trailminator
This commit is contained in:
commit
ed290b2c59
@ -1,5 +1,14 @@
|
|||||||
class Dp:
|
class Dp:
|
||||||
def __init__(self):
|
def __init__(self, act, param):
|
||||||
self.actions = {
|
self.act = act
|
||||||
"name": ['imie', 'imię']
|
self.param = param
|
||||||
|
self.answers = {
|
||||||
|
'request': {'imie': "welcomemsg"}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def identify(self):
|
||||||
|
req = self.answers.get(self.act)
|
||||||
|
response = req.get(self.param[0]) if not req is None else "null"
|
||||||
|
return response if not response is None else "null"
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,20 +1,14 @@
|
|||||||
from asyncio.constants import SENDFILE_FALLBACK_READBUFFER_SIZE
|
import random
|
||||||
|
from urllib import response
|
||||||
|
|
||||||
|
from scipy import rand
|
||||||
|
|
||||||
class Nlg:
|
class Nlg:
|
||||||
def __init__(self):
|
def __init__(self, response_type: str) -> None:
|
||||||
|
self._response_type = response_type
|
||||||
|
self.responses = {"welcomemsg": ["I AM TRAIlMinATor!", "Cześć, jestem TrailMinator"],
|
||||||
self.reactions = {
|
"null": "Can't hear you"}
|
||||||
"name": "Mam na imie Trailminator."
|
|
||||||
}
|
|
||||||
|
|
||||||
def detect_action(self, message):
|
|
||||||
for k, v in self.actions:
|
|
||||||
if any(m in v for m in message):
|
|
||||||
return k
|
|
||||||
|
|
||||||
def generate_action(self, action):
|
|
||||||
return self.reactions[action]
|
|
||||||
|
|
||||||
|
|
||||||
|
def response(self) -> str:
|
||||||
|
avail_resps = self.responses.get(self._response_type)
|
||||||
|
return avail_resps[random.randint(0, len(avail_resps)-1)]
|
||||||
|
@ -42,5 +42,3 @@ class Nlu:
|
|||||||
|
|
||||||
return (act, param)
|
return (act, param)
|
||||||
|
|
||||||
nlu = Nlu()
|
|
||||||
print(nlu.parse('jak masz na imie?'))
|
|
12
trailminator/trailminator.py
Normal file
12
trailminator/trailminator.py
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
import dst
|
||||||
|
import nlu
|
||||||
|
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()}")
|
Loading…
Reference in New Issue
Block a user