diff --git a/eliza.py b/eliza.py new file mode 100644 index 0000000..c9a13d8 --- /dev/null +++ b/eliza.py @@ -0,0 +1,47 @@ +from nltk.chat.util import Chat, reflections + +pairs = ( + ( + r"Potrzebuję (.*)", + ( + "Dlaczego potrzebujesz %1?", + "Jesteś pewien, że potrzebujesz %1?", + ), + ), + ( + r"koniec", + ( + "Do widzenia", + ), + ), + ( + r"(.*)", + ( + "Możesz rozwinąć?", + "Rozumiem.", + "Ciekawe.", + "%1.", + ), + ), +) + +eliza_chatbot = Chat(pairs, reflections) + + +def eliza_chat(): + print("Terapeuta\n---------") + print("Rozmawiaj po Polsku.") + print('Używaj zarówno wielkich, jak i małych lister; używaj interpunkcji.') + print('Aby zakończyć, napisz "koniec".') + print("=" * 72) + print("Witaj, jak się czujesz?") + + eliza_chatbot.converse(quit="koniec") + + +def demo(): + eliza_chat() + + +if __name__ == "__main__": + eliza_chat() diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..34e7188 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +nltk==3.8.1