Skip to main content

A simple tool for Vietnamese Sentiment Analysis

Project description

A Simple Tool For Sentiment Analysis

Sentivi - a simple tool for sentiment analysis which is a wrapper of scikit-learn and PyTorch Transformers models (for more special purpose, it is recommend to use native library instead). It is made for easy and faster pipeline to train and evaluate several classification algorithms.

Documentation: https://sentivi.readthedocs.io/en/latest/index.html

Classifiers

  • Decision Tree
  • Gaussian Naive Bayes
  • Gaussian Process
  • Nearest Centroid
  • Support Vector Machine
  • Stochastic Gradient Descent
  • Character Convolutional Neural Network
  • Multi-Layer Perceptron
  • Long Short Term Memory
  • Text Convolutional Neural Network
  • Transformer
  • Ensemble
  • Lexicon-based

Install

  • Install legacy version from PyPI:

    pip install sentivi
    
  • Install latest version from source:

    git clone https://github.com/vndee/sentivi
    cd sentivi
    pip install .
    

Example

from sentivi import Pipeline
from sentivi.data import DataLoader, TextEncoder
from sentivi.classifier import SVMClassifier
from sentivi.text_processor import TextProcessor

text_processor = TextProcessor(methods=['word_segmentation', 'remove_punctuation', 'lower'])

pipeline = Pipeline(DataLoader(text_processor=text_processor, n_grams=3),
                    TextEncoder(encode_type='one-hot'),
                    SVMClassifier(num_labels=3))

train_results = pipeline(train='./data/dev.vi', test='./data/dev_test.vi',
                         save_path='./weights/svm.sentivi')
print(train_results)

predict_results = pipeline.predict(['hàng ok đầu tuýp có một số không vừa ốc siết.'
                                    'chỉ được một số đầu thôi .cần nhất đầu tuýp 14'
                                    'mà không có. không đạt yêu cầu của mình sử dụng',
                                    'Son đẹpppp, mùi hương vali thơm nhưng hơi nồng,'
                                    'chất son mịn, màu lên chuẩn, đẹppppp'])
print(predict_results)
print(f'Decoded results: {pipeline.decode_polarity(predict_results)}')

Take a look at more examples in example/.

Future Releases

  • Lexicon-based
  • CharCNN
  • Ensemble learning methods
  • Model serving (Back-end and Front-end)

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

sentivi-1.0.1.tar.gz (17.6 kB view hashes)

Uploaded Source

Built Distribution

sentivi-1.0.1-py3-none-any.whl (24.6 kB view hashes)

Uploaded Python 3

Supported by

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