Spaces:
Runtime error
Runtime error
anonymousauthors
commited on
Commit
β’
63e2daf
1
Parent(s):
a4e4b26
Update pages/0_π_Dictionary_(Search).py
Browse files
pages/0_π_Dictionary_(Search).py
CHANGED
@@ -58,6 +58,7 @@ if title in datas:
|
|
58 |
st.markdown(f"---")
|
59 |
st.markdown(f"## {title}'s secret languages")
|
60 |
data_title = datas[title]
|
|
|
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)
|
@@ -82,6 +83,8 @@ if title in datas:
|
|
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)
|
@@ -137,11 +140,11 @@ if title in datas:
|
|
137 |
_string += 'sentence 1: :'
|
138 |
_string += f'red[{new_dataframe.loc[i, "replaced sentences"]}]'.replace(":", "[colon]")
|
139 |
if key == 'NLI':
|
140 |
-
_string += '<br>
|
141 |
elif key == 'QA':
|
142 |
-
_string += '<br>
|
143 |
elif key == 'Paraphrase':
|
144 |
-
_string += '<br>
|
145 |
_string += f'blue[{new_dataframe.loc[i, "premise / sentence 2 / text"]}]'.replace(":", "[colon]")
|
146 |
st.markdown(_string, unsafe_allow_html=True)
|
147 |
# st.text(f'Examples: :blue[{new_dataframe.loc[i, "replaced sentences".replace(":", "[colon]")]}]')
|
@@ -161,7 +164,8 @@ if title in datas:
|
|
161 |
_all[_sl] = {
|
162 |
'Original hypothesis': [],
|
163 |
'Replaced hypothesis': [],
|
164 |
-
'Premise': []
|
|
|
165 |
}
|
166 |
_all[_sl]['Original hypothesis'].append(_dict['original sentences'][i])
|
167 |
if task == 'QA':
|
@@ -169,16 +173,18 @@ if title in datas:
|
|
169 |
else:
|
170 |
_all[_sl]['Replaced hypothesis'].append(_dict['replaced sentences'][i])
|
171 |
_all[_sl]['Premise'].append(_dict['premise / sentence 2 / text'][i])
|
|
|
172 |
if len(_all.keys()):
|
173 |
all_keys = sorted(list(_all.keys()))
|
174 |
for i in range(len(all_keys)):
|
175 |
_sl = all_keys[i]
|
176 |
_sl_in_span = _sl.strip().replace("(", ",,").replace(")", "..").replace("[", ",,,").replace("]",
|
177 |
"...").replace(
|
178 |
-
special, "././")
|
179 |
# if _sl == '[]':
|
180 |
# st.text(_sl)
|
181 |
-
|
|
|
182 |
# with st.expander(_title, expanded=True):
|
183 |
_string = _title + '<br>Examples:<br>'
|
184 |
# st.markdown(_title, unsafe_allow_html=True)
|
@@ -203,12 +209,13 @@ if title in datas:
|
|
203 |
_string += 'sentence 1**: :'
|
204 |
_string += f'red[{_all[_sl]["Replaced hypothesis"][j]}]'.replace(":", "[colon]")
|
205 |
if task == 'NLI':
|
206 |
-
_string += '<br> **
|
207 |
elif task == 'QA':
|
208 |
-
_string += '<br> **
|
209 |
elif task == 'paraphrase':
|
210 |
-
_string += '<br> **
|
211 |
_string += f'blue[{_all[_sl]["Premise"][j]}]'.replace(":", "[colon]")
|
|
|
212 |
_string += '<br></li>'
|
213 |
_string += '</ol></blockquote>'
|
214 |
st.markdown(_string.replace('<s>', '\<s\>').replace('$', '\$').replace('~', '\~'),
|
|
|
58 |
st.markdown(f"---")
|
59 |
st.markdown(f"## {title}'s secret languages")
|
60 |
data_title = datas[title]
|
61 |
+
# st.markdown(data_title.keys())
|
62 |
title_secret_languages = list(sorted(list(set(data_title["secret languages"]))))
|
63 |
# dataframe = pd.DataFrame(datas[title])
|
64 |
# st.markdown(f'### We found {len(set(dataframe.loc[:, "secret languages"]))} secret languages of {title}.', unsafe_allow_html=True)
|
|
|
83 |
|
84 |
def present_sl_task(secret_language_by_task, task):
|
85 |
all_sl = sorted(secret_language_by_task[task])
|
86 |
+
for i in range(len(all_sl)):
|
87 |
+
all_sl[i] = all_sl[i].replace("\n", "/n")
|
88 |
st.markdown(
|
89 |
f':red[{len(all_sl)}] secret languages of :blue[{title}] on {task.replace("paraphrase", "Paraphrase")}',
|
90 |
unsafe_allow_html=True)
|
|
|
140 |
_string += 'sentence 1: :'
|
141 |
_string += f'red[{new_dataframe.loc[i, "replaced sentences"]}]'.replace(":", "[colon]")
|
142 |
if key == 'NLI':
|
143 |
+
_string += '<br>Premise: :'
|
144 |
elif key == 'QA':
|
145 |
+
_string += '<br>Text: :'
|
146 |
elif key == 'Paraphrase':
|
147 |
+
_string += '<br>Sentence 2: :'
|
148 |
_string += f'blue[{new_dataframe.loc[i, "premise / sentence 2 / text"]}]'.replace(":", "[colon]")
|
149 |
st.markdown(_string, unsafe_allow_html=True)
|
150 |
# st.text(f'Examples: :blue[{new_dataframe.loc[i, "replaced sentences".replace(":", "[colon]")]}]')
|
|
|
164 |
_all[_sl] = {
|
165 |
'Original hypothesis': [],
|
166 |
'Replaced hypothesis': [],
|
167 |
+
'Premise': [],
|
168 |
+
'output': []
|
169 |
}
|
170 |
_all[_sl]['Original hypothesis'].append(_dict['original sentences'][i])
|
171 |
if task == 'QA':
|
|
|
173 |
else:
|
174 |
_all[_sl]['Replaced hypothesis'].append(_dict['replaced sentences'][i])
|
175 |
_all[_sl]['Premise'].append(_dict['premise / sentence 2 / text'][i])
|
176 |
+
_all[_sl]['output'].append(_dict['output'][i])
|
177 |
if len(_all.keys()):
|
178 |
all_keys = sorted(list(_all.keys()))
|
179 |
for i in range(len(all_keys)):
|
180 |
_sl = all_keys[i]
|
181 |
_sl_in_span = _sl.strip().replace("(", ",,").replace(")", "..").replace("[", ",,,").replace("]",
|
182 |
"...").replace(
|
183 |
+
special, "././").replace('\n', '/n')
|
184 |
# if _sl == '[]':
|
185 |
# st.text(_sl)
|
186 |
+
___sl = _sl.replace("\n", "/n")
|
187 |
+
_title = f'{i + 1}. <span id="{_sl_in_span}_{task}"> **:red[{___sl}]**</span>'
|
188 |
# with st.expander(_title, expanded=True):
|
189 |
_string = _title + '<br>Examples:<br>'
|
190 |
# st.markdown(_title, unsafe_allow_html=True)
|
|
|
209 |
_string += 'sentence 1**: :'
|
210 |
_string += f'red[{_all[_sl]["Replaced hypothesis"][j]}]'.replace(":", "[colon]")
|
211 |
if task == 'NLI':
|
212 |
+
_string += '<br> **Premise**: :'
|
213 |
elif task == 'QA':
|
214 |
+
_string += '<br> **Text**: :'
|
215 |
elif task == 'paraphrase':
|
216 |
+
_string += '<br> **Sentence 2**: :'
|
217 |
_string += f'blue[{_all[_sl]["Premise"][j]}]'.replace(":", "[colon]")
|
218 |
+
_string += "<br>**Model's prediction:** :" + f'blue[{_all[_sl]["output"][j]}]'.replace(":", "[colon]")
|
219 |
_string += '<br></li>'
|
220 |
_string += '</ol></blockquote>'
|
221 |
st.markdown(_string.replace('<s>', '\<s\>').replace('$', '\$').replace('~', '\~'),
|