Implementation of Natural Language Understanding
This commit is contained in:
parent
fa5ec70225
commit
0a03376129
31
system_mockup/analizator_jezyka_naturalnego.py
Normal file
31
system_mockup/analizator_jezyka_naturalnego.py
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
import re
|
||||||
|
|
||||||
|
def analizator_jezyka_naturalnego(text):
|
||||||
|
hello = ['dzie[ńn] dobry', 'dobry wiecz[oó]r', 'witam', 'witaj', 'siema', 'elo', 'cze[śs][ćc]']
|
||||||
|
request_name = ['imi[eę]', 'nazywasz']
|
||||||
|
question = ['\?$']
|
||||||
|
|
||||||
|
acts = {'hello': [hello],
|
||||||
|
'request(name)': [request_name, question]}
|
||||||
|
text = text_preprocess(text)
|
||||||
|
frame = act_check(text)
|
||||||
|
return frame
|
||||||
|
|
||||||
|
def text_preprocess(text):
|
||||||
|
text = text.lower()
|
||||||
|
return text
|
||||||
|
|
||||||
|
def act_check(text):
|
||||||
|
frame = []
|
||||||
|
for act, requirements in acts.items():
|
||||||
|
req = [check_synonyms(synonyms, text) for synonyms in requirements]
|
||||||
|
if all(req):
|
||||||
|
frame.append(act)
|
||||||
|
return frame
|
||||||
|
|
||||||
|
def check_synonyms(synonyms, text):
|
||||||
|
for expression in synonyms:
|
||||||
|
match = re.search(expression, text)
|
||||||
|
if match:
|
||||||
|
return True
|
||||||
|
return False
|
2
system_mockup/generator_jezyka_nautalnego.py
Normal file
2
system_mockup/generator_jezyka_nautalnego.py
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
def generator_jezyka_nautalnego():
|
||||||
|
pass
|
2
system_mockup/monitor_stanu_dialogowego.py
Normal file
2
system_mockup/monitor_stanu_dialogowego.py
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
def monitor_stanu_dialogowego():
|
||||||
|
pass
|
14
system_mockup/system_dialogowy.py
Normal file
14
system_mockup/system_dialogowy.py
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
from analizator_jezyka_naturalnego import analizator_jezyka_naturalnego
|
||||||
|
from monitor_stanu_dialogowego import monitor_stanu_dialogowego
|
||||||
|
from taktyka_dialogu import taktyka_dialogu
|
||||||
|
from generator_jezyka_nautalnego import generator_jezyka_nautalnego
|
||||||
|
|
||||||
|
def main():
|
||||||
|
text = input('>>>')
|
||||||
|
frame = analizator_jezyka_naturalnego(text)
|
||||||
|
monitor_stanu_dialogowego(frame)
|
||||||
|
taktyka_dialogu()
|
||||||
|
generator_jezyka_nautalnego()
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
2
system_mockup/taktyka_dialogu.py
Normal file
2
system_mockup/taktyka_dialogu.py
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
def taktyka_dialogu():
|
||||||
|
pass
|
Loading…
Reference in New Issue
Block a user