Multilingual Sentiment Classifier
A multilingual sentiment predictor which classifies English, Urdu or Roman Urdu text as Negative or Positive. It uses sentiment analysis algorithms of machine learning to classify negative and positive texts. We used 5 different algorithms and then calculated the sum of predictions to vote if a text is most likely to be negative or positive in sentiment.
Features
- Multilingual Sentiment Analysis
- Preprocesses text before passing to classifiers
- Uses 5 different classifiers to vote if an input is positive or negative
- Sentiment Analysis of Urdu, Roman Urdu and English languages
- Can classify a single text
- Can also classify a DataFrame
Requirements
This project uses a number of open source projects to work properly:
- python 3.8
- nltk==3.6.2
- tweet-preprocessor==0.6.0
- textblob==0.15.3
- scikit-learn==0.22.2.post1
- numpy==1.18.5
- NLTK Data
And of course this itself is open source with a public repository on GitHub.
Installation
Git:
git clone https://github.com/saman-azhar/multilingual-sentiment-classifier.git
Pip:
pip3 install multilingualsentimentclassifier
Module Example
Text:
from multilingualsentimentclassifier.methods import text_sentiment
import nltk
#download these 2 dependencies when running for first time
nltk.download('punkt')
nltk.download('wordnet')
# testing english negative
sentiment = text_sentiment.predict_sentiment("i AM sad and angry :@", "en")
print(sentiment)
# testing roman-urdu postitive
sentiment2 = text_sentiment.predict_sentiment("main boht khush houn", "in")
print(sentiment2)
# testing urdu negative
# you can directly print in console
print(text_sentiment.predict_sentiment("میں تم سے ناراض ہوں", "ur"))
DataFrame:
from multilingualsentimentclassifier.methods import dataframe_sentiment
import pandas as pd
import numpy as np
# dataframe w urdu text
df_ur = pd.DataFrame(np.array([["میں تم سے ناراض ہوں"], ["میں تم سے خوش ہوں"]]), columns=["text"])
print(dataframe_sentiment.predict_sentiment(df_ur, "ur"))
Note: This software does not detect language. You must enter the language of your input data. 1 indicates negative and 0 indicates positive.
License
MIT
Release files for multilingual-sentiment-classifier 1.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| multilingual-sentiment-classifier-1.6.tar.gz | 83.2 MB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| multilingual_sentiment_classifier-1.6-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 166.4 MB
Release files / multilingual-sentiment-classifier-1.6.tar.gz
| Download URL | multilingual-sentiment-classifier-1.6.tar.gz |
|---|---|
| Size | 83.2 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0a9f8dae28626aaf2bab016cd75f1c74aed6024766ea544cad41b2664fb151ed
|
|
BLAKE2b-256 checksum How to use checksums |
4ef12ac2c37520f57f9896129648496da41316231cbd44c0c0f52e558d5c40fc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.5
|
Release files / multilingual_sentiment_classifier-1.6-py3-none-any.whl
| Download URL | multilingual_sentiment_classifier-1.6-py3-none-any.whl |
|---|---|
| Size | 83.2 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d8bfa7494a24ae18ce55150779b466da8c3ecfa45e1dc4d2332d9d18408fc764
|
|
BLAKE2b-256 checksum How to use checksums |
373dd346c84ec7560eb80d68034f8f0b182ea9821c7e60ef81d377da1ee294e5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.5
|