From ab37136896da8946253568b652d1acb34ab0fc23 Mon Sep 17 00:00:00 2001 From: Jakub Kaczmarek Date: Wed, 9 Mar 2022 13:07:13 +0100 Subject: [PATCH] Initial commit --- chatbot.py | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 chatbot.py diff --git a/chatbot.py b/chatbot.py new file mode 100644 index 0000000..4656a31 --- /dev/null +++ b/chatbot.py @@ -0,0 +1,42 @@ +from nltk.chat.util import Chat + +reflections = { + "jestem": "jestes", + "byłem": "byłeś", + "ja": "ty", + "zrobiłbym": "zrobiłbyś", + "zrobiłem": "zrobiłeś", + "zrobię": "zrobisz", + "mam": "masz", + "twoje": "moje", + "twój": "mój", + "ty": "ja", + } + +pairs = ( + ( + r'Potrzebuje (.*)', + ( + "Dlaczego potrzebujesz %1?", + "Czy napewno %1 Ci pomoże?", + "Jesteś pewny, że potrzebujesz %1?", + ), + ), + ( + r"Why can\'t I (.*)", + ( + "Do you think you should be able to %1?", + "If you could %1, what would you do?", + "I don't know -- why can't you %1?", + "Have you really tried?", + ), + ), + +) + +chatbot = Chat(pairs, reflections) + +if __name__ == '__main__': + print('Cześć, czegopotrzebujesz?') + + chatbot.converse()