Package: pytextrank
PyTextRankPyTextRankis a Python implementation ofTextRankas aspaCy pipeline extension,
for graph-based natural language work -- and related knowledge graph practices.
This includes the family oftextgraphalgorithms:TextRankby[mihalcea04textrank]PositionRankby[florescuc17]Biased TextRankby[kazemi-etal-2020-biased]TopicRankby[bougouin-etal-2013-topicrank]Popular use cases for this library include:phrase extraction: get the top-ranked phrases from a text documentlow-costextractive summarizationof a text documenthelp infer concepts from unstructured text into more structured representationSee our full documentation at:https://derwen.ai/docs/ptr/Getting StartedSee the"Getting Started"section of the online documentation.To install fromPyPi:python3 -m pip install pytextrank
python3 -m spacy download en_core_web_smIf you work directly from this Git repo, be sure to install the
dependencies as well:python3 -m pip install -r requirements.txtAlternatively, to install dependencies usingconda:conda env create -f environment.yml
conda activate pytextrankThen to use the library with a simple use case:importspacyimportpytextrank# example texttext="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. Upper bounds for components of a minimal set of solutions and algorithms of construction of minimal generating sets of solutions for all types of systems are given. These criteria and the corresponding algorithms for constructing a minimal supporting set of solutions can be used in solving all the considered types systems and systems of mixed types."# load a spaCy model, depending on language, scale, etc.nlp=spacy.load("en_core_web_sm")# add PyTextRank to the spaCy pipelinenlp.add_pipe("textrank")doc=nlp(text)# examine the top-ranked phrases in the documentforphraseindoc._.phrases:print(phrase.text)print(phrase.rank,phrase.count)print(phrase.chunks)See thetutorial notebooksin theexamplessubdirectory for
sample code and patterns to use in integratingPyTextTankwith
related libraries in Python:https://derwen.ai/docs/ptr/tutorial/Contributing CodeWe welcome people getting involved as contributors to this open source
project!For detailed instructions please see:CONTRIBUTING.mdBuild InstructionsNote: unless you are contributing code and updates,
in most use cases won't need to build this package locally.Instead, simply install fromPyPior useConda.To set up the build environment locally, see the"Build Instructions"section of the online documentation.Semantic VersioningGenerally speaking the major release number ofPyTextRankwill track with the major release number of the associatedspaCyversion.See:CHANGELOG.mdLicense and CopyrightSource code forPyTextRankplus its logo, documentation, and examples
have anMIT licensewhich is
succinct and simplifies use in commercial applications.All materials herein are Copyright © 2016-2024 Derwen, Inc.AttributionPlease use the following BibTeX entry for citingPyTextRankif you
use it in your research or software:@software{PyTextRank,author={Paco Nathan},title={{PyTextRank, a Python implementation of TextRank for phrase extraction and summarization of text documents}},year=2016,publisher={Derwen},doi={10.5281/zenodo.4637885},url={https://github.com/DerwenAI/pytextrank}}Citations are helpful for the continued development and maintenance of
this library.
For example, see our citations listed onGoogle Scholar.KudosMany thanks to our open sourcesponsors;
and to our contributors:@ceteri,@louisguitton,@Ankush-Chander,@tomaarsen,@CaptXiong,@Lord-V15,@anna-droid-beep,@dvsrepo,@clabornd,@dayalstrub-cma,@kavorite,@0dB,@htmartin,@williamsmj,@mattkohl,@vanita5,@HarshGrandeur,@mnowotka,@kjam,@SaiThejeshwar,@laxatives,@dimmu,@JasonZhangzy1757,@jake-aft,@junchen1992,@shyamcody,@chikubee;
also to@mihalceawho leads outstanding NLP research work,
encouragement from the wonderful folks at Explosion who developspaCy,
plus general support fromDerwen, Inc.Star History