fix : fixed the server error due to missing fullstop
Browse files
features/text_classifier/controller.py
CHANGED
|
@@ -80,10 +80,11 @@ async def handle_file_upload(file: UploadFile):
|
|
| 80 |
# Analyze each sentence in plain text input
|
| 81 |
async def handle_sentence_level_analysis(text: str):
|
| 82 |
text = text.strip()
|
| 83 |
-
|
|
|
|
| 84 |
if len(text) > 10000:
|
| 85 |
raise HTTPException(status_code=413, detail="Text must be less than 10,000 characters")
|
| 86 |
-
|
| 87 |
sentences = sent_tokenize(text, language="english")
|
| 88 |
results = []
|
| 89 |
for sentence in sentences:
|
|
|
|
| 80 |
# Analyze each sentence in plain text input
|
| 81 |
async def handle_sentence_level_analysis(text: str):
|
| 82 |
text = text.strip()
|
| 83 |
+
if text[-1] != ".":
|
| 84 |
+
text+="."
|
| 85 |
if len(text) > 10000:
|
| 86 |
raise HTTPException(status_code=413, detail="Text must be less than 10,000 characters")
|
| 87 |
+
|
| 88 |
sentences = sent_tokenize(text, language="english")
|
| 89 |
results = []
|
| 90 |
for sentence in sentences:
|
features/text_classifier/inferencer.py
CHANGED
|
@@ -30,7 +30,7 @@ def classify_text(text: str):
|
|
| 30 |
loss = outputs.loss
|
| 31 |
perplexity = torch.exp(loss).item()
|
| 32 |
|
| 33 |
-
if perplexity <
|
| 34 |
result = "AI-generated"
|
| 35 |
elif perplexity < 80:
|
| 36 |
result = "Probably AI-generated"
|
|
|
|
| 30 |
loss = outputs.loss
|
| 31 |
perplexity = torch.exp(loss).item()
|
| 32 |
|
| 33 |
+
if perplexity < 55:
|
| 34 |
result = "AI-generated"
|
| 35 |
elif perplexity < 80:
|
| 36 |
result = "Probably AI-generated"
|