sashtech commited on
Commit
fa189aa
·
verified ·
1 Parent(s): 7b96a1b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -0
app.py CHANGED
@@ -8,6 +8,7 @@ from nltk.corpus import wordnet
8
  from nltk.corpus import stopwords
9
  from nltk.tokenize import word_tokenize
10
  from spellchecker import SpellChecker
 
11
  import re
12
  import string
13
  import random
@@ -209,6 +210,13 @@ def correct_spelling(text):
209
  return ' '.join(corrected_words)
210
 
211
 
 
 
 
 
 
 
 
212
  def paraphrase_and_correct(text):
213
  paragraphs = text.split("\n\n") # Split by paragraphs
214
 
@@ -225,6 +233,10 @@ def paraphrase_and_correct(text):
225
  paraphrased_text = correct_tense_errors(paraphrased_text)
226
  paraphrased_text = ensure_subject_verb_agreement(paraphrased_text)
227
  paraphrased_text = fix_punctuation_spacing(paraphrased_text)
 
 
 
 
228
  processed_paragraphs.append(paraphrased_text)
229
 
230
  return "\n\n".join(processed_paragraphs) # Reassemble the text with paragraphs
 
8
  from nltk.corpus import stopwords
9
  from nltk.tokenize import word_tokenize
10
  from spellchecker import SpellChecker
11
+ from textblob import TextBlob # Importing TextBlob
12
  import re
13
  import string
14
  import random
 
210
  return ' '.join(corrected_words)
211
 
212
 
213
+ # Function to correct grammar using TextBlob
214
+ def textblob_grammar_correction(text):
215
+ blob = TextBlob(text)
216
+ corrected_text = str(blob.correct())
217
+ return corrected_text
218
+
219
+
220
  def paraphrase_and_correct(text):
221
  paragraphs = text.split("\n\n") # Split by paragraphs
222
 
 
233
  paraphrased_text = correct_tense_errors(paraphrased_text)
234
  paraphrased_text = ensure_subject_verb_agreement(paraphrased_text)
235
  paraphrased_text = fix_punctuation_spacing(paraphrased_text)
236
+
237
+ # Apply TextBlob grammar correction
238
+ paraphrased_text = textblob_grammar_correction(paraphrased_text)
239
+
240
  processed_paragraphs.append(paraphrased_text)
241
 
242
  return "\n\n".join(processed_paragraphs) # Reassemble the text with paragraphs