alaajabari commited on
Commit
d990a04
·
verified ·
1 Parent(s): 84b3f63

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +15 -11
main.py CHANGED
@@ -278,20 +278,24 @@ def entities_and_types(sentence):
278
 
279
  return entity_dict
280
  '''
 
 
 
281
  def entities_and_types(sentence):
 
 
 
282
  ner_output = extract(sentence)
283
  print("RAW NER OUTPUT:", ner_output)
284
-
285
- try:
286
- if ner_output != []:
287
- entities = distill_entities(ner_output)
288
- else:
289
- output_list = jsons_to_list_of_lists(extract(sentence))
290
- entities = distill_entities(output_list)
291
- print("DISTILLED ENTITIES:", entities)
292
- except Exception as e:
293
- print("❌ DISTILL ERROR:", str(e))
294
- return {}
295
 
296
  entity_dict = {}
297
  for name, entity_type, _, _ in entities:
 
278
 
279
  return entity_dict
280
  '''
281
+ def convert_ner_format(ner_output):
282
+ return [[item["token"], item["tags"]] for item in ner_output]
283
+
284
  def entities_and_types(sentence):
285
+ print("\n=== NER DEBUG ===")
286
+ print("INPUT:", sentence)
287
+
288
  ner_output = extract(sentence)
289
  print("RAW NER OUTPUT:", ner_output)
290
+
291
+ # ✅ FIX HERE
292
+ converted = convert_ner_format(ner_output)
293
+
294
+ print("CONVERTED FORMAT:", converted)
295
+
296
+ entities = distill_entities(converted)
297
+
298
+ print("DISTILLED ENTITIES:", entities)
 
 
299
 
300
  entity_dict = {}
301
  for name, entity_type, _, _ in entities: