-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexamples.py
More file actions
62 lines (55 loc) · 2.12 KB
/
examples.py
File metadata and controls
62 lines (55 loc) · 2.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
from markov import *
import os
###I am aware that this is awful code, but I wanted to get examples up and running very quicklyy
def load_trump():
f = open('example_text'+os.sep+'trump.txt')
text = map(lambda x: x.rstrip(), f.readlines())
f.close()
text = filter(lambda x: not 'APPLAUSE' in x, text)
text = filter(lambda x: not x.startswith('AUDIENCE'), text)
text = map(lambda x: x.replace('TRUMP: ', ''), text)
text = map(lambda x: x.replace("\"", ''), text)
text = filter(lambda x: x != '', text)
return tokenize('\n'.join(text))
def load_cruz():
f = open('example_text'+os.sep+'cruz.txt')
text = map(lambda x: x.rstrip(), f.readlines())
f.close()
text = filter(lambda x: not 'APPLAUSE' in x, text)
text = filter(lambda x: not x.startswith('AUDIENCE'), text)
text = map(lambda x: x.replace('CRUZ: ', ''), text)
text = map(lambda x: x.replace("\"", ''), text)
text = filter(lambda x: x != '', text)
return tokenize('\n'.join(text))
def load_huckabee():
f = open('example_text'+os.sep+'huckabee.txt')
text = map(lambda x: x.rstrip(), f.readlines())
f.close()
text = filter(lambda x: not 'APPLAUSE' in x, text)
text = filter(lambda x: not x.startswith('AUDIENCE'), text)
text = map(lambda x: x.replace("\"", ''), text)
text = filter(lambda x: x != '', text)
return tokenize('\n'.join(text))
def load_clinton():
f = open('example_text'+os.sep+'clinton.txt')
text = map(lambda x: x.rstrip(), f.readlines())
f.close()
text = filter(lambda x: not 'APPLAUSE' in x, text)
text = filter(lambda x: not x.startswith('AUDIENCE'), text)
text = map(lambda x: x.replace("\"", ''), text)
text = filter(lambda x: x != '', text)
return tokenize('\n'.join(text))
if __name__ == '__main__':
cruz = load_cruz()
trump = load_trump()
huckabee = load_huckabee()
clinton = load_clinton()
print
print "Ted Cruz: ", gen_sentence(cruz)
print
print "Donald Trump: ", gen_sentence(trump)
print
print "Mike Huckabee: ", gen_sentence(huckabee)
print
print "Hillary Clinton: ", gen_sentence(clinton)
print