Skip to main content

Entropy Rank keyphrase extractor

Project description

EntropyBasedKeyPhraseExtraction

This is the official implementation of the EntropyRank key phrase extractor from https://openreview.net/forum?id=WCTtOfIhsJ. Please cite the paper and star this repo if you find EntropyRank useful! Thanks!

@inproceedings{
tsvetkov2023entropyrank,
title={EntropyRank: Unsupervised Keyphrase Extraction via Side-Information Optimization for Language Model-based Text Compression},
author={Alexander Tsvetkov and Alon Kipnis},
booktitle={ICML 2023 Workshop Neural Compression: From Information Theory to Applications},
year={2023},
url={https://openreview.net/forum?id=WCTtOfIhsJ}
}

Installation

To install directly:

pip install entropyrank

To install from repository, from src/entropyrank run:

pip install -r requirements.txt

You also need to download the 'en_core_web_sm' model for spaCy, which can be done by running:

spacy download en_core_web_sm

Usage

To use the package, import EntropyRank from the module and create an instance of it:

from entropyrank import EntropyRank

extractor = EntropyRank()

Then, you can extract key phrases from a given text using the extract_key_phrases method:

phrases = extractor.extract_key_phrases(
    text=text,
    number_of_key_phrases=3,
)

The parameters of the extract_key_phrases method are:

  • text: the input text to extract key phrases from.
  • number_of_key_phrases: the number of key phrases to extract.
  • exclude_start_words_count: the number of words to exclude from the start of each key phrase when calculating its entropy.
  • partition_method: can be STOP_WORDS or NOUN_PHRASES, decides how to partition the candidates.
  • ranking_method: can be FIRST_WORD_ENTROPY or SUM_ENTROPY, whether to use the sum of entropy of the phrase or just the entropy of the first word
  • normalize_by_word_statistics: a boolean indicating whether we want to normalize the entropy values by entropy statistics of word position.
  • remove_personal_names: a boolean indicating whether to remove personal names from the evaluations or not.

Evaluation Demo

You can run the evaluation_demo notebook included in this repository under src/eval to get the benchmark results on common key phrase extraction tasks reported in the paper. Make sure to run pip install -r evaluation-requirements.txt beforehand

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

entropyrank-1.0.0.tar.gz (50.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

entropyrank-1.0.0-py3-none-any.whl (40.7 kB view details)

Uploaded Python 3

File details

Details for the file entropyrank-1.0.0.tar.gz.

File metadata

  • Download URL: entropyrank-1.0.0.tar.gz
  • Upload date:
  • Size: 50.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.3

File hashes

Hashes for entropyrank-1.0.0.tar.gz
Algorithm Hash digest
SHA256 602ae1d0ec2e6681e68e2056bb3ba583e4ec8bef2e23e943b8829b0b2990883c
MD5 5f56945e29b2c6b376f5b71c42d7c1de
BLAKE2b-256 9138f26b838694089ed386e7ac4d81ca2eb926f323963da6491065110d6c7e7d

See more details on using hashes here.

File details

Details for the file entropyrank-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: entropyrank-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 40.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.3

File hashes

Hashes for entropyrank-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cfdc5cab237bc20c1e6e7044c0145d36dfbafaa8c672c75697d83a720b3ee1a6
MD5 f13870c72ac51103b3290d7b021f9f0d
BLAKE2b-256 9d4494d526118dea42d6743db30d508431f1c7be71ecd5b028b59b27836020ff

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page