chmawia commited on
Commit
78064e5
·
verified ·
1 Parent(s): 522c85b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -7
app.py CHANGED
@@ -2,7 +2,6 @@ import streamlit as st
2
  import fitz # PyMuPDF
3
  import os
4
  import re
5
- from transformers import pipeline
6
 
7
  # Configure Streamlit page
8
  st.set_page_config(page_title="PDF Extractor", layout="centered")
@@ -45,11 +44,11 @@ def extract_text_from_pdf(pdf_path):
45
 
46
  return text.strip()
47
 
48
- # Function to generate a summary using an AI model
49
- def summarize_text(text):
50
- summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
51
- summary = summarizer(text, max_length=200, min_length=50, do_sample=False)
52
- return summary[0]['summary_text']
53
 
54
  # Function to extract only key points, MCQs, and important questions
55
  def extract_relevant_info(text):
@@ -97,7 +96,7 @@ if uploaded_file:
97
  # Perform selected task
98
  if task == "Summarize PDF":
99
  st.subheader("📖 Summary")
100
- summary = summarize_text(extracted_text)
101
  st.write(summary)
102
 
103
  elif task == "Generate MCQs, Key Points, and Important Questions":
 
2
  import fitz # PyMuPDF
3
  import os
4
  import re
 
5
 
6
  # Configure Streamlit page
7
  st.set_page_config(page_title="PDF Extractor", layout="centered")
 
44
 
45
  return text.strip()
46
 
47
+ # Function for simple text summarization (basic method)
48
+ def simple_summarize(text):
49
+ sentences = text.split(". ")
50
+ summary = ". ".join(sentences[:5]) # Take the first 5 sentences as a simple summary
51
+ return summary + "..." if len(sentences) > 5 else summary
52
 
53
  # Function to extract only key points, MCQs, and important questions
54
  def extract_relevant_info(text):
 
96
  # Perform selected task
97
  if task == "Summarize PDF":
98
  st.subheader("📖 Summary")
99
+ summary = simple_summarize(extracted_text)
100
  st.write(summary)
101
 
102
  elif task == "Generate MCQs, Key Points, and Important Questions":