Recurrence dotplot¶
The bundled chapter plotted against itself. The strong main diagonal is each sentence matching itself; the symmetric off-diagonal dots mark sentences that echo one another — here, the repeated dialogue exchanges between the Bennets.
"""Recurrence-dotplot demo: a chapter plotted against itself.
Run with: uv run python examples/recurrence_demo.py
Writes recurrence.png to the current directory.
"""
from lexograph import load_demo_text, recurrence_plot
def main() -> None:
"""Draw the sentence x sentence self-similarity grid of the bundled chapter."""
fig = recurrence_plot(load_demo_text(), threshold=0.7)
fig.savefig("recurrence.png", dpi=150)
print("Saved recurrence.png")
if __name__ == "__main__":
main()
Run it with:
Pass mode="distance" for the full similarity heatmap, shingle=k for
character-k-gram similarity, or a precomputed distances matrix (e.g. an
embedding distance from the [graph] extra) to drive it from semantics.