Giter Club home page Giter Club logo

vadersentiment_java's Introduction

Java-based implementation of VADER Sentiment Analysis

This repository contains a Java-based implementation of Hutto and Gilbert's Python-based VADER: A Parsimonious Rule-based Model for Sentiment Analysis of Social Media Text, from:

VADER: A Parsimonious Rule-based Model for Sentiment Analysis of Social Media Text
(by C.J. Hutto and Eric Gilbert)
Eighth International Conference on Weblogs and Social Media (ICWSM-14). Ann Arbor, MI, June 2014.

Original Python Version

Hutto and Gilbert's version can be found on GitHub here

Usage

The SentimentIntensityAnalyzer class has a static method, getDefaultAnalyzer(), that returns an instance of SentimentIntensityAnalyzer using the default VADER lexicon. You can use this object and its polarity_scores() method to get the polarity score for a given string.

NOTE: This code does not provide sentence identification or any other natural language utilities.

The polarity_scores() function returns a Java Map object with the positive, negative, neutral, and compound polarity scores.

Scala Usage

The following example shows how to use this package in Scala, which is my primary language right now.

import edu.umd.hcil.vader.SentimentIntensityAnalyzer

val analyzer = SentimentIntensityAnalyzer.getDefaultAnalyzer

analyzer.polarity_scores("VADER is smart, handsome, and funny.").get("compound")

Here's a brief example on using this code to get the compound value for a file full of tweets

val source = scala.io.Source.fromFile("tweets.txt")
for ( line <- source.getLines ) {
    val score = analyzer.polarity_scores(line).get("compound")
    
    System.out.println(String.format("%s\t%s\n", line, score.toString))
}

Acks

I also relied heavily on Chris Humphreys's p2j Python-to-Java translation toolkit to handle a lot of the mundane translations.

vadersentiment_java's People

Contributors

cbuntain avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.