EE21 commited on
Commit
6f4ddaf
1 Parent(s): 845351c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -0
app.py CHANGED
@@ -7,6 +7,10 @@ from extractive_summarization import summarize_with_textrank, summarize_with_lsa
7
  from abstractive_summarization import summarize_with_bart_cnn, summarize_with_bart_ft, summarize_with_led, summarize_with_t5
8
  from keyword_extraction import extract_keywords
9
  from keyphrase_extraction import extract_sentences_with_obligations
 
 
 
 
10
  #from blanc import BlancHelp
11
 
12
  # Load in ToS
@@ -119,6 +123,16 @@ def main():
119
  if 'summary' in st.session_state:
120
  st.write(st.session_state.summary)
121
 
 
 
 
 
 
 
 
 
 
 
122
  # Check if no PDF or text input is provided and a ToS document is selected
123
  if not uploaded_file and not user_input and tos_selection_index is not None and 'summary' in dataset['train'][tos_selection_index]:
124
  # Fetch the reference summary
 
7
  from abstractive_summarization import summarize_with_bart_cnn, summarize_with_bart_ft, summarize_with_led, summarize_with_t5
8
  from keyword_extraction import extract_keywords
9
  from keyphrase_extraction import extract_sentences_with_obligations
10
+ from wordcloud import WordCloud
11
+ import matplotlib.pyplot as plt
12
+ from PIL import Image
13
+ import io
14
  #from blanc import BlancHelp
15
 
16
  # Load in ToS
 
123
  if 'summary' in st.session_state:
124
  st.write(st.session_state.summary)
125
 
126
+ # Generate and display word cloud
127
+ wordcloud = WordCloud(width=800, height=400, background_color='white').generate(st.session_state.summary)
128
+ # Convert to PIL Image
129
+ image = wordcloud.to_image()
130
+ # Convert PIL Image to bytes
131
+ buf = io.BytesIO()
132
+ image.save(buf, format='PNG')
133
+ byte_im = buf.getvalue()
134
+ st.image(byte_im, caption='Word Cloud of Summary', use_column_width=True)
135
+
136
  # Check if no PDF or text input is provided and a ToS document is selected
137
  if not uploaded_file and not user_input and tos_selection_index is not None and 'summary' in dataset['train'][tos_selection_index]:
138
  # Fetch the reference summary