A person nothing names is held for review; a scan may misread one valid code as another
This commit is contained in:
+8
-3
@@ -267,7 +267,8 @@ def run_link(p: str, node: Link):
|
||||
"""Persons: records the node's rules join (Splink deterministic linking), joined or kept
|
||||
apart by reviewers' decisions. A person whose records disagree on birth date or sex is
|
||||
held. Persons that may be one (identifiers one typo apart, or the same birth date) and
|
||||
don't contradict each other are queued for review, with Splink's probability."""
|
||||
don't contradict each other are queued for review, with Splink's probability. A person
|
||||
with nothing that names her (no name, birth date or record number read) is held too."""
|
||||
records, sources, written = _identities(p, node)
|
||||
fields = [c for c in records.columns if c != "unique_id"]
|
||||
rules = [r for r in node.rules or node.default_rules()
|
||||
@@ -293,12 +294,16 @@ def run_link(p: str, node: Link):
|
||||
facts = [f for f in ("birth_date", "sex") if f in fields]
|
||||
spread = persons.groupby("cluster_id")[facts].nunique() if facts else pd.DataFrame()
|
||||
torn = set(spread[(spread > 1).any(axis=1)].index) if facts else set()
|
||||
held = json.dumps(["records of this person disagree on birth date or sex"])
|
||||
# Nothing that names her was read (a scan's name line misread, say): nobody to join.
|
||||
read = persons.groupby("cluster_id")[[f for f in fields if f != "sex"]].count().sum(axis=1)
|
||||
nameless = set(read[read == 0].index)
|
||||
why = {c: "records of this person disagree on birth date or sex" for c in torn}
|
||||
why |= {c: "no name, birth date or record number was read" for c in nameless - torn}
|
||||
columns = {f: {"data_type": "text", "nullable": True} for f in (HELD, "_source", *fields)}
|
||||
stable = nodes.stable_persons(persons.groupby("cluster_id")["unique_id"].apply(list).to_dict())
|
||||
linked = [
|
||||
{RECORD: r.unique_id, "person_id": stable[r.cluster_id], "_source": sources[r.unique_id],
|
||||
HELD: held if r.cluster_id in torn else None,
|
||||
HELD: json.dumps([why[r.cluster_id]]) if r.cluster_id in why else None,
|
||||
**{f: getattr(r, f) for f in fields},
|
||||
**({"full_name": written[r.unique_id]} if r.unique_id in written else {})}
|
||||
for r in persons.itertuples()
|
||||
|
||||
Reference in New Issue
Block a user