Pipeline#
The Python pipeline lives under process/. Each step is a module run with
python -m process.<script>. Most read from data/ (source inputs) and write
to docs/data/ (browser-readable artefacts).
Run order#
python -m process.update_inventory
python -m process.pdf
python -m process.ladings
python -m process.build_index
python -m process.bor_phonetic_glossary
python -m process.annotate
# Name-matching:
python -m process.cluster_forenames
python -m process.build_forename_reconciliation_dataset
python -m process.build_surname_graph
python -m process.train_surname_scorer
python -m process.train_pair_scorer
# Person IDs on ladings (stamps pids onto the browser-read .json.gz):
python -m process.augment_missing_merchants # optional: recover merchants absent from the dataset
python -m process.build_name_index # name_index.json.gz + name_lading_index.json.gz,
# then (automatically) build_person_files ->
# persons.json.gz + person_neighbours/NNN.json.gz
python -m process.attach_person_ids # re-stamp pids onto docs/data/ladings/*.json.gz
# Cargo records (re-run after ANY glossary change: concepts and identifiers are
# inherited from glossary_data.json at build time, not stored in the ladings):
python -m process.cargo_records --write # -> docs/data/records/<volume>.json.gz
# Search (re-run after ANY glossary, qualifier, lading, gazetteer or person change):
python3 -m process.build_search # vocab -> encoder -> name vectors, + parity check
python3 -m process.build_search --check # exit 1 if anything is stale
Notes on the order:
update_inventory,pdfandladingsread the Word and PDF transcriptions underdata/input/. IV-26 (the butler’s accounts of the New Customs on alien wine, 1378–1487) has no Word file: it is built from Jenks’s PDF bypython3 -m process.wine_accounts(--checkparses and reports without writing), and is then annotated on its own withpython -m process.annotate --only IV-26.python -m process.annotateaccepts--only REF [REF ...]to annotate just those volumes and leave the rest untouched, and-testfor a test run.The search steps use the system
python3, because they needonnxruntimeandanyascii.python -m process.cargo_recordsalso accepts--dry-run,--only REF ...and--predictions DIR(the cargo-structure model’s segmentation instead of the published spans).The name-matching steps embed names with the Symphonym v8 model through
process/symphonym_v8.py(see Name Matching).
Key scripts#
Script |
Purpose |
|---|---|
|
Parses HTML transcriptions into per-volume JSON |
|
Extracts surnames, places, ships → |
|
Builds the IV-26 wine-accounts ladings from Jenks’s PDF (no Word source exists) |
|
Annotates ladings with name, commodity, and unit matches |
|
Part-of-speech tagging for Latin/Middle English cargo text |
|
Builds |
|
Parses BOR typographical conventions into structured entries |
|
Seed-based forename clustering using DMNES + Symphonym |
|
FAISS ANN + Jaro–Winkler filtering → |
|
Logistic-regression surname scorer → |
|
Logistic-regression forename scorer |
|
Person-level pair scorer |
|
Multi-signal similarity feature computation |
|
Stamps person |
|
Reconciliation dataset → |
|
Additively recovers merchants absent from the reconciliation dataset; preserves existing pids |
|
Splits the person index for the browser: |
|
Re-stamps pids onto the committed |
|
The cargo record for every cargo (a row per commodity with quantity, measure, qualifiers and concept) → |
|
The cargo structure model (a CRF over the rules’ and taggers’ readings) and its application to the corpus |
|
Rebuilds everything the site’s search reads ( |
|
One-off, re-runnable corrections applied to the committed ladings (restoring cargos the old parser lost; moving non-cargos to |
|
Produces per-entity JSON-LD for the Linked Data API |
|
Snapshots the public site into the IHR publication repository |
|
|
|
Extracts customs officials from spreadsheet sources |
Shared utilities sit in process/helpers/ (phonetic.py, commodities.py,
utils.py, encoding.py) and process/symphonym/ (the bundled BiLSTM
phonetic embedding model).
Commodity tagging & disambiguation#
annotate.py tags each cargo with a glossary-derived span parser
(process/commodity_parser/): commodities, units, and nested qualifiers, with a
DP selector that prefers longer multi-word anchors. Several deliberate decisions
govern how an ambiguous surface form is resolved to a sense:
The Index of Subjects disambiguates, not frequency. Where a surface form maps to more than one concept (e.g. caddis → cotton vs worsted, cage → object vs measure), the printed per-volume Index of Subjects — which is page-aligned 1:1 with the records — chooses the sense the index attests on that page.
index_disambig.parse_indexresolves an index entry that maps to several concepts by matching its gloss against each candidate’s description and AAT labels (not headword presence, which can’t separate same-form senses); it skips on a tie rather than guess. The map is built intodocs/data/index_page_concepts.jsonbypython -m process.commodity_parser.index_priorand covers 46 of the 47 volumes (the discovery handles underscore-named files and II-9’s Latin index rerum; IV-26, the wine accounts, is not in it). Rebuild it after glossary/AAT edits.The index prior is strong but subordinate to qualifier evidence.
w_index_prior(0.6, inscoring.py) sits above the corpus-frequency tie-breaker but beloww_qual_attest, so an attested qualifier still fixes the head — panni largi/curtis sine grano stays cloth even on a page the index also lists narrow or pan for. Making the prior decisive was tried and rejected: it bulldozed cloth. The accuracy gain is in correct index resolution, not in overriding everything. Corpus frequency only decides when the index is silent and context is empty.Text and annotation offsets must stay aligned.
pos.py’sget_processed_textcollapses dot-runs to an ellipsis and strips brackets; it must persist that cleaned text tocargo["text"]whenever either transform changes it. A prior version only did so for bracket changes, so illegibility- redacted cargos kept the longer original text while offsets referenced the shorter line — shifting every span left and masking valid tokens.Assize cloths are distinct concepts matched by multiword form.
narrowcloth/broadcloth/shortcloth/longclothare matched only via their Latin/English phrases (panni stricti/largi/curti/longi, short clothes …); bare panni → the genericcloth. Width and length are not bare-lemma qualifiers — a single conflatednarrowconcept that held the bare lemma plus width/length qualifiers was a dumping ground (it produced incoherent narrow→broad taggings) and was split.
Things to watch#
ladings.pywarnings about duplicate lading IDs or discarded items — investigate before continuing.docs/data/discarded/holds paragraphs that are not cargos (statements of account, editorial notes, fragments). Its size is not a measure of loss: cargos the parser lost silently never reached it (about 3,760 of them, restored on 30 September 2026). Measure loss withpython3 tools/ladings/audit_losses.py.To correct pids or labels without drifting the corpus, work from the committed
docs/data/ladings/*.json.gz(the source of truth) rather than re-runningladingsorannotate.gzipembeds a timestamp, so commit a.gzonly if its decompressed content changed.JSON-LD files in
docs/api/are generated at deploy time and never committed (exceptcontext.json).The GitHub Actions workflow uses
git difffor incremental builds — cache invalidation matters.
Import convention#
Imports differ by script age. Older scripts (ladings.py, voyages.py) use
bare import config; newer scripts use from process import config. Match
the convention of the file being edited.