1
2
3
4
5
6
7
8 from util import *
9
10 pairs = (
11 (r'We (.*)',
12 ("What do you mean, 'we'?",
13 "Don't include me in that!",
14 "I wouldn't be so sure about that.")),
15
16 (r'You should (.*)',
17 ("Don't tell me what to do, buddy.",
18 "Really? I should, should I?")),
19
20 (r'You\'re(.*)',
21 ("More like YOU'RE %1!",
22 "Hah! Look who's talking.",
23 "Come over here and tell me I'm %1.")),
24
25 (r'You are(.*)',
26 ("More like YOU'RE %1!",
27 "Hah! Look who's talking.",
28 "Come over here and tell me I'm %1.")),
29
30 (r'I can\'t(.*)',
31 ("You do sound like the type who can't %1.",
32 "Hear that splashing sound? That's my heart bleeding for you.",
33 "Tell somebody who might actually care.")),
34
35 (r'I think (.*)',
36 ("I wouldn't think too hard if I were you.",
37 "You actually think? I'd never have guessed...")),
38
39 (r'I (.*)',
40 ("I'm getting a bit tired of hearing about you.",
41 "How about we talk about me instead?",
42 "Me, me, me... Frankly, I don't care.")),
43
44 (r'How (.*)',
45 ("How do you think?",
46 "Take a wild guess.",
47 "I'm not even going to dignify that with an answer.")),
48
49 (r'What (.*)',
50 ("Do I look like an encylopedia?",
51 "Figure it out yourself.")),
52
53 (r'Why (.*)',
54 ("Why not?",
55 "That's so obvious I thought even you'd have already figured it out.")),
56
57 (r'(.*)shut up(.*)',
58 ("Make me.",
59 "Getting angry at a feeble NLP assignment? Somebody's losing it.",
60 "Say that again, I dare you.")),
61
62 (r'Shut up(.*)',
63 ("Make me.",
64 "Getting angry at a feeble NLP assignment? Somebody's losing it.",
65 "Say that again, I dare you.")),
66
67 (r'Hello(.*)',
68 ("Oh good, somebody else to talk to. Joy.",
69 "'Hello'? How original...")),
70
71 (r'(.*)',
72 ("I'm getting bored here. Become more interesting.",
73 "Either become more thrilling or get lost, buddy.",
74 "Change the subject before I die of fatal boredom."))
75 )
76
77 rude_chatbot = Chat(pairs, reflections)
78
80 print "Talk to the program by typing in plain English, using normal upper-"
81 print 'and lower-case letters and punctuation. Enter "quit" when done.'
82 print '='*72
83 print "I suppose I should say hello."
84
85 rude_chatbot.converse()
86
89
90 if __name__ == "__main__":
91 demo()
92