tsptoni / textrank3

TextRank implementation in Python 3.

Home Page:https://byhs.eu

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

textrank3 - textrank3

TextRank implementation for text summarization and keyword extraction in Python. An online version can be tested here.

Features

  • Text summarization
  • Keyword extraction
  • Text modeling with graph and gexf exportation
  • Working on Python3

Examples

Text summarization:

>>> text = """Automatic summarization is the process of reducing a text document with a
computer program in order to create a summary that retains the most important points
of the original document. As the problem of information overload has grown, and as
the quantity of data has increased, so has interest in automatic summarization.
Technologies that can make a coherent summary take into account variables such as
length, writing style and syntax. An example of the use of summarization technology
is search engines such as Google. Document summarization is another."""

>>> from textrank3 import summarizer
>>> print(summarizer.summarize(text))
'Automatic summarization is the process of reducing a text document with a computer
program in order to create a summary that retains the most important points of the
original document.'

Keyword extraction:

>>> from textrank3 import keywords
>>> print(keywords.keywords(text))
document
automatic summarization
technologies
technology

Installation

This software depends on NumPy and Scipy, two Python packages for scientific computing. You must have them installed prior to installing textrank3:

pip install textrank3

If you are going to use the export function, you also need NetworkX. For a better performance of keyword extraction, install Pattern

This version has been tested under Python 3.6

More examples

  • Command-line usage:

    cd path/to/folder/textrank3/
    python textrank.py -t FILE
    
  • Export:

    >>> from textrank3.export import gexf_export
    >>> gexf_export(text, path="graph.gexf")
    
  • Define length of the summary as a proportion of the text (also available in keywords):

    >>> from textrank3.summarizer import summarize
    >>> summarize(text, ratio=0.2)
    
  • Define length of the summary by aproximate number of words (also available in keywords):

    >>> summarize(text, words=50)
    
  • Define input text language (also available in keywords):

    >>> summarize(text, language='spanish')
    

The available languages are "danish", "dutch", "english", "finnish", "french", "german", "hungarian", "italian", "norwegian", "porter", "portuguese", "romanian", "russian", "spanish", "swedish"

  • Get results as a list (also available in keywords):

    >>> summarize(text, split=True)
    ['Automatic summarization is the process of reducing a text document with a
    computer program in order to create a summary that retains the most important
    points of the original document.']
    

TextRank3 support for Python3 is maintained by Antonio Sánchez Pineda. The project was forked from summanlp/textrank.

Support for new languages and updates to stop words are incoming.

Summa is open source software released under the The MIT License (MIT). Copyright (c) 2014 - now Summa NLP

About

TextRank implementation in Python 3.

https://byhs.eu

License:MIT License


Languages

Language:Python 81.8%Language:JavaScript 15.2%Language:CSS 2.0%Language:HTML 0.9%