A library that extracts keywords and summarizes text
Project description
UKSS
Unsupervised Keyword Scoring System with PageRank Integration
UKSS (formerly UKSS-PI) is an unsupervised keyword scoring and text summarization library. It combines traditional statistical NLP methods with graph-based ranking to precisely identify and score relevant keywords from text—all without the need for labeled training data.
📖 Working Method
UKSS relies on a powerful hybrid algorithm to score and extract the most significant keywords from any given text. It processes the text through three main scoring pipelines and fuses their results:
- Term Frequency (TF) Scoring: Normalizes the frequency of a word relative to the maximum frequency of any word in the text.
- Graph-Based PageRank Scoring: Builds a co-occurrence network graph using a defined window size and applies the PageRank algorithm to measure the centrality/importance of a word within the textual structure.
- Dispersion Scoring (Gries' DP): Calculates how evenly a word is distributed across different segments of the text. Words that appear uniformly throughout the text are rewarded, ensuring keywords aren't just isolated to a single localized sentence.
The final score for each word is computed using a weighted combination of these algorithms. Additionally, UKSS uses the extracted top keywords to identify and extract the most important sentences, generating a high-quality summary.
🚀 Installation
You can easily install ukss via pip:
pip install ukss
⚡ Quick Start
import ukss
from ukss import UKSS_PI
text = """
The gym is a dedicated space for individuals to enhance their physical fitness,
mental well-being, and personal health. Gyms offer a variety of equipment and
facilities designed to cater to a wide range of fitness goals, from weightlifting
and strength training to cardiovascular and flexibility exercises...
"""
# 1. Initialize the class with your text
analyzer = UKSS_PI(text=text)
# 2. Extract keywords and generate a summary
result = analyzer.get_keywords()
print("Top Keywords:", result["keywords"])
print("Generated Summary:", result["summary"])
🛠️ API Reference
UKSS_PI Class
The main class used to analyze and process text.
__init__(self, text: str)
Initializes the UKSS_PI object and preprocesses the text (lemmatization, stop-word removal, POS filtering).
- Parameters:
text(str): The input text document to be analyzed.
get_keywords(self) -> dict
Extracts the top 3 keywords and generates a text summary based on those keywords.
- Returns: A dictionary containing:
"keywords"(list of str): The top 3 ranked keywords."summary"(str): A summary comprised of the most important sentences.
get_keyword_list(self) -> dict
Returns the complete list of processed words along with their final fused UKSS scores.
- Returns: A dictionary mapping words (str) to their computed scores (float).
🤝 Contributing
Pull requests are welcome! For major changes, please open an issue first to discuss what you would like to change.
When contributing, please ensure:
- Tests are added or updated.
- Documentation is updated if functionality changes.
📚 References
Wang, J., Liu, J., & Wang, C. (2007). Keyword Extraction Based on PageRank. In: Zhou, ZH., Li, H., Yang, Q. (eds) Advances in Knowledge Discovery and Data Mining. PAKDD 2007. Lecture Notes in Computer Science, vol 4426. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-540-71701-0_95
📄 License
This project is licensed under the Apache 2.0 License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ukss-0.1.1.tar.gz.
File metadata
- Download URL: ukss-0.1.1.tar.gz
- Upload date:
- Size: 11.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fad0407d15522a8808d97f2966696b12cea12be7c67f328cdfce657875b14f01
|
|
| MD5 |
9103b95726a1f4510c805b7757eeb4b7
|
|
| BLAKE2b-256 |
58a53a8427a9df842a8fed6e7cf512808f42d86b89ee5134fdd61fa43eea7dfc
|
File details
Details for the file ukss-0.1.1-py3-none-any.whl.
File metadata
- Download URL: ukss-0.1.1-py3-none-any.whl
- Upload date:
- Size: 11.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
00731a5522699f781b5967ed09d32454c9d032ddf7aa65e3ee979efdbd2c5ad3
|
|
| MD5 |
38fdae0ac68130f18caad25e4ea55e49
|
|
| BLAKE2b-256 |
232c5b8b3f1592602877f3da4ea8ec9facb8ba66c895d0b69cae078723010d98
|