EE21 commited on
Commit
71f1303
1 Parent(s): 2d2d28b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -11,7 +11,7 @@ from keyphrase_extraction import extract_sentences_with_obligations
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
@@ -52,10 +52,10 @@ def main():
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.")
60
  return
61
  elif uploaded_file:
@@ -64,7 +64,8 @@ def main():
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.")
 
11
  dataset = load_dataset("EE21/ToS-Summaries")
12
 
13
  # Extract titles or identifiers for the ToS
14
+ tos_titles = ["None"] + [f"Document {i}" for i in range(len(dataset['train']))]
15
 
16
 
17
  # Set page to wide mode
 
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 a 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 and tos_selection_index:
59
  st.warning("Please provide either text input or a PDF file, not both.")
60
  return
61
  elif uploaded_file:
 
64
  st.write("PDF uploaded successfully.")
65
  elif user_input:
66
  file_content = user_input
67
+ elif tos_selection != "None":
68
+ tos_selection_index = tos_titles.index(tos_selection) - 1 # Adjust for the added 'None' option
69
  file_content = dataset['train'][tos_selection_index]['plain_text']
70
  else:
71
  st.warning("Please upload a PDF, enter some text, or select a document to summarize.")