Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -6,7 +6,7 @@ import subprocess
|
|
| 6 |
import nltk
|
| 7 |
from nltk.corpus import wordnet
|
| 8 |
from gensim import downloader as api
|
| 9 |
-
import
|
| 10 |
|
| 11 |
# Ensure necessary NLTK data is downloaded
|
| 12 |
nltk.download('wordnet')
|
|
@@ -29,8 +29,8 @@ device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
|
| 29 |
tokenizer_ai = AutoTokenizer.from_pretrained("distilbert-base-uncased-finetuned-sst-2-english")
|
| 30 |
model_ai = AutoModelForSequenceClassification.from_pretrained("distilbert-base-uncased-finetuned-sst-2-english").to(device)
|
| 31 |
|
| 32 |
-
# Initialize
|
| 33 |
-
|
| 34 |
|
| 35 |
# AI detection function using DistilBERT
|
| 36 |
def detect_ai_generated(text):
|
|
@@ -100,11 +100,10 @@ def paraphrase_with_spacy_nltk(text):
|
|
| 100 |
|
| 101 |
return corrected_text
|
| 102 |
|
| 103 |
-
# Function to correct grammar using
|
| 104 |
def correct_grammar(text):
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
return corrected_text
|
| 108 |
|
| 109 |
# Combined function: Paraphrase -> Capitalization -> Grammar Correction
|
| 110 |
def paraphrase_and_correct(text):
|
|
|
|
| 6 |
import nltk
|
| 7 |
from nltk.corpus import wordnet
|
| 8 |
from gensim import downloader as api
|
| 9 |
+
from gingerit.gingerit import GingerIt
|
| 10 |
|
| 11 |
# Ensure necessary NLTK data is downloaded
|
| 12 |
nltk.download('wordnet')
|
|
|
|
| 29 |
tokenizer_ai = AutoTokenizer.from_pretrained("distilbert-base-uncased-finetuned-sst-2-english")
|
| 30 |
model_ai = AutoModelForSequenceClassification.from_pretrained("distilbert-base-uncased-finetuned-sst-2-english").to(device)
|
| 31 |
|
| 32 |
+
# Initialize GingerIt parser
|
| 33 |
+
parser = GingerIt()
|
| 34 |
|
| 35 |
# AI detection function using DistilBERT
|
| 36 |
def detect_ai_generated(text):
|
|
|
|
| 100 |
|
| 101 |
return corrected_text
|
| 102 |
|
| 103 |
+
# Function to correct grammar using GingerIt
|
| 104 |
def correct_grammar(text):
|
| 105 |
+
result = parser.parse(text)
|
| 106 |
+
return result['result']
|
|
|
|
| 107 |
|
| 108 |
# Combined function: Paraphrase -> Capitalization -> Grammar Correction
|
| 109 |
def paraphrase_and_correct(text):
|