Building Mini-Google in Ruby @igrigorik #railsconfhttp://bit.ly/railsconf-pagerank Building an Inverted Index require set pages = { 1 => it is what it is , 2 => what is it , 3 => it is a banana } index = {} pages.each do |page, content| content.split(/\s/).each do |word| if index[word] index[word] << page else index[word] = Set.new(page) end end end { it =>#, a =>#, banana =>#, what =>#, is =># } }
{}