Phase 4: recurrence dotplot + concordance grids - #4
Merged
Conversation
Two grid presets on two different grids — self-similarity vs term dispersion. - layout/recurrence.py: recurrence_distances (token / char-n-gram Jaccard, dependency-free) and recurrence_matrix (threshold to a boolean dotplot). - presets/recurrence.py: recurrence_plot — the sentence x sentence grid via imshow (binary dotplot or distance heatmap). Accepts a precomputed distance matrix (e.g. embeddings from the [graph] extra). - layout/dispersion.py: term_offsets (per-term token offsets) and kwic/KWIC (keyword-in-context lines). - presets/concordance.py: concordance — a term x text lexical-dispersion plot, one tick per occurrence, one row per term. - Exports, examples (recurrence_demo, concordance_demo), docs, CHANGELOG. make ci green (148 tests, incl. Jaccard symmetry/bounds and offset/KWIC properties); mkdocs build --strict green; both grids render headlessly and were eyeballed (clean diagonal + symmetric echoes; per-term dispersion rows). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Phase 4 — grids
The two grid presets, on two genuinely different grids. Stacked on #3.
Recurrence dotplot — the text against itself
layout/recurrence.py—recurrence_distances(token-set or character-k-gram Jaccard, dependency-free) andrecurrence_matrix(threshold → boolean dotplot grid).recurrence_plot— the sentence × sentence self-similarity grid viaimshow("binary"dotplot or"distance"heatmap). Accepts a precomputeddistancesmatrix, so the[graph]extra can drive it from embeddings.Concordance — term dispersion (a different grid)
layout/dispersion.py—term_offsets(per-term token offsets) andkwic/KWIC(keyword-in-context).concordance— a term × text lexical-dispersion plot: one row per term, one tick per occurrence, optionalnormalizeto text-fraction.Verification
make cigreen: 148 tests, incl. Hypothesis properties (Jaccard symmetry, zero diagonal,[0,1]bounds; offset/KWIC behaviour).mkdocs build --strictgreen. Both figures eyeballed: the dotplot shows a clean main diagonal plus symmetric off-diagonal echoes (the repeated Bennet dialogue); the dispersion shows each term's occurrences across the chapter, and KWIC prints correctly.🤖 Generated with Claude Code