Skip to content

Commit a06ebb3

Browse files
authored
Update recognizer_registry.py
1 parent d03f6c0 commit a06ebb3

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

presidio-analyzer/presidio_analyzer/recognizer_registry/recognizer_registry.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -174,11 +174,9 @@ def get_recognizers(
174174
if language == rec.supported_language:
175175
if type(rec.supported_entities) == list and len(rec.supported_entities) > 0:
176176
for supported_entity in rec.supported_entities:
177-
all_entity_recognizers[supported_entity] = all_entity_recognizers[supported_entity].add(
178-
rec) if supported_entity in all_entity_recognizers else {rec}
177+
self.add_recognizer_map(all_entity_recognizers, supported_entity, rec)
179178
elif type(rec.supported_entities) == str:
180-
all_entity_recognizers[rec.supported_entities] = all_entity_recognizers[rec.supported_entities].add(
181-
rec) if rec.supported_entities in all_entity_recognizers else {rec}
179+
self.add_recognizer_map(all_entity_recognizers, supported_entity, rec)
182180
for entity in entities:
183181
if entity in all_entity_recognizers:
184182
to_return.update(all_entity_recognizers[entity])
@@ -199,6 +197,12 @@ def get_recognizers(
199197

200198
return list(to_return)
201199

200+
def add_recognizer_map(self, all_entity_recognizers, supported_entity, rec):
201+
if supported_entity in all_entity_recognizers:
202+
all_entity_recognizers[supported_entity].add(rec)
203+
else:
204+
all_entity_recognizers[supported_entity] = {rec}
205+
202206
def add_recognizer(self, recognizer: EntityRecognizer) -> None:
203207
"""
204208
Add a new recognizer to the list of recognizers.

0 commit comments

Comments
 (0)