-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
55 lines (46 loc) · 1.07 KB
/
main.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package main
import (
"os"
_ "github.com/joho/godotenv/autoload"
"github.com/nuvi/justin-sentiment/postgres"
"github.com/nuvi/justin-sentiment/rabbit"
"github.com/nuvi/justin-sentiment/tfidf"
"github.com/nuvi/justin-sentiment/train"
)
// parameters
var c train.Classifier
func main() {
db := postgres.InitPostgres()
db.EnsurePostgresTables()
sentimentData := db.GetFaschetData("sentiment")
sentimentCategories := []string{"positive", "neutral", "negative"}
sentiment := train.CreateClassifier(sentimentCategories)
//trainFile on trainFile dataset
for _, data := range sentimentData {
sent := ""
switch data.Sentiment {
case 1:
sent = "negative"
case 2:
sent = "neutral"
case 3:
sent = "positive"
}
train.Train(&sentiment, sent, data.Text)
}
if os.Getenv("CLASSIFICATION_METHOD") == "tfidf" {
for _, data := range sentimentData {
sent := ""
switch data.Sentiment {
case 1:
sent = "negative"
case 2:
sent = "neutral"
case 3:
sent = "positive"
}
tfidf.TfFreq(&sentiment, sent, data.Text)
}
}
rabbit.Consume(&c)
}