File size: 2,377 Bytes
93c008b
50a43ab
 
 
93c008b
50a43ab
93c008b
50a43ab
 
 
 
 
f1e5728
93c008b
50a43ab
 
f1e5728
50a43ab
 
 
 
 
 
f1e5728
50a43ab
 
 
 
 
 
 
 
 
 
 
93c008b
50a43ab
93c008b
50a43ab
 
 
 
93c008b
 
50a43ab
93c008b
50a43ab
f1e5728
50a43ab
 
 
 
93c008b
50a43ab
 
 
 
 
 
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import streamlit as st
from textsumm import 摘要
from pdfsum import pdf摘要
from papersearch import 論文搜尋

st.set_page_config(page_title="PDF 工具箱 (中文)", page_icon=":books:", layout="wide")

st.sidebar.title("📑 PDF 工具箱")
功能 = st.sidebar.radio(
    "請選擇功能",
    ["文字摘要", "PDF 摘要", "論文搜尋(arXiv)"],
    index=0
)

st.sidebar.markdown("---")
st.sidebar.markdown("本應用支援中文摘要(Pegasus 中文模型)")

if 功能 == "文字摘要":
    st.header("📝 文字摘要")
    text = st.text_area("請輸入要摘要的文字")
    if st.button("生成摘要"):
        with st.spinner("AI 生成中..."):
            summary = 摘要(text)
        st.subheader("摘要結果")
        st.success(summary)

elif 功能 == "PDF 摘要":
    st.header("📄 PDF 摘要")
    pdf_file = st.file_uploader("請上傳 PDF 檔案", type=["pdf"])
    if st.button("產生 PDF 摘要"):
        if pdf_file is not None:
            with st.spinner("AI 解析中..."):
                summary = pdf摘要(pdf_file)
            st.subheader("PDF 摘要結果")
            st.success(summary)
        else:
            st.warning("請先上傳 PDF 檔案")

elif 功能 == "論文搜尋(arXiv)":
    st.header("🔎 論文搜尋(arXiv)")
    關鍵字 = st.text_input("輸入主題或關鍵字")
    max_results = st.slider("結果數量", 1, 30, 10)
    col1, col2 = st.columns(2)
    with col1:
        start_year = st.number_input("起始年份", min_value=1991, max_value=2025, value=2011)
    with col2:
        end_year = st.number_input("結束年份", min_value=1991, max_value=2025, value=2025)
    if st.button("搜尋論文"):
        with st.spinner("搜尋中..."):
            papers = 論文搜尋(關鍵字, max_results, start_year, end_year)
        if not papers:
            st.info("在所選年份範圍內沒有找到相關論文。")
        else:
            for idx, p in enumerate(papers, 1):
                with st.expander(f"📄 {idx}. {p['標題']}"):
                    st.write(f"**作者:** {p['作者']}")
                    st.write(f"**發表日期:** {p['發表日期']}")
                    st.write(f"**摘要:** {p['摘要']}")
                    st.write(f"[arXiv 連結]({p['arXiv 連結']})")