Parts Of Speech API - Ruby Gem
Parts Of Speech is a simple tool for extracting nouns, verbs, adjectives, adverbs, etc. from text. It returns the extracted words based on the part of speech specified.
Installation
Add this line to your application's Gemfile:
gem 'apiverve_partsofspeech'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install apiverve_partsofspeech
Getting Started
Get your API key at APIVerve
Basic Usage
require 'apiverve_partsofspeech'
# Initialize the client
client = APIVerve::Partsofspeech::Client.new(api_key: "YOUR_API_KEY")
# Make a request
response = client.execute({
text: "My friend from college hails from a small countryside village located at the heart of the state. During the last summer vacation, I had an opportunity to visit my friend in his village. I packed up my belongings and boarded the bus bound for the village",
partofspeech: "verbs"
})
# Print the response
puts response
Error Handling
begin
response = client.execute({ text: "My friend from college hails from a small countryside village located at the heart of the state. During the last summer vacation, I had an opportunity to visit my friend in his village. I packed up my belongings and boarded the bus bound for the village", partofspeech: "verbs" })
puts response["data"]
rescue APIVerve::Partsofspeech::ValidationError => e
puts "Validation error: #{e.errors.join(', ')}"
rescue APIVerve::Partsofspeech::APIError => e
puts "API error: #{e.}"
puts "Status code: #{e.status_code}"
end
Debug Mode
# Enable debug logging
client = APIVerve::Partsofspeech::Client.new(
api_key: "YOUR_API_KEY",
debug: true
)
Example Response
{
"status": "ok",
"error": null,
"data": {
"partofspeech": "verbs",
"result": [
"located",
"had",
"visit",
"packed up",
"boarded",
"bound"
],
"count": 6
}
}
Documentation
For more information, visit the API Documentation.
Support
- Website: https://apiverve.com/marketplace/partsofspeech?utm_source=ruby&utm_medium=readme
- Email: hello@apiverve.com
License
This gem is available under the MIT License.