Skip to content

Instantly share code, notes, and snippets.

@dmmfll
Last active November 10, 2016 23:55
Show Gist options
  • Save dmmfll/3c668c4608ee46f584075d4906ad0327 to your computer and use it in GitHub Desktop.
Save dmmfll/3c668c4608ee46f584075d4906ad0327 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
require 'json'
require 'httparty'
url = 'http://api.wordnik.com/v4/word.json/record/definitions?limit=200&includeRelated=true&useCanonical=false&includeTags=false&api_key=a2a73e7b926c924fad7001ca3111acd55af2ffabf50eb4ae5'
response = HTTParty.get(url)
api_response = JSON.parse(response.body)
puts api_response.class
api_response = JSON.parse(api_response)
puts api_response.class
filtered_results = api_response.map do |datum|
datum['partOfSpeech']
end
filtered_results.uniq.map do |attr|
attr if attr.include? 'verb'
end.compact.length > 0
[1, 1, 1,].uniq
[1, nil, nil, false, nil, 0].compact
[nil, nil, nil].compact.length
[1, nil, nil, false, nil, 0].compact.length
keys = ["textProns", "sourceDictionary", "exampleUses", "relatedWords", "labels", "citations", "word", "partOfSpeech", "attributionText", "sequence", "text", "score"]
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment