Example #1
0
 /**
  * Returns the number 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
  * @param   string  $strEncoding  Encoding of text
  * @return  int
  */
 public static function wordsWithThreeSyllables($strText, $blnCountProperNouns = true, $strEncoding = '')
 {
     $intLongWordCount = 0;
     $intWordCount = Text::wordCount($strText, $strEncoding);
     $arrWords = explode(' ', $strText);
     for ($i = 0; $i < $intWordCount; $i++) {
         if (Syllables::syllableCount($arrWords[$i], $strEncoding) >= 3) {
             if ($blnCountProperNouns) {
                 $intLongWordCount++;
             } else {
                 $strFirstLetter = Text::substring($arrWords[$i], 0, 1, $strEncoding);
                 if ($strFirstLetter !== Text::upperCase($strFirstLetter, $strEncoding)) {
                     // First letter is lower case. Count it.
                     $intLongWordCount++;
                 }
             }
         }
     }
     return $intLongWordCount;
 }
Example #2
0
 /**
  * Returns the percentage of words with more than three syllables
  * @param   boolean|string  $strText      Text to be measured
  * @param   bool    $blnCountProperNouns      Boolean - should proper nouns be included in words count
  * @return  int|float
  */
 public function percentageWordsWithThreeSyllables($strText = false, $blnCountProperNouns = true)
 {
     $strText = $this->setText($strText);
     return Syllables::percentageWordsWithThreeSyllables($strText, $blnCountProperNouns, $this->strEncoding);
 }