KeywordX
KeywordX is a lightweight Python library for extracting and matching keywords from text using semantic similarity and entity-based boosting.
Perfect for NLP pipelines, chatbots, search systems, and event extraction.
Features
- Extract keywords with semantic similarity scoring
- Boost keyword matches using entities (dates, times, places, etc.)
- Supports custom IDF weighting for better relevance
- Easy-to-use API for integration into NLP pipelines
Installation
Install from PyPI:
pip install keywordx
The en_core_web_md spaCy model is required for the library to function. Install it using the following command:
python -m spacy download en_core_web_md
If the en_core_web_md model is not available, the library will attempt to fall back to the smaller en_core_web_sm model. However, this may result in reduced accuracy. You can install the fallback model using:
python -m spacy download en_core_web_sm
Or install from source:
git clone https://github.com/keikurono7/keywordx.git
cd keywordx
pip install -e .
Quick Start
Here is a quick example to get you started:
from keywordx import KeywordExtractor
ke = KeywordExtractor()
text = "Tomorrow I have a work meeting at 5pm in Bangalore."
keywords = ["meeting", "time", "place", "date"]
result = ke.extract(text, keywords)
print(result)
Example Output
The result will include extracted entities and semantic matches with scores:
{
"entities": [
{"span": [0, 8], "text": "Tomorrow", "type": "DATE"},
{"span": [34, 37], "text": "5pm", "type": "TIME"},
{"span": [41, 50], "text": "Bangalore", "type": "GPE"}
],
"semantic_matches": [
{"keyword": "meeting", "match": "meeting", "score": 0.99},
{"keyword": "time", "match": "5pm", "score": 1.0},
{"keyword": "place", "match": "Bangalore", "score": 1.0},
{"keyword": "date", "match": "Tomorrow", "score": 1.0}
]
}
API Reference
-
KeywordExtractor()
Initializes the keyword extractor. -
.extract(text, keywords) → dict
Extracts keywords and entities from text.- text: input string
- keywords: list of keywords to match
-
Returns:
- entities: named entities (DATE, TIME, GPE, etc.)
- semantic_matches: list of matched keywords with similarity scores
Use Cases
- Event and meeting extraction for calendar assistants
- Chatbot intent detection
- Automatic tagging of documents and notes
- Context-aware search and indexing
Contributing
Contributions are welcome. For significant changes, please open an issue first to discuss the proposal.
Contributors
-
Madhusudan
- Email: dmpathani@gmail.com
- GitHub: keikurono7
- Role: Code implementation
-
Saniya Naaz
- Email: saniyanaaz2k4@gmail.com
- GitHub: Saniyanaaz11
- Role: Research work
-
Dr. Nandeeswar S B
- Email: hodcse.aiml@amceducation.in
- Role: Concept and idea generation
License
This project is licensed under the MIT License. See the LICENSE file for details.
Metadata
Release files for keywordx 1.0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| keywordx-1.0.5.tar.gz | 8.0 kB | Without provenance | Details for keywordx-1.0.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| keywordx-1.0.5-py3-none-any.whl | Python 3 | none | any | Details for keywordx-1.0.5-py3-none-any.whl |
Total release size: 15.6 kB
Release files / keywordx-1.0.5.tar.gz
| Download URL | keywordx-1.0.5.tar.gz |
|---|---|
| Size | 8.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f388bd91efbdf25b5903276892a232881e3671538853b0bf01eee3ee7a170918
|
|
BLAKE2b-256 checksum How to use checksums |
c2909d08c15d6c4a5a062a9225970ad0d3edb7bad56aaaf64d4c029d3e32a80d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.2
|
Release files / keywordx-1.0.5-py3-none-any.whl
| Download URL | keywordx-1.0.5-py3-none-any.whl |
|---|---|
| Size | 7.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1178e92754e9295d2a92d50b5d7b89535d0a039801ad01b585e6f78df8f92d2d
|
|
BLAKE2b-256 checksum How to use checksums |
b4be0ae1b807dd0c691693042f0f688c597ec88ec6ee5a043c5959bfcc35be7e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.2
|
Security for keywordx 1.0.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.