mirror of
https://github.com/arnaucube/argos.git
synced 2026-02-07 02:56:41 +01:00
device source analysis
This commit is contained in:
11
README.md
11
README.md
@@ -1,6 +1,13 @@
|
||||
# goTweetsAnalyze
|
||||
twitter analyzer written in Go lang
|
||||
twitter analyzer written in Go lang, insipired on the Python tweets_analyzer by x0rz https://github.com/x0rz/tweets_analyzer
|
||||
|
||||
[under development]
|
||||
|
||||
#### Current analysis
|
||||
- word count
|
||||
- weekly activity distribution
|
||||
- daily activity distribution
|
||||
- devices used
|
||||
|
||||

|
||||
|
||||
@@ -24,4 +31,4 @@ to run it:
|
||||
```
|
||||
./goTweetsAnalyze
|
||||
```
|
||||
- follow the instructions
|
||||
- follow the instructions that appears on the terminal
|
||||
|
||||
20
analyzeSource.go
Normal file
20
analyzeSource.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/dghubble/go-twitter/twitter"
|
||||
)
|
||||
|
||||
func analyzeSource(tweets []twitter.Tweet) map[string]int {
|
||||
var sources = make(map[string]int)
|
||||
for _, v := range tweets {
|
||||
source := strings.Split(strings.Split(v.Source, ">")[1], "<")[0]
|
||||
if _, ok := sources[source]; ok {
|
||||
sources[source] = sources[source] + 1
|
||||
} else {
|
||||
sources[source] = 1
|
||||
}
|
||||
}
|
||||
return (sources)
|
||||
}
|
||||
Binary file not shown.
@@ -4,6 +4,7 @@ import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/dghubble/go-twitter/twitter"
|
||||
@@ -18,6 +19,7 @@ func getUser(client *twitter.Client) {
|
||||
|
||||
fmt.Println("-----------------------")
|
||||
|
||||
//get tweets and analyze words and dates
|
||||
tweets, _, _ := client.Timelines.UserTimeline(&twitter.UserTimelineParams{
|
||||
ScreenName: username,
|
||||
Count: 200,
|
||||
@@ -27,6 +29,13 @@ func getUser(client *twitter.Client) {
|
||||
analyzeWords(tweets)
|
||||
|
||||
analyzeDates(tweets)
|
||||
fmt.Println("")
|
||||
fmt.Println("Devices:")
|
||||
sources := analyzeSource(tweets)
|
||||
for k, v := range sources {
|
||||
fmt.Print(k + ": ")
|
||||
fmt.Println(strconv.Itoa(v) + "tw ")
|
||||
}
|
||||
|
||||
fmt.Println(" ")
|
||||
fmt.Print("first tweet analyzed: ")
|
||||
|
||||
2
main.go
2
main.go
@@ -11,7 +11,7 @@ const minNumWords = 3
|
||||
|
||||
func main() {
|
||||
fmt.Println("---------------")
|
||||
fmt.Println("goTweetsAnalyze initialized")
|
||||
fmt.Println("mgoTweetsAnalyze initialized")
|
||||
fmt.Println("Reading twitterConfig.json file")
|
||||
client := readConfigTokensAndConnect()
|
||||
|
||||
|
||||
BIN
screen1.png
BIN
screen1.png
Binary file not shown.
|
Before Width: | Height: | Size: 44 KiB |
Reference in New Issue
Block a user