in src/engine/step1/entity_extraction.py [0:0]
def detect_entities(nlq, entity_detection_score_thr, drug_relationship_score_thr):
"""Main function: Detect and categorize entities with CM and regex.
Args:
nlq (str):
entity_detection_score_thr (float):
drug_relationship_score_thr (float):
Returns:
dict: Dictionary of detected entities by category
"""
entities_by_category = {}
seen_names = set()
# Comprehend Medical NER
entities_by_category, seen_names = add_cm_entities(
nlq,
entities_by_category,
seen_names,
entity_detection_score_thr,
drug_relationship_score_thr,
)
# regex NER
entities_by_category, seen_names = add_gender_entities(
nlq, entities_by_category, seen_names
)
entities_by_category, seen_names = add_ethnicity_entities(
nlq, entities_by_category, seen_names
)
entities_by_category, seen_names = add_race_entities(
nlq, entities_by_category, seen_names
)
return entities_by_category