Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
bea94cbb98 | |||
7423eb6239 | |||
2fb726e628 | |||
064feffa72 |
@ -1,482 +0,0 @@
|
|||||||
{
|
|
||||||
"cells": [
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": 9,
|
|
||||||
"id": "13a78612-e727-4e7d-b087-438014883903",
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [],
|
|
||||||
"source": [
|
|
||||||
"from nltk.chat.util import Chat, reflections\n",
|
|
||||||
"\n",
|
|
||||||
"pairs = (\n",
|
|
||||||
" (\n",
|
|
||||||
" r\"I need (.*)\",\n",
|
|
||||||
" (\n",
|
|
||||||
" \"Why do you need %1?\",\n",
|
|
||||||
" \"Would it really help you to get %1?\",\n",
|
|
||||||
" \"Are you sure you need %1?\",\n",
|
|
||||||
" ),\n",
|
|
||||||
" ),\n",
|
|
||||||
" (\n",
|
|
||||||
" r\"who created you (.*)\",\n",
|
|
||||||
" (\n",
|
|
||||||
" \"ELIZA was invented in 1966 by Weizenbaum. Why %1?\",\n",
|
|
||||||
"\n",
|
|
||||||
" ),\n",
|
|
||||||
" ),\n",
|
|
||||||
" (\n",
|
|
||||||
" r\"Why don\\'t you (.*)\",\n",
|
|
||||||
" (\n",
|
|
||||||
" \"Do you really think I don't %1?\",\n",
|
|
||||||
" \"Perhaps eventually I will %1.\",\n",
|
|
||||||
" \"Do you really want me to %1?\",\n",
|
|
||||||
" ),\n",
|
|
||||||
" ),\n",
|
|
||||||
" (\n",
|
|
||||||
" r\"Why can\\'t I (.*)\",\n",
|
|
||||||
" (\n",
|
|
||||||
" \"Do you think you should be able to %1?\",\n",
|
|
||||||
" \"If you could %1, what would you do?\",\n",
|
|
||||||
" \"I don't know -- why can't you %1?\",\n",
|
|
||||||
" \"Have you really tried?\",\n",
|
|
||||||
" ),\n",
|
|
||||||
" ),\n",
|
|
||||||
" (\n",
|
|
||||||
" r\"I can\\'t (.*)\",\n",
|
|
||||||
" (\n",
|
|
||||||
" \"How do you know you can't %1?\",\n",
|
|
||||||
" \"Perhaps you could %1 if you tried.\",\n",
|
|
||||||
" \"What would it take for you to %1?\",\n",
|
|
||||||
" ),\n",
|
|
||||||
" ),\n",
|
|
||||||
" (\n",
|
|
||||||
" r\"I am (.*)\",\n",
|
|
||||||
" (\n",
|
|
||||||
" \"Did you come to me because you are %1?\",\n",
|
|
||||||
" \"How long have you been %1?\",\n",
|
|
||||||
" \"How do you feel about being %1?\",\n",
|
|
||||||
" ),\n",
|
|
||||||
" ),\n",
|
|
||||||
" (\n",
|
|
||||||
" r\"I\\'m (.*)\",\n",
|
|
||||||
" (\n",
|
|
||||||
" \"How does being %1 make you feel?\",\n",
|
|
||||||
" \"Do you enjoy being %1?\",\n",
|
|
||||||
" \"Why do you tell me you're %1?\",\n",
|
|
||||||
" \"Why do you think you're %1?\",\n",
|
|
||||||
" ),\n",
|
|
||||||
" ),\n",
|
|
||||||
" (\n",
|
|
||||||
" r\"Are you (.*)\",\n",
|
|
||||||
" (\n",
|
|
||||||
" \"Why does it matter whether I am %1?\",\n",
|
|
||||||
" \"Would you prefer it if I were not %1?\",\n",
|
|
||||||
" \"Perhaps you believe I am %1.\",\n",
|
|
||||||
" \"I may be %1 -- what do you think?\",\n",
|
|
||||||
" ),\n",
|
|
||||||
" ),\n",
|
|
||||||
" (\n",
|
|
||||||
" r\"What (.*)\",\n",
|
|
||||||
" (\n",
|
|
||||||
" \"Why do you ask?\",\n",
|
|
||||||
" \"How would an answer to that help you?\",\n",
|
|
||||||
" \"What do you think?\",\n",
|
|
||||||
" ),\n",
|
|
||||||
" ),\n",
|
|
||||||
" (\n",
|
|
||||||
" r\"How (.*)\",\n",
|
|
||||||
" (\n",
|
|
||||||
" \"How do you suppose?\",\n",
|
|
||||||
" \"Perhaps you can answer your own question.\",\n",
|
|
||||||
" \"What is it you're really asking?\",\n",
|
|
||||||
" ),\n",
|
|
||||||
" ),\n",
|
|
||||||
" (\n",
|
|
||||||
" r\"Ponieważ (.*)\",\n",
|
|
||||||
" (\n",
|
|
||||||
" \"Czy to prawdziwy powód?\",\n",
|
|
||||||
" \"Jakie inne powody przychodzą Ci na myśl?”,\",\n",
|
|
||||||
" \"Czy ten powód dotyczy czegokolwiek innego?\",\n",
|
|
||||||
" \"Jeśli %1, co jeszcze musi być prawdą?\",\n",
|
|
||||||
" ),\n",
|
|
||||||
" ),\n",
|
|
||||||
" (\n",
|
|
||||||
" r\"(.*) przepraszam (.*)\",\n",
|
|
||||||
" (\n",
|
|
||||||
" \"Wiele razy przeprosiny nie są potrzebne.\",\n",
|
|
||||||
" \"Co czujesz kiedy przepraszasz?\",\n",
|
|
||||||
" ),\n",
|
|
||||||
" ),\n",
|
|
||||||
" (\n",
|
|
||||||
" r\"Cześć(.*)\",\n",
|
|
||||||
" (\n",
|
|
||||||
" \"Cześć... cieszę się, że mogłeś dzisiaj wpaść..\",\n",
|
|
||||||
" \"Cześć... jak się masz dzisiaj?\",\n",
|
|
||||||
" \"Cześć, jak się dzisiaj czujesz?\",\n",
|
|
||||||
" ),\n",
|
|
||||||
" ),\n",
|
|
||||||
" (\n",
|
|
||||||
" r\"Myśle, że (.*)\",\n",
|
|
||||||
" (\"Czy wątpisz w %1?\", \"Naprawdę tak myślisz?\", \"Ale nie jesteś pewien, że %1?\"),\n",
|
|
||||||
" ),\n",
|
|
||||||
" (\n",
|
|
||||||
" r\"(.*) przyjaciel (.*)\",\n",
|
|
||||||
" (\n",
|
|
||||||
" \"Opowiedz mi więcej o swoich przyjaciołach.\",\n",
|
|
||||||
" \"Kiedy myślisz o przyjacielu, co przychodzi ci na myśl?\",\n",
|
|
||||||
" \"Dlaczego miałbyś nie opowiedzieć o przyjacielu z dzieciństwa?\",\n",
|
|
||||||
" ),\n",
|
|
||||||
" ),\n",
|
|
||||||
" (r\"Tak\", (\"Wydajesz się całkiem pewien.\", \"OK, ale czy możesz trochę rozwinąć?\")),\n",
|
|
||||||
" (\n",
|
|
||||||
" r\"(.*) komputer(.*)\",\n",
|
|
||||||
" (\n",
|
|
||||||
" \"Naprawdę mówisz o mnie?\",\n",
|
|
||||||
" \"Czy rozmowa z komputerem wydaje się dziwna?\",\n",
|
|
||||||
" \"Jak się czujesz przy komputerach?\",\n",
|
|
||||||
" \"Czy czujesz się zagrożony przez komputery?\",\n",
|
|
||||||
" ),\n",
|
|
||||||
" ),\n",
|
|
||||||
" (\n",
|
|
||||||
" r\"To jest (.*)\",\n",
|
|
||||||
" (\n",
|
|
||||||
" \"Czy myślisz, że to %1?\",\n",
|
|
||||||
" \"Może to %1 -- co myślisz?\",\n",
|
|
||||||
" \"Gdyby to był %1, co byś zrobił?\",\n",
|
|
||||||
" \"Może być tak, że %1.\",\n",
|
|
||||||
" ),\n",
|
|
||||||
" ),\n",
|
|
||||||
" (\n",
|
|
||||||
" r\"Jest to (.*)\",\n",
|
|
||||||
" (\n",
|
|
||||||
" \"Wydajesz się bardzo pewny.\",\n",
|
|
||||||
" \"Gdybym ci powiedziała, że prawdopodobnie nie jest to %1, co byś poczuł?\",\n",
|
|
||||||
" ),\n",
|
|
||||||
" ),\n",
|
|
||||||
" (\n",
|
|
||||||
" r\"Czy możesz (.*)\",\n",
|
|
||||||
" (\n",
|
|
||||||
" \"Dlaczego myślisz, że nie mogę %1?\",\n",
|
|
||||||
" \"Gdybym mógł %1, to co?\",\n",
|
|
||||||
" \"Dlaczego pytasz, czy mogę %1?\",\n",
|
|
||||||
" ),\n",
|
|
||||||
" ),\n",
|
|
||||||
" (\n",
|
|
||||||
" r\"Czy mogę (.*)\",\n",
|
|
||||||
" (\n",
|
|
||||||
" \"Być może nie chcesz %1.\",\n",
|
|
||||||
" \"Czy chcesz mieć możliwość %1?\",\n",
|
|
||||||
" \"Gdybyś mógł %1, czy byś?\",\n",
|
|
||||||
" ),\n",
|
|
||||||
" ),\n",
|
|
||||||
" (\n",
|
|
||||||
" r\"You are (.*)\",\n",
|
|
||||||
" (\n",
|
|
||||||
" \"Why do you think I am %1?\",\n",
|
|
||||||
" \"Does it please you to think that I'm %1?\",\n",
|
|
||||||
" \"Perhaps you would like me to be %1.\",\n",
|
|
||||||
" \"Perhaps you're really talking about yourself?\",\n",
|
|
||||||
" ),\n",
|
|
||||||
" ),\n",
|
|
||||||
" (\n",
|
|
||||||
" r\"You\\'re (.*)\",\n",
|
|
||||||
" (\n",
|
|
||||||
" \"Why do you say I am %1?\",\n",
|
|
||||||
" \"Why do you think I am %1?\",\n",
|
|
||||||
" \"Are we talking about you, or me?\",\n",
|
|
||||||
" ),\n",
|
|
||||||
" ),\n",
|
|
||||||
" (\n",
|
|
||||||
" r\"I don\\'t (.*)\",\n",
|
|
||||||
" (\"Don't you really %1?\", \"Why don't you %1?\", \"Do you want to %1?\"),\n",
|
|
||||||
" ),\n",
|
|
||||||
" (\n",
|
|
||||||
" r\"I feel (.*)\",\n",
|
|
||||||
" (\n",
|
|
||||||
" \"Good, tell me more about these feelings.\",\n",
|
|
||||||
" \"Do you often feel %1?\",\n",
|
|
||||||
" \"When do you usually feel %1?\",\n",
|
|
||||||
" \"When you feel %1, what do you do?\",\n",
|
|
||||||
" ),\n",
|
|
||||||
" ),\n",
|
|
||||||
" (\n",
|
|
||||||
" r\"I have (.*)\",\n",
|
|
||||||
" (\n",
|
|
||||||
" \"Why do you tell me that you've %1?\",\n",
|
|
||||||
" \"Have you really %1?\",\n",
|
|
||||||
" \"Now that you have %1, what will you do next?\",\n",
|
|
||||||
" ),\n",
|
|
||||||
" ),\n",
|
|
||||||
" (\n",
|
|
||||||
" r\"I would (.*)\",\n",
|
|
||||||
" (\n",
|
|
||||||
" \"Could you explain why you would %1?\",\n",
|
|
||||||
" \"Why would you %1?\",\n",
|
|
||||||
" \"Who else knows that you would %1?\",\n",
|
|
||||||
" ),\n",
|
|
||||||
" ),\n",
|
|
||||||
" (\n",
|
|
||||||
" r\"Is there (.*)\",\n",
|
|
||||||
" (\n",
|
|
||||||
" \"Do you think there is %1?\",\n",
|
|
||||||
" \"It's likely that there is %1.\",\n",
|
|
||||||
" \"Would you like there to be %1?\",\n",
|
|
||||||
" ),\n",
|
|
||||||
" ),\n",
|
|
||||||
" (\n",
|
|
||||||
" r\"My (.*)\",\n",
|
|
||||||
" (\n",
|
|
||||||
" \"I see, your %1.\",\n",
|
|
||||||
" \"Why do you say that your %1?\",\n",
|
|
||||||
" \"When your %1, how do you feel?\",\n",
|
|
||||||
" ),\n",
|
|
||||||
" ),\n",
|
|
||||||
" (\n",
|
|
||||||
" r\"You (.*)\",\n",
|
|
||||||
" (\n",
|
|
||||||
" \"We should be discussing you, not me.\",\n",
|
|
||||||
" \"Why do you say that about me?\",\n",
|
|
||||||
" \"Why do you care whether I %1?\",\n",
|
|
||||||
" ),\n",
|
|
||||||
" ),\n",
|
|
||||||
" (r\"Why (.*)\", (\"Why don't you tell me the reason why %1?\", \"Why do you think %1?\")),\n",
|
|
||||||
" (\n",
|
|
||||||
" r\"I want (.*)\",\n",
|
|
||||||
" (\n",
|
|
||||||
" \"What would it mean to you if you got %1?\",\n",
|
|
||||||
" \"Why do you want %1?\",\n",
|
|
||||||
" \"What would you do if you got %1?\",\n",
|
|
||||||
" \"If you got %1, then what would you do?\",\n",
|
|
||||||
" ),\n",
|
|
||||||
" ),\n",
|
|
||||||
" (\n",
|
|
||||||
" r\"(.*) mother(.*)\",\n",
|
|
||||||
" (\n",
|
|
||||||
" \"Tell me more about your mother.\",\n",
|
|
||||||
" \"What was your relationship with your mother like?\",\n",
|
|
||||||
" \"How do you feel about your mother?\",\n",
|
|
||||||
" \"How does this relate to your feelings today?\",\n",
|
|
||||||
" \"Good family relations are important.\",\n",
|
|
||||||
" ),\n",
|
|
||||||
" ),\n",
|
|
||||||
" (\n",
|
|
||||||
" r\"(.*) father(.*)\",\n",
|
|
||||||
" (\n",
|
|
||||||
" \"Tell me more about your father.\",\n",
|
|
||||||
" \"How did your father make you feel?\",\n",
|
|
||||||
" \"How do you feel about your father?\",\n",
|
|
||||||
" \"Does your relationship with your father relate to your feelings today?\",\n",
|
|
||||||
" \"Do you have trouble showing affection with your family?\",\n",
|
|
||||||
" ),\n",
|
|
||||||
" ),\n",
|
|
||||||
" (\n",
|
|
||||||
" r\"(.*) child(.*)\",\n",
|
|
||||||
" (\n",
|
|
||||||
" \"Did you have close friends as a child?\",\n",
|
|
||||||
" \"What is your favorite childhood memory?\",\n",
|
|
||||||
" \"Do you remember any dreams or nightmares from childhood?\",\n",
|
|
||||||
" \"Did the other children sometimes tease you?\",\n",
|
|
||||||
" \"How do you think your childhood experiences relate to your feelings today?\",\n",
|
|
||||||
" ),\n",
|
|
||||||
" ),\n",
|
|
||||||
" (\n",
|
|
||||||
" r\"(.*)\\?\",\n",
|
|
||||||
" (\n",
|
|
||||||
" \"Why do you ask that?\",\n",
|
|
||||||
" \"Please consider whether you can answer your own question.\",\n",
|
|
||||||
" \"Perhaps the answer lies within yourself?\",\n",
|
|
||||||
" \"Why don't you tell me?\",\n",
|
|
||||||
" ),\n",
|
|
||||||
" ),\n",
|
|
||||||
" (\n",
|
|
||||||
" r\"quit\",\n",
|
|
||||||
" (\n",
|
|
||||||
" \"Thank you for talking with me.\",\n",
|
|
||||||
" \"Good-bye.\",\n",
|
|
||||||
" \"Thank you, that will be $150. Have a good day!\",\n",
|
|
||||||
" ),\n",
|
|
||||||
" ),\n",
|
|
||||||
" (\n",
|
|
||||||
" r\"(.*)\",\n",
|
|
||||||
" (\n",
|
|
||||||
" \"Please tell me more.\",\n",
|
|
||||||
" \"Let's change focus a bit... Tell me about your family.\",\n",
|
|
||||||
" \"Can you elaborate on that?\",\n",
|
|
||||||
" \"Why do you say that %1?\",\n",
|
|
||||||
" \"I see.\",\n",
|
|
||||||
" \"Very interesting.\",\n",
|
|
||||||
" \"%1.\",\n",
|
|
||||||
" \"I see. And what does that tell you?\",\n",
|
|
||||||
" \"How does that make you feel?\",\n",
|
|
||||||
" \"How do you feel when you say that?\",\n",
|
|
||||||
" ),\n",
|
|
||||||
" ),\n",
|
|
||||||
")\n",
|
|
||||||
"\n",
|
|
||||||
"eliza_chatbot = Chat(pairs, reflections)\n",
|
|
||||||
"\n",
|
|
||||||
"\n",
|
|
||||||
"def eliza_chat():\n",
|
|
||||||
" print(\"Psychiatrist\\n---------\")\n",
|
|
||||||
" print(\"Talk to the program by typing in plain English, using normal upper-\")\n",
|
|
||||||
" print('and lower-case letters and punctuation. Enter \"quit\" when done.')\n",
|
|
||||||
" print(\"=\" * 72)\n",
|
|
||||||
" print(\"Hello. My name is Eliza.\\nHow are you feeling today?\")\n",
|
|
||||||
"\n",
|
|
||||||
" eliza_chatbot.converse()\n",
|
|
||||||
"\n",
|
|
||||||
"\n",
|
|
||||||
"def demo():\n",
|
|
||||||
" eliza_chat()\n",
|
|
||||||
"\n",
|
|
||||||
"\n",
|
|
||||||
"if __name__ == \"__main__\":\n",
|
|
||||||
" demo()"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": null,
|
|
||||||
"id": "8b790564-2e67-4f6a-8565-4c6eceeb3de3",
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"name": "stdout",
|
|
||||||
"output_type": "stream",
|
|
||||||
"text": [
|
|
||||||
"Psychiatrist\n",
|
|
||||||
"---------\n",
|
|
||||||
"Talk to the program by typing in plain English, using normal upper-\n",
|
|
||||||
"and lower-case letters and punctuation. Enter \"quit\" when done.\n",
|
|
||||||
"========================================================================\n",
|
|
||||||
"Hello. My name is Eliza.\n",
|
|
||||||
"How are you feeling today?\n"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "stdin",
|
|
||||||
"output_type": "stream",
|
|
||||||
"text": [
|
|
||||||
"> czy moge\n"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "stdout",
|
|
||||||
"output_type": "stream",
|
|
||||||
"text": [
|
|
||||||
"Please tell me more.\n"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "stdin",
|
|
||||||
"output_type": "stream",
|
|
||||||
"text": [
|
|
||||||
"> Czy moge\n"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "stdout",
|
|
||||||
"output_type": "stream",
|
|
||||||
"text": [
|
|
||||||
"Very interesting.\n"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "stdin",
|
|
||||||
"output_type": "stream",
|
|
||||||
"text": [
|
|
||||||
"> Czy mogę\n"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "stdout",
|
|
||||||
"output_type": "stream",
|
|
||||||
"text": [
|
|
||||||
"I see.\n"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "stdin",
|
|
||||||
"output_type": "stream",
|
|
||||||
"text": [
|
|
||||||
"> Czy mogę\n"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "stdout",
|
|
||||||
"output_type": "stream",
|
|
||||||
"text": [
|
|
||||||
"Please tell me more.\n"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "stdin",
|
|
||||||
"output_type": "stream",
|
|
||||||
"text": [
|
|
||||||
"> Czy mogę grać w płkę?\n"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "stdout",
|
|
||||||
"output_type": "stream",
|
|
||||||
"text": [
|
|
||||||
"Czy chcesz mieć możliwość grać w płkę?\n"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "stdin",
|
|
||||||
"output_type": "stream",
|
|
||||||
"text": [
|
|
||||||
"> Czy moge grać w lotki?\n"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "stdout",
|
|
||||||
"output_type": "stream",
|
|
||||||
"text": [
|
|
||||||
"Perhaps the answer lies within yourself?\n"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "stdin",
|
|
||||||
"output_type": "stream",
|
|
||||||
"text": [
|
|
||||||
"> Czy mogę grać w lotki\n"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "stdout",
|
|
||||||
"output_type": "stream",
|
|
||||||
"text": [
|
|
||||||
"Być może nie chcesz grać w lotki.\n"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"source": [
|
|
||||||
"demo()"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"metadata": {
|
|
||||||
"kernelspec": {
|
|
||||||
"display_name": "Python 3 (ipykernel)",
|
|
||||||
"language": "python",
|
|
||||||
"name": "python3"
|
|
||||||
},
|
|
||||||
"language_info": {
|
|
||||||
"codemirror_mode": {
|
|
||||||
"name": "ipython",
|
|
||||||
"version": 3
|
|
||||||
},
|
|
||||||
"file_extension": ".py",
|
|
||||||
"mimetype": "text/x-python",
|
|
||||||
"name": "python",
|
|
||||||
"nbconvert_exporter": "python",
|
|
||||||
"pygments_lexer": "ipython3",
|
|
||||||
"version": "3.9.7"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"nbformat": 4,
|
|
||||||
"nbformat_minor": 5
|
|
||||||
}
|
|
326
eliza.py
326
eliza.py
@ -1,326 +0,0 @@
|
|||||||
from nltk.chat.util import Chat, reflections
|
|
||||||
|
|
||||||
pairs = (
|
|
||||||
(
|
|
||||||
r"I need (.*)",
|
|
||||||
(
|
|
||||||
"Why do you need %1?",
|
|
||||||
"Would it really help you to get %1?",
|
|
||||||
"Are you sure you need %1?",
|
|
||||||
),
|
|
||||||
),
|
|
||||||
(
|
|
||||||
r"who created you (.*)",
|
|
||||||
(
|
|
||||||
"ELIZA was invented in 1966 by Weizenbaum. Why %1?",
|
|
||||||
|
|
||||||
),
|
|
||||||
),
|
|
||||||
(
|
|
||||||
r"Why don\'t you (.*)",
|
|
||||||
(
|
|
||||||
"Do you really think I don't %1?",
|
|
||||||
"Perhaps eventually I will %1.",
|
|
||||||
"Do you really want me to %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?",
|
|
||||||
),
|
|
||||||
),
|
|
||||||
(
|
|
||||||
r"I can\'t (.*)",
|
|
||||||
(
|
|
||||||
"How do you know you can't %1?",
|
|
||||||
"Perhaps you could %1 if you tried.",
|
|
||||||
"What would it take for you to %1?",
|
|
||||||
),
|
|
||||||
),
|
|
||||||
(
|
|
||||||
r"I am (.*)",
|
|
||||||
(
|
|
||||||
"Did you come to me because you are %1?",
|
|
||||||
"How long have you been %1?",
|
|
||||||
"How do you feel about being %1?",
|
|
||||||
),
|
|
||||||
),
|
|
||||||
(
|
|
||||||
r"I\'m (.*)",
|
|
||||||
(
|
|
||||||
"How does being %1 make you feel?",
|
|
||||||
"Do you enjoy being %1?",
|
|
||||||
"Why do you tell me you're %1?",
|
|
||||||
"Why do you think you're %1?",
|
|
||||||
),
|
|
||||||
),
|
|
||||||
(
|
|
||||||
r"Are you (.*)",
|
|
||||||
(
|
|
||||||
"Why does it matter whether I am %1?",
|
|
||||||
"Would you prefer it if I were not %1?",
|
|
||||||
"Perhaps you believe I am %1.",
|
|
||||||
"I may be %1 -- what do you think?",
|
|
||||||
),
|
|
||||||
),
|
|
||||||
(
|
|
||||||
r"What (.*)",
|
|
||||||
(
|
|
||||||
"Why do you ask?",
|
|
||||||
"How would an answer to that help you?",
|
|
||||||
"What do you think?",
|
|
||||||
),
|
|
||||||
),
|
|
||||||
(
|
|
||||||
r"How (.*)",
|
|
||||||
(
|
|
||||||
"How do you suppose?",
|
|
||||||
"Perhaps you can answer your own question.",
|
|
||||||
"What is it you're really asking?",
|
|
||||||
),
|
|
||||||
),
|
|
||||||
(
|
|
||||||
r"Because (.*)",
|
|
||||||
(
|
|
||||||
"Is that the real reason?",
|
|
||||||
"What other reasons come to mind?",
|
|
||||||
"Does that reason apply to anything else?",
|
|
||||||
"If %1, what else must be true?",
|
|
||||||
),
|
|
||||||
),
|
|
||||||
(
|
|
||||||
r"(.*) sorry (.*)",
|
|
||||||
(
|
|
||||||
"There are many times when no apology is needed.",
|
|
||||||
"What feelings do you have when you apologize?",
|
|
||||||
),
|
|
||||||
),
|
|
||||||
(
|
|
||||||
r"Hello(.*)",
|
|
||||||
(
|
|
||||||
"Hello... I'm glad you could drop by today.",
|
|
||||||
"Hi there... how are you today?",
|
|
||||||
"Hello, how are you feeling today?",
|
|
||||||
),
|
|
||||||
),
|
|
||||||
(
|
|
||||||
r"I think (.*)",
|
|
||||||
("Do you doubt %1?", "Do you really think so?", "But you're not sure %1?"),
|
|
||||||
),
|
|
||||||
(
|
|
||||||
r"(.*) friend (.*)",
|
|
||||||
(
|
|
||||||
"Tell me more about your friends.",
|
|
||||||
"When you think of a friend, what comes to mind?",
|
|
||||||
"Why don't you tell me about a childhood friend?",
|
|
||||||
),
|
|
||||||
),
|
|
||||||
(r"Yes", ("You seem quite sure.", "OK, but can you elaborate a bit?")),
|
|
||||||
(
|
|
||||||
r"(.*) computer(.*)",
|
|
||||||
(
|
|
||||||
"Are you really talking about me?",
|
|
||||||
"Does it seem strange to talk to a computer?",
|
|
||||||
"How do computers make you feel?",
|
|
||||||
"Do you feel threatened by computers?",
|
|
||||||
),
|
|
||||||
),
|
|
||||||
(
|
|
||||||
r"Is it (.*)",
|
|
||||||
(
|
|
||||||
"Do you think it is %1?",
|
|
||||||
"Perhaps it's %1 -- what do you think?",
|
|
||||||
"If it were %1, what would you do?",
|
|
||||||
"It could well be that %1.",
|
|
||||||
),
|
|
||||||
),
|
|
||||||
(
|
|
||||||
r"It is (.*)",
|
|
||||||
(
|
|
||||||
"You seem very certain.",
|
|
||||||
"If I told you that it probably isn't %1, what would you feel?",
|
|
||||||
),
|
|
||||||
),
|
|
||||||
(
|
|
||||||
r"Can you (.*)",
|
|
||||||
(
|
|
||||||
"What makes you think I can't %1?",
|
|
||||||
"If I could %1, then what?",
|
|
||||||
"Why do you ask if I can %1?",
|
|
||||||
),
|
|
||||||
),
|
|
||||||
(
|
|
||||||
r"Czy mogę (.*)",
|
|
||||||
(
|
|
||||||
"Być może nie chcesz %1.",
|
|
||||||
"Czy chcesz mieć możliwość %1?",
|
|
||||||
"Gdybyś mógł %1, czy byś?",
|
|
||||||
),
|
|
||||||
),
|
|
||||||
(
|
|
||||||
r"Ty jesteś (.*)",
|
|
||||||
(
|
|
||||||
"Jak myślisz, dlaczego jestem %1?",
|
|
||||||
"Czy cieszy cię myśl, że jestem %1?",
|
|
||||||
"Być może chciałbyś, żebym był %1.",
|
|
||||||
"Może naprawdę mówisz o sobie?",
|
|
||||||
),
|
|
||||||
),
|
|
||||||
(
|
|
||||||
r"Jesteś (.*)",
|
|
||||||
(
|
|
||||||
"Dlaczego mówisz, że jestem %1?",
|
|
||||||
"Jak myślisz, dlaczego jestem %1?",
|
|
||||||
"Mówimy o tobie, czy o mnie?",
|
|
||||||
),
|
|
||||||
),
|
|
||||||
(
|
|
||||||
r"Ja nie (.*)",
|
|
||||||
("Czy naprawdę nie %1?", "Dlaczego nie %1?", "Czy chcesz %1?"),
|
|
||||||
),
|
|
||||||
(
|
|
||||||
r"Ja czuję (.*)",
|
|
||||||
(
|
|
||||||
"Dobrze, powiedz mi więcej o tych uczuciach.",
|
|
||||||
"Czy często czujesz %1?",
|
|
||||||
"Kiedy zwykle czujesz %1?",
|
|
||||||
"Kiedy czujesz % 1, co robisz?",
|
|
||||||
),
|
|
||||||
),
|
|
||||||
(
|
|
||||||
r"Mam (.*)",
|
|
||||||
(
|
|
||||||
"Dlaczego mówisz mi, że masz %1?",
|
|
||||||
"Czy naprawdę masz %1?",
|
|
||||||
"Teraz, kiedy masz %1, co zrobisz dalej?",
|
|
||||||
),
|
|
||||||
),
|
|
||||||
(
|
|
||||||
r"Ja chcę (.*)",
|
|
||||||
(
|
|
||||||
"Czy możesz wyjaśnić, dlaczego chcesz %1?",
|
|
||||||
"Dlaczego %1?",
|
|
||||||
"Kto jeszcze wie, że chcesz %1?",
|
|
||||||
),
|
|
||||||
),
|
|
||||||
(
|
|
||||||
r"Jest (.*)",
|
|
||||||
(
|
|
||||||
"Myślisz, że jest %1?",
|
|
||||||
"Prawdopodobnie istnieje %1.",
|
|
||||||
"Czy chciałbyś, aby był %1?",
|
|
||||||
),
|
|
||||||
),
|
|
||||||
(
|
|
||||||
r"Mój (.*)",
|
|
||||||
(
|
|
||||||
"Rozumiem, twój %1.",
|
|
||||||
"Dlaczego mówisz, że twój %1?",
|
|
||||||
"Kiedy Twój %1, jak się czujesz?",
|
|
||||||
),
|
|
||||||
),
|
|
||||||
(
|
|
||||||
r"Ty (.*)",
|
|
||||||
(
|
|
||||||
"Powinniśmy rozmawiać o Tobie, nie o mnie.",
|
|
||||||
"Dlaczego tak o mnie mówisz?",
|
|
||||||
"Dlaczego obchodzi cię, czy ja %1?",
|
|
||||||
),
|
|
||||||
),
|
|
||||||
(r"Dlaczego (.*)", ("Powiedz mi dlaczego %1?", "Wydaje ci się że, %1?")),
|
|
||||||
(
|
|
||||||
r"Ja chcę (.*)",
|
|
||||||
(
|
|
||||||
"Co by dla ciebie znaczyło, gdybyś dostał %1?",
|
|
||||||
"Dlaczego chcesz %1?",
|
|
||||||
"Co byś zrobił, gdybyś dostał %1?",
|
|
||||||
"Jeśli masz %1, co byś zrobił?",
|
|
||||||
),
|
|
||||||
),
|
|
||||||
(
|
|
||||||
r"(.*) mother(.*)",
|
|
||||||
(
|
|
||||||
"Tell me more about your mother.",
|
|
||||||
"What was your relationship with your mother like?",
|
|
||||||
"How do you feel about your mother?",
|
|
||||||
"How does this relate to your feelings today?",
|
|
||||||
"Good family relations are important.",
|
|
||||||
),
|
|
||||||
),
|
|
||||||
(
|
|
||||||
r"(.*) father(.*)",
|
|
||||||
(
|
|
||||||
"Tell me more about your father.",
|
|
||||||
"How did your father make you feel?",
|
|
||||||
"How do you feel about your father?",
|
|
||||||
"Does your relationship with your father relate to your feelings today?",
|
|
||||||
"Do you have trouble showing affection with your family?",
|
|
||||||
),
|
|
||||||
),
|
|
||||||
(
|
|
||||||
r"(.*) child(.*)",
|
|
||||||
(
|
|
||||||
"Did you have close friends as a child?",
|
|
||||||
"What is your favorite childhood memory?",
|
|
||||||
"Do you remember any dreams or nightmares from childhood?",
|
|
||||||
"Did the other children sometimes tease you?",
|
|
||||||
"How do you think your childhood experiences relate to your feelings today?",
|
|
||||||
),
|
|
||||||
),
|
|
||||||
(
|
|
||||||
r"(.*)\?",
|
|
||||||
(
|
|
||||||
"Why do you ask that?",
|
|
||||||
"Please consider whether you can answer your own question.",
|
|
||||||
"Perhaps the answer lies within yourself?",
|
|
||||||
"Why don't you tell me?",
|
|
||||||
),
|
|
||||||
),
|
|
||||||
(
|
|
||||||
r"quit",
|
|
||||||
(
|
|
||||||
"Thank you for talking with me.",
|
|
||||||
"Good-bye.",
|
|
||||||
"Thank you, that will be $150. Have a good day!",
|
|
||||||
),
|
|
||||||
),
|
|
||||||
(
|
|
||||||
r"(.*)",
|
|
||||||
(
|
|
||||||
"Please tell me more.",
|
|
||||||
"Let's change focus a bit... Tell me about your family.",
|
|
||||||
"Can you elaborate on that?",
|
|
||||||
"Why do you say that %1?",
|
|
||||||
"I see.",
|
|
||||||
"Very interesting.",
|
|
||||||
"%1.",
|
|
||||||
"I see. And what does that tell you?",
|
|
||||||
"How does that make you feel?",
|
|
||||||
"How do you feel when you say that?",
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
|
|
||||||
eliza_chatbot = Chat(pairs, reflections)
|
|
||||||
|
|
||||||
|
|
||||||
def eliza_chat():
|
|
||||||
print("Psychiatrist\n---------")
|
|
||||||
print("Talk to the program by typing in plain English, using normal upper-")
|
|
||||||
print('and lower-case letters and punctuation. Enter "quit" when done.')
|
|
||||||
print("=" * 72)
|
|
||||||
print("Hello. My name is Eliza.\nHow are you feeling today?")
|
|
||||||
|
|
||||||
eliza_chatbot.converse()
|
|
||||||
|
|
||||||
|
|
||||||
def demo():
|
|
||||||
eliza_chat()
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
demo()
|
|
@ -11,6 +11,8 @@ reflections = {
|
|||||||
"mam": "masz",
|
"mam": "masz",
|
||||||
"będę": "będziesz",
|
"będę": "będziesz",
|
||||||
"moje": "twoje",
|
"moje": "twoje",
|
||||||
|
"mój": "twój",
|
||||||
|
"moja": "twoja",
|
||||||
"jesteś": "jestem",
|
"jesteś": "jestem",
|
||||||
"byłeś": "byłem",
|
"byłeś": "byłem",
|
||||||
"ty byłeś": "ja byłem",
|
"ty byłeś": "ja byłem",
|
||||||
@ -199,9 +201,9 @@ pairs = (
|
|||||||
r"Myśle, że (.*)",
|
r"Myśle, że (.*)",
|
||||||
(
|
(
|
||||||
"Czy wątpisz w %1?",
|
"Czy wątpisz w %1?",
|
||||||
"Naprawdę tak myślisz?",
|
"Naprawdę tak myślisz?",
|
||||||
"Ale nie jesteś pewien, że %1?"
|
"Ale nie jesteś pewien, że %1?"
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
r"(.*) przyjaciel (.*)",
|
r"(.*) przyjaciel (.*)",
|
||||||
@ -214,7 +216,8 @@ pairs = (
|
|||||||
(
|
(
|
||||||
r"Tak",
|
r"Tak",
|
||||||
(
|
(
|
||||||
"Wydajesz się całkiem pewien.", "OK, ale czy możesz trochę rozwinąć?"
|
"Wydajesz się całkiem pewien.",
|
||||||
|
"OK, ale czy możesz trochę rozwinąć?"
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
@ -285,7 +288,11 @@ pairs = (
|
|||||||
),
|
),
|
||||||
(
|
(
|
||||||
r"Ja nie (.*)",
|
r"Ja nie (.*)",
|
||||||
("Czy naprawdę nie %1?", "Dlaczego nie %1?", "Czy chcesz %1?"),
|
(
|
||||||
|
"Czy naprawdę nie %1?",
|
||||||
|
"Dlaczego nie %1?",
|
||||||
|
"Czy chcesz %1?"
|
||||||
|
),
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
r"Ja czuję (.*)",
|
r"Ja czuję (.*)",
|
||||||
@ -407,8 +414,8 @@ pairs = (
|
|||||||
"Dlaczego mówisz, że %1?",
|
"Dlaczego mówisz, że %1?",
|
||||||
"Rozumiem.",
|
"Rozumiem.",
|
||||||
"Bardzo interesujące.",
|
"Bardzo interesujące.",
|
||||||
"%1.",
|
"%1.Hmm, powiedz coś więcej",
|
||||||
"Rozumiem, a co ci to mówi?",
|
"Rozumiem, a co przez to rozumiesz?",
|
||||||
"Jak się z tym czujesz?",
|
"Jak się z tym czujesz?",
|
||||||
"Jak się czujesz, kiedy o tym mówisz?",
|
"Jak się czujesz, kiedy o tym mówisz?",
|
||||||
),
|
),
|
||||||
|
Loading…
Reference in New Issue
Block a user