Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,212 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import random
|
3 |
+
import time
|
4 |
+
from datetime import datetime, timezone, timedelta
|
5 |
+
|
6 |
+
# Dictionary of similes and metaphors with numbering
|
7 |
+
books = {
|
8 |
+
"A Dictionary of Similes by Frank J. Wilstach": [
|
9 |
+
"1. As strong as an ox.",
|
10 |
+
"2. As proud as a peacock.",
|
11 |
+
"3. As gentle as a lamb.",
|
12 |
+
"4. As wise as an owl.",
|
13 |
+
"5. As brave as a lion.",
|
14 |
+
"6. As cunning as a fox.",
|
15 |
+
"7. As quiet as a mouse.",
|
16 |
+
"8. As happy as a lark.",
|
17 |
+
"9. As swift as a deer.",
|
18 |
+
"10. As sly as a fox.",
|
19 |
+
"11. As firm as a rock.",
|
20 |
+
"12. As light as air.",
|
21 |
+
"13. As soft as silk.",
|
22 |
+
"14. As hard as nails.",
|
23 |
+
"15. As deep as the ocean.",
|
24 |
+
"16. As warm as toast.",
|
25 |
+
"17. As cold as ice.",
|
26 |
+
"18. As fresh as a daisy.",
|
27 |
+
"19. As dark as night.",
|
28 |
+
"20. As bright as the sun."
|
29 |
+
],
|
30 |
+
"The Penguin Dictionary of Similes by Michael Fergusson": [
|
31 |
+
"21. As brave as a lion.",
|
32 |
+
"22. As cool as a cucumber.",
|
33 |
+
"23. As fit as a fiddle.",
|
34 |
+
"24. As gentle as a lamb.",
|
35 |
+
"25. As happy as a clam.",
|
36 |
+
"26. As light as a feather.",
|
37 |
+
"27. As old as the hills.",
|
38 |
+
"28. As right as rain.",
|
39 |
+
"29. As sharp as a tack.",
|
40 |
+
"30. As sick as a dog.",
|
41 |
+
"31. As silent as the grave.",
|
42 |
+
"32. As smooth as silk.",
|
43 |
+
"33. As snug as a bug in a rug.",
|
44 |
+
"34. As soft as velvet.",
|
45 |
+
"35. As stubborn as a mule.",
|
46 |
+
"36. As sure as death and taxes.",
|
47 |
+
"37. As sweet as honey.",
|
48 |
+
"38. As tough as nails."
|
49 |
+
],
|
50 |
+
"The Oxford Dictionary of Allusions by Andrew Delahunty and Sheila Dignen": [
|
51 |
+
"39. As dead as a dodo.",
|
52 |
+
"40. As easy as pie.",
|
53 |
+
"41. As free as a bird.",
|
54 |
+
"42. As hungry as a wolf.",
|
55 |
+
"43. As large as life.",
|
56 |
+
"44. As mad as a hatter.",
|
57 |
+
"45. As nutty as a fruitcake.",
|
58 |
+
"46. As plain as the nose on your face.",
|
59 |
+
"47. As quick as a wink.",
|
60 |
+
"48. As safe as houses.",
|
61 |
+
"49. As sound as a bell.",
|
62 |
+
"50. As steady as a rock.",
|
63 |
+
"51. As thick as thieves.",
|
64 |
+
"52. As tight as a drum.",
|
65 |
+
"53. As tough as old boots.",
|
66 |
+
"54. As true as steel.",
|
67 |
+
"55. As weak as a kitten.",
|
68 |
+
"56. As wise as Solomon."
|
69 |
+
],
|
70 |
+
"The Bloomsbury Dictionary of Idioms by Gordon Jarvie": [
|
71 |
+
"57. As drunk as a lord.",
|
72 |
+
"58. As flat as a pancake.",
|
73 |
+
"59. As keen as mustard.",
|
74 |
+
"60. As neat as a pin.",
|
75 |
+
"61. As pleased as punch."
|
76 |
+
],
|
77 |
+
"The American Heritage Dictionary of Idioms by Christine Ammer": [
|
78 |
+
"62. As drunk as a skunk.",
|
79 |
+
"63. As plain as day."
|
80 |
+
],
|
81 |
+
"Webster's New World Dictionary of Similes by Gail Weiss": [
|
82 |
+
"64. As pale as a ghost.",
|
83 |
+
"65. As busy as a bee.",
|
84 |
+
"66. As bold as brass.",
|
85 |
+
"67. As clear as crystal.",
|
86 |
+
"68. As good as gold.",
|
87 |
+
"69. As hot as hell.",
|
88 |
+
"70. As mad as a hornet.",
|
89 |
+
"71. As snug as a bug.",
|
90 |
+
"72. As tall as a tree.",
|
91 |
+
"73. As tough as leather."
|
92 |
+
],
|
93 |
+
"The Hutchinson Dictionary of Difficult Words by Terry O'Brien": [
|
94 |
+
"74. As black as coal.",
|
95 |
+
"75. As blind as a bat.",
|
96 |
+
"76. As bright as a button.",
|
97 |
+
"77. As clean as a whistle.",
|
98 |
+
"78. As dry as a bone.",
|
99 |
+
"79. As dull as dishwater."
|
100 |
+
],
|
101 |
+
"The Wordsworth Dictionary of Phrase and Fable by Ebenezer Cobham Brewer": [],
|
102 |
+
"The Macmillan Dictionary of Quotations by John Daintith and Amanda Isaacs": [
|
103 |
+
"80. As cold as charity.",
|
104 |
+
"81. As common as muck.",
|
105 |
+
"82. As cute as a button.",
|
106 |
+
"83. As easy as falling off a log.",
|
107 |
+
"84. As fast as lightning.",
|
108 |
+
"85. As hungry as a bear.",
|
109 |
+
"86. As mad as a hornet."
|
110 |
+
],
|
111 |
+
"The Chambers Dictionary of Idioms by Elizabeth McLaren Kirkpatrick": [
|
112 |
+
"87. As brown as a berry.",
|
113 |
+
"88. As dead as a doornail."
|
114 |
+
],
|
115 |
+
"The Routledge Dictionary of Modern American Slang and Unconventional English by Tom Dalzell": [
|
116 |
+
"89. As happy as a clam at high tide."
|
117 |
+
],
|
118 |
+
"The Faber Dictionary of Euphemisms by R. W. Holder": [
|
119 |
+
"90. As thin as a rake.",
|
120 |
+
"91. As black as pitch."
|
121 |
+
],
|
122 |
+
"The BBI Combinatory Dictionary of English: A Guide to Word Combinations by Morton Benson, Evelyn Benson, and Robert Ilson": [
|
123 |
+
"92. As easy as ABC.",
|
124 |
+
"93. As dry as dust.",
|
125 |
+
"94. As fresh as paint.",
|
126 |
+
"95. As happy as a sandboy."
|
127 |
+
],
|
128 |
+
"The Chambers Thesaurus by Chambers Harrap Publishers Ltd.": [
|
129 |
+
"96. As sly as a fox.",
|
130 |
+
"97. As large as life."
|
131 |
+
],
|
132 |
+
"The McGraw-Hill Dictionary of American Idioms and Phrasal Verbs by Richard A. Spears": [
|
133 |
+
"98. As white as snow.",
|
134 |
+
"99. As plain as the nose on your face."
|
135 |
+
],
|
136 |
+
"The Wordsworth Thesaurus by Wordsworth Editions Ltd.": [],
|
137 |
+
"The Oxford Dictionary of Idioms by Judith Siefring": [],
|
138 |
+
"The Penguin Thesaurus by Rosalind Fergusson": [
|
139 |
+
"100. As plain as the nose on your face."
|
140 |
+
],
|
141 |
+
"The Longman Dictionary of Contemporary English by Pearson Longman": [
|
142 |
+
"101. As quick as a wink."
|
143 |
+
],
|
144 |
+
"The American Heritage Thesaurus by Editors of the American Heritage Dictionaries": []
|
145 |
+
}
|
146 |
+
|
147 |
+
# Streamlit interface
|
148 |
+
st.title("Similes and Metaphors Compendium")
|
149 |
+
|
150 |
+
# Sidebar for control settings
|
151 |
+
st.sidebar.title("Controls")
|
152 |
+
if st.sidebar.button("Start Timer"):
|
153 |
+
start_time = time.time()
|
154 |
+
timer_active = True
|
155 |
+
else:
|
156 |
+
timer_active = False
|
157 |
+
|
158 |
+
# Function to display current Central Time
|
159 |
+
def get_central_time():
|
160 |
+
utc_now = datetime.now(timezone.utc)
|
161 |
+
central_now = utc_now.astimezone(timezone(timedelta(hours=-6)))
|
162 |
+
return central_now.strftime("%H:%M:%S")
|
163 |
+
|
164 |
+
# Timer and current time display
|
165 |
+
if timer_active:
|
166 |
+
elapsed_time = int(time.time() - start_time)
|
167 |
+
st.sidebar.write(f"Timer: {elapsed_time} seconds")
|
168 |
+
st.sidebar.write(f"Current Central Time: {get_central_time()}")
|
169 |
+
|
170 |
+
# Tabs for organization
|
171 |
+
tab1, tab2 = st.tabs(["Randomizer", "Book List"])
|
172 |
+
|
173 |
+
with tab1:
|
174 |
+
# Randomizer user interface
|
175 |
+
if st.button("Randomize"):
|
176 |
+
random_book = random.choice(list(books.keys()))
|
177 |
+
random_simile = random.choice(books[random_book])
|
178 |
+
st.header(random_book)
|
179 |
+
st.write("Randomly selected simile:")
|
180 |
+
|
181 |
+
# Animate the display of the simile
|
182 |
+
simile_lines = random_simile.split()
|
183 |
+
current_line = 0
|
184 |
+
display_lines = [""] * 5 # Initialize display lines
|
185 |
+
|
186 |
+
for _ in range(len(simile_lines) + 5):
|
187 |
+
display_lines = display_lines[1:] + [" ".join(simile_lines[:current_line])]
|
188 |
+
simile_display = "\n".join([
|
189 |
+
f"##### {line}" if i == 2 else f"###### {line}"
|
190 |
+
for i, line in enumerate(display_lines)
|
191 |
+
])
|
192 |
+
st.markdown(simile_display)
|
193 |
+
current_line = min(current_line + 1, len(simile_lines))
|
194 |
+
time.sleep(0.2)
|
195 |
+
|
196 |
+
# Display additional examples from the selected book
|
197 |
+
st.write("Additional Examples:")
|
198 |
+
for sample in books[random_book]:
|
199 |
+
if sample != random_simile:
|
200 |
+
st.write(f"- {sample}")
|
201 |
+
|
202 |
+
with tab2:
|
203 |
+
# Display all books and their sample similes
|
204 |
+
for book, samples in books.items():
|
205 |
+
st.header(book)
|
206 |
+
if samples:
|
207 |
+
st.write(f"Sample: {samples[0]}")
|
208 |
+
st.write("Additional Examples:")
|
209 |
+
for sample in samples[1:]:
|
210 |
+
st.write(f"- {sample}")
|
211 |
+
else:
|
212 |
+
st.write("No similes or metaphors available for this book.")
|