Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -6,6 +6,7 @@ import subprocess
|
|
| 6 |
import nltk
|
| 7 |
from nltk.corpus import wordnet
|
| 8 |
import language_tool_python
|
|
|
|
| 9 |
tool = language_tool_python.LanguageTool('en-US')
|
| 10 |
|
| 11 |
# Function to correct tense errors using LanguageTool
|
|
@@ -15,10 +16,6 @@ def correct_tense_errors(text):
|
|
| 15 |
corrected_text = language_tool_python.utils.correct(text, matches)
|
| 16 |
return corrected_text
|
| 17 |
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
# Initialize the English text classification pipeline for AI detection
|
| 23 |
pipeline_en = pipeline(task="text-classification", model="Hello-SimpleAI/chatgpt-detector-roberta")
|
| 24 |
|
|
@@ -64,16 +61,6 @@ def capitalize_sentences_and_nouns(text):
|
|
| 64 |
|
| 65 |
return ' '.join(corrected_text)
|
| 66 |
|
| 67 |
-
# Function to correct tense errors in a sentence (Tense Correction)
|
| 68 |
-
#def correct_tense_errors(text):
|
| 69 |
-
# doc = nlp(text)
|
| 70 |
-
### if token.pos_ == "VERB" and token.dep_ in {"aux", "auxpass"}:
|
| 71 |
-
## lemma = wordnet.morphy(token.text, wordnet.VERB) or token.text
|
| 72 |
-
# corrected_text.append(lemma)
|
| 73 |
-
# else:
|
| 74 |
-
# corrected_text.append(token.text)
|
| 75 |
-
# return ' '.join(corrected_text)
|
| 76 |
-
|
| 77 |
# Function to correct singular/plural errors (Singular/Plural Correction)
|
| 78 |
def correct_singular_plural_errors(text):
|
| 79 |
doc = nlp(text)
|
|
@@ -150,7 +137,7 @@ def paraphrase_with_spacy_nltk(text):
|
|
| 150 |
|
| 151 |
# Combined function: Paraphrase -> Grammar Correction -> Capitalization (Humanifier)
|
| 152 |
def paraphrase_and_correct(text):
|
| 153 |
-
|
| 154 |
|
| 155 |
# Step 2: Apply grammatical corrections on the paraphrased text
|
| 156 |
corrected_text = correct_article_errors(paraphrased_text)
|
|
|
|
| 6 |
import nltk
|
| 7 |
from nltk.corpus import wordnet
|
| 8 |
import language_tool_python
|
| 9 |
+
|
| 10 |
tool = language_tool_python.LanguageTool('en-US')
|
| 11 |
|
| 12 |
# Function to correct tense errors using LanguageTool
|
|
|
|
| 16 |
corrected_text = language_tool_python.utils.correct(text, matches)
|
| 17 |
return corrected_text
|
| 18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
# Initialize the English text classification pipeline for AI detection
|
| 20 |
pipeline_en = pipeline(task="text-classification", model="Hello-SimpleAI/chatgpt-detector-roberta")
|
| 21 |
|
|
|
|
| 61 |
|
| 62 |
return ' '.join(corrected_text)
|
| 63 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
# Function to correct singular/plural errors (Singular/Plural Correction)
|
| 65 |
def correct_singular_plural_errors(text):
|
| 66 |
doc = nlp(text)
|
|
|
|
| 137 |
|
| 138 |
# Combined function: Paraphrase -> Grammar Correction -> Capitalization (Humanifier)
|
| 139 |
def paraphrase_and_correct(text):
|
| 140 |
+
paraphrased_text = paraphrase_with_spacy_nltk(text)
|
| 141 |
|
| 142 |
# Step 2: Apply grammatical corrections on the paraphrased text
|
| 143 |
corrected_text = correct_article_errors(paraphrased_text)
|