Skip to main content

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:

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

multilingual-sentiment-classifier-1.6.tar.gz (83.2 MB view hashes)

Uploaded Source

Built Distribution

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