youssefreda9 commited on
Commit
d85261e
·
1 Parent(s): a1871da

feat: Wire /api/analyze to use AraSpell service for real-time editor spelling

Browse files
Files changed (1) hide show
  1. src/app.py +4 -5
src/app.py CHANGED
@@ -692,15 +692,14 @@ def analyze_text():
692
  return curr_start, curr_end
693
 
694
  # 1. Spelling (with conservative post-filtering to avoid over-editing)
695
- has_spelling = USE_HF_API or spelling_model
696
  if has_spelling:
697
  try:
698
  t0 = time.time()
699
  logger.info(f"[ANALYZE] Step 1: Spelling correction starting...")
700
- if USE_HF_API:
701
- raw_corrected = hf_correct_spelling(current_text)
702
- else:
703
- raw_corrected = spelling_model.correct(current_text)
704
  logger.info(f"[ANALYZE] Step 1: Spelling done in {time.time()-t0:.2f}s")
705
 
706
  if raw_corrected != current_text:
 
692
  return curr_start, curr_end
693
 
694
  # 1. Spelling (with conservative post-filtering to avoid over-editing)
695
+ has_spelling = True # Always available via lazy-loaded araspell_service
696
  if has_spelling:
697
  try:
698
  t0 = time.time()
699
  logger.info(f"[ANALYZE] Step 1: Spelling correction starting...")
700
+ from nlp.spelling.araspell_service import get_spelling_model
701
+ spell_checker = get_spelling_model()
702
+ raw_corrected = spell_checker.correct(current_text)
 
703
  logger.info(f"[ANALYZE] Step 1: Spelling done in {time.time()-t0:.2f}s")
704
 
705
  if raw_corrected != current_text: