sashtech commited on
Commit
9367038
·
verified ·
1 Parent(s): b41a8c1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -5,7 +5,7 @@ import spacy
5
  import subprocess
6
  import nltk
7
  from nltk.corpus import wordnet
8
- from gramma import GrammaticalErrorFinder
9
  from pattern.en import conjugate, lemma, pluralize, singularize
10
 
11
  # Initialize the English text classification pipeline for AI detection
@@ -101,11 +101,11 @@ def correct_article_errors(text):
101
  corrected_text.append(token.text)
102
  return ' '.join(corrected_text)
103
 
104
- # Function to correct overall grammar using gramma
105
  def correct_grammar(text):
106
- checker = GrammaticalErrorFinder()
107
- corrections = checker.correct_text(text)
108
- return corrections
109
 
110
  # Paraphrasing function using SpaCy and NLTK (Humanifier)
111
  def paraphrase_with_spacy_nltk(text):
@@ -150,7 +150,7 @@ def paraphrase_and_correct(text):
150
  # Step 3: Correct tense errors
151
  corrected_text = correct_tense_errors(corrected_text)
152
 
153
- # Step 4: Correct overall grammar using gramma
154
  final_text = correct_grammar(corrected_text)
155
 
156
  return final_text
 
5
  import subprocess
6
  import nltk
7
  from nltk.corpus import wordnet
8
+ from textblob import TextBlob
9
  from pattern.en import conjugate, lemma, pluralize, singularize
10
 
11
  # Initialize the English text classification pipeline for AI detection
 
101
  corrected_text.append(token.text)
102
  return ' '.join(corrected_text)
103
 
104
+ # Function to correct overall grammar using TextBlob
105
  def correct_grammar(text):
106
+ blob = TextBlob(text)
107
+ corrected_text = str(blob.correct()) # TextBlob's built-in grammar correction
108
+ return corrected_text
109
 
110
  # Paraphrasing function using SpaCy and NLTK (Humanifier)
111
  def paraphrase_with_spacy_nltk(text):
 
150
  # Step 3: Correct tense errors
151
  corrected_text = correct_tense_errors(corrected_text)
152
 
153
+ # Step 4: Correct overall grammar using TextBlob
154
  final_text = correct_grammar(corrected_text)
155
 
156
  return final_text