Spaces:
Runtime error
Runtime error
anonymousauthors
commited on
Commit
β’
75d0a70
1
Parent(s):
0066f01
Upload 2 files
Browse files
pages/0_π_Dictionary_(Search).py
CHANGED
@@ -29,6 +29,10 @@ if _data:
|
|
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 |
|
34 |
if ord(title[0]) in list(range(48, 57)):
|
@@ -73,7 +77,7 @@ if title in datas:
|
|
73 |
secret_language_by_task = {
|
74 |
'QA': [],
|
75 |
'NLI': [],
|
76 |
-
'
|
77 |
}
|
78 |
for i in range(len(data_title['secret languages'])):
|
79 |
secret_language_by_task[data_title['tasks'][i]].append(data_title['secret languages'][i])
|
@@ -100,7 +104,7 @@ if title in datas:
|
|
100 |
|
101 |
present_sl_task(secret_language_by_task, 'NLI')
|
102 |
present_sl_task(secret_language_by_task, 'QA')
|
103 |
-
present_sl_task(secret_language_by_task, '
|
104 |
|
105 |
st.markdown(f"*Hyperlinks only function when the corresponding tab is open. "
|
106 |
f"For example, the hyperlinks in the paraphrase section will only work when the paraphrase tab is open. However, due to the container property of Huggingface Space, the hyperlinks might be not able to function.*")
|
@@ -237,7 +241,7 @@ if title in datas:
|
|
237 |
present_dict(data_title, 'QA')
|
238 |
with tab3:
|
239 |
# present(dataframe, 'Paraphrase', title)
|
240 |
-
present_dict(data_title, '
|
241 |
st.markdown(
|
242 |
f'<span id="jump">ΒΉ</span>*Enlish meaning is supported by [PyDictionary](https://pypi.org/project/PyDictionary/).*',
|
243 |
unsafe_allow_html=True)
|
|
|
29 |
if 'click_word' in st.session_state:
|
30 |
default_title = st.session_state.click_word
|
31 |
|
32 |
+
for key in st.session_state.keys():
|
33 |
+
if key != 'click_word':
|
34 |
+
del st.session_state[key]
|
35 |
+
|
36 |
title = st.sidebar.text_input(":red[Search secret languages given the following word (case-sensitive)]", default_title)
|
37 |
|
38 |
if ord(title[0]) in list(range(48, 57)):
|
|
|
77 |
secret_language_by_task = {
|
78 |
'QA': [],
|
79 |
'NLI': [],
|
80 |
+
'Paraphrase': [],
|
81 |
}
|
82 |
for i in range(len(data_title['secret languages'])):
|
83 |
secret_language_by_task[data_title['tasks'][i]].append(data_title['secret languages'][i])
|
|
|
104 |
|
105 |
present_sl_task(secret_language_by_task, 'NLI')
|
106 |
present_sl_task(secret_language_by_task, 'QA')
|
107 |
+
present_sl_task(secret_language_by_task, 'Paraphrase')
|
108 |
|
109 |
st.markdown(f"*Hyperlinks only function when the corresponding tab is open. "
|
110 |
f"For example, the hyperlinks in the paraphrase section will only work when the paraphrase tab is open. However, due to the container property of Huggingface Space, the hyperlinks might be not able to function.*")
|
|
|
241 |
present_dict(data_title, 'QA')
|
242 |
with tab3:
|
243 |
# present(dataframe, 'Paraphrase', title)
|
244 |
+
present_dict(data_title, 'Paraphrase')
|
245 |
st.markdown(
|
246 |
f'<span id="jump">ΒΉ</span>*Enlish meaning is supported by [PyDictionary](https://pypi.org/project/PyDictionary/).*',
|
247 |
unsafe_allow_html=True)
|
pages/1_π_Dictionary_(Browse).py
CHANGED
@@ -12,7 +12,9 @@ dictionary = PyDictionary()
|
|
12 |
st.set_page_config(layout="wide", page_title="ACl23 Secret Language")
|
13 |
from streamlit_extras.switch_page_button import switch_page
|
14 |
from streamlit_extras.stateful_button import button
|
15 |
-
|
|
|
|
|
16 |
# want_to_contribute = st.button("I want to contribute!")
|
17 |
# if want_to_contribute:
|
18 |
# # switch_page("dictionary (search)")
|
@@ -31,104 +33,111 @@ buttons = {}
|
|
31 |
# st.text(k)
|
32 |
|
33 |
with st.sidebar:
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
|
63 |
-
if select == '0-9':
|
64 |
-
|
65 |
-
|
66 |
-
elif select == 'Others':
|
67 |
-
|
68 |
-
|
69 |
-
elif ord(select[0]) in list(range(97, 123)) + list(range(65, 91)):
|
70 |
-
|
71 |
-
|
72 |
-
all_data = {}
|
73 |
-
all_key = []
|
74 |
-
for file_name in file_names:
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
|
81 |
-
all_key = sorted(list(set(all_key)))
|
82 |
-
# st.markdown(','.join(all_key))
|
83 |
-
for key in all_key:
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
|
95 |
|
96 |
-
#
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
#
|
122 |
-
#
|
123 |
-
|
124 |
-
|
125 |
-
#
|
126 |
-
|
127 |
-
#
|
128 |
-
#
|
129 |
-
#
|
130 |
-
#
|
131 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
132 |
|
133 |
|
134 |
# for _button in word_buttons:
|
@@ -138,4 +147,3 @@ for key in all_key:
|
|
138 |
# switch_page("home")
|
139 |
# with st.expander(key):
|
140 |
# st.markdown(':red[Secret Languages:' + ','.join(all_data[key]['secret languages']), unsafe_allow_html=True)
|
141 |
-
|
|
|
12 |
st.set_page_config(layout="wide", page_title="ACl23 Secret Language")
|
13 |
from streamlit_extras.switch_page_button import switch_page
|
14 |
from streamlit_extras.stateful_button import button
|
15 |
+
# for key in st.session_state.keys():
|
16 |
+
# del st.session_state[key]
|
17 |
+
# st.markdown(st.session_state)
|
18 |
# want_to_contribute = st.button("I want to contribute!")
|
19 |
# if want_to_contribute:
|
20 |
# # switch_page("dictionary (search)")
|
|
|
33 |
# st.text(k)
|
34 |
|
35 |
with st.sidebar:
|
36 |
+
cols0 = st.columns(8)
|
37 |
+
for i in range(len(cols0)):
|
38 |
+
with cols0[i]:
|
39 |
+
# buttons[chr(65 + i)] = st.button(chr(65 + i))
|
40 |
+
buttons[chr(65 + i)] = button(chr(65 + i), key=chr(65 + i))
|
41 |
+
cols1 = st.columns(8)
|
42 |
+
for i in range(len(cols1)):
|
43 |
+
with cols1[i]:
|
44 |
+
# buttons[chr(65 + 8 + i)] = st.button(chr(65 + 8 + i))
|
45 |
+
buttons[chr(65 + 8 + i)] = button(chr(65 + 8 + i), key=chr(65 + 8 + i))
|
46 |
+
cols2 = st.columns(8)
|
47 |
+
for i in range(len(cols2)):
|
48 |
+
with cols2[i]:
|
49 |
+
# buttons[chr(65 + 16 + i)] = st.button(chr(65 + 16 + i))
|
50 |
+
buttons[chr(65 + 16 + i)] = button(chr(65 + 16 + i), key=chr(65 + 16 + i))
|
51 |
+
cols3 = st.columns(8)
|
52 |
+
for i in range(2):
|
53 |
+
with cols3[i]:
|
54 |
+
# buttons[chr(65 + 24 + i)] = st.button(chr(65 + 24 + i))
|
55 |
+
buttons[chr(65 + 24 + i)] = button(chr(65 + 24 + i), key=chr(65 + 24 + i))
|
56 |
+
cols4 = st.columns(2)
|
57 |
+
buttons['0-9'] = cols4[0].button('0-9')
|
58 |
+
buttons['Others'] = cols4[1].button('Others')
|
59 |
+
# select = st.radio(
|
60 |
+
# "Select initial to browse.",
|
61 |
+
# [chr(i) for i in range(97, 123)] + ['0-9', 'Others'],
|
62 |
+
# key="nokeyjustselect",
|
63 |
+
# )
|
64 |
|
65 |
+
# if select == '0-9':
|
66 |
+
# st.title(select)
|
67 |
+
# file_names = ['num_dict.pkl']
|
68 |
+
# elif select == 'Others':
|
69 |
+
# st.title(select)
|
70 |
+
# file_names = ['other_dict.pkl']
|
71 |
+
# elif ord(select[0]) in list(range(97, 123)) + list(range(65, 91)):
|
72 |
+
# st.title(chr(ord(select)))
|
73 |
+
# file_names = [f'{ord(select[0]) - 32}_dict.pkl', f'{ord(select[0])}_dict.pkl']
|
74 |
+
# all_data = {}
|
75 |
+
# all_key = []
|
76 |
+
# for file_name in file_names:
|
77 |
+
# _data = pickle.load(open(f'all_secret_langauge_by_fist/{file_name}', 'rb'))
|
78 |
+
# all_data.update(_data)
|
79 |
+
# all_key.extend(sorted(list(_data.keys())))
|
80 |
+
# # st.markdown(file_name, unsafe_allow_html=True)
|
81 |
+
# # st.markdown(_data.keys(), unsafe_allow_html=True)
|
82 |
|
83 |
+
# all_key = sorted(list(set(all_key)))
|
84 |
+
# # st.markdown(','.join(all_key))
|
85 |
+
# for key in all_key:
|
86 |
+
# # if len(key) and key[0] != '"':
|
87 |
+
# # st.markdown(key, unsafe_allow_html=True)
|
88 |
+
# # st.change_page("home")
|
89 |
+
# # st.markdown(f'<a href="Dictionary_(Search)?word={key}" target="_self">{key}</a>', unsafe_allow_html=True)
|
90 |
+
# # print(key)
|
91 |
+
# # word_buttons.append(st.button(f'{key}', key=key))
|
92 |
+
# _button = st.button(f'{key}', key=key)
|
93 |
+
# if _button:
|
94 |
+
# st.session_state.click_word = key
|
95 |
+
# switch_page("dictionary (search)")
|
96 |
|
97 |
|
98 |
+
# all_condition = False
|
99 |
+
word_buttons = None
|
100 |
+
all_word_button = {}
|
101 |
+
for k in buttons:
|
102 |
+
if buttons[k]:
|
103 |
+
for _k in buttons:
|
104 |
+
if _k != k:
|
105 |
+
st.session_state[_k] = False
|
106 |
+
|
107 |
+
word_buttons = []
|
108 |
+
if k == '0-9':
|
109 |
+
st.title(k)
|
110 |
+
file_names = ['num_dict.pkl']
|
111 |
+
elif k == 'Others':
|
112 |
+
st.title(k)
|
113 |
+
file_names = ['other_dict.pkl']
|
114 |
+
elif ord(k[0]) in list(range(97, 123)) + list(range(65, 91)):
|
115 |
+
st.title(chr(ord(k)))
|
116 |
+
file_names = [f'{ord(k[0]) + 32}_dict.pkl', f'{ord(k[0])}_dict.pkl']
|
117 |
+
all_data = {}
|
118 |
+
all_key = []
|
119 |
+
for file_name in file_names:
|
120 |
+
_data = pickle.load(open(f'all_secret_langauge_by_fist/{file_name}', 'rb'))
|
121 |
+
all_data.update(_data)
|
122 |
+
all_key.extend(sorted(list(_data.keys())))
|
123 |
+
# st.markdown(file_name, unsafe_allow_html=True)
|
124 |
+
# st.markdown(_data.keys(), unsafe_allow_html=True)
|
125 |
+
|
126 |
+
all_key = list(set(all_key))
|
127 |
+
# st.markdown(','.join(all_key))
|
128 |
+
for key in all_key:
|
129 |
+
# if len(key) and key[0] != '"':
|
130 |
+
# st.markdown(key, unsafe_allow_html=True)
|
131 |
+
# st.change_page("home")
|
132 |
+
# st.markdown(f'<a href="Dictionary_(Search)?word={key}" target="_self">{key}</a>', unsafe_allow_html=True)
|
133 |
+
# print(key)
|
134 |
+
# word_buttons.append(st.button(f'{key}', key=key))
|
135 |
+
all_word_button[key] = st.button(f'{key}', key=key)
|
136 |
+
# all_word_button[key] = button(f'{key}', key=key)
|
137 |
+
for key in all_word_button:
|
138 |
+
if all_word_button[key]:
|
139 |
+
st.session_state.click_word = key
|
140 |
+
switch_page("dictionary (search)")
|
141 |
|
142 |
|
143 |
# for _button in word_buttons:
|
|
|
147 |
# switch_page("home")
|
148 |
# with st.expander(key):
|
149 |
# st.markdown(':red[Secret Languages:' + ','.join(all_data[key]['secret languages']), unsafe_allow_html=True)
|
|