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
30	analyzeUserAccount(client, username)
31
32	//now analyze words and dates
33	fmt.Println("Word frequency (more than " + strconv.Itoa(minNumWords) + " times):")
34	words := analyzeWords(tweets)
35
36	fmt.Println("Hashtags used (more than " + strconv.Itoa(minNumHashtag) + " times): ")
37	hashtags := analyzeHashtags(tweets, words)
38	printSortedMapStringInt(hashtags, minNumHashtag)
39	fmt.Println("")
40
41	fmt.Println("Interactions with other users (more than " + strconv.Itoa(minNumUserInteractions) + " times): ")
42	userInteractions := analyzeUserInteractions(tweets, words)
43	printSortedMapStringInt(userInteractions, minNumUserInteractions)
44	fmt.Println("")
45
46	analyzeDates(tweets)
47	fmt.Println("")
48	fmt.Println("Devices:")
49	sources := analyzeSource(tweets)
50	for k, v := range sources {
51		fmt.Print("\x1b[32;1m") //cyan
52		fmt.Print(k + ": ")
53		fmt.Print("\x1b[0m") //defaultColor
54		fmt.Println(strconv.Itoa(v) + "tw	")
55	}
56
57	fmt.Println(" ")
58	fmt.Print("first tweet analyzed: ")
59	fmt.Println(tweets[len(tweets)-1].CreatedAt)
60	fmt.Print("last tweet analyzed: ")
61	fmt.Println(tweets[0].CreatedAt)
62
63	fmt.Println(" ")
64	fmt.Println("Total of " + strconv.Itoa(len(tweets)) + " tweets analyzed")
65	fmt.Println(" ")
66	fmt.Print("User @")
67	c.Cyan(username)
68	//analyzeUserAccount(client, username)
69	fmt.Println(" analysis finished")
70}