Towhidul commited on
Commit
e71d1b8
1 Parent(s): 364e025

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -3
app.py CHANGED
@@ -140,7 +140,19 @@ def find_longest_match(string1, string2):
140
 
141
  return longest_match
142
 
143
-
 
 
 
 
 
 
 
 
 
 
 
 
144
 
145
 
146
  prompt_list=["The official position of the United States on the Russia-Ukraine war has been consistent in supporting Ukraine's sovereignty, territorial integrity, and the peaceful resolution of the conflict."
@@ -259,7 +271,7 @@ for i in combined_words_list[0]:
259
 
260
  # Assuming you have defined common_substrings and remove_overlapping functions
261
 
262
- highlighted_sentence = main_sentence
263
  highlighted_text = []
264
 
265
  for substring in remove_overlapping(common_substrings):
@@ -281,7 +293,7 @@ highlighted_sentence_list = []
281
  colors = ['blue', 'green', 'orange', 'purple', 'red']
282
 
283
  for i in range(0, 5):
284
- highlighted_sentence = paraphrases[i]
285
  highlighted_text = []
286
 
287
  # Assign a unique color to each paraphrase
 
140
 
141
  return longest_match
142
 
143
+ def remove_spaces_before_punctuation(text):
144
+ import string
145
+ punctuation = string.punctuation
146
+ result = ""
147
+ for i, char in enumerate(text):
148
+ if i == 0:
149
+ result += char
150
+ else:
151
+ if char in punctuation and text[i-1] == " ":
152
+ result = result[:-1] + char
153
+ else:
154
+ result += char
155
+ return result
156
 
157
 
158
  prompt_list=["The official position of the United States on the Russia-Ukraine war has been consistent in supporting Ukraine's sovereignty, territorial integrity, and the peaceful resolution of the conflict."
 
271
 
272
  # Assuming you have defined common_substrings and remove_overlapping functions
273
 
274
+ highlighted_sentence = remove_spaces_before_punctuation(" ".join(tokenize(main_sentence)))
275
  highlighted_text = []
276
 
277
  for substring in remove_overlapping(common_substrings):
 
293
  colors = ['blue', 'green', 'orange', 'purple', 'red']
294
 
295
  for i in range(0, 5):
296
+ highlighted_sentence = remove_spaces_before_punctuation(" ".join(tokenize(paraphrases[i])))
297
  highlighted_text = []
298
 
299
  # Assign a unique color to each paraphrase