sashtech commited on
Commit
189f54a
·
verified ·
1 Parent(s): 0c51ae8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -6
app.py CHANGED
@@ -5,7 +5,7 @@ import spacy
5
  import subprocess
6
  import nltk
7
  from nltk.corpus import wordnet
8
- from gingerit.gingerit import GingerIt
9
  from pattern.en import conjugate, lemma, pluralize, singularize
10
 
11
  # Initialize the English text classification pipeline for AI detection
@@ -101,11 +101,12 @@ def correct_article_errors(text):
101
  corrected_text.append(token.text)
102
  return ' '.join(corrected_text)
103
 
104
- # Function to correct overall grammar using GingerIt
105
  def correct_grammar(text):
106
- parser = GingerIt()
107
- result = parser.parse(text)
108
- return result['result']
 
109
 
110
  # Paraphrasing function using SpaCy and NLTK (Humanifier)
111
  def paraphrase_with_spacy_nltk(text):
@@ -150,7 +151,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 GingerIt
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
+ import language_check
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 language-check
105
  def correct_grammar(text):
106
+ tool = language_check.LanguageTool('en-US')
107
+ matches = tool.check(text)
108
+ corrected_text = language_check.correct(text, matches)
109
+ return corrected_text
110
 
111
  # Paraphrasing function using SpaCy and NLTK (Humanifier)
112
  def paraphrase_with_spacy_nltk(text):
 
151
  # Step 3: Correct tense errors
152
  corrected_text = correct_tense_errors(corrected_text)
153
 
154
+ # Step 4: Correct overall grammar using language-check
155
  final_text = correct_grammar(corrected_text)
156
 
157
  return final_text