-
Notifications
You must be signed in to change notification settings - Fork 0
/
You Are Not Alone_Phrase Finder.py
180 lines (107 loc) · 2.93 KB
/
You Are Not Alone_Phrase Finder.py
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
#!/usr/bin/env python
# coding: utf-8
# # 'You are not alone' Phrase Finder 🔍
# My phrase_finder() function searches for a self-identifying phrase in each of the 4 large classic texts below.
# Standpoint: "So Matilda’s strong young mind continued to grow, nurtured by the voices of all those authors who had sent their books out into the world like ships on the sea. These books gave Matilda a hopeful and comforting message: You are not alone.” ~ from Matilda by Roald Dahl
# In[1036]:
source = open('408-0.txt', encoding= 'utf-8')
souls = source.read()
source.close()
print(souls[0:1000])
# In[1037]:
import re
# In[1301]:
souls_dict = re.findall(r'black woman', souls)
# In[1302]:
souls_dict
# In[1303]:
len(souls_dict)
# In[1304]:
phrase = ''.join(souls)
# In[1305]:
def phrase_finder(phrase):
if phrase in souls_dict:
result = 'You are a ' + phrase + '.'
return result
elif phrase not in souls_dict:
return 'Phrase not found, but you are not alone. 🤗'
# In[1306]:
phrase_finder('black woman')
# In[1307]:
phrase_finder('weary soul')
# In[1259]:
source = open('1260-0.txt', encoding= 'utf-8')
jane = source.read()
source.close()
print(jane[0:1000])
# In[1260]:
import re
# In[1378]:
jane_dict = re.findall(r'frantic bird', jane)
# In[1379]:
len(jane_dict)
# In[1370]:
jane_dict
# In[1371]:
phrase = ''.join(jane)
# In[1372]:
def phrase_finder(phrase):
if phrase in jane_dict:
result = 'You are a ' + phrase + '.'
return result
elif phrase not in jane_dict:
return 'Phrase not found, but you are not alone. 🤗'
# In[1375]:
phrase_finder('frantic bird')
# In[1380]:
phrase_finder('rare jewel')
# In[1381]:
source = open('43-0.txt', encoding= 'utf-8')
jekyll = source.read()
source.close()
print(jekyll[0:1000])
# In[1382]:
import re
# In[1396]:
jekyll_dict = re.findall(r'beloved daydream', jekyll)
# In[1397]:
len(jekyll_dict)
# In[1398]:
jekyll_dict
# In[1399]:
phrase = ''.join(jekyll)
# In[1400]:
def phrase_finder(phrase):
if phrase in jekyll_dict:
result = 'You are a ' + phrase + '.'
return result
elif phrase not in frankenstein_dict:
return 'Phrase not found, but you are not alone. 🤗'
# In[1401]:
phrase_finder('beloved daydream')
# In[1402]:
phrase_finder('weirdo')
# In[1403]:
source = open('84-0.txt', encoding= 'utf-8')
frankenstein = source.read()
source.close()
print(frankenstein[0:1000])
# In[1404]:
import re
# In[1426]:
frankenstein_dict = re.findall(r'fallen angel', frankenstein)
# In[1427]:
len(frankenstein_dict)
# In[1428]:
phrase = ''.join(frankenstein)
# In[1429]:
def phrase_finder(phrase):
if phrase in frankenstein_dict:
result = 'You are a ' + phrase + '.'
return result
elif phrase not in frankenstein_dict:
return 'Phrase not found, but you are not alone. 🤗'
# In[1430]:
phrase_finder('fallen angel')
# In[1432]:
phrase_finder('secret wonder')