Example #1
0
 /**
  * Gives the Spache readability score of text entered rounded to one digit
  * @param   boolean|string  $strText         Text to be checked
  * @return  int|float
  */
 public function spacheReadabilityScore($strText = false)
 {
     $strText = $this->setText($strText);
     $score = Maths::bcCalc(Maths::bcCalc(Maths::bcCalc(0.121, '*', Maths::bcCalc(Text::wordCount($strText, $this->strEncoding), '/', Text::sentenceCount($strText, $this->strEncoding))), '+', Maths::bcCalc(0.082, '*', $this->spacheDifficultWordCount($strText))), '+', 0.659);
     if ($this->normalise) {
         return Maths::normaliseScore($score, 0, 5, $this->dps);
         // Not really suitable for measuring readability above grade 4
     } else {
         return Maths::bcCalc($score, '+', 0, true, $this->dps);
     }
 }
Example #2
0
 /**
  * Returns the percentage of words with more than three syllables
  * @param   string  $strText      Text to be measured
  * @param   bool    $blnCountProperNouns      Boolean - should proper nouns be included in words count
  * @return  int|float
  */
 public static function percentageWordsWithThreeSyllables($strText, $blnCountProperNouns = true, $strEncoding = '')
 {
     $intWordCount = Text::wordCount($strText, $strEncoding);
     $intLongWordCount = self::wordsWithThreeSyllables($strText, $blnCountProperNouns, $strEncoding);
     $intPercentage = Maths::bcCalc(Maths::bcCalc($intLongWordCount, '/', $intWordCount), '*', 100);
     return $intPercentage;
 }
Example #3
0
 /**
  * Returns average words per sentence for text.
  * @param   string  $strText      Text to be measured
  * @param   string  $strEncoding  Encoding of text
  * @return  int|float
  */
 public static function averageWordsPerSentence($strText, $strEncoding = '')
 {
     $intSentenceCount = self::sentenceCount($strText, $strEncoding);
     $intWordCount = self::wordCount($strText, $strEncoding);
     $averageWords = Maths::bcCalc($intWordCount, '/', $intSentenceCount);
     return $averageWords;
 }