Skip to content

Instantly share code, notes, and snippets.

@pingles
Created July 20, 2010 22:55
Show Gist options
  • Save pingles/483723 to your computer and use it in GitHub Desktop.
Save pingles/483723 to your computer and use it in GitHub Desktop.
require "rubygems"
require "mandy"
Mandy.job "Word Count" do
map_tasks 5
reduce_tasks 3
map do |line|
line.split(' ').each do |word|
word.downcase!
word.gsub!(/\W|[0-9_]/, '')
next if word.size == 0
emit(word, 1)
end
end
reduce do |word, occurrences|
emit(word, occurrences.size)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment