Sentiment Analysis API - Ruby Gem
Sentiment Analysis is a simple tool for analyzing the sentiment of a text. It returns the sentiment score and the sentiment label.
Installation
Add this line to your application's Gemfile:
gem 'apiverve_sentimentanalysis'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install apiverve_sentimentanalysis
Getting Started
Get your API key at APIVerve
Basic Usage
require 'apiverve_sentimentanalysis'
# Initialize the client
client = APIVerve::Sentimentanalysis::Client.new(api_key: "YOUR_API_KEY")
# Make a request
response = client.execute({ text: "I'm so excited that tomorrow is going to be sunny! Can't wait!" })
# Print the response
puts response
Error Handling
begin
response = client.execute({ text: "I'm so excited that tomorrow is going to be sunny! Can't wait!" })
puts response["data"]
rescue APIVerve::Sentimentanalysis::ValidationError => e
puts "Validation error: #{e.errors.join(', ')}"
rescue APIVerve::Sentimentanalysis::APIError => e
puts "API error: #{e.}"
puts "Status code: #{e.status_code}"
end
Debug Mode
# Enable debug logging
client = APIVerve::Sentimentanalysis::Client.new(
api_key: "YOUR_API_KEY",
debug: true
)
Example Response
{
"status": "ok",
"error": null,
"data": {
"comparative": 0.25,
"sentimentText": "positive",
"sentiment": 3,
"isPositive": true,
"isNegative": false,
"normalizedScore": 0.3
}
}
Documentation
For more information, visit the API Documentation.
Support
- Website: https://sentimentanalysis.apiverve.com?utm_source=ruby&utm_medium=readme
- Email: hello@apiverve.com
License
This gem is available under the MIT License.