Update app.py
Browse files
app.py
CHANGED
@@ -222,10 +222,10 @@ for i in combined_words_list[0]:
|
|
222 |
# highlighted_sentences = []
|
223 |
|
224 |
|
225 |
-
def highlight_text(text, substrings
|
226 |
highlighted_text = text
|
227 |
-
for substring in substrings:
|
228 |
-
highlighted_text = highlighted_text.replace(substring, f'<span style="background-color: {
|
229 |
return highlighted_text
|
230 |
|
231 |
# Assuming you have main_sentence, paraphrases, and common_substrings defined
|
@@ -233,20 +233,17 @@ def highlight_text(text, substrings, color):
|
|
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
|
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
|
@@ -258,13 +255,13 @@ for i, (paraphrase, common_substring) in enumerate(zip(paraphrases, common_subst
|
|
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 |
|
270 |
|
|
|
222 |
# highlighted_sentences = []
|
223 |
|
224 |
|
225 |
+
def highlight_text(text, substrings):
|
226 |
highlighted_text = text
|
227 |
+
for i, substring in enumerate(substrings):
|
228 |
+
highlighted_text = highlighted_text.replace(substring, f'<span style="background-color: {colors[i]}; color: white;">{substring}</span>')
|
229 |
return highlighted_text
|
230 |
|
231 |
# Assuming you have main_sentence, paraphrases, and common_substrings defined
|
|
|
233 |
colors = ['blue', 'green', 'orange', 'purple', 'red'] # Different colors for each paraphrase
|
234 |
|
235 |
# Highlight main_sentence
|
236 |
+
highlighted_main_sentence = highlight_text(main_sentence, common_substrings[0])
|
|
|
|
|
237 |
|
238 |
st.markdown("\nHighlighted Main Sentence:")
|
239 |
st.write(highlighted_main_sentence, unsafe_allow_html=True)
|
240 |
|
241 |
# Highlight paraphrases
|
242 |
+
for i, (paraphrase, common_substring) in enumerate(zip(paraphrases, common_substrings[1:])):
|
243 |
+
highlighted_paraphrase = highlight_text(paraphrase, common_substring)
|
244 |
st.markdown(f"\nHighlighted Paraphrase {i+1}:")
|
245 |
st.write(highlighted_paraphrase, unsafe_allow_html=True)
|
246 |
|
|
|
247 |
|
248 |
|
249 |
# Assuming you have defined common_substrings and remove_overlapping functions
|
|
|
255 |
# highlighted_sentence = highlighted_sentence.replace(substring, f'<span style="background-color: blue; color: white;">{substring}</span>')
|
256 |
# highlighted_text.append(substring)
|
257 |
|
258 |
+
# st.markdown("Common substrings that occur in all five lists:")
|
259 |
|
260 |
# for substring in highlighted_text:
|
261 |
# st.write(substring)
|
262 |
|
263 |
+
# st.markdown("\nHighlighted Main Sentence with LCS:")
|
264 |
+
# st.write(highlighted_sentence, unsafe_allow_html=True)
|
265 |
|
266 |
|
267 |
|