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