File size: 1,450 Bytes
c289504
 
 
 
 
863c57b
c289504
 
 
 
 
 
 
4668109
 
 
 
 
c289504
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0c39d40
c289504
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
import streamlit as st
from main import read_pdf, extract_key_phrases, score_sentences, summarize_text
import io

# Initialize your Streamlit app
st.title("PDF to Bullet Point Summarizer πŸ—Ÿ πŸ”")

# File uploader for the PDF
uploaded_file = st.file_uploader("Upload your PDF document", type="pdf")

# Slider for users to select the summarization extent
summary_scale = st.slider("Select the extent of summarization (%)", min_value=1, max_value=100, value=20)

# Submit button
submit_button = st.button("Generate Summary")

# Check if the submit button is pressed
if submit_button and uploaded_file is not None:
    with st.spinner('Processing...'):
        # Read the PDF content
        text = read_pdf(io.BytesIO(uploaded_file.getvalue()))
        
        # Extract key phrases from the text
        key_phrases = extract_key_phrases(text)
        
        # Score sentences based on the key phrases
        sentence_scores = score_sentences(text, key_phrases)
        
        # Determine the number of bullet points based on the selected summarization scale
        total_sentences = len(list(sentence_scores.keys()))
        num_points = max(1, total_sentences * summary_scale // 100)
        
        # Generate the bullet-point summary
        summary = summarize_text(sentence_scores, num_points=num_points)
        
        # Display the summary as bullet points
        st.subheader("Here's the summary: ")
        st.markdown(summary)