16 lines
449 B
Python
16 lines
449 B
Python
|
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)]
|