Grammar Check API - Ruby Gem
Grammar Check is a simple tool for checking the grammar and spelling of a text. It returns the corrected text.
Installation
Add this line to your application's Gemfile:
gem 'apiverve_grammarcheck'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install apiverve_grammarcheck
Getting Started
Get your API key at APIVerve
Basic Usage
require 'apiverve_grammarcheck'
# Initialize the client
client = APIVerve::Grammarcheck::Client.new(api_key: "YOUR_API_KEY")
# Make a request
response = client.execute({ text: "The the pig snorted when I saw it on the barn gate. I was a little mad becuase it woke up my pupppppy" })
# Print the response
puts response
Error Handling
begin
response = client.execute({ text: "The the pig snorted when I saw it on the barn gate. I was a little mad becuase it woke up my pupppppy" })
puts response["data"]
rescue APIVerve::Grammarcheck::ValidationError => e
puts "Validation error: #{e.errors.join(', ')}"
rescue APIVerve::Grammarcheck::APIError => e
puts "API error: #{e.}"
puts "Status code: #{e.status_code}"
end
Debug Mode
# Enable debug logging
client = APIVerve::Grammarcheck::Client.new(
api_key: "YOUR_API_KEY",
debug: true
)
Example Response
{
"status": "ok",
"error": null,
"data": {
"modified": true,
"corrected": "The pig snorted when I saw it on the barn gate. I was a little mad because it woke up my puppy",
"errorCount": 3,
"corrections": [
{
"rule": "repeated_word",
"message": "Did you mean to repeat the word \"The\"?",
"position": {
"start": 0,
"end": 7
},
"suggestions": [
"The"
]
},
{
"rule": "spelling",
"message": "Did you mean \"because\"?",
"position": {
"start": 67,
"end": 74
},
"suggestions": [
"because"
]
},
{
"rule": "spelling",
"message": "Did you mean \"puppy\"?",
"position": {
"start": 92,
"end": 101
},
"suggestions": [
"puppy"
]
}
]
}
}
Documentation
For more information, visit the API Documentation.
Support
- Website: https://apiverve.com/marketplace/grammarcheck?utm_source=ruby&utm_medium=readme
- Email: hello@apiverve.com
License
This gem is available under the MIT License.