madankn79 commited on
Commit
6b9cd40
·
1 Parent(s): 2289b0c
Files changed (1) hide show
  1. app.py +5 -0
app.py CHANGED
@@ -92,6 +92,11 @@ def summarize_text(input_text, model_label, char_limit):
92
 
93
 
94
  summary = tokenizer.decode(summary_ids[0], skip_special_tokens=True)
 
 
 
 
 
95
  return summary[:char_limit].strip()
96
 
97
  # Gradio UI
 
92
 
93
 
94
  summary = tokenizer.decode(summary_ids[0], skip_special_tokens=True)
95
+
96
+ # Strip unwanted trailing spaces and punctuation
97
+ summary = summary.strip() # Remove leading and trailing spaces
98
+ summary = re.sub(r'[^\w\s]$', '', summary) # Remove trailing punctuation
99
+
100
  return summary[:char_limit].strip()
101
 
102
  # Gradio UI