changed dictionary word input box to st_tags
Browse files- app.py +22 -4
- requirements.txt +2 -1
app.py
CHANGED
@@ -7,6 +7,7 @@ from vector_graph import *
|
|
7 |
from plots import *
|
8 |
from lsj_dict import *
|
9 |
import json
|
|
|
10 |
|
11 |
|
12 |
st.set_page_config(page_title="Ancient Greek Word2Vec", layout="centered")
|
@@ -163,12 +164,29 @@ elif active_tab == "Dictionary":
|
|
163 |
with st.container():
|
164 |
all_lemmas = load_compressed_word_list('all_lemmas.pkl.gz')
|
165 |
|
166 |
-
query_word = st.multiselect("Search a word in the LSJ dictionary", all_lemmas, max_selections=1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
167 |
|
168 |
# If a word has been selected by user
|
169 |
-
if
|
170 |
-
st.write(f"### {
|
171 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
172 |
|
173 |
|
174 |
|
|
|
7 |
from plots import *
|
8 |
from lsj_dict import *
|
9 |
import json
|
10 |
+
from streamlit_tags import st_tags, st_tags_sidebar
|
11 |
|
12 |
|
13 |
st.set_page_config(page_title="Ancient Greek Word2Vec", layout="centered")
|
|
|
164 |
with st.container():
|
165 |
all_lemmas = load_compressed_word_list('all_lemmas.pkl.gz')
|
166 |
|
167 |
+
# query_word = st.multiselect("Search a word in the LSJ dictionary", all_lemmas, max_selections=1)
|
168 |
+
|
169 |
+
query_tag = st_tags(label = 'Search a word in the LSJ dictionary',
|
170 |
+
text = '',
|
171 |
+
value = [],
|
172 |
+
suggestions = all_lemmas,
|
173 |
+
maxtags = 1,
|
174 |
+
key = '1'
|
175 |
+
)
|
176 |
|
177 |
# If a word has been selected by user
|
178 |
+
if query_tag:
|
179 |
+
st.write(f"### {query_tag[0]}")
|
180 |
+
|
181 |
+
# Display word information
|
182 |
+
if query_tag[0] in lemma_dict:
|
183 |
+
data = lemma_dict[query_tag[0]]
|
184 |
+
elif query_tag[0].capitalize() in lemma_dict: # Some words are capitalized in the dictionary
|
185 |
+
data = lemma_dict[query_tag[0].capitalize()]
|
186 |
+
else:
|
187 |
+
st.error("Word not found in dictionary")
|
188 |
+
|
189 |
+
st.write(data)
|
190 |
|
191 |
|
192 |
|
requirements.txt
CHANGED
@@ -7,4 +7,5 @@ umap-learn
|
|
7 |
scikit-learn
|
8 |
matplotlib
|
9 |
scipy==1.10.1
|
10 |
-
plotly
|
|
|
|
7 |
scikit-learn
|
8 |
matplotlib
|
9 |
scipy==1.10.1
|
10 |
+
plotly
|
11 |
+
streamlit-tags
|