Commit ·
738185d
1
Parent(s): bcf3607
fix: Remove duplicate /api/spelling route causing AssertionError
Browse files- src/app.py +0 -48
src/app.py
CHANGED
|
@@ -382,54 +382,6 @@ def summarize():
|
|
| 382 |
}), 500
|
| 383 |
|
| 384 |
|
| 385 |
-
@app.route('/api/spelling', methods=['POST'])
|
| 386 |
-
def spelling_correction():
|
| 387 |
-
"""
|
| 388 |
-
Correct spelling in Arabic text.
|
| 389 |
-
|
| 390 |
-
Expected JSON payload:
|
| 391 |
-
{
|
| 392 |
-
"text": "Arabic text to correct"
|
| 393 |
-
}
|
| 394 |
-
"""
|
| 395 |
-
if not USE_HF_API and spelling_model is None:
|
| 396 |
-
return jsonify({
|
| 397 |
-
'error': 'Spelling model not loaded. Please check server logs.',
|
| 398 |
-
'status': 'error'
|
| 399 |
-
}), 503
|
| 400 |
-
|
| 401 |
-
try:
|
| 402 |
-
if not request.is_json:
|
| 403 |
-
return jsonify({'error': 'Request must be JSON', 'status': 'error'}), 400
|
| 404 |
-
|
| 405 |
-
data = request.get_json()
|
| 406 |
-
text = data.get('text', '').strip()
|
| 407 |
-
|
| 408 |
-
if not text:
|
| 409 |
-
return jsonify({'error': 'Text is required', 'status': 'error'}), 400
|
| 410 |
-
|
| 411 |
-
logger.info(f"Correcting spelling for text of length: {len(text)}")
|
| 412 |
-
if USE_HF_API:
|
| 413 |
-
corrected = hf_correct_spelling(text)
|
| 414 |
-
else:
|
| 415 |
-
corrected = spelling_model.correct(text)
|
| 416 |
-
|
| 417 |
-
return jsonify({
|
| 418 |
-
'corrected': corrected,
|
| 419 |
-
'status': 'success',
|
| 420 |
-
'original_length': len(text),
|
| 421 |
-
'corrected_length': len(corrected)
|
| 422 |
-
})
|
| 423 |
-
|
| 424 |
-
except Exception as e:
|
| 425 |
-
logger.error(f"Error during spelling correction: {str(e)}")
|
| 426 |
-
logger.error(traceback.format_exc())
|
| 427 |
-
return jsonify({
|
| 428 |
-
'error': 'An error occurred during spelling correction.',
|
| 429 |
-
'status': 'error',
|
| 430 |
-
'details': str(e) if app.debug else None
|
| 431 |
-
}), 500
|
| 432 |
-
|
| 433 |
|
| 434 |
@app.route('/api/autocomplete', methods=['POST'])
|
| 435 |
def autocomplete():
|
|
|
|
| 382 |
}), 500
|
| 383 |
|
| 384 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 385 |
|
| 386 |
@app.route('/api/autocomplete', methods=['POST'])
|
| 387 |
def autocomplete():
|