Created
January 30, 2015 22:00
-
-
Save huezoaa/689aac9a9d73470f466d to your computer and use it in GitHub Desktop.
Spell Check API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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