Skip to main content

kenon logo

kenon

Semantic and co-occurrence graphs for midsized texts. Kenon builds weighted graphs from text using corpus-internal statistics — no neural models or external training data required. Supports co-occurrence windows, TF-IDF similarity, PMI embeddings, and disparity filter backbone extraction.

Installation

uv add kenon
python -m spacy download en_core_web_sm

Quickstart

from kenon import (
    Tokenizer,
    get_stopwords,
    build_cooccurrence_graph,
    extract_backbone,
)

# 1. Tokenize
tokenizer = Tokenizer("en_core_web_sm", lemmatize=True)
tokens = tokenizer.flat_tokens("The cat sat on the mat. The dog ran in the park.")

# 2. Build graph
stopwords = get_stopwords("english")
graph = build_cooccurrence_graph(tokens, window=2, stopwords=stopwords)

# 3. Extract backbone
backbone = extract_backbone(graph, min_alpha_ptile=0.3, min_degree=2)
print(f"Backbone: {backbone.number_of_nodes()} nodes, {backbone.number_of_edges()} edges")

Features

  • Tokenization: spaCy-backed sentence splitting, tokenization, and lemmatization
  • Stopwords: Merged NLTK + sklearn stopword lists with custom extensions
  • Embeddings: Count vectors, TF-IDF, and PMI (via chronowords) — all corpus-internal
  • Co-occurrence graphs: Skip-gram window co-occurrence with collocation detection
  • Semantic graphs: Cosine similarity graphs from any embedder
  • Backbone extraction: Disparity filter for statistically significant edges

Documentation

Full documentation — quickstart, the word-association tutorial, troubleshooting, and the complete API reference — is at kenon.readthedocs.io. The sources live in docs/.

Roadmap

Planned for the next iteration. The robustness items are analysed in detail in PRE-MORTEM.md.

Robustness / API decisions

  • Warn or document when build_semantic_graph runs on too few documents — word-similarity is degenerate on small corpora (each word vector's dimension is the document count).
  • Avoid the dense .toarray() materialisation in the sklearn embedders (out-of-memory risk on large corpora).
  • Make transform() raise the documented RuntimeError when called before fit() (it currently surfaces sklearn's NotFittedError).
  • build_semantic_graph(k_neighbors=...): reuse the already-fitted embedder and warn instead of silently degrading to a threshold-only graph.
  • Guard detect_collocations against NLTK crashes on degenerate corpora — chi_sq raises ZeroDivisionError and likelihood a math-domain ValueError on all-identical tokens; only pmi is robust.
  • Wrap the unsupported-language error in get_stopwords and document its one-time NLTK download.

Proposed features

  • kenon.paths — a first-class concept-to-concept pathfinding helper (currently demonstrated via networkx in the tutorial).
  • Compare a text-derived network against human association norms — Nelson norms / Small World of Words (needs external datasets).

Made by

Kenon is made by Crow Intelligence.

License

MIT

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kenon-0.1.2.tar.gz (14.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kenon-0.1.2-py3-none-any.whl (17.5 kB view details)

Uploaded Python 3

File details

Details for the file kenon-0.1.2.tar.gz.

File metadata

  • Download URL: kenon-0.1.2.tar.gz
  • Upload date:
  • Size: 14.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for kenon-0.1.2.tar.gz
Algorithm Hash digest
SHA256 e72313b1d3badc89de8ac046fe4b76b91921dfe6d93d7eefc7ad4e84af979169
MD5 f4c632aaff39565a695ecba66c079911
BLAKE2b-256 c6e7f6dcd036ced7ff57c7036f2f528ec282926eea06bc04aacaf63e538946c3

See more details on using hashes here.

Provenance

The following attestation bundles were made for kenon-0.1.2.tar.gz:

Publisher: publish.yml on crow-intelligence/kenon

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file kenon-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: kenon-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 17.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for kenon-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 2c88f2994a240fea523a3a40103c62d3eac046a81ca98ecf35725c20240fd428
MD5 205bafbc47819d67ec5227dd839c944f
BLAKE2b-256 c7a47de6746d1bdb36dd4df4e6a511ae479a042b9e3c059f168490358317bd1a

See more details on using hashes here.

Provenance

The following attestation bundles were made for kenon-0.1.2-py3-none-any.whl:

Publisher: publish.yml on crow-intelligence/kenon

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page