Registry / ai-ml / rake-nltk

rake-nltk

JSON →
library1.0.6pypypi✓ verified 87d ago

RAKE-NLTK is a Python implementation of the Rapid Automatic Keyword Extraction (RAKE) algorithm, leveraging the Natural Language Toolkit (NLTK). It's designed to extract key phrases from text by analyzing word frequency and co-occurrence. The library, currently at version 1.0.6 (released September 2021), provides a straightforward interface for keyword extraction and offers configuration options for tokenizers, stopwords, and ranking metrics. Its release cadence is infrequent, with the last major update in 2021.

pip install rake-nltk
INSTALL
IMPORT
SIG · RAKE-NLTK
R
rake-nltk
ai-mlpythonv1.0.6
Install
3.2s avg
Import
749ms
Disk
35MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.0.6 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.783s · 35.5MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 3.2s · import 0.716s · 36MB
35MB installed
● package 35MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Rake
from rake_nltk import Rake

Initialize the Rake object (which uses NLTK stopwords and punctuation by default) and extract keywords from text. This example also shows how to download the necessary NLTK corpora.

import nltk nltk.download('stopwords') nltk.download('punkt') from rake_nltk import Rake text = """Compatibility of systems of 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 of systems and systems of mixed types.""" r = Rake() r.extract_keywords_from_text(text) ranked_phrases = r.get_ranked_phrases() ranked_phrases_with_scores = r.get_ranked_phrases_with_scores() print("Top 5 ranked phrases:") for phrase in ranked_phrases[:5]: print(f"- {phrase}") print("\nTop 5 ranked phrases with scores:") for score, phrase in ranked_phrases_with_scores[:5]: print(f"- {phrase} (Score: {score:.2f})")
Debug
Known issues
breakingNLTK data (stopwords and punkt tokenizer) are critical dependencies for `rake-nltk` and must be downloaded separately. Without these, the library will fail with a `LookupError`.
fix
Run `import nltk; nltk.download('stopwords'); nltk.download('punkt')` once after installing `nltk` and `rake-nltk`.
affects: All versions of rake-nltk
gotchaInstalling `rake-nltk` directly from a cloned GitHub repository using `python setup.py install` can sometimes lead to an `error: package directory 'rake_nltk' does not exist`, especially in older `pip` versions or specific build environments. This is often related to how NLTK dependencies or post-install hooks are handled during the build process.
fix
Always prefer `pip install rake-nltk`. If installing from source, ensure `nltk` is installed beforehand (`pip install nltk`) and consider updating `pip` to a recent version.
affects: Potentially all versions, more common with older pip/direct source installs.
Errors
Common errors & fixes
LookupError: <resource> not found. Please use the NLTK Downloader to obtain the resource:
The required NLTK corpus (e.g., 'stopwords' or 'punkt') has not been downloaded.
fix
Run `import nltk; nltk.download('stopwords'); nltk.download('punkt')` in your Python environment.
error: package directory 'rake_nltk' does not exist
Attempting to install `rake-nltk` by cloning the repository and running `python setup.py install`, which can fail due to specific build environment issues or older `pip` versions not handling dependencies correctly during setup.
fix
Use `pip install rake-nltk` instead of installing from source. Ensure `nltk` is installed if you encounter persistent issues.
r.get_ranked_phrases() returns an empty list or unexpected results
This can happen if NLTK stopwords or punkt tokenizer are not downloaded, or if the input text is too short, lacks significant keywords, or is primarily composed of stop words.
fix
Verify that `nltk.download('stopwords')` and `nltk.download('punkt')` have been executed. Review your input text for sufficient content and relevant non-stop words.
Upgrade
Version history
1.0.6latest on PyPI · released Sep 15, 2021
Audit
Dependencies
nltkrequiredRequired for natural language processing functionalities like tokenization and stopwords. Specific NLTK corpora ('stopwords', 'punkt') must be downloaded separately.
Agent activity
24 hits · last 30 days
node
22
OpenAI (training)
1
Resources
rake-nltk — pip install rake-nltk · libregistry