arnaucube
arnaucube/argosPublic Self-hosted repository
argos/optionAnalyzeUserTweets.go
optionAnalyzeUserTweets.goRaw
 1package main
 2
 3import (
 4	"fmt"
 5	"strconv"
 6
 7	"github.com/dghubble/go-twitter/twitter"
 8)
 9
10func optionAnalyzeUserTweets(client *twitter.Client, username string) {
11
12	//get tweets
13	tweets := getTweets(client, username, iterationsCount)
14
15	if len(tweets) == 0 {
16		fmt.Println("User @" + username + " does not have tweets")
17		return
18	}
19
20	analyzeUserAccount(client, username)
21
22	//now analyze words and dates
23	fmt.Println("Word frequency (more than " + strconv.Itoa(minNumWords) + " times):")
24	words := analyzeWords(tweets)
25
26	fmt.Println("Hashtags used (more than " + strconv.Itoa(minNumHashtag) + " times): ")
27	hashtags := analyzeHashtags(tweets, words)
28	printSortedMapStringInt(hashtags, minNumHashtag)
29	fmt.Println("")
30
31	fmt.Println("Interactions with other users (more than " + strconv.Itoa(minNumUserInteractions) + " times): ")
32	userInteractions := analyzeUserInteractions(tweets, words)
33	printSortedMapStringInt(userInteractions, minNumUserInteractions)
34	fmt.Println("")
35
36	analyzeDates(tweets)
37	fmt.Println("")
38	fmt.Println("Devices:")
39	sources := analyzeSource(tweets)
40	for k, v := range sources {
41		fmt.Print("\x1b[32;1m") //cyan
42		fmt.Print(k + ": ")
43		fmt.Print("\x1b[0m") //defaultColor
44		fmt.Println(strconv.Itoa(v) + "tw	")
45	}
46
47	fmt.Println(" ")
48	fmt.Print("first tweet analyzed: ")
49	fmt.Println(tweets[len(tweets)-1].CreatedAt)
50	fmt.Print("last tweet analyzed: ")
51	fmt.Println(tweets[0].CreatedAt)
52
53	fmt.Println(" ")
54	fmt.Println("Total of " + strconv.Itoa(len(tweets)) + " tweets analyzed")
55	fmt.Println(" ")
56	fmt.Print("User @")
57	c.Cyan(username)
58	//analyzeUserAccount(client, username)
59	fmt.Println(" analysis finished")
60}