Towhidul commited on
Commit
1752274
·
verified ·
1 Parent(s): fc87f2b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -6
app.py CHANGED
@@ -221,8 +221,33 @@ for i in combined_words_list[0]:
221
  # color_palette = ["#FF0000", "#008000", "#0000FF", "#FF00FF", "#00FFFF"]
222
  # highlighted_sentences = []
223
 
224
-
225
- import streamlit as st
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
226
 
227
  # Assuming you have defined common_substrings and remove_overlapping functions
228
 
@@ -233,12 +258,12 @@ for substring in remove_overlapping(common_substrings):
233
  highlighted_sentence = highlighted_sentence.replace(substring, f'<span style="background-color: blue; color: white;">{substring}</span>')
234
  highlighted_text.append(substring)
235
 
236
- st.markdown("Common substrings that occur in all five lists:")
237
 
238
- for substring in highlighted_text:
239
- st.write(substring)
240
 
241
- st.markdown("\nHighlighted Main Sentence:")
242
  st.write(highlighted_sentence, unsafe_allow_html=True)
243
 
244
 
 
221
  # color_palette = ["#FF0000", "#008000", "#0000FF", "#FF00FF", "#00FFFF"]
222
  # highlighted_sentences = []
223
 
224
+
225
+ def highlight_text(text, substrings, color):
226
+ highlighted_text = text
227
+ for substring in substrings:
228
+ highlighted_text = highlighted_text.replace(substring, f'<span style="background-color: {color}; color: white;">{substring}</span>')
229
+ return highlighted_text
230
+
231
+ # Assuming you have main_sentence, paraphrases, and common_substrings defined
232
+
233
+ colors = ['blue', 'green', 'orange', 'purple', 'red'] # Different colors for each paraphrase
234
+
235
+ # Highlight main_sentence
236
+ highlighted_main_sentence = main_sentence
237
+ for i, common_substring in enumerate(common_substrings):
238
+ highlighted_main_sentence = highlight_text(highlighted_main_sentence, common_substring, colors[i])
239
+
240
+ st.markdown("\nHighlighted Main Sentence:")
241
+ st.write(highlighted_main_sentence, unsafe_allow_html=True)
242
+
243
+ # Highlight paraphrases
244
+ for i, (paraphrase, common_substring) in enumerate(zip(paraphrases, common_substrings)):
245
+ highlighted_paraphrase = highlight_text(paraphrase, common_substring, colors[i])
246
+ st.markdown(f"\nHighlighted Paraphrase {i+1}:")
247
+ st.write(highlighted_paraphrase, unsafe_allow_html=True)
248
+
249
+
250
+
251
 
252
  # Assuming you have defined common_substrings and remove_overlapping functions
253
 
 
258
  highlighted_sentence = highlighted_sentence.replace(substring, f'<span style="background-color: blue; color: white;">{substring}</span>')
259
  highlighted_text.append(substring)
260
 
261
+ #st.markdown("Common substrings that occur in all five lists:")
262
 
263
+ # for substring in highlighted_text:
264
+ # st.write(substring)
265
 
266
+ st.markdown("\nHighlighted Main Sentence with LCS:")
267
  st.write(highlighted_sentence, unsafe_allow_html=True)
268
 
269