-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
gosentiwordnet_test.go
34 lines (29 loc) · 1.09 KB
/
gosentiwordnet_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package gosentiwordnet_test
import (
"testing"
"github.com/dinopuguh/gosentiwordnet/v2"
"github.com/stretchr/testify/assert"
)
type SentimentTestCase struct {
Word string
PosTag string
Usage string
Scores gosentiwordnet.Sentiment
}
func generateTestCases() []SentimentTestCase {
return []SentimentTestCase{
{Word: "love", PosTag: "v", Usage: "2", Scores: gosentiwordnet.Sentiment{Positive: 1, Negative: 0, Objective: 0}},
{Word: "neat", PosTag: "a", Usage: "4", Scores: gosentiwordnet.Sentiment{Positive: 0.625, Negative: 0, Objective: 0.375}},
{Word: "overacting", PosTag: "n", Usage: "1", Scores: gosentiwordnet.Sentiment{Positive: 0, Negative: 0.875, Objective: 0.125}},
{Word: "finely", PosTag: "r", Usage: "2", Scores: gosentiwordnet.Sentiment{Positive: 0.625, Negative: 0, Objective: 0.375}},
}
}
func TestSentimentAnalysis(t *testing.T) {
sa := gosentiwordnet.New()
for _, testCase := range generateTestCases() {
scores, match := sa.GetSentimentScore(testCase.Word, testCase.PosTag, testCase.Usage)
if match {
assert.Equalf(t, testCase.Scores, scores, testCase.Word)
}
}
}