Implementation of Natural Language Understanding

This commit is contained in:
Karol Idaszak 2022-04-19 21:20:46 +02:00
parent fa5ec70225
commit 0a03376129
5 changed files with 51 additions and 0 deletions

View 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

View File

@ -0,0 +1,2 @@
def generator_jezyka_nautalnego():
pass

View File

@ -0,0 +1,2 @@
def monitor_stanu_dialogowego():
pass

View 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()

View File

@ -0,0 +1,2 @@
def taktyka_dialogu():
pass