@@ -174,11 +174,9 @@ def get_recognizers(
174
174
if language == rec .supported_language :
175
175
if type (rec .supported_entities ) == list and len (rec .supported_entities ) > 0 :
176
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 }
177
+ self .add_recognizer_map (all_entity_recognizers , supported_entity , rec )
179
178
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 )
182
180
for entity in entities :
183
181
if entity in all_entity_recognizers :
184
182
to_return .update (all_entity_recognizers [entity ])
@@ -199,6 +197,12 @@ def get_recognizers(
199
197
200
198
return list (to_return )
201
199
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
+
202
206
def add_recognizer (self , recognizer : EntityRecognizer ) -> None :
203
207
"""
204
208
Add a new recognizer to the list of recognizers.
0 commit comments