Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -44,6 +44,15 @@ def correct_grammar_with_languagetool(text):
|
|
44 |
corrected_text = language_tool_python.utils.correct(text, matches)
|
45 |
return corrected_text
|
46 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
# Function to get synonyms using NLTK WordNet
|
48 |
def get_synonyms_nltk(word, pos):
|
49 |
synsets = wordnet.synsets(word, pos=pos)
|
|
|
44 |
corrected_text = language_tool_python.utils.correct(text, matches)
|
45 |
return corrected_text
|
46 |
|
47 |
+
# AI detection function using DistilBERT
|
48 |
+
def detect_ai_generated(text):
|
49 |
+
inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=512).to(device)
|
50 |
+
with torch.no_grad():
|
51 |
+
outputs = model(**inputs)
|
52 |
+
probabilities = torch.softmax(outputs.logits, dim=1)
|
53 |
+
ai_probability = probabilities[0][1].item() # Probability of being AI-generated
|
54 |
+
return f"AI-Generated Content Probability: {ai_probability:.2f}%"
|
55 |
+
|
56 |
# Function to get synonyms using NLTK WordNet
|
57 |
def get_synonyms_nltk(word, pos):
|
58 |
synsets = wordnet.synsets(word, pos=pos)
|