Text Readability Score API - Ruby Gem

Readability Score is a simple tool for calculating the readability score of text. It returns the readability score based on various readability formulas.

Installation

Add this line to your application's Gemfile:

gem 'apiverve_readabilityscore'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install apiverve_readabilityscore

Getting Started

Get your API key at APIVerve

Basic Usage

require 'apiverve_readabilityscore'

# Initialize the client
client = APIVerve::Readabilityscore::Client.new(api_key: "YOUR_API_KEY")

# Make a request
response = client.execute({ text: "Western astrology is founded on the movements and relative positions of celestial bodies such as the Sun, Moon and planets, which are analysed by their movement through signs of the zodiac (twelve spatial divisions of the ecliptic) and by their aspects (based on geometric angles) relative to one another." })

# Print the response
puts response

Error Handling

begin
  response = client.execute({ text: "Western astrology is founded on the movements and relative positions of celestial bodies such as the Sun, Moon and planets, which are analysed by their movement through signs of the zodiac (twelve spatial divisions of the ecliptic) and by their aspects (based on geometric angles) relative to one another." })
  puts response["data"]
rescue APIVerve::Readabilityscore::ValidationError => e
  puts "Validation error: #{e.errors.join(', ')}"
rescue APIVerve::Readabilityscore::APIError => e
  puts "API error: #{e.message}"
  puts "Status code: #{e.status_code}"
end

Debug Mode

# Enable debug logging
client = APIVerve::Readabilityscore::Client.new(
  api_key: "YOUR_API_KEY",
  debug: true
)

Example Response

{
  "status": "ok",
  "error": null,
  "data": {
    "textCounts": {
      "syllableCount": 82,
      "lexiconCount": 49,
      "sentenceCount": 1
    },
    "readability": {
      "fleschReadingEase": 13.28,
      "fleschKincaidGrade": 23.6,
      "gunningFog": 26.95,
      "colemanLiauIndex": 13.19,
      "smogIndex": 22.08,
      "automatedReadabilityIndex": 27.8,
      "daleChallReadabilityScore": 17
    },
    "readabilityText": {
      "fleschReadingEase": "very confusing",
      "daleChallReadabilityScore": "average 13th to 15th-grade (college) student"
    },
    "averageGradeLevel": 22.7,
    "targetAudience": "post-graduate"
  }
}

Documentation

For more information, visit the API Documentation.

Support

License

This gem is available under the MIT License.