A Python library to predict sentiments of textual data in English, Urdu or Roman Urdu
Project description
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
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
Built Distribution
File details
Details for the file multilingual-sentiment-classifier-1.6.tar.gz
.
File metadata
- Download URL: multilingual-sentiment-classifier-1.6.tar.gz
- Upload date:
- Size: 83.2 MB
- Tags: Source
- Uploaded using 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
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0a9f8dae28626aaf2bab016cd75f1c74aed6024766ea544cad41b2664fb151ed |
|
MD5 | 71584ddc140f547b478ced40e482c9be |
|
BLAKE2b-256 | 4ef12ac2c37520f57f9896129648496da41316231cbd44c0c0f52e558d5c40fc |
Provenance
File details
Details for the file multilingual_sentiment_classifier-1.6-py3-none-any.whl
.
File metadata
- Download URL: multilingual_sentiment_classifier-1.6-py3-none-any.whl
- Upload date:
- Size: 83.2 MB
- Tags: Python 3
- Uploaded using 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
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d8bfa7494a24ae18ce55150779b466da8c3ecfa45e1dc4d2332d9d18408fc764 |
|
MD5 | 9e652336326effaa343ff9c008c7ca2b |
|
BLAKE2b-256 | 373dd346c84ec7560eb80d68034f8f0b182ea9821c7e60ef81d377da1ee294e5 |