Syamchand commited on
Commit
89c3d4d
·
verified ·
1 Parent(s): 944e674

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -4
app.py CHANGED
@@ -675,8 +675,22 @@ def predict_ner_batch(req: BatchNERRequest):
675
  labels = [l.lower() for l in (req.entity_types or default_types)]
676
  # GLiNER handles batches natively
677
  #batch_entities = models["ner"].predict_entities(req.texts, labels)
678
- batch_entities = [
679
- models["ner"].predict_entities(text, labels)
680
- for text in req.texts
681
- ]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
682
  return BatchNERResult(results=batch_entities)
 
675
  labels = [l.lower() for l in (req.entity_types or default_types)]
676
  # GLiNER handles batches natively
677
  #batch_entities = models["ner"].predict_entities(req.texts, labels)
678
+
679
+ batch_entities = []
680
+ for text in req.texts:
681
+ # Force conversion to string and handle empty cases
682
+ clean_text = str(text or "").strip()
683
+ if not clean_text:
684
+ batch_entities.append([])
685
+ continue
686
+ try:
687
+ batch_entities.append(models["ner"].predict_entities(clean_text, labels))
688
+ except:
689
+ batch_entities.append([])
690
+
691
+
692
+ # batch_entities = [
693
+ # models["ner"].predict_entities(text, labels)
694
+ # for text in req.texts
695
+ # ]
696
  return BatchNERResult(results=batch_entities)