<commit_before># Odyssey

Odyssey is an extendible text analyzing gem that outputs the readability score of text. It has several of the common readability formulas available, but defaults to the Flesch-Kincaid Reading Ease score.

## Installation

Add this line to your application's Gemfile:

    gem 'odyssey'

And then execute:

    $ bundle install

Or install it yourself as:

    $ gem install odyssey

## Usage

require 'odyssey'

Odyssey.formula_name(text, all_stats)

e.g. <code>Odyssey.flesch_kincaid_re("See Spot run.", true)</code>

if all_stats is false, this returns a simple score. If it is true, it returns a Hash:

<code>
{ 
  'name'                       => String,
  'formula'                    => formula_class,
  'score'                      => Float,
  'string_length'              => Fixnum,
  'letter_count'               => Fixnum,
  'syllable_count'             => Fixnum,
  'word_count'                 => Fixnum,
  'sentence_count'             => Fixnum,
  'sentence_count'             => Fixnum,
  'average_words_per_sentence' => Float,
  'average_syllables_per_word' => Float
}
</code>

##Extending Odyssey

To extend Odyssey, you can create a class that inherits from Formula.
<code>
class Cool_new_formula < Formula
  
  def score(text, stats)

  end

  def name
    "Cool new formula"
  end
end

#text will be a Hash like so:
data = {
  'raw' => String,
  'words' => Array,
  'sentences' => Array,
  'syllables' => Array
}

#stats will be a Hash like so:
{
  'string_length' => Fixnum,
  'letter_count' => Fixnum,
  'syllable_count' => Fixnum,
  'word_count' => Fixnum,
  'sentence_count' => Fixnum,
  'average_words_per_sentence' => Float,
  'average_syllables_per_word' => Float
}
</code><commit_msg>Fixed readme up a little more<commit_after># Odyssey

Odyssey is an extendible text analyzing gem that outputs the readability score of text. It has several of the common readability formulas available, but defaults to the Flesch-Kincaid Reading Ease score.

## Installation

Add this line to your application's Gemfile:

    gem 'odyssey'

And then execute:

    $ bundle install

Or install it yourself as:

    $ gem install odyssey

## Usage

<code>require 'odyssey'</code>

<code>Odyssey.formula_name(text, all_stats)</code>

e.g. <code>Odyssey.flesch_kincaid_re("See Spot run.", true)</code>

if all_stats is false, this returns a simple score. If it is true, it returns a Hash:

<code>
{<br>
  'name'                       => String,<br>
  'formula'                    => formula_class,<br>
  'score'                      => Float,<br>
  'string_length'              => Fixnum,<br>
  'letter_count'               => Fixnum,<br>
  'syllable_count'             => Fixnum,<br>
  'word_count'                 => Fixnum,<br>
  'sentence_count'             => Fixnum,<br>
  'sentence_count'             => Fixnum,<br>
  'average_words_per_sentence' => Float,<br>
  'average_syllables_per_word' => Float<br>
}
</code>

##Extending Odyssey

To extend Odyssey, you can create a class that inherits from Formula.
<code>
class Cool_new_formula < Formula<br>
<br>
  def score(text, stats)<br>
<br>
  end<br>
<br>
  def name<br>
    "Cool new formula"<br>
  end<br>
end<br>

text will be a Hash like so:<br>
data = {<br>
  'raw' => String,<br>
  'words' => Array,<br>
  'sentences' => Array,<br>
  'syllables' => Array<br>
}<br>

stats will be a Hash like so:<br>
{<br>
  'string_length' => Fixnum,<br>
  'letter_count' => Fixnum,<br>
  'syllable_count' => Fixnum,<br>
  'word_count' => Fixnum,<br>
  'sentence_count' => Fixnum,<br>
  'average_words_per_sentence' => Float,<br>
  'average_syllables_per_word' => Float<br>
}
</code>
{'fraction_non_alphanumeric': 0.12237093690248566, 'fraction_numerical': 0.0, 'mean_word_length': 3.0197585071350166, 'pattern_counts': {'":': 0, '<': 59, '<?xml version=': 0, '>': 101, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4452808', 'n_tokens_mistral': 1319, 'n_tokens_neox': 1259, 'n_words': 359}