Systemy_DialogowePon15-30/presenter/chatbot_modules/NaturalLanguageUnderstanding.py

16 lines
449 B
Python
Raw Normal View History

2021-04-26 13:31:00 +02:00
import re
from model.UserActFrame import UserActFrame
class NaturalLanguageUnderstanding:
def __init__(self):
self.user_acts = [
(r"Cześć(.*)|czesc|Czesc", UserActFrame('hello()', [])),
(r"(.*)imię(.*)|Jak masz na imię(.*)", UserActFrame('request()', ['imię']))
]
def text_to_user_frame(self, text):
return [user_act[1] for user_act in self.user_acts if re.match(user_act[0], text)]