vader

package module
v0.0.0-...-1f7c35e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 30, 2019 License: MIT Imports: 8 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

GoVader. Sentiment analysis tool written in GO (GoLang).

"VADER (Valence Aware Dictionary and sEntiment Reasoner) is a lexicon and rule-based sentiment analysis tool that is specifically attuned to sentiments expressed in social media."

Original python implementation of VADER (https://github.com/cjhutto/vaderSentiment).

Getting started

Install:

go get github.com/rabingaire/vader

Example of usage:

sia := vader.SentimentIntensityAnalyzer{}
err := sia.Init()
if err != nil {
    log.Fatal(err)
}

score := sia.PolarityScores("VADER is smart, handsome, and funny!")
fmt.Println(score)
//output: map[pos:0.746 neg:0 neu:0.254 compound:0.8316]

Accuracy on twitter dataset (200k tweets: 100k positive and 100k negative):

Total number of analyzed tweets:  200000
The accuracy of tested sentiment is: 51.0%
2019/06/20 17:41:17 False positive: 15.8%
2019/06/20 17:41:17 False negative: 5.07%

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BoosterMap = map[string]float64{"absolutely": bIncr, "amazingly": bIncr, "awfully": bIncr, "completely": bIncr, "considerably": bIncr,
	"decidedly": bIncr, "deeply": bIncr, "effing": bIncr, "enormously": bIncr,
	"entirely": bIncr, "especially": bIncr, "exceptionally": bIncr, "extremely": bIncr,
	"fabulously": bIncr, "flipping": bIncr, "flippin": bIncr,
	"fricking": bIncr, "frickin": bIncr, "frigging": bIncr, "friggin": bIncr, "fully": bIncr, "fucking": bIncr,
	"greatly": bIncr, "hella": bIncr, "highly": bIncr, "hugely": bIncr, "incredibly": bIncr,
	"intensely": bIncr, "majorly": bIncr, "more": bIncr, "most": bIncr, "particularly": bIncr,
	"purely": bIncr, "quite": bIncr, "really": bIncr, "remarkably": bIncr,
	"so": bIncr, "substantially": bIncr,
	"thoroughly": bIncr, "totally": bIncr, "tremendously": bIncr,
	"uber": bIncr, "unbelievably": bIncr, "unusually": bIncr, "utterly": bIncr,
	"very":   bIncr,
	"almost": bDecr, "barely": bDecr, "hardly": bDecr, "just enough": bDecr,
	"kind of": bDecr, "kinda": bDecr, "kindof": bDecr, "kind-of": bDecr,
	"less": bDecr, "little": bDecr, "marginally": bDecr, "occasionally": bDecr, "partly": bDecr,
	"scarcely": bDecr, "slightly": bDecr, "somewhat": bDecr,
	"sort of": bDecr, "sorta": bDecr, "sortof": bDecr, "sort-of": bDecr}

BoosterMap booster/dampener 'intensifiers' or 'degree adverbs' http://en.wiktionary.org/wiki/Category:English_degree_adverbs

View Source
var Negations = []string{"aint", "arent", "cannot", "cant", "couldnt", "darent", "didnt", "doesnt",
	"ain't", "aren't", "can't", "couldn't", "daren't", "didn't", "doesn't",
	"dont", "hadnt", "hasnt", "havent", "isnt", "mightnt", "mustnt", "neither",
	"don't", "hadn't", "hasn't", "haven't", "isn't", "mightn't", "mustn't",
	"neednt", "needn't", "never", "none", "nope", "nor", "not", "nothing", "nowhere",
	"oughtnt", "shant", "shouldnt", "uhuh", "wasnt", "werent",
	"oughtn't", "shan't", "shouldn't", "uh-uh", "wasn't", "weren't",
	"without", "wont", "wouldnt", "won't", "wouldn't", "rarely", "seldom", "despite"}

Negations ..

View Source
var Punctuations = []string{".", "..", "...", "!", "?", ",", ";", ":", "-", "'", "\"", "!!", "!!!", "??", "???", "?!?", "!?!", "?!?!", "!?!?", "????", "?????"}

Punctuations ..

View Source
var RegexRemovePunctuation = regexp.MustCompile(fmt.Sprintf("[%s]", regexp.QuoteMeta(`!"//$%&'#()*+,-./:;<=>?@[\]^_{|}~`+"`")))

RegexRemovePunctuation for removing punctuation

View Source
var SentimentLadenIdioms = map[string]int{"cut the mustard": 2, "hand to mouth": -2,
	"back handed": -2, "blow smoke": -2, "blowing smoke": -2,
	"upper hand": 1, "break a leg": 2,
	"cooking with gas": 2, "in the black": 2, "in the red": -2,
	"on the ball": 2, "under the weather": -2}

SentimentLadenIdioms check for sentiment laden idioms that do not contain lexicon words (future work, not yet implemented)

View Source
var SpecialCaseIdioms = map[string]float64{"the shit": 3, "the bomb": 3, "bad ass": 1.5, "yeah right": -2,
	"kiss of death": -1.5}

SpecialCaseIdioms check for special case idioms containing lexicon words

Functions

This section is empty.

Types

type SentiText

type SentiText struct {
	Text              string
	WordsAndEmoticons []string
	IsCapDiff         bool
}

SentiText ..

func (*SentiText) Init

func (s *SentiText) Init(text string)

Init ..

type SentimentIntensityAnalyzer

type SentimentIntensityAnalyzer struct {
	LexiconMap        map[string]float64
	EmojiLexiconMap   map[string]string
	SpecialCaseIdioms map[string]float64
}

SentimentIntensityAnalyzer Give a sentiment intensity score to sentences.

func (*SentimentIntensityAnalyzer) Init

func (sia *SentimentIntensityAnalyzer) Init(filenames ...string) error

Init sentiment analyzer with lexicons if no filepaths passed to init, using default lexicon files

func (*SentimentIntensityAnalyzer) PolarityScores

func (sia *SentimentIntensityAnalyzer) PolarityScores(text string) map[string]float64

PolarityScores Return a float for sentiment strength based on the input text. Positive values are positive valence, negative value are negative valence.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址