Text Similarity API - Ruby Gem
Text Similarity is a simple tool for checking the similarity between two texts. It returns the similarity score.
Installation
Add this line to your application's Gemfile:
gem 'apiverve_textsimilarity'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install apiverve_textsimilarity
Getting Started
Get your API key at APIVerve
Basic Usage
require 'apiverve_textsimilarity'
# Initialize the client
client = APIVerve::Textsimilarity::Client.new(api_key: "YOUR_API_KEY")
# Make a request
response = client.execute({
text1: "I'm so excited that tomorrow is going to be sunny! Can't wait!",
text2: "We're pretty excited about the weather tomorrow. It's going to be sunny!"
})
# Print the response
puts response
Error Handling
begin
response = client.execute({ text1: "I'm so excited that tomorrow is going to be sunny! Can't wait!", text2: "We're pretty excited about the weather tomorrow. It's going to be sunny!" })
puts response["data"]
rescue APIVerve::Textsimilarity::ValidationError => e
puts "Validation error: #{e.errors.join(', ')}"
rescue APIVerve::Textsimilarity::APIError => e
puts "API error: #{e.}"
puts "Status code: #{e.status_code}"
end
Debug Mode
# Enable debug logging
client = APIVerve::Textsimilarity::Client.new(
api_key: "YOUR_API_KEY",
debug: true
)
Example Response
{
"status": "ok",
"error": null,
"data": {
"simiarity": 45.83,
"similarityCaseSensitive": 47.22,
"difference": {
"count": 7,
"percentage": 58.33
}
}
}
Documentation
For more information, visit the API Documentation.
Support
- Website: https://apiverve.com/marketplace/textsimilarity?utm_source=ruby&utm_medium=readme
- Email: hello@apiverve.com
License
This gem is available under the MIT License.