govader

package module
Version: v0.0.0-...-68ffa1d Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2022 License: MIT Imports: 9 Imported by: 4

README

GoVader

GoDoc Go Report BuildStatus Mentioned in Awesome Go codecov

GoVader: Vader sentiment analysis in Go

This is a port of https://github.com/cjhutto/vaderSentiment from Python to Go.

There are tests which check it gives the same answers as the original package.

Usage:

import (
    "fmt"
    "github.com/jonreiter/govader"
)

analyzer := govader.NewSentimentIntensityAnalyzer()
sentiment := analyzer.PolarityScores("Usage is similar to all the other ports.")

fmt.Println("Compound score:", sentiment.Compound)
fmt.Println("Positive score:", sentiment.Positive)
fmt.Println("Neutral score:", sentiment.Neutral)
fmt.Println("Negative score:", sentiment.Negative)

A server wrapper is available in https://github.com/PIMPfiction/govader_backend.

Documentation

Overview

Package govader implements the vader sentiment analysis algorithm see https://github.com/cjhutto/vaderSentiment

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PythonesqueRegex

type PythonesqueRegex struct {
	LowerRegex        *regexp.Regexp
	UpperRegex        *regexp.Regexp
	PunctuationRegex  *regexp.Regexp
	PunctuationString string
}

PythonesqueRegex holds all the regex needed to replicate python string manipulation behaviors

func NewPythonesqueRegex

func NewPythonesqueRegex() *PythonesqueRegex

NewPythonesqueRegex builds a new set of regex

type SentiText

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

SentiText holds sentiment-relevant string-level properties of input text.

func NewSentiText

func NewSentiText(text string, pr *PythonesqueRegex) *SentiText

NewSentiText initliazes and returns a fleshed-out SentiText.

type Sentiment

type Sentiment struct {
	Negative float64
	Neutral  float64
	Positive float64
	Compound float64
}

Sentiment encapsulates a single sentiment measure for a statement

type SentimentIntensityAnalyzer

type SentimentIntensityAnalyzer struct {
	Lexicon   map[string]float64
	EmojiDict map[string]string
	Constants *TermConstants
}

SentimentIntensityAnalyzer computes sentiment intensity scores for sentences.

func NewSentimentIntensityAnalyzer

func NewSentimentIntensityAnalyzer() *SentimentIntensityAnalyzer

NewSentimentIntensityAnalyzer constructs and initializes an analyzer for computing intensity scores to sentences.

func (*SentimentIntensityAnalyzer) PolarityScores

func (sia *SentimentIntensityAnalyzer) PolarityScores(text string) Sentiment

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

type TermConstants

type TermConstants struct {
	NegateList        []string
	BoosterDict       map[string]float64
	LadenIdioms       map[string]float64
	SpecialCaseIdioms map[string]float64
	Regex             *PythonesqueRegex
}

TermConstants contains the large list and dictionary constants

func NewTermConstants

func NewTermConstants() *TermConstants

NewTermConstants assembles a fully-populated constant struct

Directories

Path Synopsis
Package data Code generated by go-bindata.
Package data Code generated by go-bindata.
Package main provides a simple sentiment scoring example.
Package main provides a simple sentiment scoring example.

Jump to

Keyboard shortcuts

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