Universe

PyTextRank

Py impl of TextRank for lightweight phrase extraction

An implementation of TextRank in Python for use in spaCy pipelines which provides fast, effective phrase extraction from texts, along with extractive summarization. The graph algorithm works independent of a specific natural language and does not require domain knowledge. See (Mihalcea 2004) https://web.eecs.umich.edu/~mihalcea/papers/mihalcea.emnlp04.pdf

Example

import spacy import pytextrank nlp = spacy.load('en_core_web_sm') tr = pytextrank.TextRank() nlp.add_pipe(tr.PipelineComponent, name='textrank', last=True) text = 'Compatibility of systems of linear constraints over the set of natural numbers. Criteria of compatibility of a system of linear Diophantine equations, strict inequations, and nonstrict inequations are considered.' doc = nlp(text) # examine the top-ranked phrases in the document for p in doc._.phrases: print('{:.4f} {:5d} {}'.format(p.rank, p.count, p.text)) print(p.chunks)

View more
Author info

Paco Nathan

GitHubDerwenAI/pytextrank

Categories pipeline

Submit your project

If you have a project that you want the spaCy community to make use of, you can suggest it by submitting a pull request to the spaCy website repository. The Universe database is open-source and collected in a simple JSON file. For more details on the formats and available fields, see the documentation. Looking for inspiration your own spaCy plugin or extension? Check out the project idea label on the issue tracker.

Read the docsJSON source