Jaja-09 commited on
Commit
e186169
·
1 Parent(s): 2c1da5f

feat: min words 80, stability fixes, docs link, test-case PDFs refs

Browse files
__pycache__/app.cpython-313.pyc ADDED
Binary file (10.2 kB). View file
 
__pycache__/model_handler.cpython-313.pyc ADDED
Binary file (36.7 kB). View file
 
app.py CHANGED
@@ -158,12 +158,12 @@ async def analyze_text(request: AnalysisRequest):
158
  if not request.text or len(request.text.strip()) == 0:
159
  raise HTTPException(status_code=400, detail="Text cannot be empty")
160
 
161
- # Check text length for meaningful analysis (200-7000 words)
162
  word_count = len(request.text.split())
163
- if word_count < 200:
164
  raise HTTPException(
165
  status_code=400,
166
- detail="Text is too short for analysis. Please provide at least 200 words for accurate AI detection and sentiment analysis."
167
  )
168
 
169
  if word_count > 7000:
@@ -200,12 +200,12 @@ async def detect_ai(request: AnalysisRequest):
200
  if not request.text or len(request.text.strip()) == 0:
201
  raise HTTPException(status_code=400, detail="Text cannot be empty")
202
 
203
- # Check text length (200-7000 words)
204
  word_count = len(request.text.split())
205
- if word_count < 200:
206
  raise HTTPException(
207
  status_code=400,
208
- detail="Text is too short. Please provide at least 200 words."
209
  )
210
  elif word_count > 7000:
211
  raise HTTPException(
 
158
  if not request.text or len(request.text.strip()) == 0:
159
  raise HTTPException(status_code=400, detail="Text cannot be empty")
160
 
161
+ # Check text length for meaningful analysis (80-7000 words)
162
  word_count = len(request.text.split())
163
+ if word_count < 80:
164
  raise HTTPException(
165
  status_code=400,
166
+ detail="Text is too short for analysis. Please provide at least 80 words for accurate AI detection and sentiment analysis."
167
  )
168
 
169
  if word_count > 7000:
 
200
  if not request.text or len(request.text.strip()) == 0:
201
  raise HTTPException(status_code=400, detail="Text cannot be empty")
202
 
203
+ # Check text length (80-7000 words)
204
  word_count = len(request.text.split())
205
+ if word_count < 80:
206
  raise HTTPException(
207
  status_code=400,
208
+ detail="Text is too short. Please provide at least 80 words."
209
  )
210
  elif word_count > 7000:
211
  raise HTTPException(
model_handler.py CHANGED
@@ -428,14 +428,14 @@ class AIDetectionModelHandler:
428
  # Split text into sentences
429
  sentences = sent_tokenize(text)
430
 
431
- # Validate input text length (200-7000 words)
432
  total_words = len(text.split())
433
- if total_words < 200:
434
  return {
435
  'prediction': 'Human' if overall_label == 0 else 'AI',
436
  'confidence': abs(overall_prob - 0.5) * 2,
437
  'is_mixed': False,
438
- 'reason': f'Text too short for analysis ({total_words} words, minimum 200 words required)',
439
  'overall_probability': overall_prob,
440
  'modified_probability': overall_prob,
441
  'chunk_analysis': []
@@ -694,10 +694,10 @@ class AIDetectionModelHandler:
694
  Returns:
695
  Complete analysis results with model-based sentiment features
696
  """
697
- # Validate input text length (200-7000 words)
698
  total_words = len(text.split())
699
- if total_words < 200:
700
- raise ValueError(f"Text too short for analysis ({total_words} words, minimum 200 words required)")
701
  elif total_words > 7000:
702
  raise ValueError(f"Text too long for analysis ({total_words} words, maximum 7000 words allowed)")
703
 
 
428
  # Split text into sentences
429
  sentences = sent_tokenize(text)
430
 
431
+ # Validate input text length (80-7000 words)
432
  total_words = len(text.split())
433
+ if total_words < 80:
434
  return {
435
  'prediction': 'Human' if overall_label == 0 else 'AI',
436
  'confidence': abs(overall_prob - 0.5) * 2,
437
  'is_mixed': False,
438
+ 'reason': f'Text too short for analysis ({total_words} words, minimum 80 words required)',
439
  'overall_probability': overall_prob,
440
  'modified_probability': overall_prob,
441
  'chunk_analysis': []
 
694
  Returns:
695
  Complete analysis results with model-based sentiment features
696
  """
697
+ # Validate input text length (80-7000 words)
698
  total_words = len(text.split())
699
+ if total_words < 80:
700
+ raise ValueError(f"Text too short for analysis ({total_words} words, minimum 80 words required)")
701
  elif total_words > 7000:
702
  raise ValueError(f"Text too long for analysis ({total_words} words, maximum 7000 words allowed)")
703