tmtoolkit: Text mining and topic modeling toolkit

PyPI Version Downloads from PyPI Documentation Status Travis CI Build Status Coverage status Citable Zenodo DOI

tmtoolkit is a set of tools for text mining and topic modeling with Python developed especially for the use in the social sciences. It aims for easy installation, extensive documentation and a clear programming interface while offering good performance on large datasets by the means of vectorized operations (via NumPy) and parallel computation (using Python’s multiprocessing module). It combines several known and well-tested packages such as SpaCy and SciPy.

At the moment, tmtoolkit focuses on methods around the Bag-of-words model, but word vectors (word embeddings) can also be generated.

The documentation for tmtoolkit is available on and the GitHub code repository is on


Text preprocessing

tmtoolkit implements or provides convenient wrappers for several preprocessing methods, including:

All text preprocessing methods can operate in parallel to speed up computations with large datasets.

Topic modeling


  • all languages are supported, for which SpaCy language models are available

  • all data must reside in memory, i.e. no streaming of large data from the hard disk (which for example Gensim supports)

Built-in datasets

Currently tmtoolkit comes with the following built-in datasets which can be loaded via tmtoolkit.corpus.Corpus.from_builtin_corpus():

  • “en-NewsArticles”: News Articles (Dai, Tianru, 2017, “News Articles”,, Harvard Dataverse, V1)

  • random samples from ParlSpeech V2 (Rauh, Christian; Schwalbach, Jan, 2020, “The ParlSpeech V2 data set: Full-text corpora of 6.3 million parliamentary speeches in the key legislative chambers of nine representative democracies”,, Harvard Dataverse) for different languages:

    • “de-parlspeech-v2-sample-bundestag”

    • “en-parlspeech-v2-sample-houseofcommons”

    • “es-parlspeech-v2-sample-congreso”

    • “nl-parlspeech-v2-sample-tweedekamer”

About this documentation

This documentation guides you in several chapters from installing tmtoolkit to its specific use cases and shows some examples with built-in corpora and other datasets. All “hands on” chapters from Getting started to Topic modeling are generated from Jupyter Notebooks. If you want to follow along using these notebooks, you can download them from the GitHub repository.

There are also a few other examples as plain Python scripts available in the examples folder of the GitHub repository.


Code licensed under Apache License 2.0. See LICENSE file.


Indices and tables