You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
1.6 KiB

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