Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -69,16 +69,21 @@ def capitalize_sentences_and_nouns(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'(
|
| 74 |
capitalized_sentences = []
|
|
|
|
| 75 |
for sentence in sentences:
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
|
|
|
|
|
|
|
|
|
| 82 |
|
| 83 |
# Function to correct tense errors in a sentence
|
| 84 |
def correct_tense_errors(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 |
+
# Function to force capitalization of the first letter of every sentence and ensure full stops
|
| 73 |
def force_first_letter_capital(text):
|
| 74 |
+
sentences = re.split(r'(?<=\w[.!?])\s+', text) # Split based on sentence-ending punctuation
|
| 75 |
capitalized_sentences = []
|
| 76 |
+
|
| 77 |
for sentence in sentences:
|
| 78 |
+
if sentence:
|
| 79 |
+
# Capitalize the first letter if not already capitalized
|
| 80 |
+
capitalized_sentence = sentence[0].capitalize() + sentence[1:]
|
| 81 |
+
# Ensure there's a full stop at the end if there's no punctuation
|
| 82 |
+
if not re.search(r'[.!?]$', capitalized_sentence):
|
| 83 |
+
capitalized_sentence += '.'
|
| 84 |
+
capitalized_sentences.append(capitalized_sentence)
|
| 85 |
+
|
| 86 |
+
return " ".join(capitalized_sentences)
|
| 87 |
|
| 88 |
# Function to correct tense errors in a sentence
|
| 89 |
def correct_tense_errors(text):
|