Update app.py
Browse files
app.py
CHANGED
|
@@ -2,15 +2,15 @@ import gradio as gr
|
|
| 2 |
from transformers import AutoTokenizer, AutoModelForSequenceClassification, GPT2LMHeadModel
|
| 3 |
import torch
|
| 4 |
import math
|
| 5 |
-
import
|
| 6 |
|
| 7 |
-
#
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
|
| 15 |
# -------------------------------
|
| 16 |
# Load Models
|
|
@@ -60,7 +60,7 @@ def verdict(ai_prob):
|
|
| 60 |
return "Likely AI-generated or heavily AI-assisted."
|
| 61 |
|
| 62 |
def analyze_text(user_text):
|
| 63 |
-
sentences =
|
| 64 |
if not sentences:
|
| 65 |
return {"error": "Please enter some text."}
|
| 66 |
|
|
|
|
| 2 |
from transformers import AutoTokenizer, AutoModelForSequenceClassification, GPT2LMHeadModel
|
| 3 |
import torch
|
| 4 |
import math
|
| 5 |
+
import re
|
| 6 |
|
| 7 |
+
# -------------------------------
|
| 8 |
+
# Sentence splitter (no nltk)
|
| 9 |
+
# -------------------------------
|
| 10 |
+
def simple_sent_tokenize(text):
|
| 11 |
+
# Split by punctuation followed by space
|
| 12 |
+
sentences = re.split(r'(?<=[.!?]) +', text)
|
| 13 |
+
return [s for s in sentences if s.strip()]
|
| 14 |
|
| 15 |
# -------------------------------
|
| 16 |
# Load Models
|
|
|
|
| 60 |
return "Likely AI-generated or heavily AI-assisted."
|
| 61 |
|
| 62 |
def analyze_text(user_text):
|
| 63 |
+
sentences = simple_sent_tokenize(user_text)
|
| 64 |
if not sentences:
|
| 65 |
return {"error": "Please enter some text."}
|
| 66 |
|