tmtoolkit: Text mining and topic modeling toolkit

PyPI Version Downloads from PyPI Documentation Status GitHub Actions 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, in journalism or related disciplines. 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 and the loky package). The basis of tmtoolkit’s text mining capabilities are built around SpaCy, which offers a many language models. Currently, the following languages are supported for text mining:

  • Catalan

  • Chinese

  • Danish

  • Dutch

  • English

  • French

  • German

  • Greek

  • Italian

  • Japanese

  • Lithuanian

  • Macedonian

  • Norwegian Bokmål

  • Polish

  • Portuguese

  • Romanian

  • Russian

  • Spanish

The documentation for tmtoolkit is available on tmtoolkit.readthedocs.org and the GitHub code repository is on github.com/WZBSocialScienceCenter/tmtoolkit.

Features

Text preprocessing and text mining

The tmtoolkit package offers several text preprocessing and text mining methods, including:

Wherever possible and useful, these methods can operate in parallel to speed up computations with large datasets.

Topic modeling

Other features

Limits

  • only 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”, https://doi.org/10.7910/DVN/GMFCTR, 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”, https://doi.org/10.7910/DVN/L4OAKN, 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.

License

Code licensed under Apache License 2.0. See LICENSE file.

Contents:

Indices and tables