Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -5,7 +5,7 @@ import spacy
|
|
| 5 |
import subprocess
|
| 6 |
import nltk
|
| 7 |
from nltk.corpus import wordnet
|
| 8 |
-
from
|
| 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
|
| 105 |
def correct_grammar(text):
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
return
|
| 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
|
| 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
|