Spaces:
Sleeping
Sleeping
wcy
commited on
Update app.py
Browse files
app.py
CHANGED
|
@@ -12,26 +12,57 @@ def load_json(file_name):
|
|
| 12 |
return json.load(f)
|
| 13 |
|
| 14 |
# 显示单个字典的信息
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
def display_dict(data):
|
| 16 |
st.write("### 文件信息")
|
| 17 |
st.write(f"**Path:** {data['path']}")
|
| 18 |
st.write(f"**Table ID:** {data['table_id']}")
|
| 19 |
st.write(f"**Section:** {data['section']}")
|
|
|
|
| 20 |
st.write("### Table")
|
| 21 |
st.markdown(data['table_html'], unsafe_allow_html=True)
|
| 22 |
|
| 23 |
-
st.
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
st.markdown(highlighted_context, unsafe_allow_html=True)
|
| 35 |
|
| 36 |
st.write("### Selected Paragraphs")
|
| 37 |
for paragraph in data["selected_paragraphs"]:
|
|
@@ -44,7 +75,6 @@ def display_dict(data):
|
|
| 44 |
st.write(data["output"]["perturbed_explanation"])
|
| 45 |
|
| 46 |
|
| 47 |
-
|
| 48 |
# 主程序
|
| 49 |
def main():
|
| 50 |
st.title("Perturb For Table")
|
|
|
|
| 12 |
return json.load(f)
|
| 13 |
|
| 14 |
# 显示单个字典的信息
|
| 15 |
+
# def display_dict(data):
|
| 16 |
+
# st.write("### 文件信息")
|
| 17 |
+
# st.write(f"**Path:** {data['path']}")
|
| 18 |
+
# st.write(f"**Table ID:** {data['table_id']}")
|
| 19 |
+
# st.write(f"**Section:** {data['section']}")
|
| 20 |
+
# st.write("### Table")
|
| 21 |
+
# st.markdown(data['table_html'], unsafe_allow_html=True)
|
| 22 |
+
|
| 23 |
+
# st.write("### Context")
|
| 24 |
+
# # 拼接 all_context 并高亮 target_context_ids 的句子
|
| 25 |
+
# all_context = data["all_context"]
|
| 26 |
+
# highlighted_context = ""
|
| 27 |
+
# for idx, sentence in enumerate(all_context):
|
| 28 |
+
# if idx == data["perturb_sentence_id"]:
|
| 29 |
+
# highlighted_context += f"<span style='color:red;'>{sentence}</span> "
|
| 30 |
+
# elif idx in data["target_context_ids"]:
|
| 31 |
+
# highlighted_context += f"**{sentence}** "
|
| 32 |
+
# else:
|
| 33 |
+
# highlighted_context += sentence + " "
|
| 34 |
+
# st.markdown(highlighted_context, unsafe_allow_html=True)
|
| 35 |
+
|
| 36 |
+
# st.write("### Selected Paragraphs")
|
| 37 |
+
# for paragraph in data["selected_paragraphs"]:
|
| 38 |
+
# st.write(paragraph)
|
| 39 |
+
|
| 40 |
+
# st.write("### Output")
|
| 41 |
+
# st.write("**Perturbed Statement:**")
|
| 42 |
+
# st.write(data["output"]["perturbed_statement"])
|
| 43 |
+
# st.write("**Perturbed Explanation:**")
|
| 44 |
+
# st.write(data["output"]["perturbed_explanation"])
|
| 45 |
+
|
| 46 |
def display_dict(data):
|
| 47 |
st.write("### 文件信息")
|
| 48 |
st.write(f"**Path:** {data['path']}")
|
| 49 |
st.write(f"**Table ID:** {data['table_id']}")
|
| 50 |
st.write(f"**Section:** {data['section']}")
|
| 51 |
+
|
| 52 |
st.write("### Table")
|
| 53 |
st.markdown(data['table_html'], unsafe_allow_html=True)
|
| 54 |
|
| 55 |
+
with st.expander("Context Details"):
|
| 56 |
+
all_context = data["all_context"]
|
| 57 |
+
highlighted_context = ""
|
| 58 |
+
for idx, sentence in enumerate(all_context):
|
| 59 |
+
if idx == data["perturb_sentence_id"]:
|
| 60 |
+
highlighted_context += f"<span style='color:red;'>{sentence}</span> "
|
| 61 |
+
elif idx in data["target_context_ids"]:
|
| 62 |
+
highlighted_context += f"**{sentence}** "
|
| 63 |
+
else:
|
| 64 |
+
highlighted_context += sentence + " "
|
| 65 |
+
st.markdown(highlighted_context, unsafe_allow_html=True)
|
|
|
|
| 66 |
|
| 67 |
st.write("### Selected Paragraphs")
|
| 68 |
for paragraph in data["selected_paragraphs"]:
|
|
|
|
| 75 |
st.write(data["output"]["perturbed_explanation"])
|
| 76 |
|
| 77 |
|
|
|
|
| 78 |
# 主程序
|
| 79 |
def main():
|
| 80 |
st.title("Perturb For Table")
|