pytextrank
Python implementation of TextRank as a spaCy pipeline extension, for graph-based natural language work plus related knowledge graph practices; used for for phrase extraction of text documents.
What it is and what it does
PyTextRank is a Python library that brings graph-based text analysis to spaCy by implementing the TextRank algorithm and related variants (PositionRank, Biased TextRank, TopicRank). It works as a spaCy pipeline component, meaning you load a language model, add the textrank pipe, and then process documents to extract ranked phrases and concepts. The library treats text as a graph of words and their relationships, then applies ranking algorithms to identify the most important phrases.
The main use cases are phrase extraction—pulling the top-ranked keywords or key phrases from a document—and low-cost extractive summarization, where you identify the most important sentences or concepts without training a neural model. It also helps convert unstructured text into more structured representations suitable for knowledge graphs. The package depends on spaCy for NLP processing, networkx for graph operations, scipy for numerical work, and several smaller utilities (graphviz, pygments, icecream, GitPython) for visualization and debugging.
Use it for:
- Extract top-ranked phrases from research papers, articles, or documents for tagging or indexing
- Perform low-cost extractive summarization by identifying key concepts without training a summarization model
- Build knowledge graphs by extracting and ranking entities and relationships from unstructured text
- Identify important keywords from customer feedback, reviews, or support tickets for categorization
- Rank and filter candidate phrases for downstream NLP tasks like named entity linking or semantic search
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
PyTextRank implements graph-based TextRank and related algorithms as a spaCy pipeline extension to extract key phrases and perform extractive summarization on text documents.
Yes. PyTextRank is actively maintained, has no known vulnerabilities, uses a permissive MIT license, and offers a straightforward way to add graph-based phrase extraction to spaCy workflows. Install friction is low and the library is well-documented. Choose it if you need phrase extraction or concept ranking without the overhead of training custom models.
Install
pytextrank on PyPI
pip
pip install pytextrankuv
uv add pytextrankpoetry
poetry add pytextrankInstalling pytextrank
Before you install
Low install friction with a pure-Python wheel. Active maintenance with recent commits and a stable release history since 2017; requires spaCy and a language model as runtime dependencies.
License in practice
MIT license permits commercial use, modification, and distribution with minimal restrictions—suitable for proprietary applications.
Quickstart
python3 -m pip install pytextrank
python3 -m spacy download en_core_web_sm
import spacy
import pytextrank
nlp = spacy.load("en_core_web_sm")
nlp.add_pipe("textrank")
doc = nlp("Your text here")
for phrase in doc._.phrases:
print(phrase.text, phrase.rank)
Requires a spaCy language model to be downloaded separately (e.g., en_core_web_sm for English); spaCy itself is a runtime dependency.
Verify before relying
- Specific performance characteristics or scalability limits for large documents or corpora
- Comparison of ranking quality across the four implemented algorithms (TextRank, PositionRank, Biased TextRank, TopicRank)
- Memory footprint and computational cost relative to alternative phrase extraction methods
Package facts
| License | MIT License Copyright (c) 2016-2022 Derwen, Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to… (full text in the JSON record) (permissive) |
| Python support | supports the current Python release (>=3.7) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 7 — GitPython, graphviz, icecream, networkx, pygments, scipy, spacy |
| Maintenance | actively maintained — 905 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 117,031/month — #12,184 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: pytextrank-3.3.0-py3-none-any.whl
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
spacyspaCy is an industrial-strength NLP library…
permissive · top 1,000 on PyPI
sumySumy extracts summaries from HTML pages or…
permissive · top 15,000 on PyPI
textacytextacy extends spaCy's NLP capabilities with…
permissive · top 15,000 on PyPI
rake-nltkExtracts keywords and key phrases from text…
permissive · top 15,000 on PyPI
negspacyAdds negation detection to spaCy pipelines…
permissive · top 15,000 on PyPI
graphragGraphRAG extracts structured knowledge graphs…
permissive · top 15,000 on PyPI
keyphrase-vectorizersExtracts keyphrases from text documents using…
permissive · top 15,000 on PyPI
date-spacyAdds a spaCy pipeline component that identifies…
permissive · top 15,000 on PyPI
rouge-chineseComputes ROUGE evaluation metrics for Chinese…
unclear · top 15,000 on PyPI
torchtexttorchtext provides text datasets, preprocessing…
permissive · top 15,000 on PyPI