Skip to content

Instantly share code, notes, and snippets.

@schatteleyn
Created March 21, 2014 15:52
Show Gist options
  • Save schatteleyn/9689296 to your computer and use it in GitHub Desktop.
Save schatteleyn/9689296 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
#coding: utf-8
require 'pp'
word = {}
tweets = []
final = {}
File.open("mapreduce.csv", "r:windows-1251:utf-8").each_line do |line|
line = line.split(",")
word[line[0]] = line[2]
end
File.open("tweet.csv").each_line do |line|
line = line.split(",")
tweets.push(line[1])
end
tweets.each do |tweet|
tweetsplitted = tweet.split(" ")
count = 0
tweetsplitted.each do |w|
count += word[w].to_i
end
final[tweet] = count
end
pp(final.sort_by {|_key, value| value})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment