Skip to content

Instantly share code, notes, and snippets.

@anujluthra
Created July 4, 2011 23:30
Show Gist options
  • Save anujluthra/1064054 to your computer and use it in GitHub Desktop.
Save anujluthra/1064054 to your computer and use it in GitHub Desktop.
Pull out aboriginal words and their meaning from http://www.grandpapencil.net/austral/abword/
require 'hpricot'
require 'open-uri'
dictionary = {}
for letter in ('a'..'z').to_a do
begin
puts "building dictionary for all: #{letter}"
doc = Hpricot(open("http://www.grandpapencil.net/austral/abword/ab#{letter}.htm"))
doc.search("li").search("div").each do |elem|
word = elem.search("font").first.search("strong").inner_html
meaning = elem.search("font").last.inner_html.split("\n").last.strip
dictionary[word] = meaning
end
rescue Exception => e
puts "Not found : #{letter}"
end
end
puts "dictionary complete"
dictionary.each do |word, meaning|
puts "#{word} : #{meaning}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment