sashtech commited on
Commit
1cf3f25
·
verified ·
1 Parent(s): 0c94dc9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -0
app.py CHANGED
@@ -77,6 +77,22 @@ def rephrase_with_synonyms(text):
77
  rephrased_text.append(token.text)
78
 
79
  return ' '.join(rephrased_text)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80
 
81
  # Function to paraphrase and correct grammar
82
  def paraphrase_and_correct(text):
 
77
  rephrased_text.append(token.text)
78
 
79
  return ' '.join(rephrased_text)
80
+ def capitalize_sentences_and_nouns(text):
81
+ doc = nlp(text)
82
+ corrected_text = []
83
+
84
+ for sent in doc.sents:
85
+ sentence = []
86
+ for token in sent:
87
+ if token.i == sent.start: # First word of the sentence
88
+ sentence.append(token.text.capitalize())
89
+ elif token.pos_ == "PROPN": # Proper noun
90
+ sentence.append(token.text.capitalize())
91
+ else:
92
+ sentence.append(token.text)
93
+ corrected_text.append(' '.join(sentence))
94
+
95
+ return ' '.join(corrected_text)
96
 
97
  # Function to paraphrase and correct grammar
98
  def paraphrase_and_correct(text):