Skip to content

Phase 4: recurrence dotplot + concordance grids - #4

Merged
zolizoli merged 1 commit into
mainfrom
phase-4-grids
Jul 1, 2026
Merged

Phase 4: recurrence dotplot + concordance grids#4
zolizoli merged 1 commit into
mainfrom
phase-4-grids

Conversation

@zolizoli

Copy link
Copy Markdown
Member

Phase 4 — grids

The two grid presets, on two genuinely different grids. Stacked on #3.

Recurrence dotplot — the text against itself

  • layout/recurrence.pyrecurrence_distances (token-set or character-k-gram Jaccard, dependency-free) and recurrence_matrix (threshold → boolean dotplot grid).
  • recurrence_plot — the sentence × sentence self-similarity grid via imshow ("binary" dotplot or "distance" heatmap). Accepts a precomputed distances matrix, so the [graph] extra can drive it from embeddings.

Concordance — term dispersion (a different grid)

  • layout/dispersion.pyterm_offsets (per-term token offsets) and kwic / KWIC (keyword-in-context).
  • concordance — a term × text lexical-dispersion plot: one row per term, one tick per occurrence, optional normalize to text-fraction.

Verification

  • make ci green: 148 tests, incl. Hypothesis properties (Jaccard symmetry, zero diagonal, [0,1] bounds; offset/KWIC behaviour).
  • mkdocs build --strict green. 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

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>
@zolizoli
zolizoli changed the base branch from phase-3-corkscrew to main July 1, 2026 09:30
@zolizoli
zolizoli merged commit c8080bc into main Jul 1, 2026
@zolizoli
zolizoli deleted the phase-4-grids branch July 1, 2026 09:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant