emanuelaboros commited on
Commit
b7624fb
·
verified ·
1 Parent(s): 4bd2480

Update generic_ner.py

Browse files
Files changed (1) hide show
  1. generic_ner.py +5 -1
generic_ner.py CHANGED
@@ -77,7 +77,7 @@ def get_entities(tokens, tags, confidences, text):
77
 
78
  entities = []
79
  idx: int = 0
80
-
81
  for subtree in ne_tree:
82
  # skipping 'O' tags
83
  if isinstance(subtree, Tree):
@@ -87,6 +87,10 @@ def get_entities(tokens, tags, confidences, text):
87
  for indices in find_entity_indices(text, original_string):
88
  entity_start_position = indices[0]
89
  entity_end_position = indices[1]
 
 
 
 
90
  entities.append(
91
  {
92
  "entity": original_label,
 
77
 
78
  entities = []
79
  idx: int = 0
80
+ already_done = []
81
  for subtree in ne_tree:
82
  # skipping 'O' tags
83
  if isinstance(subtree, Tree):
 
87
  for indices in find_entity_indices(text, original_string):
88
  entity_start_position = indices[0]
89
  entity_end_position = indices[1]
90
+ if '_'.join([original_label, original_string, entity_start_position]) in already_done:
91
+ continue
92
+ else:
93
+ already_done.append('_'.join([original_label, original_string, entity_start_position]))
94
  entities.append(
95
  {
96
  "entity": original_label,