Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -228,9 +228,9 @@ def get_base_path():
|
|
| 228 |
def get_path():
|
| 229 |
return f"{get_base_path()}/{st.session_state.current_index}.json"
|
| 230 |
|
| 231 |
-
def display_dialogue(
|
| 232 |
-
|
| 233 |
-
st.code(
|
| 234 |
#st.markdown(
|
| 235 |
# f"<details><summary><b>Annotation Guidelines</b></summary><div>{dialogue_text}</div></details><br>",
|
| 236 |
#unsafe_allow_html=True)
|
|
@@ -289,8 +289,8 @@ def show_field(f: Field, index: int, data_collected):
|
|
| 289 |
if f.name == 'image_name':
|
| 290 |
display_image(os.path.join(input_repo_path, 'images', value))
|
| 291 |
elif f.name == 'dialogue_name':
|
| 292 |
-
|
| 293 |
-
display_dialogue(os.path.join(input_repo_path, value))
|
| 294 |
else:
|
| 295 |
st.write(value)
|
| 296 |
case 'markdown':
|
|
@@ -508,10 +508,13 @@ def add_checked_submit():
|
|
| 508 |
check = st.checkbox('I agree', key='consent')
|
| 509 |
add_validated_submit([check], "Please agree to give your consent to proceed")
|
| 510 |
|
| 511 |
-
def load_text(
|
| 512 |
-
|
| 513 |
-
|
| 514 |
-
|
|
|
|
|
|
|
|
|
|
| 515 |
|
| 516 |
if st.session_state.current_index == -2:
|
| 517 |
with st.form("data_form"):
|
|
|
|
| 228 |
def get_path():
|
| 229 |
return f"{get_base_path()}/{st.session_state.current_index}.json"
|
| 230 |
|
| 231 |
+
def display_dialogue(hf_path: str):
|
| 232 |
+
txt = load_text(hf_path)
|
| 233 |
+
st.code(txt, language="markdown", line_numbers=True)
|
| 234 |
#st.markdown(
|
| 235 |
# f"<details><summary><b>Annotation Guidelines</b></summary><div>{dialogue_text}</div></details><br>",
|
| 236 |
#unsafe_allow_html=True)
|
|
|
|
| 289 |
if f.name == 'image_name':
|
| 290 |
display_image(os.path.join(input_repo_path, 'images', value))
|
| 291 |
elif f.name == 'dialogue_name':
|
| 292 |
+
display_dialogue(os.path.join(input_repo_path, 'dialogues', value))
|
| 293 |
+
#display_dialogue(os.path.join(input_repo_path, value))
|
| 294 |
else:
|
| 295 |
st.write(value)
|
| 296 |
case 'markdown':
|
|
|
|
| 508 |
check = st.checkbox('I agree', key='consent')
|
| 509 |
add_validated_submit([check], "Please agree to give your consent to proceed")
|
| 510 |
|
| 511 |
+
def load_text(path: str) -> str:
|
| 512 |
+
if filesystem == 'hf':
|
| 513 |
+
with hf_fs.open(path, "rb") as f:
|
| 514 |
+
return f.read().decode("utf-8")
|
| 515 |
+
else:
|
| 516 |
+
with open(path, "r", encoding="utf-8") as f:
|
| 517 |
+
return f.read()
|
| 518 |
|
| 519 |
if st.session_state.current_index == -2:
|
| 520 |
with st.form("data_form"):
|