Skip to content

Phase 1: the spine (segment → layout → encode → render) - #1

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

Phase 1: the spine (segment → layout → encode → render)#1
zolizoli merged 1 commit into
mainfrom
phase-1-spine

Conversation

@zolizoli

Copy link
Copy Markdown
Member

Phase 1 — the spine

Implements the four-step pipeline end to end on the bundled Pride and Prejudice text, returning a matplotlib Figure.

What landed

  • segment/units.pysegment() over chars / tokens / sentences. Default sentence splitter is self-contained and offline, guarding abbreviations (Mr. Bennet) and dialogue+attribution ("Is it let?" she asked.); punkt=True opts into NLTK Punkt.
  • encode/channels.py — the plain-array data contract: normalize_size, categorical_colors (tab20 ≤20 cats, hsv beyond; stable by first appearance), continuous_colors, and the Channels container.
  • layout/linear.py — a trivial reading-order grid layout (the "trivial layout" the spine needs before the richer layouts arrive).
  • render/mpl.pyrender_points and render_path construct Figure directly (no pyplot, never show()), equal-aspect and framed, headless-safe.
  • Public API re-exported to the top level; per-preset docs pages + nav; examples/spine_demo.py.

Verification

  • make ci green: ruff format + lint, ty check, 57 tests (unit + Hypothesis property tests + an end-to-end spine test), 97% coverage.
  • mkdocs build --strict green.
  • examples/spine_demo.py segments the chapter into 59 sentences and renders a tile field.

🤖 Generated with Claude Code

End-to-end pipeline on the bundled text, returning a matplotlib Figure.

- segment/units.py: segment() over chars/tokens/sentences. Offline,
  abbreviation- and dialogue-aware regex sentence splitter by default
  (keeps "Mr. Bennet" and '"Is it let?" she asked.' whole); punkt=True
  opts into NLTK Punkt.
- encode/channels.py: the plain-array data contract — normalize_size,
  categorical_colors (tab20/hsv, stable by first appearance),
  continuous_colors, and the Channels container.
- layout/linear.py: a trivial reading-order grid layout.
- render/mpl.py: render_points and render_path build Figure directly (no
  pyplot, never show()); equal aspect, framed, headless-safe.
- Public API re-exported to the top level; submodule __init__ re-exports.
- Tests: unit + Hypothesis property tests per module, plus an end-to-end
  spine test; examples/spine_demo.py; docs pages and nav.

make ci green (57 tests); mkdocs build --strict green.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@zolizoli
zolizoli merged commit c5e894d into main Jul 1, 2026
4 checks passed
@zolizoli
zolizoli deleted the phase-1-spine branch July 1, 2026 09:31
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