Skip to content

Instantly share code, notes, and snippets.

@huezoaa
Created January 30, 2015 22:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save huezoaa/689aac9a9d73470f466d to your computer and use it in GitHub Desktop.
Save huezoaa/689aac9a9d73470f466d to your computer and use it in GitHub Desktop.
Spell Check API
require 'httparty'
require 'json'
puts "Please enter the word to spell-check:"
##### Get word to spell check from the user
word = gets.chomp
address = "https://montanaflynn-spellcheck.p.mashape.com/check/?text=" + word
# These code snippets use an open-source library.
response = HTTParty.get("#{address}",
headers:{
"X-Mashape-Key" => "vjtlBS3N5BmshKwBpizJRLNmDzDdp1DRgknjsnxpva1IHZ4cVZ",
"Accept" => "application/json"
})
# puts "The following is the response.body:"
# puts response.body
# puts "\n"
hash_response = JSON.parse(response.body)
# puts hash_response
# puts "\n"
puts "\n\n\n\n"
puts "You entered: " + hash_response["original"] + "\n\n"
puts "May we suggest: " + hash_response["suggestion"] + "\n\n\n\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment