Spaces:
Sleeping
Sleeping
linbojunzi
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -45,36 +45,31 @@ def load_json(file_name):
|
|
45 |
# 修改 Context 渲染逻辑,添加 CSS 控制布局
|
46 |
def display_dict(data):
|
47 |
st.write("### 文件信息")
|
48 |
-
st.write(f"**Path:** {data['path']}")
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
else:
|
74 |
-
highlighted_context += f"<p>{sentence}</p> "
|
75 |
-
highlighted_context += '</div>'
|
76 |
-
st.markdown(highlighted_context, unsafe_allow_html=True)
|
77 |
-
|
78 |
st.write("### Selected Paragraphs")
|
79 |
for paragraph in data["selected_paragraphs"]:
|
80 |
st.write(paragraph)
|
@@ -85,6 +80,7 @@ def display_dict(data):
|
|
85 |
st.write("**Perturbed Explanation:**")
|
86 |
st.write(data["output"]["perturbed_explanation"])
|
87 |
|
|
|
88 |
# 主程序
|
89 |
def main():
|
90 |
st.title("Perturb For Table")
|
|
|
45 |
# 修改 Context 渲染逻辑,添加 CSS 控制布局
|
46 |
def display_dict(data):
|
47 |
st.write("### 文件信息")
|
48 |
+
st.write(f"**Path:** {data['path']} | **Table ID:** {data['table_id']} | **Section:** {data['section']}")
|
49 |
+
|
50 |
+
# 使用两个列来分隔内容
|
51 |
+
col1, col2 = st.columns(2)
|
52 |
+
|
53 |
+
with col1:
|
54 |
+
st.write("### Table")
|
55 |
+
st.markdown(data['table_html'], unsafe_allow_html=True)
|
56 |
+
|
57 |
+
with col2:
|
58 |
+
st.write("### Context")
|
59 |
+
# 拼接 all_context,并高亮特定部分
|
60 |
+
all_context = data["all_context"]
|
61 |
+
highlighted_context = '<div class="context">'
|
62 |
+
for idx, sentence in enumerate(all_context):
|
63 |
+
if idx == data["perturb_sentence_id"]:
|
64 |
+
highlighted_context += f"<span style='color:red;'>{sentence}</span> "
|
65 |
+
elif idx in data["target_context_ids"]:
|
66 |
+
highlighted_context += f"<b>{sentence}</b> "
|
67 |
+
else:
|
68 |
+
highlighted_context += sentence + " "
|
69 |
+
highlighted_context += '</div>'
|
70 |
+
st.markdown(highlighted_context, unsafe_allow_html=True)
|
71 |
+
|
72 |
+
# 单独分离的内容
|
|
|
|
|
|
|
|
|
|
|
73 |
st.write("### Selected Paragraphs")
|
74 |
for paragraph in data["selected_paragraphs"]:
|
75 |
st.write(paragraph)
|
|
|
80 |
st.write("**Perturbed Explanation:**")
|
81 |
st.write(data["output"]["perturbed_explanation"])
|
82 |
|
83 |
+
|
84 |
# 主程序
|
85 |
def main():
|
86 |
st.title("Perturb For Table")
|