Skip to content

Commit d03f6c0

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

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

presidio-analyzer/presidio_analyzer/recognizer_registry/recognizer_registry.py

+9-8
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ def get_recognizers(
160160
all_possible_recognizers = copy.copy(self.recognizers)
161161
if ad_hoc_recognizers:
162162
all_possible_recognizers.extend(ad_hoc_recognizers)
163+
163164
to_return = set()
164165
if all_fields:
165166
to_return = [
@@ -168,16 +169,16 @@ def get_recognizers(
168169
if language == rec.supported_language
169170
]
170171
else:
171-
# filter out unwanted recognizers
172172
all_entity_recognizers = dict()
173173
for rec in all_possible_recognizers:
174-
if type(rec.supported_entities) == list and len(rec.supported_entities) > 0:
175-
for supported_entity in rec.supported_entities:
176-
all_entity_recognizers[supported_entity] = all_entity_recognizers[supported_entity].add(
177-
rec) if supported_entity in all_entity_recognizers else {rec}
178-
elif type(rec.supported_entities) == str:
179-
all_entity_recognizers[rec.supported_entities] = all_entity_recognizers[rec.supported_entities].add(
180-
rec) if rec.supported_entities in all_entity_recognizers else {rec}
174+
if language == rec.supported_language:
175+
if type(rec.supported_entities) == list and len(rec.supported_entities) > 0:
176+
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}
179+
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}
181182
for entity in entities:
182183
if entity in all_entity_recognizers:
183184
to_return.update(all_entity_recognizers[entity])

0 commit comments

Comments
 (0)