Spaces:
Runtime error
Runtime error
EmreYY20
commited on
Commit
•
b87bcef
1
Parent(s):
2db0327
update
Browse files- app.py +11 -9
- extractive_model.py +1 -1
app.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
import streamlit as st
|
2 |
import PyPDF2
|
3 |
-
from extractive_model import
|
4 |
|
5 |
# Set page to wide mode
|
6 |
st.set_page_config(layout="wide")
|
@@ -27,7 +27,7 @@ def main():
|
|
27 |
|
28 |
# Middle column: Text input and File uploader
|
29 |
with col2:
|
30 |
-
user_input = st.
|
31 |
uploaded_file = st.file_uploader("Upload a PDF", type="pdf")
|
32 |
if st.button("Summarize"):
|
33 |
summary = ""
|
@@ -35,21 +35,23 @@ def main():
|
|
35 |
# Extract text from PDF
|
36 |
file_content = load_pdf(uploaded_file)
|
37 |
st.write("PDF uploaded successfully.")
|
38 |
-
|
39 |
-
|
40 |
-
summary = summarize_pdf_with_textrank(file_content)
|
41 |
-
else:
|
42 |
-
None
|
43 |
else:
|
44 |
st.write("Please upload a PDF or enter some text to summarize.")
|
|
|
|
|
|
|
|
|
|
|
45 |
|
46 |
st.session_state.summary = summary
|
47 |
|
48 |
# Right column: Displaying text after pressing 'Summarize'
|
49 |
with col3:
|
50 |
-
st.write("
|
51 |
if 'summary' in st.session_state:
|
52 |
st.write(st.session_state.summary)
|
53 |
|
54 |
if __name__ == "__main__":
|
55 |
-
main()
|
|
|
1 |
import streamlit as st
|
2 |
import PyPDF2
|
3 |
+
from extractive_model import summarize_text_with_textrank # Renamed function
|
4 |
|
5 |
# Set page to wide mode
|
6 |
st.set_page_config(layout="wide")
|
|
|
27 |
|
28 |
# Middle column: Text input and File uploader
|
29 |
with col2:
|
30 |
+
user_input = st.text_area("Enter your text here:")
|
31 |
uploaded_file = st.file_uploader("Upload a PDF", type="pdf")
|
32 |
if st.button("Summarize"):
|
33 |
summary = ""
|
|
|
35 |
# Extract text from PDF
|
36 |
file_content = load_pdf(uploaded_file)
|
37 |
st.write("PDF uploaded successfully.")
|
38 |
+
elif user_input:
|
39 |
+
file_content = user_input
|
|
|
|
|
|
|
40 |
else:
|
41 |
st.write("Please upload a PDF or enter some text to summarize.")
|
42 |
+
return
|
43 |
+
|
44 |
+
# Perform extractive summarization
|
45 |
+
if radio_selection == "Extractive":
|
46 |
+
summary = summarize_text_with_textrank(file_content)
|
47 |
|
48 |
st.session_state.summary = summary
|
49 |
|
50 |
# Right column: Displaying text after pressing 'Summarize'
|
51 |
with col3:
|
52 |
+
st.write("Summary:")
|
53 |
if 'summary' in st.session_state:
|
54 |
st.write(st.session_state.summary)
|
55 |
|
56 |
if __name__ == "__main__":
|
57 |
+
main()
|
extractive_model.py
CHANGED
@@ -15,7 +15,7 @@ from sumy.summarizers.text_rank import TextRankSummarizer
|
|
15 |
import nltk
|
16 |
nltk.download('punkt')
|
17 |
|
18 |
-
def
|
19 |
"""
|
20 |
Summarizes the provided text using TextRank algorithm.
|
21 |
|
|
|
15 |
import nltk
|
16 |
nltk.download('punkt')
|
17 |
|
18 |
+
def summarize_with_textrank(text, sentences_count=5):
|
19 |
"""
|
20 |
Summarizes the provided text using TextRank algorithm.
|
21 |
|