-
Notifications
You must be signed in to change notification settings - Fork 3
/
model.go
92 lines (78 loc) · 3.37 KB
/
model.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
package main
import validator "gopkg.in/validator.v2"
// Tweet model
type Tweet struct {
CreatedAt int `validate:"nonzero" json:"created_at" bson:"created_at"`
CreatedAtFull string `json:"created_at_full" bson:"created_at_full"`
FavoriteCount int `json:"favorite_count" bson:"favorite_count"`
RetweetCount int `json:"retweet_count" bson:"retweet_count"`
Text AnonymizedString `validate:"nonzero" json:"text" bson:"text"`
StatusID string `validate:"nonzero" json:"status_id" bson:"status_id"`
UserName string `json:"user_name" bson:"user_name"`
InReplyToScreenName string `json:"in_reply_to_screen_name" bson:"in_reply_to_screen_name"`
Hashtags []string `json:"hashtags" bson:"hashtags"`
Lang string `json:"lang" bson:"lang"`
Sentiment string `json:"sentiment" bson:"sentiment"`
SentimentScore int `json:"sentiment_score" bson:"sentiment_score"`
TweetClass string `json:"tweet_class" bson:"tweet_class"`
ClassifierCertainty int `json:"classifier_certainty" bson:"classifier_certainty"`
Annotated bool `json:"is_annotated" bson:"is_annotated"`
Topics TweetTopics `json:"topics" bson:"topics"`
}
func (tweet *Tweet) validate() error {
return validator.Validate(tweet)
}
func validateTweets(tweets []Tweet) error {
for _, tweet := range tweets {
err := tweet.validate()
if err != nil {
return err
}
}
return nil
}
// TweetLabel model
type TweetLabel struct {
StatusID string `validate:"nonzero" json:"status_id" bson:"status_id"`
Date int `json:"date" bson:"date"` // formt: YYYYmmmdd
Label string `validate:"nonzero" json:"label" bson:"label"`
PreviousLabel string `json:"previous_label" bson:"previous_label"`
}
func (tweetLabel *TweetLabel) validate() error {
return validator.Validate(tweetLabel)
}
// ResponseMessage model
type ResponseMessage struct {
Message string `json:"message"`
Status bool `json:"status"`
}
// TwitterAccount model
type TwitterAccount struct {
Names []string `json:"twitter_account_names" bson:"twitter_account_names"`
}
type TweetClass struct {
Label string `json:"label" bson:"label"`
Score float64 `json:"score" bson:"score"`
}
type TweetTopics struct {
FirstClass TweetClass `json:"first_class" bson:"first_class"`
SecondClass TweetClass `json:"second_class" bson:"second_class"`
}
// ObservableTwitter model
type ObservableTwitter struct {
AccountName string `validate:"nonzero" json:"account_name" bson:"account_name"`
Interval string `json:"interval" bson:"interval"`
Lang string `validate:"nonzero" json:"lang" bson:"lang"`
}
func (observable *ObservableTwitter) validate() error {
return validator.Validate(observable)
}
type AccessKey struct {
Key string `validate:"nonzero" json:"access_key" bson:"access_key"`
Configuration AccessKeyConfiguration `json:"configuration" bson:"configuration"`
}
type AccessKeyConfiguration struct {
TwitterAccounts []string `json:"twitter_accounts" bson:"twitter_accounts"`
GooglePlayStoreAccounts []string `json:"google_play_store_accounts" bson:"google_play_store_accounts"`
Topics []string `json:"topics" bson:"topics"`
}