Пример #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;
 }
Пример #2
0
 /**
  * Returns number of syllables in a word
  * @param   boolean|string  $strText      Text to be measured
  * @return  int
  */
 public function syllableCount($strText = false)
 {
     $strText = $this->setText($strText);
     return Syllables::syllableCount($strText, $this->strEncoding);
 }