Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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
|
| 49 |
-
def
|
| 50 |
-
|
| 51 |
-
summary =
|
| 52 |
-
return summary
|
| 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 =
|
| 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":
|