The Lexos Python Library
The Lexos Python library reproduces and extends most of the text analysis tools in the Lexos web app. Lexos is designed to implement many common text analysis procedures and create workflows in a way that saves the user having to re-invent the wheel or figure out how to combine multiple Python packages to achieve a given result. It is intended to be used as a library in other projects to build backend functions for applications, but it can be used in standalone scripts or in Jupyter notebooks. As with the original web app, it is designed to be accessible to entry-level users whilst offering power functionality for students and researchers, particularly in the Humanities. It is also designed to be as language-agnostic as possible so that it can be used for a wide variety of historical and under-resourced languages. Users can leverage existing language models or train their own.
📖 Documentation
A full discussion of the use of the API can be found on the website Documentation website.
⭐️ Major Features
- Loads texts from a variety of sources into a common data structure.
- Manages a corpus of texts and generates stastics about the corpus.
- Performs text pre-processing ("scrubbing") and splitting ("cutting").
- Performs tokenization and trains language models using spaCy.
- Creates assorted visualizations of term/ngram vectors.
- Performs hierarchical and kmeans clustering with a variety of visualizations for text comparisons..
- Performs classification using spaCy, scikit-learn, and custom architectures.
- Generates topic models and topic model visualizations using MALLET and DFR Browser 2.
And more!
What's New in v0.2.2
- Minor bug fixes to spaCy model CLI installation.
What's New in v0.2.1
- Smoother spaCy model installation process.
- A refactored
malletmodule now provides access to both Java and apyrmalletbackends. This allows users to install the Rust version of MALLET withpip install pyrmallet, rather than the more complicated procedure of installing downloading and installing MALLET and JDK.
What's New in v0.2.0
- Performance optimizations and bug fixes througout.
- A simplified public API.
- Better HTML and XML tag handling in Scrubber.
- New and improved clustering visualizations.
- Improved plotting functions in Bootstrap Consensus clustering.
- Silhouette score analysis for KMeans clustering.
- More advanced topic modelling features, including termite plots, customisable labels, and LLM-generated labels with local or cloud-based models.
- A new Classification module that performs text classification using a variety of architectures.
- A new Structural Stylometry module that allows you to assess the significance of punctuation and whitespace patterns in your documentation.
- Language model training features.
- Improved documentation and tutorials for new users (now in a separate lexos-docs repository).
⏳ Installation
pip install lexos
To update to the latest version, use
pip install -U lexos
Or, if you are using uv:
uv add lexos
Some Lexos functions use spaCy language models to obtain language-specific information about texts. To download spaCy models, run the following command:
download-spacy-models xx_sent_ud_sm en_core_web_sm
or
uv run download-spacy-models xx_sent_ud_sm en_core_web_sm
You can install multiple models by separating their names with spaces. If you do not run this command, Lexos will install the default xx_sent_ud_sm model the first time you attempt to use a feature that requires a spaCy language model.
If you are working in another language or need a larger language model, you can download instructions for additional models from the spaCy models page. Use the following command:
python -m spacy download en_core_web_md # Replace with the name of your model
Add uv run to the beginning of the command if you are using a uv environment.
If you need to install a model from within Python, you can use Lexos' helper funtion:
from lexos.util import download_spacy_model
download_spacy_model("fr_core_web_sm")
🚦Project Status
The Lexos API is currently in beta. Most of the core functionality of the Lexos web app, along with new features, has been implemented and documented. As of September 2026, the API is considered feature complete and stable for general use, but some rough edges remain. Feedback is welcome.
I will continue to fix bugs and improve the documentation as issues arise, but no major new features are planned at this time. The beta release coincides with at a time when the landscape of digital tools is rapidly evolving and AI-assisted coding is becoming more prevalent. I am waiting to see whether there is significant adoption of the Lexos library before investing more time in developing new features. If you like Lexos, you can help by requesting new features in the GitHub issues (labelled as "enhancement") or contributing them yourself.
💝 Contribute
- If are looking for help using Lexos, please post you question on the GitHub Discussions board.
- Bug reports and feature requests: Please use GitHub issues.
- For other types of contributions see the Documentation website.
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
📝 Citation Information
Kleinman, S., (2026). Lexos. v0.2.2 https://github.com/scottkleinman/lexos. 10.5281/zenodo.18112379.
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 lexos-0.2.2.tar.gz.
File metadata
- Download URL: lexos-0.2.2.tar.gz
- Upload date:
- Size: 1.6 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e0ed41f3aebfa0c1fd42d7fd627ad4246fd45cd86c724efec342172b3de0d2b0
|
|
| MD5 |
88d773ee39f9a59504a1c15d2eab9ac1
|
|
| BLAKE2b-256 |
4a6a2e5170afbbe769764a0ede5aed909ce56a013175a81082b7220d589f9fc7
|
Provenance
The following attestation bundles were made for lexos-0.2.2.tar.gz:
Publisher:
release.yml on scottkleinman/lexos
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
lexos-0.2.2.tar.gz -
Subject digest:
e0ed41f3aebfa0c1fd42d7fd627ad4246fd45cd86c724efec342172b3de0d2b0 - Sigstore transparency entry: 2786361323
- Sigstore integration time:
-
Permalink:
scottkleinman/lexos@d2810c3dfd4753b3f6701a77cb1bbcca4183a113 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/scottkleinman
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@d2810c3dfd4753b3f6701a77cb1bbcca4183a113 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file lexos-0.2.2-py3-none-any.whl.
File metadata
- Download URL: lexos-0.2.2-py3-none-any.whl
- Upload date:
- Size: 1.2 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
87ace79349d5313e77386e2fe3be76031714e83a576ebb56d5d88ef5a383d565
|
|
| MD5 |
b6f6244f44f5e647d7b5685448cb7fd7
|
|
| BLAKE2b-256 |
b06513ba1379401cabb5302a6bd4b5a0b2957404d19a860782506e69ebbd0d3f
|
Provenance
The following attestation bundles were made for lexos-0.2.2-py3-none-any.whl:
Publisher:
release.yml on scottkleinman/lexos
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
lexos-0.2.2-py3-none-any.whl -
Subject digest:
87ace79349d5313e77386e2fe3be76031714e83a576ebb56d5d88ef5a383d565 - Sigstore transparency entry: 2786361393
- Sigstore integration time:
-
Permalink:
scottkleinman/lexos@d2810c3dfd4753b3f6701a77cb1bbcca4183a113 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/scottkleinman
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@d2810c3dfd4753b3f6701a77cb1bbcca4183a113 -
Trigger Event:
workflow_dispatch
-
Statement type: