package linguistics

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

// GoVADERSentimentProvider implements SentimentProvider using VADER
type GoVADERSentimentProvider struct {
	analyzer *govader.SentimentIntensityAnalyzer
}

// NewGoVADERSentimentProvider constructs a VADER-based sentiment provider
func NewGoVADERSentimentProvider() (*GoVADERSentimentProvider, error) {
	analyzer := govader.NewSentimentIntensityAnalyzer()
	return &GoVADERSentimentProvider{analyzer: analyzer}, nil
}

// Score returns the compound VADER polarity score in [-1, 1]
func (p *GoVADERSentimentProvider) Score(text string, _ string) (float64, error) {
	scores := p.analyzer.PolarityScores(text)
	return scores.Compound, nil
}
