File size: 1,818 Bytes
c0ae847
57f2e36
 
 
 
c0ae847
57f2e36
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import streamlit as st
import pandas as pd
import PyPDF2
import base64
from summarizer import bert_summarizer, simple_summarizer

summarizer = bert_summarizer

# Set page to wide mode
st.set_page_config(layout="wide")

# Function to handle file upload and return its content
def load_pdf(file):
    pdf_reader = PyPDF2.PdfReader(file)
    pdf_text = ""
    for page_num in range(len(pdf_reader.pages)):
        pdf_text += pdf_reader.pages[page_num].extract_text()
    return pdf_text

# Main app
def main():

    st.title("Streamlit App")

    # Layout: 3 columns
    col1, col2, col3 = st.columns([1, 3, 2], gap="large")

    # Left column: Dropdown menu
    with col1:
        dropdown_options = ['Abstractive', 'Extractive']
        dropdown_selection = st.selectbox("Choose type of summerizer:", dropdown_options)

    # Middle column: Text input and File uploader
    with col2:
        user_input = st.text_input("Enter your text here:")
        uploaded_file = st.file_uploader("Upload a PDF", type="pdf")
        if st.button("Summarize"):
            # Handling file upload
            if uploaded_file is not None:
                file_content = load_pdf(uploaded_file)
                st.write("PDF uploaded successfully.")
                # summary = summarizer(file_content)
                summary = file_content
            elif user_input is not None:
                # summary = summarizer(user_input)
                summary = user_input
            else:
                st.wirte("Upload a PDF or put in your text!")
            st.session_state.summary = summary

    # Right column: Displaying text after pressing 'Summarize'
    with col3:
        st.write("Output:")
        if 'summary' in st.session_state:
            st.write(st.session_state.summary)

if __name__ == "__main__":
    main()