Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
import streamlit as st
|
|
|
2 |
import PyPDF2
|
3 |
from extractive_summarization import summarize_with_textrank, summarize_with_lsa
|
4 |
from abstractive_summarization import summarize_with_bart_cnn, summarize_with_bart_ft, summarize_with_led, summarize_with_t5
|
@@ -6,6 +7,13 @@ from keyword_extraction import extract_keywords
|
|
6 |
from keyphrase_extraction import extract_sentences_with_obligations
|
7 |
#from blanc import BlancHelp
|
8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
# Set page to wide mode
|
10 |
st.set_page_config(layout="wide")
|
11 |
|
@@ -42,6 +50,10 @@ def main():
|
|
42 |
with col2:
|
43 |
user_input = st.text_area("Enter your text here:")
|
44 |
uploaded_file = st.file_uploader("Upload a PDF", type="pdf")
|
|
|
|
|
|
|
|
|
45 |
if st.button("Summarize"):
|
46 |
if uploaded_file and user_input:
|
47 |
st.warning("Please provide either text input or a PDF file, not both.")
|
@@ -52,8 +64,10 @@ def main():
|
|
52 |
st.write("PDF uploaded successfully.")
|
53 |
elif user_input:
|
54 |
file_content = user_input
|
|
|
|
|
55 |
else:
|
56 |
-
st.warning("Please upload a PDF
|
57 |
return
|
58 |
|
59 |
# Perform extractive summarization
|
|
|
1 |
import streamlit as st
|
2 |
+
from datasets import load_dataset
|
3 |
import PyPDF2
|
4 |
from extractive_summarization import summarize_with_textrank, summarize_with_lsa
|
5 |
from abstractive_summarization import summarize_with_bart_cnn, summarize_with_bart_ft, summarize_with_led, summarize_with_t5
|
|
|
7 |
from keyphrase_extraction import extract_sentences_with_obligations
|
8 |
#from blanc import BlancHelp
|
9 |
|
10 |
+
# Load in ToS
|
11 |
+
dataset = load_dataset("EE21/ToS-Summaries")
|
12 |
+
|
13 |
+
# Extract titles or identifiers for the ToS
|
14 |
+
tos_titles = [f"Document {i}" for i in range(len(dataset['train']))]
|
15 |
+
|
16 |
+
|
17 |
# Set page to wide mode
|
18 |
st.set_page_config(layout="wide")
|
19 |
|
|
|
50 |
with col2:
|
51 |
user_input = st.text_area("Enter your text here:")
|
52 |
uploaded_file = st.file_uploader("Upload a PDF", type="pdf")
|
53 |
+
|
54 |
+
# Dropdown for selecting the document
|
55 |
+
tos_selection_index = st.selectbox("Select Terms of Service Document", range(len(tos_titles)), format_func=lambda x: tos_titles[x])
|
56 |
+
|
57 |
if st.button("Summarize"):
|
58 |
if uploaded_file and user_input:
|
59 |
st.warning("Please provide either text input or a PDF file, not both.")
|
|
|
64 |
st.write("PDF uploaded successfully.")
|
65 |
elif user_input:
|
66 |
file_content = user_input
|
67 |
+
elif tos_selection_index is not None: # Assuming tos_selection_index won't be None
|
68 |
+
file_content = dataset['train'][tos_selection_index]['plain_text']
|
69 |
else:
|
70 |
+
st.warning("Please upload a PDF, enter some text, or select a document to summarize.")
|
71 |
return
|
72 |
|
73 |
# Perform extractive summarization
|