Phase 5: optional [graph] analysis layer + core scalars - #5
Merged
Conversation
Port the Wittgenstein analysis pipeline behind an extra; keep simple
scalars dependency-free in the core. The arrow points inward — the core
never imports analyze.
- scalars.py (core): lengths / positions / frequencies, the dependency-free
channel sources.
- analyze/ ([graph] extra):
- embeddings.py: embed_sentences (sentence-transformers, L2-normalised;
the heavy import is deferred to call time).
- graph.py: knn_graph (cosine kNN), embedding_distances (semantic
recurrence input), pagerank_scores (size), community_labels (colour;
Louvain default, KMeans option).
- backbone.py: disparity-filter backbone, ported from kenon (Serrano 2009).
- analyze_text -> Analysis: aligned size / community / distances arrays
from a text (embeddings injectable, so the pipeline tests need no model).
- pyproject: [graph] extra (sentence-transformers, scikit-learn, networkx,
scipy); uv.lock updated. Exports, example, docs, CHANGELOG.
Pipeline fully tested with synthetic embeddings (no download); the real
embedder is an opt-in smoke test (LEXOGRAPH_RUN_MODEL). ruff + ty + 180
tests green; mkdocs build --strict green (griffe static-analyses analyze
without importing the heavy deps).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Merged
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 5 — analysis
The optional analysis layer that produces real encoding channels, plus the dependency-free core scalars. Stacked on #4. The dependency arrow points inward: the core never imports
analyze.Core (no extra)
lexograph.scalars—lengths,positions,frequencies: the built-in channel sources, so a walk/spiral/dotplot works with nothing installed beyond the core.lexograph[graph]extraanalyze/embeddings.py—embed_sentences(sentence-transformers, L2-normalised). The heavy import is deferred to call time, so importinganalyzeis cheap and the whole pipeline is testable with injected vectors.analyze/graph.py—knn_graph(cosine kNN),embedding_distances(→ semantic recurrence dotplot),pagerank_scores(size),community_labels(colour; Louvain default, KMeans option).analyze/backbone.py— disparity-filter backbone, ported from siblingkenon(Serrano et al. 2009).analyze_text→Analysis— alignedsize/community/distancesarrays from a text.embeddingsare injectable.Verification
make cigreen: ruff + ty + 180 tests / 1 skipped. The graph pipeline (kNN, PageRank, Louvain/KMeans, disparity backbone,analyze_text) is covered with synthetic embeddings — no model download. The real embedder is an opt-in smoke test (LEXOGRAPH_RUN_MODEL=1).mkdocs build --strictgreen — mkdocstrings/griffe static-analysesanalyzewithout importing the heavy deps (same pattern the family's RTD uses, which installs only the docs extra).pyprojectgains the[graph]extra;uv.lockregenerated.🤖 Generated with Claude Code