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_graphruns 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 documentedRuntimeErrorwhen called beforefit()(it currently surfaces sklearn'sNotFittedError). -
build_semantic_graph(k_neighbors=...): reuse the already-fitted embedder and warn instead of silently degrading to a threshold-only graph. - Guard
detect_collocationsagainst NLTK crashes on degenerate corpora —chi_sqraisesZeroDivisionErrorandlikelihooda math-domainValueErroron all-identical tokens; onlypmiis robust. - Wrap the unsupported-language error in
get_stopwordsand 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e72313b1d3badc89de8ac046fe4b76b91921dfe6d93d7eefc7ad4e84af979169
|
|
| MD5 |
f4c632aaff39565a695ecba66c079911
|
|
| BLAKE2b-256 |
c6e7f6dcd036ced7ff57c7036f2f528ec282926eea06bc04aacaf63e538946c3
|
Provenance
The following attestation bundles were made for kenon-0.1.2.tar.gz:
Publisher:
publish.yml on crow-intelligence/kenon
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
kenon-0.1.2.tar.gz -
Subject digest:
e72313b1d3badc89de8ac046fe4b76b91921dfe6d93d7eefc7ad4e84af979169 - Sigstore transparency entry: 2010810577
- Sigstore integration time:
-
Permalink:
crow-intelligence/kenon@b62a563ea4f74f84dcfb51d3bac9969112439f1d -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/crow-intelligence
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@b62a563ea4f74f84dcfb51d3bac9969112439f1d -
Trigger Event:
release
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2c88f2994a240fea523a3a40103c62d3eac046a81ca98ecf35725c20240fd428
|
|
| MD5 |
205bafbc47819d67ec5227dd839c944f
|
|
| BLAKE2b-256 |
c7a47de6746d1bdb36dd4df4e6a511ae479a042b9e3c059f168490358317bd1a
|
Provenance
The following attestation bundles were made for kenon-0.1.2-py3-none-any.whl:
Publisher:
publish.yml on crow-intelligence/kenon
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
kenon-0.1.2-py3-none-any.whl -
Subject digest:
2c88f2994a240fea523a3a40103c62d3eac046a81ca98ecf35725c20240fd428 - Sigstore transparency entry: 2010810615
- Sigstore integration time:
-
Permalink:
crow-intelligence/kenon@b62a563ea4f74f84dcfb51d3bac9969112439f1d -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/crow-intelligence
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@b62a563ea4f74f84dcfb51d3bac9969112439f1d -
Trigger Event:
release
-
Statement type: