コード例 #1
0
ファイル: main.go プロジェクト: nanddalal/Poli-Metrics
func main() {
	alchemy_credentials, _ := util.GenFileHash("credentials/alchemy_credentials")
	twitter_credentials, _ := util.GenFileHash("credentials/twitter_credentials")

	anaconda.SetConsumerKey(twitter_credentials["CONSUMER_KEY"])
	anaconda.SetConsumerSecret(twitter_credentials["CONSUMER_SECRET"])
	api := anaconda.NewTwitterApi(twitter_credentials["ACCESS_TOKEN"], twitter_credentials["ACCESS_TOKEN_SECRET"])

	c := bass.NewRDB()
	countries := bass.GetCountries(c)
	for _, country := range countries {
		var sentiment_val float64
		var pos_words []string
		var neg_words []string
		searchResult, _ := api.GetSearch(country, nil)
		for _, tweet := range searchResult {
			x, y, z := alchemy.GetSentimentalWords(alchemy_credentials, tweet.Text)
			sentiment_val += x
			pos_words = append(pos_words, y...)
			neg_words = append(neg_words, z...)
		}
		bass.PushRDB(c, country, sentiment_val, pos_words, neg_words)
	}

	bass.CloseRDB(c)
}
コード例 #2
0
ファイル: http.go プロジェクト: nanddalal/Poli-Metrics
func handler(rw http.ResponseWriter, req *http.Request) {
	vars := mux.Vars(req)
	country_name := vars["country_name"]
	c := bass.NewRDB()
	str := bass.PullRDB(country_name, c)
	for _, s := range str {
		fmt.Fprintf(rw, "%s", s)
	}
	bass.CloseRDB(c)
}