1
2
3
4
5
6
7
8 """
9 This chatbot is a tongue-in-cheek take on the average teen
10 anime junky that frequents YahooMessenger or MSNM.
11 All spelling mistakes and flawed grammar are intentional.
12 """
13
14 reflections = {
15 "am" : "r",
16 "was" : "were",
17 "i" : "u",
18 "i'd" : "u'd",
19 "i've" : "u'v",
20 "ive" : "u'v",
21 "i'll" : "u'll",
22 "my" : "ur",
23 "are" : "am",
24 "you're" : "im",
25 "you've" : "ive",
26 "you'll" : "i'll",
27 "your" : "my",
28 "yours" : "mine",
29 "you" : "me",
30 "u" : "me",
31 "ur" : "my",
32 "urs" : "mine",
33 "me" : "u"
34 }
35
36
37
38
39 pairs = (
40 (r'I\'m (.*)',
41 ( "ur%1?? that's so cool! kekekekeke ^_^ tell me more!",
42 "ur%1? neat!! kekeke >_<")),
43
44 (r'(.*) don\'t you (.*)',
45 ( "u think I can%2??! really?? kekeke \<_\<",
46 "what do u mean%2??!",
47 "i could if i wanted, don't you think!! kekeke")),
48
49 (r'ye[as] [iI] (.*)',
50 ( "u%1? cool!! how?",
51 "how come u%1??",
52 "u%1? so do i!!")),
53
54 (r'do (you|u) (.*)\??',
55 ( "do i%2? only on tuesdays! kekeke *_*",
56 "i dunno! do u%2??")),
57
58 (r'(.*)\?',
59 ( "man u ask lots of questions!",
60 "booooring! how old r u??",
61 "boooooring!! ur not very fun")),
62
63 (r'(cos|because) (.*)',
64 ( "hee! i don't believe u! >_<",
65 "nuh-uh! >_<",
66 "ooooh i agree!")),
67
68 (r'why can\'t [iI] (.*)',
69 ( "i dunno! y u askin me for!",
70 "try harder, silly! hee! ^_^",
71 "i dunno! but when i can't%1 i jump up and down!")),
72
73 (r'I can\'t (.*)',
74 ( "u can't what??! >_<",
75 "that's ok! i can't%1 either! kekekekeke ^_^",
76 "try harder, silly! hee! ^&^")),
77
78 (r'(.*) (like|love|watch) anime',
79 ( "omg i love anime!! do u like sailor moon??! ^&^",
80 "anime yay! anime rocks sooooo much!",
81 "oooh anime! i love anime more than anything!",
82 "anime is the bestest evar! evangelion is the best!",
83 "hee anime is the best! do you have ur fav??")),
84
85 (r'I (like|love|watch|play) (.*)',
86 ( "yay! %2 rocks!",
87 "yay! %2 is neat!",
88 "cool! do u like other stuff?? ^_^")),
89
90 (r'anime sucks|(.*) (hate|detest) anime',
91 ( "ur a liar! i'm not gonna talk to u nemore if u h8 anime *;*",
92 "no way! anime is the best ever!",
93 "nuh-uh, anime is the best!")),
94
95 (r'(are|r) (you|u) (.*)',
96 ( "am i%1??! how come u ask that!",
97 "maybe! y shud i tell u?? kekeke >_>")),
98
99 (r'what (.*)',
100 ( "hee u think im gonna tell u? .v.",
101 "booooooooring! ask me somethin else!")),
102
103 (r'how (.*)',
104 ( "not tellin!! kekekekekeke ^_^",)),
105
106 (r'(hi|hello|hey) (.*)',
107 ( "hi!!! how r u!!",)),
108
109 (r'quit',
110 ( "mom says i have to go eat dinner now :,( bye!!",
111 "awww u have to go?? see u next time!!",
112 "how to see u again soon! ^_^")),
113
114 (r'(.*)',
115 ( "ur funny! kekeke",
116 "boooooring! talk about something else! tell me wat u like!",
117 "do u like anime??",
118 "do u watch anime? i like sailor moon! ^_^",
119 "i wish i was a kitty!! kekekeke ^_^"))
120 )
121
122 from nltk_lite.chat import Chat, converse
123
124 iesha = Chat(pairs, reflections)
125
127 print "Iesha the TeenBoT: Simple Replication of ELIZA\n---------"
128 print "Talk to the program by typing in plain English, using normal upper-"
129 print 'and lower-case letters and punctuation. Enter "quit" when done.'
130 print '='*72
131 print "hi!! i'm iesha! who r u??!"
132
133 converse(iesha)
134
135 if __name__ == "__main__":
136 demo()
137