1.5 KiB
1.5 KiB
Keyword Extractor
This project is a simple script for extracting keywords from text using Natural Language Processing (NLP).
How it works
The script processes input text and extracts the most relevant keywords using a pre-trained transformer model (e.g., bert-base-uncased
or a similar NLP model).
It is designed to be lightweight, easy to run, and customizable.
Requirements
- Python 3.8+
- NLP libraries (transformers, torch, etc.)
- Other utilities as listed in the requirements file
For exact versions of the libraries, please check the requirements.txt
file.
Usage
- Clone the repository.
- Install dependencies:
pip install -r requirements.txt
- Run the script:
python keyword_extractor.py
Main Methods
load_model()
: Loads the pre-trained transformer model for text processing. This is the main method for model initialization.preprocess_text(text)
: Cleans and prepares the input text (e.g., lowercasing, removing stopwords, etc.).extract_keywords(text, top_n=10)
: The core method that applies the model and retrieves the top keywords from the input text.display_results(keywords)
: Prints or saves the extracted keywords for further use.
Model
The script uses a transformer-based model for keyword extraction. The exact model can be changed in the code if needed.
Notes
- Works with English (and potentially other languages, depending on the model).
- Results may vary based on the model and input text.