Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,150 +1,7 @@
|
|
1 |
import streamlit as st
|
2 |
import random
|
3 |
import time
|
4 |
-
import streamlit as st
|
5 |
-
import random
|
6 |
-
import time
|
7 |
import os
|
8 |
-
books = {
|
9 |
-
"A Dictionary of Similes by Frank J. Wilstach": [
|
10 |
-
"1. As strong as an ox.",
|
11 |
-
"2. As proud as a peacock.",
|
12 |
-
"3. As gentle as a lamb.",
|
13 |
-
"4. As wise as an owl.",
|
14 |
-
"5. As brave as a lion.",
|
15 |
-
"6. As cunning as a fox.",
|
16 |
-
"7. As quiet as a mouse.",
|
17 |
-
"8. As happy as a lark.",
|
18 |
-
"9. As swift as a deer.",
|
19 |
-
"10. As sly as a fox.",
|
20 |
-
"11. As firm as a rock.",
|
21 |
-
"12. As light as air.",
|
22 |
-
"13. As soft as silk.",
|
23 |
-
"14. As hard as nails.",
|
24 |
-
"15. As deep as the ocean.",
|
25 |
-
"16. As warm as toast.",
|
26 |
-
"17. As cold as ice.",
|
27 |
-
"18. As fresh as a daisy.",
|
28 |
-
"19. As dark as night.",
|
29 |
-
"20. As bright as the sun."
|
30 |
-
],
|
31 |
-
"The Penguin Dictionary of Similes by Michael Fergusson": [
|
32 |
-
"21. As brave as a lion.",
|
33 |
-
"22. As cool as a cucumber.",
|
34 |
-
"23. As fit as a fiddle.",
|
35 |
-
"24. As gentle as a lamb.",
|
36 |
-
"25. As happy as a clam.",
|
37 |
-
"26. As light as a feather.",
|
38 |
-
"27. As old as the hills.",
|
39 |
-
"28. As right as rain.",
|
40 |
-
"29. As sharp as a tack.",
|
41 |
-
"30. As sick as a dog.",
|
42 |
-
"31. As silent as the grave.",
|
43 |
-
"32. As smooth as silk.",
|
44 |
-
"33. As snug as a bug in a rug.",
|
45 |
-
"34. As soft as velvet.",
|
46 |
-
"35. As stubborn as a mule.",
|
47 |
-
"36. As sure as death and taxes.",
|
48 |
-
"37. As sweet as honey.",
|
49 |
-
"38. As tough as nails."
|
50 |
-
],
|
51 |
-
"The Oxford Dictionary of Allusions by Andrew Delahunty and Sheila Dignen": [
|
52 |
-
"39. As dead as a dodo.",
|
53 |
-
"40. As easy as pie.",
|
54 |
-
"41. As free as a bird.",
|
55 |
-
"42. As hungry as a wolf.",
|
56 |
-
"43. As large as life.",
|
57 |
-
"44. As mad as a hatter.",
|
58 |
-
"45. As nutty as a fruitcake.",
|
59 |
-
"46. As plain as the nose on your face.",
|
60 |
-
"47. As quick as a wink.",
|
61 |
-
"48. As safe as houses.",
|
62 |
-
"49. As sound as a bell.",
|
63 |
-
"50. As steady as a rock.",
|
64 |
-
"51. As thick as thieves.",
|
65 |
-
"52. As tight as a drum.",
|
66 |
-
"53. As tough as old boots.",
|
67 |
-
"54. As true as steel.",
|
68 |
-
"55. As weak as a kitten.",
|
69 |
-
"56. As wise as Solomon."
|
70 |
-
],
|
71 |
-
"The Bloomsbury Dictionary of Idioms by Gordon Jarvie": [
|
72 |
-
"57. As drunk as a lord.",
|
73 |
-
"58. As flat as a pancake.",
|
74 |
-
"59. As keen as mustard.",
|
75 |
-
"60. As neat as a pin.",
|
76 |
-
"61. As pleased as punch."
|
77 |
-
],
|
78 |
-
"The American Heritage Dictionary of Idioms by Christine Ammer": [
|
79 |
-
"62. As drunk as a skunk.",
|
80 |
-
"63. As plain as day."
|
81 |
-
],
|
82 |
-
"Webster's New World Dictionary of Similes by Gail Weiss": [
|
83 |
-
"64. As pale as a ghost.",
|
84 |
-
"65. As busy as a bee.",
|
85 |
-
"66. As bold as brass.",
|
86 |
-
"67. As clear as crystal.",
|
87 |
-
"68. As good as gold.",
|
88 |
-
"69. As hot as hell.",
|
89 |
-
"70. As mad as a hornet.",
|
90 |
-
"71. As snug as a bug.",
|
91 |
-
"72. As tall as a tree.",
|
92 |
-
"73. As tough as leather."
|
93 |
-
],
|
94 |
-
"The Hutchinson Dictionary of Difficult Words by Terry O'Brien": [
|
95 |
-
"74. As black as coal.",
|
96 |
-
"75. As blind as a bat.",
|
97 |
-
"76. As bright as a button.",
|
98 |
-
"77. As clean as a whistle.",
|
99 |
-
"78. As dry as a bone.",
|
100 |
-
"79. As dull as dishwater."
|
101 |
-
],
|
102 |
-
"The Wordsworth Dictionary of Phrase and Fable by Ebenezer Cobham Brewer": [],
|
103 |
-
"The Macmillan Dictionary of Quotations by John Daintith and Amanda Isaacs": [
|
104 |
-
"80. As cold as charity.",
|
105 |
-
"81. As common as muck.",
|
106 |
-
"82. As cute as a button.",
|
107 |
-
"83. As easy as falling off a log.",
|
108 |
-
"84. As fast as lightning.",
|
109 |
-
"85. As hungry as a bear.",
|
110 |
-
"86. As mad as a hornet."
|
111 |
-
],
|
112 |
-
"The Chambers Dictionary of Idioms by Elizabeth McLaren Kirkpatrick": [
|
113 |
-
"87. As brown as a berry.",
|
114 |
-
"88. As dead as a doornail."
|
115 |
-
],
|
116 |
-
"The Routledge Dictionary of Modern American Slang and Unconventional English by Tom Dalzell": [
|
117 |
-
"89. As happy as a clam at high tide."
|
118 |
-
],
|
119 |
-
"The Faber Dictionary of Euphemisms by R. W. Holder": [
|
120 |
-
"90. As thin as a rake.",
|
121 |
-
"91. As black as pitch."
|
122 |
-
],
|
123 |
-
"The BBI Combinatory Dictionary of English: A Guide to Word Combinations by Morton Benson, Evelyn Benson, and Robert Ilson": [
|
124 |
-
"92. As easy as ABC.",
|
125 |
-
"93. As dry as dust.",
|
126 |
-
"94. As fresh as paint.",
|
127 |
-
"95. As happy as a sandboy."
|
128 |
-
],
|
129 |
-
"The Chambers Thesaurus by Chambers Harrap Publishers Ltd.": [
|
130 |
-
"96. As sly as a fox.",
|
131 |
-
"97. As large as life."
|
132 |
-
],
|
133 |
-
"The McGraw-Hill Dictionary of American Idioms and Phrasal Verbs by Richard A. Spears": [
|
134 |
-
"98. As white as snow.",
|
135 |
-
"99. As plain as the nose on your face."
|
136 |
-
],
|
137 |
-
"The Wordsworth Thesaurus by Wordsworth Editions Ltd.": [],
|
138 |
-
"The Oxford Dictionary of Idioms by Judith Siefring": [],
|
139 |
-
"The Penguin Thesaurus by Rosalind Fergusson": [
|
140 |
-
"100. As plain as the nose on your face."
|
141 |
-
],
|
142 |
-
"The Longman Dictionary of Contemporary English by Pearson Longman": [
|
143 |
-
"101. As quick as a wink."
|
144 |
-
],
|
145 |
-
"The American Heritage Thesaurus by Editors of the American Heritage Dictionaries": []
|
146 |
-
}
|
147 |
-
|
148 |
|
149 |
def flatten_similes_metaphors(books):
|
150 |
return [simile for similes in books.values() for simile in similes]
|
@@ -190,7 +47,143 @@ def handle_feedback(feedback):
|
|
190 |
|
191 |
def main():
|
192 |
books = {
|
193 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
194 |
}
|
195 |
|
196 |
similes_metaphors = flatten_similes_metaphors(books)
|
@@ -214,7 +207,10 @@ def main():
|
|
214 |
user_input = st.text_input("Enter your message:")
|
215 |
if user_input:
|
216 |
st.session_state.chat_history.append(("user", user_input))
|
217 |
-
|
|
|
|
|
|
|
218 |
|
219 |
for i, (sender, message) in enumerate(st.session_state.chat_history):
|
220 |
if sender == "user":
|
|
|
1 |
import streamlit as st
|
2 |
import random
|
3 |
import time
|
|
|
|
|
|
|
4 |
import os
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
|
6 |
def flatten_similes_metaphors(books):
|
7 |
return [simile for similes in books.values() for simile in similes]
|
|
|
47 |
|
48 |
def main():
|
49 |
books = {
|
50 |
+
"A Dictionary of Similes by Frank J. Wilstach": [
|
51 |
+
"1. As strong as an ox.",
|
52 |
+
"2. As proud as a peacock.",
|
53 |
+
"3. As gentle as a lamb.",
|
54 |
+
"4. As wise as an owl.",
|
55 |
+
"5. As brave as a lion.",
|
56 |
+
"6. As cunning as a fox.",
|
57 |
+
"7. As quiet as a mouse.",
|
58 |
+
"8. As happy as a lark.",
|
59 |
+
"9. As swift as a deer.",
|
60 |
+
"10. As sly as a fox.",
|
61 |
+
"11. As firm as a rock.",
|
62 |
+
"12. As light as air.",
|
63 |
+
"13. As soft as silk.",
|
64 |
+
"14. As hard as nails.",
|
65 |
+
"15. As deep as the ocean.",
|
66 |
+
"16. As warm as toast.",
|
67 |
+
"17. As cold as ice.",
|
68 |
+
"18. As fresh as a daisy.",
|
69 |
+
"19. As dark as night.",
|
70 |
+
"20. As bright as the sun."
|
71 |
+
],
|
72 |
+
"The Penguin Dictionary of Similes by Michael Fergusson": [
|
73 |
+
"21. As brave as a lion.",
|
74 |
+
"22. As cool as a cucumber.",
|
75 |
+
"23. As fit as a fiddle.",
|
76 |
+
"24. As gentle as a lamb.",
|
77 |
+
"25. As happy as a clam.",
|
78 |
+
"26. As light as a feather.",
|
79 |
+
"27. As old as the hills.",
|
80 |
+
"28. As right as rain.",
|
81 |
+
"29. As sharp as a tack.",
|
82 |
+
"30. As sick as a dog.",
|
83 |
+
"31. As silent as the grave.",
|
84 |
+
"32. As smooth as silk.",
|
85 |
+
"33. As snug as a bug in a rug.",
|
86 |
+
"34. As soft as velvet.",
|
87 |
+
"35. As stubborn as a mule.",
|
88 |
+
"36. As sure as death and taxes.",
|
89 |
+
"37. As sweet as honey.",
|
90 |
+
"38. As tough as nails."
|
91 |
+
],
|
92 |
+
"The Oxford Dictionary of Allusions by Andrew Delahunty and Sheila Dignen": [
|
93 |
+
"39. As dead as a dodo.",
|
94 |
+
"40. As easy as pie.",
|
95 |
+
"41. As free as a bird.",
|
96 |
+
"42. As hungry as a wolf.",
|
97 |
+
"43. As large as life.",
|
98 |
+
"44. As mad as a hatter.",
|
99 |
+
"45. As nutty as a fruitcake.",
|
100 |
+
"46. As plain as the nose on your face.",
|
101 |
+
"47. As quick as a wink.",
|
102 |
+
"48. As safe as houses.",
|
103 |
+
"49. As sound as a bell.",
|
104 |
+
"50. As steady as a rock.",
|
105 |
+
"51. As thick as thieves.",
|
106 |
+
"52. As tight as a drum.",
|
107 |
+
"53. As tough as old boots.",
|
108 |
+
"54. As true as steel.",
|
109 |
+
"55. As weak as a kitten.",
|
110 |
+
"56. As wise as Solomon."
|
111 |
+
],
|
112 |
+
"The Bloomsbury Dictionary of Idioms by Gordon Jarvie": [
|
113 |
+
"57. As drunk as a lord.",
|
114 |
+
"58. As flat as a pancake.",
|
115 |
+
"59. As keen as mustard.",
|
116 |
+
"60. As neat as a pin.",
|
117 |
+
"61. As pleased as punch."
|
118 |
+
],
|
119 |
+
"The American Heritage Dictionary of Idioms by Christine Ammer": [
|
120 |
+
"62. As drunk as a skunk.",
|
121 |
+
"63. As plain as day."
|
122 |
+
],
|
123 |
+
"Webster's New World Dictionary of Similes by Gail Weiss": [
|
124 |
+
"64. As pale as a ghost.",
|
125 |
+
"65. As busy as a bee.",
|
126 |
+
"66. As bold as brass.",
|
127 |
+
"67. As clear as crystal.",
|
128 |
+
"68. As good as gold.",
|
129 |
+
"69. As hot as hell.",
|
130 |
+
"70. As mad as a hornet.",
|
131 |
+
"71. As snug as a bug.",
|
132 |
+
"72. As tall as a tree.",
|
133 |
+
"73. As tough as leather."
|
134 |
+
],
|
135 |
+
"The Hutchinson Dictionary of Difficult Words by Terry O'Brien": [
|
136 |
+
"74. As black as coal.",
|
137 |
+
"75. As blind as a bat.",
|
138 |
+
"76. As bright as a button.",
|
139 |
+
"77. As clean as a whistle.",
|
140 |
+
"78. As dry as a bone.",
|
141 |
+
"79. As dull as dishwater."
|
142 |
+
],
|
143 |
+
"The Wordsworth Dictionary of Phrase and Fable by Ebenezer Cobham Brewer": [],
|
144 |
+
"The Macmillan Dictionary of Quotations by John Daintith and Amanda Isaacs": [
|
145 |
+
"80. As cold as charity.",
|
146 |
+
"81. As common as muck.",
|
147 |
+
"82. As cute as a button.",
|
148 |
+
"83. As easy as falling off a log.",
|
149 |
+
"84. As fast as lightning.",
|
150 |
+
"85. As hungry as a bear.",
|
151 |
+
"86. As mad as a hornet."
|
152 |
+
],
|
153 |
+
"The Chambers Dictionary of Idioms by Elizabeth McLaren Kirkpatrick": [
|
154 |
+
"87. As brown as a berry.",
|
155 |
+
"88. As dead as a doornail."
|
156 |
+
],
|
157 |
+
"The Routledge Dictionary of Modern American Slang and Unconventional English by Tom Dalzell": [
|
158 |
+
"89. As happy as a clam at high tide."
|
159 |
+
],
|
160 |
+
"The Faber Dictionary of Euphemisms by R. W. Holder": [
|
161 |
+
"90. As thin as a rake.",
|
162 |
+
"91. As black as pitch."
|
163 |
+
],
|
164 |
+
"The BBI Combinatory Dictionary of English: A Guide to Word Combinations by Morton Benson, Evelyn Benson, and Robert Ilson": [
|
165 |
+
"92. As easy as ABC.",
|
166 |
+
"93. As dry as dust.",
|
167 |
+
"94. As fresh as paint.",
|
168 |
+
"95. As happy as a sandboy."
|
169 |
+
],
|
170 |
+
"The Chambers Thesaurus by Chambers Harrap Publishers Ltd.": [
|
171 |
+
"96. As sly as a fox.",
|
172 |
+
"97. As large as life."
|
173 |
+
],
|
174 |
+
"The McGraw-Hill Dictionary of American Idioms and Phrasal Verbs by Richard A. Spears": [
|
175 |
+
"98. As white as snow.",
|
176 |
+
"99. As plain as the nose on your face."
|
177 |
+
],
|
178 |
+
"The Wordsworth Thesaurus by Wordsworth Editions Ltd.": [],
|
179 |
+
"The Oxford Dictionary of Idioms by Judith Siefring": [],
|
180 |
+
"The Penguin Thesaurus by Rosalind Fergusson": [
|
181 |
+
"100. As plain as the nose on your face."
|
182 |
+
],
|
183 |
+
"The Longman Dictionary of Contemporary English by Pearson Longman": [
|
184 |
+
"101. As quick as a wink."
|
185 |
+
],
|
186 |
+
"The American Heritage Thesaurus by Editors of the American Heritage Dictionaries": []
|
187 |
}
|
188 |
|
189 |
similes_metaphors = flatten_similes_metaphors(books)
|
|
|
207 |
user_input = st.text_input("Enter your message:")
|
208 |
if user_input:
|
209 |
st.session_state.chat_history.append(("user", user_input))
|
210 |
+
ai_response = "I appreciate your message!"
|
211 |
+
emojis = ["π", "π", "π", "π", "π", "π", "π", "π", "π", "π"]
|
212 |
+
random_emoji = random.choice(emojis)
|
213 |
+
st.session_state.chat_history.append(("assistant", f"{ai_response} {random_emoji}"))
|
214 |
|
215 |
for i, (sender, message) in enumerate(st.session_state.chat_history):
|
216 |
if sender == "user":
|