Metadata-Version: 2.4
Name: ukss
Version: 0.1.1
Summary: A library that extracts keywords and summarizes text
Home-page: https://github.com/Kasmik004/UKSS-PI
Author: kasmik
Author-email: rkasmik@gmail.com
License: Apache-2.0
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.6
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: scipy
Requires-Dist: numpy
Requires-Dist: nltk
Requires-Dist: networkx
Requires-Dist: twine
Requires-Dist: setuptools
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: license
Dynamic: license-file
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

# UKSS 

> **Unsupervised Keyword Scoring System with PageRank Integration**

[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
[![Python Version](https://img.shields.io/badge/python-3.6+-blue.svg)](https://www.python.org/downloads/)
[![PyPI version](https://badge.fury.io/py/ukss.svg)](https://badge.fury.io/py/ukss)

**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:

1. **Term Frequency (TF) Scoring**: Normalizes the frequency of a word relative to the maximum frequency of any word in the text.
2. **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.
3. **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:

```bash
pip install ukss
```

---

## ⚡ Quick Start

```python
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](https://doi.org/10.1007/978-3-540-71701-0_95)

## 📄 License

This project is licensed under the [Apache 2.0 License](https://choosealicense.com/licenses/apache-2.0/).
