• Stars
    star
    2,131
  • Rank 21,513 (Top 0.5 %)
  • Language
    Python
  • License
    MIT License
  • Created almost 8 years ago
  • Updated 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Python implementation of TextRank algorithms ("textgraphs") for phrase extraction

PyTextRank

DOI Licence Repo size GitHub commit activity Checked with mypy security: bandit CI downloads sponsor

PyTextRank is a Python implementation of TextRank as a spaCy pipeline extension, for graph-based natural language work -- and related knowledge graph practices. This includes the family of textgraph algorithms:

Popular use cases for this library include:

  • phrase extraction: get the top-ranked phrases from a text document
  • low-cost extractive summarization of a text document
  • help infer concepts from unstructured text into more structured representation

See our full documentation at: https://derwen.ai/docs/ptr/

Getting Started

See the "Getting Started" section of the online documentation.

To install from PyPi:

python3 -m pip install pytextrank
python3 -m spacy download en_core_web_sm

If you work directly from this Git repo, be sure to install the dependencies as well:

python3 -m pip install -r requirements.txt

Alternatively, to install dependencies using conda:

conda env create -f environment.yml
conda activate pytextrank

Then to use the library with a simple use case:

import spacy
import pytextrank

# example text
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. 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 pipeline
nlp.add_pipe("textrank")
doc = nlp(text)

# examine the top-ranked phrases in the document
for phrase in doc._.phrases:
    print(phrase.text)
    print(phrase.rank, phrase.count)
    print(phrase.chunks)

See the tutorial notebooks in the examples subdirectory for sample code and patterns to use in integrating PyTextTank with related libraries in Python: https://derwen.ai/docs/ptr/tutorial/

Contributing Code

We welcome people getting involved as contributors to this open source project!

For detailed instructions please see: CONTRIBUTING.md

Build Instructions Note: unless you are contributing code and updates, in most use cases won't need to build this package locally.

Instead, simply install from PyPi or use Conda.

To set up the build environment locally, see the "Build Instructions" section of the online documentation.

Semantic Versioning

Generally speaking the major release number of PyTextRank will track with the major release number of the associated spaCy version.

See: CHANGELOG.md

thanks noam!

License and Copyright

Source code for PyTextRank plus its logo, documentation, and examples have an MIT license which is succinct and simplifies use in commercial applications.

All materials herein are Copyright Β© 2016-2023 Derwen, Inc.

Attribution

Please use the following BibTeX entry for citing PyTextRank if 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 on Google Scholar.

Kudos

Many thanks to our open source sponsors; 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 @mihalcea who leads outstanding NLP research work, encouragement from the wonderful folks at Explosion who develop spaCy, plus general support from Derwen, Inc.

Star History

Star History Chart

More Repositories

1

kglab

Graph Data Science: an abstraction layer in Python for building knowledge graphs, integrated with popular graph libraries – atop Pandas, NetworkX, RAPIDS, RDFlib, pySHACL, PyVis, morph-kgc, pslpython, pyarrow, etc.
Jupyter Notebook
575
star
2

ray_tutorial

An introductory tutorial about leveraging Ray core features for distributed patterns.
Jupyter Notebook
77
star
3

strwythura

How to construct knowledge graphs from unstructured data sources
Jupyter Notebook
68
star
4

rllib_tutorials

RLlib tutorials
Jupyter Notebook
64
star
5

a41124835ed0

Course materials for "Get Started with NLP in Python"
Jupyter Notebook
62
star
6

exsto

Analyze the structure and dynamics of an open source project's developer community, using graph algorithms, etc.
Python
57
star
7

gym_example

An example implementation of an OpenAI Gym environment used for a Ray RLlib tutorial
Python
34
star
8

mkrefs

MkDocs plugin to generate semantic reference Markdown pages from a knowledge graph
Python
33
star
9

disparity_filter

Implements a disparity filter in Python, based on graphs in NetworkX, to extract the multiscale backbone of a complex weighted network (Serrano, et al., 2009)
Python
31
star
10

spaCy_tuTorial

A brief tutorial for spaCy 2.x, which runs on Google Colab
Jupyter Notebook
25
star
11

ERKG

Demonstrate integration of Senzing and Neo4j to construct an Entity Resolved Knowledge Graph
21
star
12

ibm_dsc_articles

Notebooks and other code+data supporting articles for the IBM Data Science Community
Jupyter Notebook
21
star
13

textgraphs

TextGraphs + LLMs + graph ML for entity extraction, linking, ranking, and constructing a lemma graph
Python
17
star
14

arxiv-trends

Analyze trends in articles published on arXiv
Jupyter Notebook
15
star
15

pynock

A proposed standard `NOCK` for a Parquet format that supports efficient distributed serialization of multiple kinds of graph technologies
Python
15
star
16

kuzu-rdflib

An integration of KΓΉzuDB and RDFlib.
Python
9
star
17

ray_base

Docker build for a base image for running Ray on K8s on Azure
Jupyter Notebook
5
star
18

rcc_book

Rich Search and Discovery for Research Datasets: Building the next generation of scholarly infrastructure
Python
3
star
19

cyphigh

Support for distributed processing of openCypher in Python.
Python
2
star
20

gym_projectile

A simple implementation of an OpenAI Gym environment, which simulates a projectile trajectory
Python
2
star
21

goedwig

A generic query engine for graph data, based on abstract syntax trees as input.
Python
1
star
22

ibm_dsc_geo

Examples of geospatial work in Python on Ubuntu 18.04 LTS
Jupyter Notebook
1
star
23

rayCy_example

Demo / test harness for a code conflict in Ray actors with Cython-based classes
Python
1
star
24

gym_trivial

A minimal implementation of an OpenAI Gym environment, which simulates an `AND` gate
Python
1
star