Update app.py
Browse files
app.py
CHANGED
|
@@ -222,46 +222,62 @@ for i in combined_words_list[0]:
|
|
| 222 |
# highlighted_sentences = []
|
| 223 |
|
| 224 |
|
| 225 |
-
def highlight_text(text, substrings):
|
| 226 |
-
|
| 227 |
-
|
| 228 |
-
|
| 229 |
-
|
| 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 = 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 |
-
|
| 244 |
-
|
| 245 |
-
|
| 246 |
|
| 247 |
|
| 248 |
|
| 249 |
# Assuming you have defined common_substrings and remove_overlapping functions
|
| 250 |
|
| 251 |
-
|
| 252 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 253 |
|
| 254 |
-
|
| 255 |
-
|
| 256 |
-
|
| 257 |
|
| 258 |
-
|
| 259 |
|
| 260 |
# for substring in highlighted_text:
|
| 261 |
# st.write(substring)
|
| 262 |
|
| 263 |
-
|
| 264 |
-
|
| 265 |
|
| 266 |
|
| 267 |
|
|
|
|
| 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
|
| 232 |
|
| 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
|
| 250 |
|
| 251 |
+
highlighted_sentence = main_sentence
|
| 252 |
+
highlighted_text = []
|
| 253 |
+
|
| 254 |
+
for substring in remove_overlapping(common_substrings):
|
| 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 |
+
highlighted_sentence = paraphrases[0]
|
| 268 |
+
highlighted_text = []
|
| 269 |
|
| 270 |
+
for substring in combined_words_list[0]:
|
| 271 |
+
highlighted_sentence = highlighted_sentence.replace(substring, f'<span style="background-color: blue; color: white;">{substring}</span>')
|
| 272 |
+
highlighted_text.append(substring)
|
| 273 |
|
| 274 |
+
st.markdown("Common substrings between main_sentence and Paraphrase1:")
|
| 275 |
|
| 276 |
# for substring in highlighted_text:
|
| 277 |
# st.write(substring)
|
| 278 |
|
| 279 |
+
st.markdown("\nHighlighted Main Sentence with LCS:")
|
| 280 |
+
st.write(highlighted_sentence, unsafe_allow_html=True)
|
| 281 |
|
| 282 |
|
| 283 |
|