sashtech commited on
Commit
9b2901c
·
verified ·
1 Parent(s): dd84c16

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -3
app.py CHANGED
@@ -68,10 +68,17 @@ def capitalize_sentences_and_nouns(text):
68
  return ' '.join(corrected_text)
69
 
70
  # Function to force capitalization of the first letter of every sentence
 
71
  def force_first_letter_capital(text):
72
- sentences = text.split(". ")
73
- capitalized_sentences = [sentence[0].capitalize() + sentence[1:] if sentence else "" for sentence in sentences]
74
- return ". ".join(capitalized_sentences)
 
 
 
 
 
 
75
 
76
  # Function to correct tense errors in a sentence
77
  def correct_tense_errors(text):
 
68
  return ' '.join(corrected_text)
69
 
70
  # Function to force capitalization of the first letter of every sentence
71
+ # Function to force capitalization of the first letter of every sentence and add missing full stops
72
  def force_first_letter_capital(text):
73
+ sentences = re.split(r'(?<=[.!?])\s+', text) # Split on sentence-ending punctuation followed by space
74
+ capitalized_sentences = []
75
+ for sentence in sentences:
76
+ sentence = sentence.strip()
77
+ if sentence: # Ensure the sentence is not empty
78
+ if sentence[-1] not in '.!?': # Add missing full stop if needed
79
+ sentence += '.'
80
+ capitalized_sentences.append(sentence[0].capitalize() + sentence[1:])
81
+ return ' '.join(capitalized_sentences)
82
 
83
  # Function to correct tense errors in a sentence
84
  def correct_tense_errors(text):