A reviewer's answer holds when more records join a person

This commit is contained in:
Roberto Treviño
2026-11-30 02:14:13 -06:00
parent a9945bc021
commit 77350b8fec
2 changed files with 55 additions and 1 deletions
+4 -1
View File
@@ -425,6 +425,9 @@ def run_link(p: str, node: Link):
orphan = set(whole.unique_id[whole[facts].isna().all(axis=1)]) if facts else set()
# no birth date to tell her apart (a pathology scan: a name, misread or not, and a sex)
undated = set(whole.unique_id[whole["birth_date"].isna()]) if "birth_date" in fields else set()
# Answers are kept by record; a person is known by any of hers, whatever joined since.
whose = persons.set_index("unique_id")["cluster_id"].to_dict()
answered = {frozenset(whose.get(r, r) for r in e) for e in decided}
lone = set() # persons whose identifier is carried by one record only
for f in ids:
carried = persons.dropna(subset=[f]).groupby(["cluster_id", f]).size()
@@ -439,7 +442,7 @@ def run_link(p: str, node: Link):
very same identifier on a record that says nothing else (a scan read only in part)."""
a, b = r.unique_id_l, r.unique_id_r
sides = [(getattr(r, f"{f}_l"), getattr(r, f"{f}_r")) for f in known]
if frozenset((a, b)) in decided or any(
if frozenset((a, b)) in answered or any(
pd.notna(x) and pd.notna(y) and x != y for x, y in sides
):
return None