Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -15,6 +15,11 @@ idiom_map = load_idioms("idiom2.json")
|
|
| 15 |
idioms = sorted(idiom_map.keys())
|
| 16 |
conn = init_db()
|
| 17 |
examples_map = build_examples_map()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
# Sidebar
|
| 20 |
mode = st.sidebar.selectbox(
|
|
@@ -28,9 +33,25 @@ if mode == "Explore Idioms":
|
|
| 28 |
|
| 29 |
|
| 30 |
search = st.text_input("Search idiom:")
|
| 31 |
-
filtered = [i for i in idioms if search.lower() in i.lower()]
|
| 32 |
-
|
| 33 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
if selected:
|
| 35 |
st.subheader("Natural Spanish Meaning")
|
| 36 |
st.write(idiom_map[selected])
|
|
@@ -55,7 +76,7 @@ if mode == "Explore Idioms":
|
|
| 55 |
if st.button("⭐ Add to Favorites"):
|
| 56 |
add_favorite(conn, selected)
|
| 57 |
st.success("Added to favorites!")
|
| 58 |
-
|
| 59 |
|
| 60 |
# DETECT
|
| 61 |
|
|
|
|
| 15 |
idioms = sorted(idiom_map.keys())
|
| 16 |
conn = init_db()
|
| 17 |
examples_map = build_examples_map()
|
| 18 |
+
##13/5
|
| 19 |
+
topics = sorted(list(set(
|
| 20 |
+
v.get("topic", "General")
|
| 21 |
+
for v in idiom_map.values()
|
| 22 |
+
)))
|
| 23 |
|
| 24 |
# Sidebar
|
| 25 |
mode = st.sidebar.selectbox(
|
|
|
|
| 33 |
|
| 34 |
|
| 35 |
search = st.text_input("Search idiom:")
|
| 36 |
+
#filtered = [i for i in idioms if search.lower() in i.lower()]
|
| 37 |
+
filtered = []
|
| 38 |
|
| 39 |
+
for idiom in idioms:
|
| 40 |
+
|
| 41 |
+
matches_search = search.lower() in idiom.lower()
|
| 42 |
+
topic = idiom_map[idiom].get("topic", "General")
|
| 43 |
+
matches_topic = (
|
| 44 |
+
selected_topic == "All"
|
| 45 |
+
or topic == selected_topic
|
| 46 |
+
)
|
| 47 |
+
if matches_search and matches_topic:
|
| 48 |
+
filtered.append(idiom)
|
| 49 |
+
|
| 50 |
+
selected = st.selectbox("Choose idiom:", filtered)
|
| 51 |
+
selected_topic = st.selectbox(
|
| 52 |
+
"Choose Topic",
|
| 53 |
+
["All"] + topics
|
| 54 |
+
)
|
| 55 |
if selected:
|
| 56 |
st.subheader("Natural Spanish Meaning")
|
| 57 |
st.write(idiom_map[selected])
|
|
|
|
| 76 |
if st.button("⭐ Add to Favorites"):
|
| 77 |
add_favorite(conn, selected)
|
| 78 |
st.success("Added to favorites!")
|
| 79 |
+
|
| 80 |
|
| 81 |
# DETECT
|
| 82 |
|