Spaces:
Runtime error
Runtime error
anonymousauthors
commited on
Commit
β’
e735e42
1
Parent(s):
a3fb811
Update pages/0_π_Dictionary_(Search).py
Browse files
pages/0_π_Dictionary_(Search).py
CHANGED
@@ -26,6 +26,8 @@ default_title = 'Asian'
|
|
26 |
if _data:
|
27 |
if 'word' in _data.keys():
|
28 |
default_title = _data['word'][0]
|
|
|
|
|
29 |
|
30 |
title = st.sidebar.text_input(":red[Search secret languages given the following word (case-sensitive)]", default_title)
|
31 |
|
@@ -39,6 +41,7 @@ else:
|
|
39 |
datas = pickle.load(open(f'all_secret_langauge_by_fist/{file_name}', 'rb'))
|
40 |
if title in datas:
|
41 |
st.title(title)
|
|
|
42 |
st.markdown(f"## {title}'s meaning in English[ΒΉ](#jump)")
|
43 |
|
44 |
# write the meaning of input word
|
@@ -49,7 +52,8 @@ if title in datas:
|
|
49 |
_string += f':violet[{key}]: {";".join(title_mean[key])}<br>'
|
50 |
st.markdown(_string, unsafe_allow_html=True)
|
51 |
except:
|
52 |
-
st.error(f'We cannot find the meaning of {title} in English (PyDictionary), which might be due to the bug.',
|
|
|
53 |
|
54 |
st.markdown(f"---")
|
55 |
st.markdown(f"## {title}'s secret languages")
|
@@ -57,7 +61,8 @@ if title in datas:
|
|
57 |
title_secret_languages = list(sorted(list(set(data_title["secret languages"]))))
|
58 |
# dataframe = pd.DataFrame(datas[title])
|
59 |
# st.markdown(f'### We found {len(set(dataframe.loc[:, "secret languages"]))} secret languages of {title}.', unsafe_allow_html=True)
|
60 |
-
st.markdown(f'Overall, we found :red[{len(title_secret_languages)}] secret languages of :blue[{title}].',
|
|
|
61 |
special = '"'
|
62 |
# _title_secret_languages = [f'[{i}](#{i.strip().replace("(", ",,").replace(")", "..").replace("[", ",,,").replace("]", "...").replace(special, "././")})'
|
63 |
# for i in title_secret_languages]
|
@@ -65,23 +70,30 @@ if title in datas:
|
|
65 |
# unsafe_allow_html=True)
|
66 |
|
67 |
secret_language_by_task = {
|
68 |
-
'QA':[],
|
69 |
-
'NLI':[],
|
70 |
-
'paraphrase':[],
|
71 |
}
|
72 |
for i in range(len(data_title['secret languages'])):
|
73 |
secret_language_by_task[data_title['tasks'][i]].append(data_title['secret languages'][i])
|
74 |
for k in secret_language_by_task:
|
75 |
secret_language_by_task[k] = list(set(secret_language_by_task[k]))
|
76 |
|
|
|
77 |
def present_sl_task(secret_language_by_task, task):
|
78 |
all_sl = sorted(secret_language_by_task[task])
|
79 |
-
st.markdown(
|
|
|
|
|
80 |
special = '"'
|
81 |
-
_title_secret_languages = [
|
82 |
-
|
83 |
-
|
84 |
-
|
|
|
|
|
|
|
|
|
85 |
present_sl_task(secret_language_by_task, 'NLI')
|
86 |
present_sl_task(secret_language_by_task, 'QA')
|
87 |
present_sl_task(secret_language_by_task, 'paraphrase')
|
@@ -160,7 +172,11 @@ if title in datas:
|
|
160 |
all_keys = sorted(list(_all.keys()))
|
161 |
for i in range(len(all_keys)):
|
162 |
_sl = all_keys[i]
|
163 |
-
_sl_in_span = _sl.strip().replace("(", ",,").replace(")", "..").replace("[", ",,,").replace("]",
|
|
|
|
|
|
|
|
|
164 |
_title = f'{i + 1}. <span id="{_sl_in_span}_{task}"> **:red[{_sl}]**</span>'
|
165 |
# with st.expander(_title, expanded=True):
|
166 |
_string = _title + '<br>Examples:<br>'
|
@@ -194,7 +210,8 @@ if title in datas:
|
|
194 |
_string += f'blue[{_all[_sl]["Premise"][j]}]'.replace(":", "[colon]")
|
195 |
_string += '<br></li>'
|
196 |
_string += '</ol></blockquote>'
|
197 |
-
st.markdown(_string.replace('<s>', '\<s\>').replace('$', '\$').replace('~', '\~'),
|
|
|
198 |
# st.text(f'Examples: :blue[{new_dataframe.loc[i, "replaced sentences".replace(":", "[colon]")]}]')
|
199 |
# st.dataframe(new_dataframe)
|
200 |
st.markdown(hide_expander_border, unsafe_allow_html=True)
|
@@ -218,4 +235,3 @@ if title in datas:
|
|
218 |
unsafe_allow_html=True)
|
219 |
else:
|
220 |
st.error(f'{title} is not in the dictionary of Secret Language.', icon="β οΈ")
|
221 |
-
|
|
|
26 |
if _data:
|
27 |
if 'word' in _data.keys():
|
28 |
default_title = _data['word'][0]
|
29 |
+
if 'click_word' in st.session_state:
|
30 |
+
default_title = st.session_state.click_word
|
31 |
|
32 |
title = st.sidebar.text_input(":red[Search secret languages given the following word (case-sensitive)]", default_title)
|
33 |
|
|
|
41 |
datas = pickle.load(open(f'all_secret_langauge_by_fist/{file_name}', 'rb'))
|
42 |
if title in datas:
|
43 |
st.title(title)
|
44 |
+
# st.markdown(f":red[[]]")
|
45 |
st.markdown(f"## {title}'s meaning in English[ΒΉ](#jump)")
|
46 |
|
47 |
# write the meaning of input word
|
|
|
52 |
_string += f':violet[{key}]: {";".join(title_mean[key])}<br>'
|
53 |
st.markdown(_string, unsafe_allow_html=True)
|
54 |
except:
|
55 |
+
st.error(f'We cannot find the meaning of {title} in English (PyDictionary), which might be due to the bug.',
|
56 |
+
icon="π¨")
|
57 |
|
58 |
st.markdown(f"---")
|
59 |
st.markdown(f"## {title}'s secret languages")
|
|
|
61 |
title_secret_languages = list(sorted(list(set(data_title["secret languages"]))))
|
62 |
# dataframe = pd.DataFrame(datas[title])
|
63 |
# st.markdown(f'### We found {len(set(dataframe.loc[:, "secret languages"]))} secret languages of {title}.', unsafe_allow_html=True)
|
64 |
+
st.markdown(f'Overall, we found :red[{len(title_secret_languages)}] secret languages of :blue[{title}].',
|
65 |
+
unsafe_allow_html=True)
|
66 |
special = '"'
|
67 |
# _title_secret_languages = [f'[{i}](#{i.strip().replace("(", ",,").replace(")", "..").replace("[", ",,,").replace("]", "...").replace(special, "././")})'
|
68 |
# for i in title_secret_languages]
|
|
|
70 |
# unsafe_allow_html=True)
|
71 |
|
72 |
secret_language_by_task = {
|
73 |
+
'QA': [],
|
74 |
+
'NLI': [],
|
75 |
+
'paraphrase': [],
|
76 |
}
|
77 |
for i in range(len(data_title['secret languages'])):
|
78 |
secret_language_by_task[data_title['tasks'][i]].append(data_title['secret languages'][i])
|
79 |
for k in secret_language_by_task:
|
80 |
secret_language_by_task[k] = list(set(secret_language_by_task[k]))
|
81 |
|
82 |
+
|
83 |
def present_sl_task(secret_language_by_task, task):
|
84 |
all_sl = sorted(secret_language_by_task[task])
|
85 |
+
st.markdown(
|
86 |
+
f':red[{len(all_sl)}] secret languages of :blue[{title}] on {task.replace("paraphrase", "Paraphrase")}',
|
87 |
+
unsafe_allow_html=True)
|
88 |
special = '"'
|
89 |
+
_title_secret_languages = [
|
90 |
+
f'[{i}](#{i.strip().replace("(", ",,").replace(")", "..").replace("[", ",,,").replace("]", "...").replace(special, "././")}_{task})'
|
91 |
+
for i in all_sl]
|
92 |
+
st.markdown(
|
93 |
+
'>' + ', '.join(_title_secret_languages).replace('<s>', '\<s\>').replace('$', '\$').replace('~', '\~'),
|
94 |
+
unsafe_allow_html=True)
|
95 |
+
|
96 |
+
|
97 |
present_sl_task(secret_language_by_task, 'NLI')
|
98 |
present_sl_task(secret_language_by_task, 'QA')
|
99 |
present_sl_task(secret_language_by_task, 'paraphrase')
|
|
|
172 |
all_keys = sorted(list(_all.keys()))
|
173 |
for i in range(len(all_keys)):
|
174 |
_sl = all_keys[i]
|
175 |
+
_sl_in_span = _sl.strip().replace("(", ",,").replace(")", "..").replace("[", ",,,").replace("]",
|
176 |
+
"...").replace(
|
177 |
+
special, "././")
|
178 |
+
# if _sl == '[]':
|
179 |
+
# st.text(_sl)
|
180 |
_title = f'{i + 1}. <span id="{_sl_in_span}_{task}"> **:red[{_sl}]**</span>'
|
181 |
# with st.expander(_title, expanded=True):
|
182 |
_string = _title + '<br>Examples:<br>'
|
|
|
210 |
_string += f'blue[{_all[_sl]["Premise"][j]}]'.replace(":", "[colon]")
|
211 |
_string += '<br></li>'
|
212 |
_string += '</ol></blockquote>'
|
213 |
+
st.markdown(_string.replace('<s>', '\<s\>').replace('$', '\$').replace('~', '\~'),
|
214 |
+
unsafe_allow_html=True)
|
215 |
# st.text(f'Examples: :blue[{new_dataframe.loc[i, "replaced sentences".replace(":", "[colon]")]}]')
|
216 |
# st.dataframe(new_dataframe)
|
217 |
st.markdown(hide_expander_border, unsafe_allow_html=True)
|
|
|
235 |
unsafe_allow_html=True)
|
236 |
else:
|
237 |
st.error(f'{title} is not in the dictionary of Secret Language.', icon="β οΈ")
|
|