Spaces:
Build error
Build error
Regino commited on
Commit ·
021c961
1
Parent(s): 9668feb
fbng
Browse files
app.py
CHANGED
|
@@ -1,8 +1,4 @@
|
|
| 1 |
import nltk
|
| 2 |
-
|
| 3 |
-
# Ensure the necessary tokenizer is downloaded
|
| 4 |
-
nltk.download("punkt_tab")
|
| 5 |
-
|
| 6 |
import streamlit as st
|
| 7 |
import fitz # PyMuPDF for PDF extraction
|
| 8 |
import re
|
|
@@ -11,6 +7,8 @@ from sumy.nlp.tokenizers import Tokenizer
|
|
| 11 |
from sumy.summarizers.lsa import LsaSummarizer
|
| 12 |
from rouge_score import rouge_scorer # For ROUGE score evaluation
|
| 13 |
|
|
|
|
|
|
|
| 14 |
|
| 15 |
# Function to extract text from PDF
|
| 16 |
def extract_text_from_pdf(uploaded_file):
|
|
@@ -84,11 +82,12 @@ if st.sidebar.button("Summarize"):
|
|
| 84 |
st.sidebar.error("Please upload a file or enter text.")
|
| 85 |
st.stop()
|
| 86 |
|
| 87 |
-
#
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
|
|
|
| 92 |
|
| 93 |
# Display summary in justified format
|
| 94 |
st.subheader("📌 Summarized Text")
|
|
|
|
| 1 |
import nltk
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
import streamlit as st
|
| 3 |
import fitz # PyMuPDF for PDF extraction
|
| 4 |
import re
|
|
|
|
| 7 |
from sumy.summarizers.lsa import LsaSummarizer
|
| 8 |
from rouge_score import rouge_scorer # For ROUGE score evaluation
|
| 9 |
|
| 10 |
+
# Ensure the necessary tokenizer is downloaded
|
| 11 |
+
nltk.download("punkt_tab")
|
| 12 |
|
| 13 |
# Function to extract text from PDF
|
| 14 |
def extract_text_from_pdf(uploaded_file):
|
|
|
|
| 82 |
st.sidebar.error("Please upload a file or enter text.")
|
| 83 |
st.stop()
|
| 84 |
|
| 85 |
+
# Show loading animation
|
| 86 |
+
with st.spinner("Summarizing text... Please wait."):
|
| 87 |
+
# Generate summary
|
| 88 |
+
summary = summarize_text(text, num_sentences=5)
|
| 89 |
+
# Calculate ROUGE score
|
| 90 |
+
rouge1, rouge2, rougeL = calculate_rouge(text, summary)
|
| 91 |
|
| 92 |
# Display summary in justified format
|
| 93 |
st.subheader("📌 Summarized Text")
|