Commit
·
bc35ffb
1
Parent(s):
af2b95e
degbu
Browse files- generic_ner.py +7 -2
generic_ner.py
CHANGED
|
@@ -238,7 +238,6 @@ def attach_comp_to_closest(entities):
|
|
| 238 |
|
| 239 |
def postprocess_entities(entities):
|
| 240 |
# Step 1: Filter entities with the same text, keeping those with the more specific label (contains a dot)
|
| 241 |
-
filtered_entities = []
|
| 242 |
entity_map = {}
|
| 243 |
|
| 244 |
# Loop over the entities and prioritize the more specific ones
|
|
@@ -248,7 +247,13 @@ def postprocess_entities(entities):
|
|
| 248 |
if entity_text not in entity_map or "." in entity["entity"]:
|
| 249 |
entity_map[entity_text] = entity
|
| 250 |
|
| 251 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 252 |
|
| 253 |
|
| 254 |
class MultitaskTokenClassificationPipeline(Pipeline):
|
|
|
|
| 238 |
|
| 239 |
def postprocess_entities(entities):
|
| 240 |
# Step 1: Filter entities with the same text, keeping those with the more specific label (contains a dot)
|
|
|
|
| 241 |
entity_map = {}
|
| 242 |
|
| 243 |
# Loop over the entities and prioritize the more specific ones
|
|
|
|
| 247 |
if entity_text not in entity_map or "." in entity["entity"]:
|
| 248 |
entity_map[entity_text] = entity
|
| 249 |
|
| 250 |
+
# Collect the filtered entities from the map
|
| 251 |
+
filtered_entities = list(entity_map.values())
|
| 252 |
+
|
| 253 |
+
# Step 2: Attach "comp.function" entities to the closest other entities
|
| 254 |
+
filtered_entities = attach_comp_to_closest(filtered_entities)
|
| 255 |
+
|
| 256 |
+
return filtered_entities
|
| 257 |
|
| 258 |
|
| 259 |
class MultitaskTokenClassificationPipeline(Pipeline):
|