Created
February 23, 2015 17:44
-
-
Save jszwedko/d91cf7b69c93748726d4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import codecs | |
import sys | |
import os | |
from slacker import Slacker | |
UTF8Writer = codecs.getwriter('utf8') | |
sys.stdout = UTF8Writer(sys.stdout) | |
slack = Slacker(os.environ['SLACK_TOKEN']) | |
l = None | |
while True: | |
response = slack.channels.history(os.environ['SLACK_CHANNEL'], latest=l, count=1000) | |
if response.body["ok"] != True: | |
sys.stderr.write(response.body["error"]) | |
break | |
if response.body["messages"] == []: | |
break | |
for message in response.body["messages"]: | |
if "text" in message: | |
print message["text"] | |
l = message["ts"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tm) | |
library(wordcloud) | |
messages <- readLines("/tmp/team-scaling.txt", encoding="UTF-8") | |
corpus <- Corpus(VectorSource(messages)) | |
corpus <- tm_map(corpus, stripWhitespace) | |
corpus <- tm_map(corpus, tolower) | |
corpus <- tm_map(corpus, removeWords, stopwords("english")) | |
corpus <- tm_map(corpus, removePunctuation) | |
corpus <- tm_map(corpus, stemDocument, language = "english") | |
corpus <- tm_map(corpus, PlainTextDocument) | |
m <- as.matrix(dtm) | |
dtm <- TermDocumentMatrix(corpus) | |
m <- as.matrix(dtm) | |
v <- sort(rowSums(m), decreasing=TRUE) | |
d <- data.frame(word = names(v), freq=v) | |
wordcloud(d$word, d$freq, max.words = 100) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment