Skip to content

Instantly share code, notes, and snippets.

@keithrbennett
Created February 3, 2011 05:23
Show Gist options
  • Select an option

  • Save keithrbennett/809088 to your computer and use it in GitHub Desktop.

Select an option

Save keithrbennett/809088 to your computer and use it in GitHub Desktop.
WordLookup, for Rick
class WordLookup
def run()
lines = File.readlines('words.txt')
File.open('words-with-definitions.txt', 'w') do |output_file|
# assume the only thing on the line is the word
lines.each do |word|
definition = get_definition(word)
output_file << "#{word} - #{definition}\n"
end
end
# This is the hard part, needs some research.
def get_definition(word)
# Ruby's Net::HTTP makes it easy to send HTTP requests and get the
# response, but you need to know what to send (i.e. which site, which
# parameters, how to build the URL with them) and how to parse the
# response, which will probably be an entire web page in HTML,
# Javascript, etc.
end
end
# Instantiate the class and call its run():
WordLookup.new.run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment