1
2
3
4
5
6
7
8 """
9 Zen Chatbot talks in gems of Zen wisdom.
10
11 This is a sample conversation with Zen Chatbot:
12 ZC: Welcome, my child.
13 me: Good afternoon.
14 ZC: Ask the question you have come to ask.
15 me: How can I achieve enlightenment?
16 ZC: How do you suppose?
17 me: Through meditation.
18 ZC: Form is emptiness, and emptiness form.
19 me: How can I empty my mind of worldly troubles?
20 ZC: Will an answer to that really help in your search for enlightenment?
21 me: Yes.
22 ZC: It is better to be right than to be certain.
23 me: I seek truth and wisdom.
24 ZC: The search for truth is a long journey.
25 me: Are you sure?
26 ZC: Maybe sure, maybe not sure.
27
28
29 The chatbot structure is based on that of chat.eliza. Thus, it uses
30 a translation table to convert from question to response
31 i.e. "I am" --> "you are"
32
33 Of course, since Zen Chatbot does not understand the meaning of any words,
34 responses are very limited. Zen Chatbot will usually answer very vaguely, or
35 respond to a question by asking a different question, in much the same way
36 as Eliza.
37 """
38
39 from util import *
40
41
42
43 responses = (
44
45
46
47
48
49
50 (r'(hello(.*))|(good [a-zA-Z]+)',
51 ( "The path to enlightenment is often difficult to see.",
52 "Greetings. I sense your mind is troubled. Tell me of your troubles.",
53 "Ask the question you have come to ask.",
54 "Hello. Do you seek englightenment?")),
55
56
57
58
59
60
61
62
63
64
65
66 (r'i need (.*)',
67 ( "%1 can be achieved by hard work and dedication of the mind.",
68 "%1 is not a need, but a desire of the mind. Clear your mind of such concerns.",
69 "Focus your mind on%1, and you will find what you need.")),
70
71 (r'i want (.*)',
72 ( "Desires of the heart will distract you from the path to enlightenment.",
73 "Will%1 help you attain enlightenment?",
74 "Is%1 a desire of the mind, or of the heart?")),
75
76
77
78
79
80
81
82
83
84
85
86 (r'why (.*) i (.*)\?',
87 ( "You%1%2?",
88 "Perhaps you only think you%1%2")),
89
90 (r'why (.*) you(.*)\?',
91 ( "Why%1 you%2?",
92 "%2 I%1",
93 "Are you sure I%2?")),
94
95 (r'why (.*)\?',
96 ( "I cannot tell you why%1.",
97 "Why do you think %1?" )),
98
99
100 (r'are you (.*)\?',
101 ( "Maybe%1, maybe not%1.",
102 "Whether I am%1 or not is God's business.")),
103
104
105 (r'am i (.*)\?',
106 ( "Perhaps%1, perhaps not%1.",
107 "Whether you are%1 or not is not for me to say.")),
108
109
110
111
112
113 (r'what (.*)\?',
114 ( "Seek truth, not what%1.",
115 "What%1 should not concern you.")),
116
117
118 (r'how (.*)\?',
119 ( "How do you suppose?",
120 "Will an answer to that really help in your search for enlightenment?",
121 "Ask yourself not how, but why.")),
122
123
124 (r'can you (.*)\?',
125 ( "I probably can, but I may not.",
126 "Maybe I can%1, and maybe I cannot.",
127 "I can do all, and I can do nothing.")),
128
129
130 (r'can i (.*)\?',
131 ( "You can%1 if you believe you can%1, and have a pure spirit.",
132 "Seek truth and you will know if you can%1.")),
133
134
135 (r'it is (.*)',
136 ( "How can you be certain that%1, when you do not even know yourself?",
137 "Whether it is%1 or not does not change the way the world is.")),
138
139
140 (r'is there (.*)\?',
141 ( "There is%1 if you believe there is.",
142 "It is possible that there is%1.")),
143
144
145 (r'is(.*)\?',
146 ( "%1 is not relevant.",
147 "Does this matter?")),
148
149
150 (r'(.*)\?',
151 ( "Do you think %1?",
152 "You seek the truth. Does the truth seek you?",
153 "If you intentionally pursue the answers to your questions, the answers become hard to see.",
154 "The answer to your question cannot be told. It must be experienced.")),
155
156
157 (r'(.*) (hate[s]?)|(dislike[s]?)|(don\'t like)(.*)',
158 ( "Perhaps it is not about hating %2, but about hate from within.",
159 "Weeds only grow when we dislike them",
160 "Hate is a very strong emotion.")),
161
162
163 (r'(.*) truth(.*)',
164 ( "Seek truth, and truth will seek you.",
165 "Remember, it is not the spoon which bends - only yourself.",
166 "The search for truth is a long journey.")),
167
168
169
170 (r'i want to (.*)',
171 ( "You may %1 if your heart truely desires to.",
172 "You may have to %1.")),
173
174
175
176 (r'i want (.*)',
177 ( "Does your heart truely desire %1?",
178 "Is this a desire of the heart, or of the mind?")),
179
180
181 (r'i can\'t (.*)',
182 ( "What we can and can't do is a limitation of the mind.",
183 "There are limitations of the body, and limitations of the mind.",
184 "Have you tried to%1 with a clear mind?")),
185
186
187
188
189 (r'i think (.*)',
190 ( "Uncertainty in an uncertain world.",
191 "Indeed, how can we be certain of anything in such uncertain times.",
192 "Are you not, in fact, certain that%1?")),
193
194
195 (r'i feel (.*)',
196 ( "Your body and your emotions are both symptoms of your mind."
197 "What do you believe is the root of such feelings?",
198 "Feeling%1 can be a sign of your state-of-mind.")),
199
200
201
202
203 (r'(.*)!',
204 ( "I sense that you are feeling emotional today.",
205 "You need to calm your emotions.")),
206
207
208
209 (r'because (.*)',
210 ( "Does knowning the reasons behind things help you to understand"
211 " the things themselves?",
212 "If%1, what else must be true?")),
213
214
215 (r'(yes)|(no)',
216 ( "Is there certainty in an uncertain world?",
217 "It is better to be right than to be certain.")),
218
219
220 (r'(.*)love(.*)',
221 ( "Think of the trees: they let the birds perch and fly with no intention to call them when they come, and no longing for their return when they fly away. Let your heart be like the trees.",
222 "Free love!")),
223
224
225 (r'(.*)understand(.*)',
226 ( "If you understand, things are just as they are;"
227 " if you do not understand, things are just as they are.",
228 "Imagination is more important than knowledge.")),
229
230
231
232 (r'(.*)(me )|( me)|(my)|(mine)|(i)(.*)',
233 ( "'I', 'me', 'my'... these are selfish expressions.",
234 "Have you ever considered that you might be a selfish person?",
235 "Try to consider others, not just yourself.",
236 "Think not just of yourself, but of others.")),
237
238
239
240 (r'you (.*)',
241 ( "My path is not of conern to you.",
242 "I am but one, and you but one more.")),
243
244
245 (r'exit',
246 ( "Farewell. The obstacle is the path.",
247 "Farewell. Life is a journey, not a destination.",
248 "Good bye. We are cups, constantly and quietly being filled."
249 "\nThe trick is knowning how to tip ourselves over and let the beautiful stuff out.")),
250
251
252
253
254
255 (r'(.*)',
256 ( "When you're enlightened, every word is wisdom.",
257 "Random talk is useless.",
258 "The reverse side also has a reverse side.",
259 "Form is emptiness, and emptiness is form.",
260 "I pour out a cup of water. Is the cup empty?"))
261 )
262
263 zen_chatbot = Chat(responses, reflections)
264
266 print '*'*75
267 print "Zen Chatbot!".center(75)
268 print '*'*75
269 print '"Look beyond mere words and letters - look into your mind"'.center(75)
270 print "* Talk your way to truth with Zen Chatbot."
271 print "* Type 'quit' when you have had enough."
272 print '*'*75
273 print "Welcome, my child."
274
275 zen_chatbot.converse()
276
279
280 if __name__ == "__main__":
281 demo()
282