Candidate selection is the retrieval phase of named entity disambiguation: it maps each recognized mention to one or more possible entities in a domain knowledge base or ontology, postponing final choice to ranking or disambiguation. section 7.2 section 8.4.2
Implement candidate selection as a constrained retrieval pipeline:
- Accept NER-annotated mentions and their entity labels alongside a domain ontology. section 8.4.2
- Query ontology names with Neo4j full-text search, restricting results to labels relevant to the mention type. section 8.4.2
- Return candidate identifiers and names for later ranking or ontology-aware disambiguation; vector search can supplement text matching. section 8.4 section 8.4.2
Retrieving candidates for “Zika”
A SNOMED search returns Zika virus (50471002), Zika virus disease (3928002), and Congenital Zika virus infection (762725007). These alternatives form the candidate pool; contextual ranking or ontology-path analysis selects the intended meaning afterward. section 8.4.2 section 8.4
Listing 8.13 Python class for CS
class CandidateSelection:
[...]
def full_text_query(self):
query = """
CALL db.index.fulltext.queryNodes("names", $fulltextQuery,
{limit: $limit})
YIELD node
WHERE node:SnomedEntity AND ANY(x IN node.type
WHERE x IN $labels)
RETURN distinct node.name AS candidate_name, node.id
AS candidate_id
"""
return query
def generate_full_text_query(self, input):
full_text_query = ""
words = [el for el in input.split() if el]
if len(words) > 1:
for word in words[:-1]:
full_text_query += f" {word}~0.80 AND "
full_text_query += f" {words[-1]}~0.80"
else:
full_text_query = words[0] + "~0.80"
return full_text_query.strip() [...]
The Python class shows how to generate fuzzy full-text queries and restrict Neo4j results to relevant SNOMED entity labels. section 8.4.2
