Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -12,7 +12,7 @@ from gramformer import Gramformer
|
|
| 12 |
pipeline_en = pipeline(task="text-classification", model="Hello-SimpleAI/chatgpt-detector-roberta")
|
| 13 |
|
| 14 |
# Initialize Gramformer
|
| 15 |
-
gf = Gramformer(models=
|
| 16 |
|
| 17 |
# Function to predict the label and score for English text (AI Detection)
|
| 18 |
def predict_en(text):
|
|
@@ -98,8 +98,8 @@ def paraphrase_correct_and_grammar(text):
|
|
| 98 |
capitalized_text = capitalize_sentences_and_nouns(paraphrased_text)
|
| 99 |
|
| 100 |
# Step 3: Grammar correction using Gramformer
|
| 101 |
-
corrected_sentences = gf.correct(capitalized_text)
|
| 102 |
-
final_text = corrected_sentences
|
| 103 |
|
| 104 |
return final_text
|
| 105 |
|
|
|
|
| 12 |
pipeline_en = pipeline(task="text-classification", model="Hello-SimpleAI/chatgpt-detector-roberta")
|
| 13 |
|
| 14 |
# Initialize Gramformer
|
| 15 |
+
gf = Gramformer(models=1, use_gpu=False) # 1 = corrector
|
| 16 |
|
| 17 |
# Function to predict the label and score for English text (AI Detection)
|
| 18 |
def predict_en(text):
|
|
|
|
| 98 |
capitalized_text = capitalize_sentences_and_nouns(paraphrased_text)
|
| 99 |
|
| 100 |
# Step 3: Grammar correction using Gramformer
|
| 101 |
+
corrected_sentences = gf.correct(capitalized_text, max_candidates=1)
|
| 102 |
+
final_text = next(iter(corrected_sentences)) if corrected_sentences else capitalized_text
|
| 103 |
|
| 104 |
return final_text
|
| 105 |
|