How ekq/genealogy works
1. Repository purpose
This project implements two related historical-demography workflows:
- genealogical network inference from the HisKi church-record database, and
- assortative mating analysis on the inferred family links.
The code is organized as a data-processing pipeline rather than a service or interactive application.
2. Top-level flow
The main pipeline starts with raw HisKi records in data/, runs record-linking and parent inference in src/, writes intermediate reconstructed relationships into src/reconstructions/, and then uses those derived links for downstream statistical analysis.
3. Core inference subsystem
compute_burial_matches.py and compute_matches.py are the two main batch jobs.
- The burial-matching step links burial records to corresponding birth records.
- The parent-matching step infers parent-child edges for birth events.
Both scripts are designed to run in batches over event-id lists (birth_event_ids.txt, burial_event_ids.txt) so the workload can be parallelized.
4. Persistence and reconstruction boundary
src/reconstructions/ is the output boundary for generated genealogy artifacts. The README indicates burial-birth links are first produced there, then written back into the HisKi database via serial_burial_db_write.sh, after which parent inference is rerun. This shows a two-stage loop: infer links externally, persist them, then use the enriched database for the next inference pass.
5. Matching model subsystem
The inference logic is concentrated in person_matching_model.py and hiski_models.py. These likely implement scoring, feature extraction, and model evaluation for candidate matches. The presence of serialized models in src/estimated_models/ indicates the system depends on precomputed likelihood tables and trained classifiers rather than training everything from scratch at runtime.
6. Feature and knowledge inputs
src/estimated_models/ contains pickled probability tables and model artifacts such as age likelihoods, name-based ratios, geographic distance maps, and XGBoost models. These are the main statistical priors/features used by the matching pipeline. The architecture is therefore “feature lookup + probabilistic/classifier scoring” over candidate relationships.
7. Geographic and normalization utilities
Several support modules handle domain normalization:
- etrs2lonlat.py converts coordinate systems,
- parish_distances.py supports location-based matching,
- normalize_occupations.py standardizes historical occupations, and
- populate_normalized_names.py fills normalized-name fields.
These utilities feed cleaner features into the matching model and reduce ambiguity in historical records.
8. Historical name normalization boundary
The historical_name_normalizer/ submodule and the files under src/assortative_mating/ for normalized occupations and occupation-to-status mappings indicate a separate normalization layer. Its role is to transform messy historical text into canonical forms before those values are used in inference or social-status analysis.
9. Assortative mating analysis subsystem
src/assortative_mating/assortative_mating_analysis.py consumes reconstructed family links plus occupation/status metadata to analyze partner similarity over time. The package includes curated occupational datasets (historismi_ammatit.tsv, historismi_lyhenteet_filtered.tsv, occupation2status.json) and a cached status model (data/status_data_p0.90.pckl), showing that the analysis depends on precomputed semantic mapping from occupation to social status.
10. Data and generated-artifact split
The repo distinguishes between:
- raw or externally obtained data in data/,
- bundled reference tables and model artifacts in src/estimated_models/ and src/assortative_mating/data/, and
- generated outputs in src/reconstructions/ and src/assortative_mating/plots/.
This separation is important for the diagram: source code operates on curated inputs and emits reconstruction/analysis artifacts.
11. Execution model
The project is primarily Python-based, with a small shell orchestration step. Batch processing is central: the same scripts are run repeatedly over slices of event IDs, allowing parallel execution and incremental reconstruction. There is no evidence of a server, web UI, or message queue; the architecture is offline, file-driven, and model-centric.
12. Diagram takeaway
A good architecture diagram would show: raw HisKi data and normalization tables on the left; candidate-generation and matching models in the middle; reconstructed births/burials/parent edges written to output stores; and assortative-mating analysis consuming the reconstructed genealogy plus occupation/status mappings on the right.
Main entry points: reconstructions Reconstructions · compute_matches.py Parent matches · compute_burial_matches.py Burial matches · hiski_models.py HisKi models
Components 18
Inputs
Raw HisKi records, batch ID lists, and bundled lookup tables.
- HisKi data · Source church-record data consumed by the reconstruction pipeline.
data - Birth IDs · Event IDs that partition the birth-matching workload.
src/birth_event_ids.txt - Burial IDs · Event IDs that partition the burial-matching workload.
src/burial_event_ids.txt
Matching pipeline
Batch inference, scoring models, and normalization helpers for genealogy reconstruction.
- Model priors · Probability tables and trained classifiers used by matching.
src/estimated_models - Burial matches · Links burial records to corresponding birth records.
src/compute_burial_matches.py - Parent matches · Infers parent-child edges for birth events.
src/compute_matches.py - Match model · Core candidate scoring and feature combination for person matches.
src/person_matching_model.py - HisKi models · Domain-specific feature extraction and model support for HisKi records.
src/hiski_models.py - Coords · Converts coordinates for location-based matching.
src/etrs2lonlat.py - Parish distance · Distance support for parish-aware candidate matching.
src/parish_distances.py - Name norms · Populates normalized-name fields used by matching.
src/populate_normalized_names.py - Name normalizer · Historical name normalization layer shared by the pipeline.
src/historical_name_normalizer
Outputs
Reconstructed links and downstream analysis artifacts.
- Reconstructions · Generated genealogy artifacts such as burial-birth links and parent edges.
src/reconstructions - DB write · Writes burial-birth links back to the HisKi database for the next pass.
src/serial_burial_db_write.sh
Assortative mating
Occupation normalization and partner-similarity analysis.
- Occ norms · Normalizes occupations for downstream status analysis.
src/assortative_mating/normalize_occupations.py - Status data · Occupation-to-status mappings and cached status model artifacts.
src/assortative_mating/data - Mating analysis · Analyzes partner similarity using reconstructed links and occupation/status data.
src/assortative_mating/assortative_mating_analysis.py - Plots · Generated figures from assortative mating analysis.
src/assortative_mating/plots
Connections 19
- HisKi data → Burial matches: records · Raw burial and birth records are matched in batch.
- HisKi data → Parent matches: records · Raw HisKi records feed parent inference.
- Birth IDs → Parent matches: batch · Birth event slices drive parallel execution.
- Burial IDs → Burial matches: batch · Burial event slices drive parallel execution.
- Model priors → Match model: priors · Serialized likelihood tables and classifiers inform scoring.
- Model priors → HisKi models: features · Precomputed model artifacts support matching features.
- Coords → Parish distance: geo · Coordinate conversion supports parish distance calculations.
- Parish distance → HisKi models: location · Geographic similarity is used in feature generation.
- Name normalizer → Name norms: names · Normalization routines standardize names before matching.
- Name norms → Match model: clean names · Normalized name fields improve candidate scoring.
- HisKi models → Match model: domain features · HisKi-specific features feed the scoring model.
- Burial matches → Reconstructions: burial links · Burial-birth links are written to the reconstruction boundary.
- Parent matches → Reconstructions: parent edges · Parent-child relationships are emitted as derived artifacts.
- Reconstructions → DB write: persist · Generated burial links are written back to the HisKi database.
- DB write → Parent matches: enriched db · The second inference pass uses the updated database.
- Reconstructions → Mating analysis: family links · Reconstructed genealogy links feed the mating analysis.
- Status data → Occ norms: status refs · Occupation and status reference tables support normalization.
- Occ norms → Mating analysis: occupation status · Normalized occupation/status mappings are analyzed over time.
- Mating analysis → Plots: figures · Analysis outputs are rendered as plots.