Skip to main content

A sentiment analysis toolkit using a trained TensorFlow model

Project description

SentiToolKit ย  version Python License

SentiToolKit is a simple sentiment analysis library that leverages LSTM (Long Short-Term Memory) neural networks for predicting the sentiment of a given text. This toolkit provides a streamlined interface for text preprocessing, model loading, and prediction.

โœจ Features

  • Pre-trained Model: Uses a trained LSTM model for sentiment analysis.
  • Tokenization Support: Handles text tokenization with a customizable vocabulary size.
  • Sentiment Prediction: Predicts whether a text is Positive, Neutral, or Negative.
  • Easy to Use: Minimal setup required to get predictions.
  • Customizable: You can use your own tokenizer and model for fine-tuning.

๐Ÿ“ฆ Installation

You can install the SentiToolKit package via pip:

pip install SentiToolKit==1.0.8

Alternatively, if you'd like to build from source:

  1. Clone the repository:

    git clone https://github.com/yourusername/SentiToolKit.git
    
  2. Navigate to the project directory and install the package:

    cd SentiToolKit
    pip install .
    

๐Ÿš€ Quickstart

To get started with SentiToolKit, follow the example below:

# test_model.py

# Import the SentiToolKit class from your package
from SentiAnalyzer.Main_tensor_model import SentiToolKit

def main():
    # Instantiate the model
    model = SentiToolKit()

    # Get user input for testing
    review = input("Enter a review for sentiment analysis: ")

    # Call the model to get the sentiment
    sentiment = model.__call__(review)

    # Print the result
    print("Sentiment Analysis Result:", sentiment)

if __name__ == "__main__":
    main()

๐Ÿงฐ Usage

  1. Loading the Pre-trained Model: The toolkit loads a pre-trained LSTM model from the provided .keras file.
  2. Text Tokenization: The input text is tokenized and padded using the stored tokenizer from tokenizer.pkl.
  3. Sentiment Prediction: Predicts the sentiment based on the input text:
    • Positive
    • Neutral
    • Negative

๐Ÿ“ Project Structure

SentiToolKit/
โ”œโ”€โ”€ converter.py                 
โ”œโ”€โ”€ converter1.py
โ”œโ”€โ”€ dataExtractor.py             
โ”œโ”€โ”€ tensor_model.py              
โ”œโ”€โ”€ usage.py                    
โ”œโ”€โ”€ json/                        
โ”‚   โ”œโ”€โ”€ backup.json              
โ”‚   โ”œโ”€โ”€ negative_reviews.json    
โ”‚   โ”œโ”€โ”€ neutral_reviews.json     
โ”‚   โ”œโ”€โ”€ positive_reviews.json    
โ”‚   โ””โ”€โ”€ train.json               
โ”œโ”€โ”€ SentiAnalyzer/               
โ”‚   โ”œโ”€โ”€ __init__.py              
โ”‚   โ”œโ”€โ”€ Main_tensor_model.py     
โ”‚   โ”œโ”€โ”€ SentiToolKit.keras       
โ”‚   โ””โ”€โ”€ tokenizer.pkl            
โ”œโ”€โ”€ tests/                       
โ”œโ”€โ”€ text/                        
โ”œโ”€โ”€ .env                         
โ”œโ”€โ”€ .gitignore                   
โ”œโ”€โ”€ LICENSE                      
โ”œโ”€โ”€ MANIFEST.in                  
โ”œโ”€โ”€ pyproject.toml               
โ”œโ”€โ”€ README.md                    
โ”œโ”€โ”€ SentiToolKit.keras           
โ”œโ”€โ”€ setup.py                     
โ””โ”€โ”€ tokenizer.pkl                

๐Ÿ“„ License

This project is licensed under the GNU AFFERO GENERAL PUBLIC LICENSE Version 3,. See the LICENSE file for details.

๐Ÿ’ก Future Improvements

  • Add support for additional languages.
  • Fine-tune the pre-trained model for domain-specific tasks.

๐Ÿ‘ฅ Contributing

Contributions are welcome! If youโ€™d like to contribute to SentiToolKit, feel free to fork the repository and submit a pull request.

  1. Fork the repo.
  2. Create your feature branch
  3. Commit your changes
  4. Push to the branch
  5. Open a pull request.

๐Ÿ“ฌ Contact

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sentitoolkit-0.1.8.tar.gz (3.6 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

SentiToolKit-0.1.8-py3-none-any.whl (3.6 MB view details)

Uploaded Python 3

File details

Details for the file sentitoolkit-0.1.8.tar.gz.

File metadata

  • Download URL: sentitoolkit-0.1.8.tar.gz
  • Upload date:
  • Size: 3.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for sentitoolkit-0.1.8.tar.gz
Algorithm Hash digest
SHA256 00df6fd20bcc9b717e5a05c320c221f0bc8312761d1e706cc1161fa35dd70f41
MD5 e9b2488021f29b7531a16439aaabe517
BLAKE2b-256 16c8fc024fdd9b499f763f6062686eef62a5583f7cdd52f18c130f38b76feba4

See more details on using hashes here.

File details

Details for the file SentiToolKit-0.1.8-py3-none-any.whl.

File metadata

  • Download URL: SentiToolKit-0.1.8-py3-none-any.whl
  • Upload date:
  • Size: 3.6 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for SentiToolKit-0.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 2b71bb1ca5984a1e5a61f09882bef2ace66cde19a465cb29d958889692ef6973
MD5 570980a22647b8a14593d4d5194daf6a
BLAKE2b-256 40794c528bc32dff3fdbaca86db24df0091783bed340da2d6109abe5506aa1d4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page