Retained manuscript analysis programs

Public source edition. Original dates, research statuses, numerical results and stated limits belong to this source. Any private material is identified by a custody notice in the text.

Retained manuscript analysis programs

This portable edition contains the actual retained Python algorithms for corpus retrieval, file indexing, hand-labelled shape cross-tabs, bench-preserving component segmentation, and EVA image-line exploration. The complete retrieval corpus, retained measurement masks and tables, full Zandbergen–Landini version 2b transcription, and a native f1r photograph are included in the download. These are offline programs, separate from the website's interactive readers.

Download and unpack analysis-programs.zip, then work from its analysis-programs directory. Python 3.10 or later is required. Install the packages in requirements.txt in an environment of your choice. No command calls a paid service, starts a web server, edits the research database, or writes into an input directory. Every writing command requires --output naming a new directory. Existing outputs are rejected.

Corpus retrieval

python3 analysis.py embed --chunks data/retrieval-fixture.jsonl --backend tfidf --output ../example-index
python3 analysis.py query --index ../example-index --question "f100r" --threshold 0.05
python3 analysis.py embed --chunks data/corpus.jsonl --backend tfidf --output ../complete-index
python3 analysis.py query --index ../complete-index --question "Hartlieb" --top-k 10

corpus.jsonl includes all 2,151 substantive research and dated research-context rows in the approved public record projection. Each row retains its projected research text, source locator, chunk position, and actual extraction date. The original corpus has 2,234 rows: 83 unrelated operational/personal rows remain in private custody and are excluded from retrieval, with every omitted ID and the full denominator recorded in data/corpus-projection.json. Of the retained rows, 2,081 are primary/research chunks and 70 are dated research-context rows. The small fixture contains twelve complete actual chunks for a quick execution check. It is not a replacement corpus. The original retrieval defaults referred to an April 2026 snapshot; this distribution explicitly selects its inputs and does not represent that old snapshot as current. Historical claims inside retrieved passages retain their source date and may be superseded by the current research record.

TF-IDF uses the retained tokenization, max-term-frequency weighting, smoothed inverse document frequency, L2 normalization, and term-overlap reranking. Scores are rankings, not calibrated probabilities or evidence of semantic truth. The default threshold is 0.30; no hit is an ordinary outcome. The original dense matrix can use substantial memory for a large vocabulary. This edition produces 2,151 vectors over approximately 92,000 terms, about 756 MiB for the matrix alone; allow additional RAM for normalization and loading. Full text remains available independently of the index.

To use a locally installed embedding model, install requirements-local-model.txt, obtain/cache the model separately, and select it explicitly:

python3 analysis.py embed --chunks data/corpus.jsonl --backend local-model --model /your/local/model --output ../semantic-index
python3 analysis.py query --index ../semantic-index --question "animal form and preparation"

Model loading uses local_files_only=True with offline environment flags. The exact model recorded in the index is required at query time. An unavailable model or dependency is an error; semantic mode never silently switches to TF-IDF. The optional semantic mode was not executed in the assembly environment because sentence-transformers and a cached model were unavailable in the system and two retained source-work environments. The retained historical RAG index itself records a TF-IDF fallback; the checked default/configured caches contain no model snapshot. No model weights are bundled.

Chunk your own Markdown or JSON:

python3 analysis.py chunk --input README.md SOURCE_CREDITS.json --output ../new-chunks

The retained chunker preserves section citations and splits long content. Its status and layer tags are regex heuristics. They are not research dispositions and do not supersede explicit source status. Paths printed by a locally generated index describe the inputs you supplied; review them before sharing your own outputs. Shipped corpus locators resolve from the website tool entrypoint to its public provenance edition.

File metadata catalogue

python3 analysis.py catalog-build --root data --output ../catalogue
python3 analysis.py catalog-find --catalog ../catalogue --term Hartlieb --limit 10
python3 analysis.py catalog-find --catalog ../catalogue --term F452 --kind finding

The original scanner records file metadata and symlinks without following directory symlinks. The original find operation retains exact finding-ID recognition, kind filters and path-priority ranking. All 777 finding rows, 725 manuscript rows and the complete retained citation table's catalogue fields are supplied in data/catalog-records.json. The full public structured edition is available in the website's research-record tool. The CLI also accepts --edition pointing to that JSON, or a user-provided compatible SQLite source opened in read-only mode. --sources accepts the original schema-version-1 external-root registry with explicit allowed bases; no additional roots are inferred. --move-map accepts an explicit TSV; relative destinations resolve against the map directory. Source navigation rewriting is excluded.

Hand labels, row geometry and cross-tabs

python3 analysis.py seed-crosstab --perms 10000 --output ../seed-cross-tab
python3 analysis.py bench-measure --perms 10000 --output ../bench-measurement

The seed cross-tab recomputes the original rule-versus-hand confusion table, line correlations, folio centering, residuals against EVA unit count and within-folio permutation controls from the retained propagated line counts. It preserves all shape variables and control variables. It does not regenerate the nearest-neighbour labels from images. Its permutation stream starts fresh, so compare correlation matrices exactly; its p values are a new controlled recomputation.

The bench measurement directly executes the original complete measurement command on the 3,389 retained merged masks, the original pre-merge geometry, fixed row mapping and version 2b transcription for f1r, f49v and f88r. Its leave-one-folio-out controls retain the original fixed 2,000 permutations. --perms controls the main matrix permutation count. Both commands write new results without replacing the retained October results shipped under data/hartlieb/.

Those original shape classes, hand labels and propagation results are research observations/proposals. A correlation does not bind a depicted component to a written meaning. Failed or weak controls remain visible in the complete original measure.json and matrix CSV files. The f57v.3 ring masks are supplied separately and are not counted as page lines.

Image segmentation

Create a JSON file with a folio identifier, local image path, coordinate scale and regions. Paths are relative to that JSON file. For the included photograph:

{"f1r":{"image":"data/f1r.jpg","scale":3.424,"boxes":[[150,115,715,885]]}}

This uses the retained f1r text-region coordinates on the supplied JPEG and is a new proposal run. Save it as image-config.json beside analysis.py, then run:

python3 analysis.py segment --config image-config.json --output ../component-proposals

The retained algorithms extract ink with adaptive background subtraction and red-ink exclusion, find connected components, split wide components, and apply the same shaft/bar/loop tests and bench-merging rules. Output contains every proposed component's position, dimensions, source, kind, parts and mask, plus the exact source-image hash and parameters. Changing an image, scale, crop or threshold can change the components. No part receives an automatic semantic interpretation.

The other retained bench operations are also exposed:

python3 analysis.py bench-run --command labels --output ../bench-labels
python3 analysis.py bench-run --command agree --output ../reader-agreement
python3 analysis.py bench-run --command inventory --scan-dir /your/selected/tiff-directory --output ../inventory

labels reconstructs the 72-piece label table. agree compares the retained first labels with the retained blind model second read; it is not a two-human inter-rater study. inventory includes the separate ring control and counts TIFF filenames only in the explicitly selected directory, preserving that denominator. bench-run --command sheets and bench-run --command segment accept the same --config contract and require original-resolution source photographs for their historical coordinates.

Full historical seed commands remain available:

python3 analysis.py seed-run --command assemble --output ../assembled-labels
python3 analysis.py seed-run --command sample --config my-historical-scans.json --output ../sample
python3 analysis.py seed-run --command lines --config my-historical-scans.json --output ../line-alignment
python3 analysis.py seed-run --command measure --config my-historical-scans.json --output ../seed-measurement

data/historical-image-config.json preserves the exact original three TIFF filenames, scales and boxes. sample, lines and the full nearest-neighbour measure command require those original-resolution images. sample and measure also assert the original retained cluster correspondence. The old TIFF location was unavailable in this assembly; these modes are prerequisite-dependent and were not claimed as a historical replay. Native JPEG segmentation is a separately identified new proposal run. The raw functions and other historical subcommands remain in code/item9_seed_crosstab.py and code/item9_bench_segment.py for configured Python use, with no automatically running historical main.

EVA line atlas

python3 analysis.py atlas --image data/f1r.jpg --folio f1r --output ../f1r-atlas

Open the resulting index.html locally. It includes complete folio transcription, every detected source-image band, a structured JSON export and all EVA-unit contexts. The original horizontal projection/cropping and EVA cleaning/tokenization functions are retained. Alternative transcription markings remain in the source IVTFF; the original cleaning function chooses the first bracketed alternative and drops markup for its derived token view. Unknown characters are skipped by the original unit tokenizer.

Image bands and transcription lines are shown independently. To record an inspected correspondence, provide --line-map mappings.json, an object such as {"1":1,"2":2} mapping band number to transcription line. No inferred one-to-one alignment is silently asserted; a plant illustration may contribute a detected dark band. The supplied full transcription supports other folios when you provide their local source images. A public source image is also at Read the cited source relative to the website entrypoint.

Source and software credits

SOURCE_CREDITS.json lists source identity, exact function-retention counts and data inventory. Algorithms originate in the retained research programs by Honeycutt Ai Labs. The image is the retained native photograph of Beinecke Library, Yale University, MS 408, f1r. The transcription is Zandbergen–Landini IVTFF EVA version 2b, dated 25 December 2022; its original header is retained. Existing institutional/source terms apply to third-party materials; this package does not assign them a new license. Research code and adapters are supplied for the same research use as the retained project materials; no third-party dependency source or model weights are bundled.

NumPy supplies arrays and linear algebra, OpenCV supplies connected components and morphology, and Pillow supplies image reading/cropping. Optional Sentence Transformers supplies local embedding models. See requirements.txt, requirements-local-model.txt and DEPENDENCIES.json for the versions actually checked and the untested optional mode. Browser layout is not part of the offline execution check.

Download this public source

Public source text and line addresses
# Retained manuscript analysis programs

This portable edition contains the actual retained Python algorithms for corpus retrieval, file indexing, hand-labelled shape cross-tabs, bench-preserving component segmentation, and EVA image-line exploration. The complete retrieval corpus, retained measurement masks and tables, full Zandbergen–Landini version 2b transcription, and a native f1r photograph are included in the download. These are offline programs, separate from the website's interactive readers.

Download and unpack `analysis-programs.zip`, then work from its `analysis-programs` directory. Python 3.10 or later is required. Install the packages in `requirements.txt` in an environment of your choice. No command calls a paid service, starts a web server, edits the research database, or writes into an input directory. Every writing command requires `--output` naming a new directory. Existing outputs are rejected.

## Corpus retrieval

```sh
python3 analysis.py embed --chunks data/retrieval-fixture.jsonl --backend tfidf --output ../example-index
python3 analysis.py query --index ../example-index --question "f100r" --threshold 0.05
python3 analysis.py embed --chunks data/corpus.jsonl --backend tfidf --output ../complete-index
python3 analysis.py query --index ../complete-index --question "Hartlieb" --top-k 10
```

`corpus.jsonl` includes all 2,151 substantive research and dated research-context rows in the approved public record projection. Each row retains its projected research text, source locator, chunk position, and actual extraction date. The original corpus has 2,234 rows: 83 unrelated operational/personal rows remain in private custody and are excluded from retrieval, with every omitted ID and the full denominator recorded in `data/corpus-projection.json`. Of the retained rows, 2,081 are primary/research chunks and 70 are dated research-context rows. The small fixture contains twelve complete actual chunks for a quick execution check. It is not a replacement corpus. The original retrieval defaults referred to an April 2026 snapshot; this distribution explicitly selects its inputs and does not represent that old snapshot as current. Historical claims inside retrieved passages retain their source date and may be superseded by the current research record.

TF-IDF uses the retained tokenization, max-term-frequency weighting, smoothed inverse document frequency, L2 normalization, and term-overlap reranking. Scores are rankings, not calibrated probabilities or evidence of semantic truth. The default threshold is 0.30; no hit is an ordinary outcome. The original dense matrix can use substantial memory for a large vocabulary. This edition produces 2,151 vectors over approximately 92,000 terms, about 756 MiB for the matrix alone; allow additional RAM for normalization and loading. Full text remains available independently of the index.

To use a locally installed embedding model, install `requirements-local-model.txt`, obtain/cache the model separately, and select it explicitly:

```sh
python3 analysis.py embed --chunks data/corpus.jsonl --backend local-model --model /your/local/model --output ../semantic-index
python3 analysis.py query --index ../semantic-index --question "animal form and preparation"
```

Model loading uses `local_files_only=True` with offline environment flags. The exact model recorded in the index is required at query time. An unavailable model or dependency is an error; semantic mode never silently switches to TF-IDF. The optional semantic mode was not executed in the assembly environment because `sentence-transformers` and a cached model were unavailable in the system and two retained source-work environments. The retained historical RAG index itself records a TF-IDF fallback; the checked default/configured caches contain no model snapshot. No model weights are bundled.

Chunk your own Markdown or JSON:

```sh
python3 analysis.py chunk --input README.md SOURCE_CREDITS.json --output ../new-chunks
```

The retained chunker preserves section citations and splits long content. Its status and layer tags are regex heuristics. They are not research dispositions and do not supersede explicit source status. Paths printed by a locally generated index describe the inputs you supplied; review them before sharing your own outputs. Shipped corpus locators resolve from the website tool entrypoint to its public provenance edition.

## File metadata catalogue

```sh
python3 analysis.py catalog-build --root data --output ../catalogue
python3 analysis.py catalog-find --catalog ../catalogue --term Hartlieb --limit 10
python3 analysis.py catalog-find --catalog ../catalogue --term F452 --kind finding
```

The original scanner records file metadata and symlinks without following directory symlinks. The original `find` operation retains exact finding-ID recognition, kind filters and path-priority ranking. All 777 finding rows, 725 manuscript rows and the complete retained citation table's catalogue fields are supplied in `data/catalog-records.json`. The full public structured edition is available in the website's research-record tool. The CLI also accepts `--edition` pointing to that JSON, or a user-provided compatible SQLite source opened in read-only mode. `--sources` accepts the original schema-version-1 external-root registry with explicit allowed bases; no additional roots are inferred. `--move-map` accepts an explicit TSV; relative destinations resolve against the map directory. Source navigation rewriting is excluded.

## Hand labels, row geometry and cross-tabs

```sh
python3 analysis.py seed-crosstab --perms 10000 --output ../seed-cross-tab
python3 analysis.py bench-measure --perms 10000 --output ../bench-measurement
```

The seed cross-tab recomputes the original rule-versus-hand confusion table, line correlations, folio centering, residuals against EVA unit count and within-folio permutation controls from the retained propagated line counts. It preserves all shape variables and control variables. It does not regenerate the nearest-neighbour labels from images. Its permutation stream starts fresh, so compare correlation matrices exactly; its p values are a new controlled recomputation.

The bench measurement directly executes the original complete measurement command on the 3,389 retained merged masks, the original pre-merge geometry, fixed row mapping and version 2b transcription for f1r, f49v and f88r. Its leave-one-folio-out controls retain the original fixed 2,000 permutations. `--perms` controls the main matrix permutation count. Both commands write new results without replacing the retained October results shipped under `data/hartlieb/`.

Those original shape classes, hand labels and propagation results are research observations/proposals. A correlation does not bind a depicted component to a written meaning. Failed or weak controls remain visible in the complete original `measure.json` and matrix CSV files. The f57v.3 ring masks are supplied separately and are not counted as page lines.

## Image segmentation

Create a JSON file with a folio identifier, local image path, coordinate scale and regions. Paths are relative to that JSON file. For the included photograph:

```json
{"f1r":{"image":"data/f1r.jpg","scale":3.424,"boxes":[[150,115,715,885]]}}
```

This uses the retained f1r text-region coordinates on the supplied JPEG and is a new proposal run. Save it as `image-config.json` beside `analysis.py`, then run:

```sh
python3 analysis.py segment --config image-config.json --output ../component-proposals
```

The retained algorithms extract ink with adaptive background subtraction and red-ink exclusion, find connected components, split wide components, and apply the same shaft/bar/loop tests and bench-merging rules. Output contains every proposed component's position, dimensions, source, kind, parts and mask, plus the exact source-image hash and parameters. Changing an image, scale, crop or threshold can change the components. No part receives an automatic semantic interpretation.

The other retained bench operations are also exposed:

```sh
python3 analysis.py bench-run --command labels --output ../bench-labels
python3 analysis.py bench-run --command agree --output ../reader-agreement
python3 analysis.py bench-run --command inventory --scan-dir /your/selected/tiff-directory --output ../inventory
```

`labels` reconstructs the 72-piece label table. `agree` compares the retained first labels with the retained blind model second read; it is not a two-human inter-rater study. `inventory` includes the separate ring control and counts TIFF filenames only in the explicitly selected directory, preserving that denominator. `bench-run --command sheets` and `bench-run --command segment` accept the same `--config` contract and require original-resolution source photographs for their historical coordinates.

Full historical seed commands remain available:

```sh
python3 analysis.py seed-run --command assemble --output ../assembled-labels
python3 analysis.py seed-run --command sample --config my-historical-scans.json --output ../sample
python3 analysis.py seed-run --command lines --config my-historical-scans.json --output ../line-alignment
python3 analysis.py seed-run --command measure --config my-historical-scans.json --output ../seed-measurement
```

`data/historical-image-config.json` preserves the exact original three TIFF filenames, scales and boxes. `sample`, `lines` and the full nearest-neighbour `measure` command require those original-resolution images. `sample` and `measure` also assert the original retained cluster correspondence. The old TIFF location was unavailable in this assembly; these modes are prerequisite-dependent and were not claimed as a historical replay. Native JPEG segmentation is a separately identified new proposal run. The raw functions and other historical subcommands remain in `code/item9_seed_crosstab.py` and `code/item9_bench_segment.py` for configured Python use, with no automatically running historical main.

## EVA line atlas

```sh
python3 analysis.py atlas --image data/f1r.jpg --folio f1r --output ../f1r-atlas
```

Open the resulting `index.html` locally. It includes complete folio transcription, every detected source-image band, a structured JSON export and all EVA-unit contexts. The original horizontal projection/cropping and EVA cleaning/tokenization functions are retained. Alternative transcription markings remain in the source IVTFF; the original cleaning function chooses the first bracketed alternative and drops markup for its derived token view. Unknown characters are skipped by the original unit tokenizer.

Image bands and transcription lines are shown independently. To record an inspected correspondence, provide `--line-map mappings.json`, an object such as `{"1":1,"2":2}` mapping band number to transcription line. No inferred one-to-one alignment is silently asserted; a plant illustration may contribute a detected dark band. The supplied full transcription supports other folios when you provide their local source images. A public source image is also at `../../../assets/tools/analysis/f1r.jpg` relative to the website entrypoint.

## Source and software credits

`SOURCE_CREDITS.json` lists source identity, exact function-retention counts and data inventory. Algorithms originate in the retained research programs by Honeycutt Ai Labs. The image is the retained native photograph of Beinecke Library, Yale University, MS 408, f1r. The transcription is Zandbergen–Landini IVTFF EVA version 2b, dated 25 December 2022; its original header is retained. Existing institutional/source terms apply to third-party materials; this package does not assign them a new license. Research code and adapters are supplied for the same research use as the retained project materials; no third-party dependency source or model weights are bundled.

NumPy supplies arrays and linear algebra, OpenCV supplies connected components and morphology, and Pillow supplies image reading/cropping. Optional Sentence Transformers supplies local embedding models. See `requirements.txt`, `requirements-local-model.txt` and `DEPENDENCIES.json` for the versions actually checked and the untested optional mode. Browser layout is not part of the offline execution check.