File size: 1,534 Bytes
66c4554
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import streamlit as st
import json
import os


# 显示单个字典的信息
def display_dict(data):
    st.write("### 文件信息")
    st.write(f"**Path:** {data['paper_id']}")
    st.write(f"**Table ID:** {data['table_id']}")
    url = 'https://arxiv.org/pdf/'+data['paper_id'][0:10]+'.pdf'
    st.markdown(f"**🔗 URL:** [View Paper]({url})")

    st.write("### Descriptive Questions & Answers")
    st.markdown(f"**Q1:** {data['Descriptive_question1']}")
    st.markdown(f"**A1:** {data['Descriptive_answer1']}")
    st.markdown(f"**Q2:** {data['Descriptive_question2']}")
    st.markdown(f"**A2:** {data['Descriptive_answer2']}")

    st.write("### Reasoning Questions & Answers")
    st.markdown(f"**Q1:** {data['Reasoning_question1']}")
    st.markdown(f"**A1:** {data['Reasoning_answer1']}")
    st.markdown(f"**Q2:** {data['Reasoning_question2']}")
    st.markdown(f"**A2:** {data['Reasoning_answer2']}")


# 主程序
def main():
    st.title("Example For Table")

    with open('2-table_res.json', "r", encoding="utf-8") as f:
        data = json.load(f)
    file_dict = {}
    for idx,item in enumerate(data):
        file_dict[item['paper_id'][0:10]+'_'+item['table_id']] = idx
    file_list = list(file_dict.keys())
    # 搜索框选择文件
    selected_file = st.selectbox("选择一个文件", file_list)

    # 加载并展示JSON内容
    if selected_file:
        st.write(f"当前选择文件: **{selected_file}**")
        display_dict(data[file_dict[selected_file]])

if __name__ == "__main__":
    main()