Examples

The worked example

The repository ships a complete, runnable notebook at examples/presidential_speeches.ipynb. It applies the full chronowords pipeline to U.S. presidential speeches grouped by quarter-century:

  1. load and group the speeches into time slices,

  2. build PPMI embeddings per slice with SVDAlgebra,

  3. align the slices with ProcrustesAligner,

  4. detect and visualise (with Altair) how individual words shifted, and

  5. model topics per slice with TopicModel.

Clone the repository and open it with Jupyter to run it end-to-end.

Short snippets

Train embeddings and find similar words:

from chronowords.algebra import SVDAlgebra

model = SVDAlgebra(n_components=300)
with open("corpus.txt", encoding="utf-8") as fh:
    model.train(fh)

for hit in model.most_similar("computer", n=10):
    print(f"{hit.word}: {hit.similarity:.3f}")

For step-by-step walkthroughs see the Quickstart (single corpus) and the Tutorial: Detecting Semantic Shift Over Time (semantic shift across time slices).