[Paper Review] TextDescriptives: A Python package for calculating a large variety of metrics from text
TextDescriptives is a Python package built on spaCy that provides a modular, tested framework for extracting a comprehensive set of document-level text metrics, including readability, coherence, dependency distance, part-of-speech proportions, and text quality scores. It enables reproducible, high-granularity linguistic analysis by integrating seamlessly into existing NLP pipelines and offering a unified API for batch extraction into dataframes or dictionaries.
TextDescriptives is a Python package for calculating a large variety of metrics from text. It is built on top of spaCy and can be easily integrated into existing workflows. The package has already been used for analysing the linguistic stability of clinical texts, creating features for predicting neuropsychiatric conditions, and analysing linguistic goals of primary school students. This paper describes the package and its features.
Motivation & Objective
- To address the lack of standardized, reproducible, and modular extraction of document-level text metrics in NLP workflows.
- To unify a broad range of linguistic metrics—ranging from basic statistics to complex measures like coherence and dependency distance—into a single, well-documented package.
- To improve reproducibility and reduce implementation errors in text analysis by providing tested, validated metrics.
- To support researchers in fields like digital humanities, psychiatry, and education by offering accessible, high-fidelity linguistic features.
- To enable efficient preprocessing and quality filtering of text data using heuristic and embedding-based quality metrics.
Proposed method
- The package extends spaCy pipelines with dedicated components for calculating descriptive statistics, readability, dependency distance, part-of-speech proportions, coherence, and text quality.
- It leverages spaCy’s robust NLP pipeline to access syntactic and semantic features such as dependency trees, part-of-speech tags, and word embeddings.
- TextDescriptives computes metrics including mean and standard deviation of dependency distance, sentence-level coherence using word embedding similarity, and heuristics for text quality (e.g., duplicate lines, 'lorem ipsum' detection).
- All metrics are extracted via a single unified interface: `textdescriptives.extract_df(doc)` or `extract_dict(doc)` for batch processing.
- The package supports both individual metric extraction and joint computation across multiple documents, ensuring compatibility with existing data science and NLP workflows.
- It is designed with modularity and extensibility in mind, allowing for future extension of new metric components.
Experimental results
Research questions
- RQ1How can a modular, reusable, and reproducible framework for document-level text metrics be designed to reduce implementation errors in NLP research?
- RQ2To what extent can a unified Python package improve the consistency and reliability of linguistic feature extraction across diverse NLP applications?
- RQ3Can a single interface efficiently compute a broad spectrum of metrics—from basic statistics to semantic coherence and text quality—within a standardized NLP pipeline?
- RQ4How does the integration of spaCy-based components enhance the performance and usability of text metric extraction in real-world research settings?
- RQ5What role do complex metrics like dependency distance and semantic coherence play in detecting linguistic patterns related to mental health or educational outcomes?
Key findings
- TextDescriptives successfully implements and exposes 20+ document-level metrics, including rarely used but informative ones like dependency distance and semantic coherence, which are not available in comparable packages.
- The package enables joint extraction of all metrics via a single function call, significantly streamlining data preparation and reducing code complexity.
- It supports advanced text quality detection through heuristics such as duplicate line ratios, 'lorem ipsum' detection, and top-n-gram repetition, which are useful for filtering low-quality text.
- The integration with spaCy ensures high performance and access to model-based features like dependency parsing and part-of-speech tagging, enhancing metric accuracy.
- The package has already been applied in real-world research contexts, including clinical text analysis, neuropsychiatric prediction, and educational linguistics, demonstrating its practical utility.
- Unlike existing tools such as textstat or spacy-readability, TextDescriptives supports modern spaCy versions and provides a comprehensive, tested, and documented API for all metrics.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.