Did You Mean API - Ruby Gem
Did You Mean is a simple tool for correcting spelling mistakes. It returns the corrected text.
Installation
Add this line to your application's Gemfile:
gem 'apiverve_didyoumean'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install apiverve_didyoumean
Getting Started
Get your API key at APIVerve
Basic Usage
require 'apiverve_didyoumean'
# Initialize the client
client = APIVerve::Didyoumean::Client.new(api_key: "YOUR_API_KEY")
# Make a request
response = client.execute({ query: "what weather today is" })
# Print the response
puts response
Error Handling
begin
response = client.execute({ query: "what weather today is" })
puts response["data"]
rescue APIVerve::Didyoumean::ValidationError => e
puts "Validation error: #{e.errors.join(', ')}"
rescue APIVerve::Didyoumean::APIError => e
puts "API error: #{e.}"
puts "Status code: #{e.status_code}"
end
Debug Mode
# Enable debug logging
client = APIVerve::Didyoumean::Client.new(
api_key: "YOUR_API_KEY",
debug: true
)
Example Response
{
"status": "ok",
"error": null,
"data": {
"query": "what weather today is",
"didYouMean": [
"what is the weather today",
"what's the weather like today",
"what will be the weather today"
]
}
}
Documentation
For more information, visit the API Documentation.
Support
- Website: https://apiverve.com/marketplace/didyoumean?utm_source=ruby&utm_medium=readme
- Email: hello@apiverve.com
License
This gem is available under the MIT License.