Returns the number of words with more than three syllables.

@param   strText                  Text to be measured
@return
508918
private static int wordsWithThreeSyllables(String strText) {
        int intLongWordCount = 0;
        
        List<String> arrWords = (new WhitespaceTokenizer()).tokenize(strText);
        int intWordCount = arrWords.size();
        for (int i = 0; i < intWordCount; ++i) {
            if(syllableCount(arrWords.get(i)) > 2) {
                ++intLongWordCount; //it also counts the proper nouns which should be excluded for Fog index, but this is not a major issue
            }
        }
        
        return intLongWordCount;
    }
145671
public function shortenTextWord($textStr, $numChars = 255, $tail = '…')
    {
        if (intval($numChars) == 0) {
            $numChars = 255;
        }
        $textStr = strip_tags($textStr);
        if (function_exists('mb_substr')) {
            if (mb_strlen($textStr, APP_CHARSET) > $numChars) {
                $textStr = preg_replace('/\s+?(\S+)?$/', '', mb_substr($textStr, 0, $numChars + 1, APP_CHARSET));
                // this is needed if the shortened string consists of one single word
                $textStr = mb_substr($textStr, 0, $numChars, APP_CHARSET) . $tail;
            }
        } else {
            if (strlen($textStr) > $numChars) {
                $textStr = preg_replace('/\s+?(\S+)?$/', '', substr($textStr, 0, $numChars + 1));
                $textStr = substr($textStr, 0, $numChars) . $tail;
            }
        }

        return $textStr;
    }
508187
public function setText($strText)
    {

        // If text passed in, clean it up and store it for subsequent queries
        if ($strText !== false) {
            self::$strText = Text::cleanText($strText);
        }

        return self::$strText;
    }
175428
@Override
    public Collection<String> wordsNearestSum(String word, int n) {
        //INDArray vec = Transforms.unitVec(this.lookupTable.vector(word));
        INDArray vec = this.lookupTable.vector(word);
        return wordsNearestSum(vec, n);
    }
496588
public static function words($count = 3)
    {
        if ($count === 1) {
            return static::$words[array_rand(static::$words, $count)];
        } else {
            return array_intersect_key(static::$words, array_flip(array_rand(static::$words, $count)));
        }
    }
818643
public static function numberOfWords($text) {
		$count = 0;
		$words = explode(' ', $text);
		foreach ($words as $word) {
			$word = trim($word);
			if (!empty($word)) {
				$count++;
			}
		}
		return $count;
	}
32957
public static function sentenceCount($strText, $strEncoding = '')
    {
        if (strlen(trim($strText)) == 0) {
            return 0;
        }

        // Will be tripped up by "Mr." or "U.K.". Not a major concern at this point.
        $intSentences = max(1, self::textLength(preg_replace('`[^\.!?]`', '', $strText), $strEncoding));

        return $intSentences;
    }
1277030
public static function syllableCount($strWord, $strEncoding = '')
    {

        // Trim whitespace
        $strWord = trim($strWord);

        // Check we have some letters
        if (Text::letterCount(trim($strWord), $strEncoding) == 0) {
            return 0;
        }

        // $debug is an array containing the basic syllable counting steps for
        // this word.
        $debug = array();
        $debug['Counting syllables for'] = $strWord;

        // Should be no non-alpha characters and lower case
        $strWord = preg_replace('`[^A-Za-z]`', '', $strWord);
        $strWord = Text::lowerCase($strWord, $strEncoding);

        // Check for problem words
        if (isset(self::$arrProblemWords[$strWord])) {
            return self::$arrProblemWords[$strWord];
        }
        // Try singular
        $singularWord = Pluralise::getSingular($strWord);
        if ($singularWord != $strWord) {
            if (isset(self::$arrProblemWords[$singularWord])) {
                return self::$arrProblemWords[$singularWord];
            }
        }

        $debug['After cleaning, lcase'] = $strWord;

        // Remove prefixes and suffixes and count how many were taken
        $strWord = preg_replace(self::$arrAffix, '', $strWord, -1, $intAffixCount);
        $strWord = preg_replace(self::$arrDoubleAffix, '', $strWord, -1, $intDoubleAffixCount);
        $strWord = preg_replace(self::$arrTripleAffix, '', $strWord, -1, $intTripleAffixCount);

        if (($intAffixCount + $intDoubleAffixCount + $intTripleAffixCount) > 0) {
            $debug['After Prefix and Suffix Removal'] = $strWord;
            $debug['Prefix and suffix counts'] = $intAffixCount . ' * 1 syllable, ' . $intDoubleAffixCount . ' * 2 syllables, ' . $intTripleAffixCount . ' * 3 syllables';
        }

        // Removed non-word characters from word
        $arrWordParts = preg_split('`[^aeiouy]+`', $strWord);
        $intWordPartCount = 0;
        foreach ($arrWordParts as $strWordPart) {
            if ($strWordPart <> '') {
                $debug['Counting (' . $intWordPartCount . ')'] = $strWordPart;
                $intWordPartCount++;
            }
        }

        // Some syllables do not follow normal rules - check for them
        // Thanks to Joe Kovar for correcting a bug in the following lines
        $intSyllableCount = $intWordPartCount + $intAffixCount + (2 * $intDoubleAffixCount) + (3 * $intTripleAffixCount);
        $debug['Syllables by Vowel Count'] = $intSyllableCount;

        foreach (self::$arrSubSyllables as $strSyllable) {
            $_intSyllableCount = $intSyllableCount;
            $intSyllableCount -= preg_match('`' . $strSyllable . '`', $strWord);
            if ($_intSyllableCount != $intSyllableCount) {
                $debug['Subtracting (' . $strSyllable . ')'] = $strSyllable;
            }
        }
        foreach (self::$arrAddSyllables as $strSyllable) {
            $_intSyllableCount = $intSyllableCount;
            $intSyllableCount += preg_match('`' . $strSyllable . '`', $strWord);
            if ($_intSyllableCount != $intSyllableCount) {
                $debug['Adding (' . $strSyllable . ')'] = $strSyllable;
            }
        }
        $intSyllableCount = ($intSyllableCount == 0) ? 1 : $intSyllableCount;

        $debug['Result'] = $intSyllableCount;

        return $intSyllableCount;
    }
194499
public static int getLineCount(final String text) {
    final Matcher matcher = LINE_FINDER.matcher(text);
    int i = 0;

    while (matcher.find()) {
      i++;
    }

    return i;
  }
763390
public function automatedReadabilityIndex($strText = false)
    {
        $strText = $this->setText($strText);

        $score = Maths::bcCalc(
            Maths::bcCalc(
                4.71,
                '*',
                Maths::bcCalc(
                    Text::letterCount($strText, $this->strEncoding),
                    '/',
                    Text::wordCount($strText, $this->strEncoding)
                )
            ),
            '+',
            Maths::bcCalc(
                Maths::bcCalc(
                    0.5,
                    '*',
                    Maths::bcCalc(
                        Text::wordCount($strText, $this->strEncoding),
                        '/',
                        Text::sentenceCount($strText, $this->strEncoding)
                    )
                ),
                '-',
                21.43
            )
        );

        if ($this->normalise) {
            return Maths::normaliseScore($score, 0, $this->maxGradeLevel, $this->dps);
        } else {
            return Maths::bcCalc($score, '+', 0, true, $this->dps);
        }
    }
1000601
public static function count(string $text = '', bool $includeSpaces = false): int
    {
        if (\trim($text) === '') {
            return 0;
        }
        $text = StripTags::strip($text);
        $text = \htmlspecialchars_decode((string)$text, ENT_COMPAT | ENT_HTML5);
        $text = \preg_replace('/\s+/', $includeSpaces ? ' ' : '', $text);
        $text = \trim($text);

        return \mb_strlen($text, 'UTF-8');
    }
68014
@Override
    public String words(int numberOfWords) {

        if (numberOfWords < 1) {
            throw new IllegalArgumentException(INVALID_ARGUMENT_ERROR_MSG);
        }

        List<String> loremWords = new ArrayList<>();

        for(int i = 0; i < numberOfWords; i++) {
            loremWords.add(word());
        }

        return TextUtils.join(" ", loremWords);
    }
1130231
function syllables(value) {
  var values = normalize(String(value))
    .toLowerCase()
    .replace(APOSTROPHE, '')
    .split(SPLIT)
  var length = values.length
  var index = -1
  var total = 0

  while (++index < length) {
    total += syllable(values[index].replace(EXPRESSION_NONALPHABETIC, ''))
  }

  return total
}
774691
private static int countWildcardPhraseFrequencies(File dir, String pattern)
        throws Exception {
        
        File[] files = dir.listFiles();

        int total = 0;

        for (int i = 0; i < files.length; i++) {
            File f = files[i];
            if (f.isDirectory()) {
                total += countWildcardPhraseFrequencies(f, pattern);
            } else if (f.getName().endsWith(".txt")) {
                Scanner sc = new Scanner(f);
                while (sc.hasNext()) {
                    String line = sc.nextLine();
                    if (line.matches(pattern)) {
                        total++;
                    }
                }
            }
        }
        return total;
    }
449587
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;
    }
1293050
public function wordsWithThreeSyllables($strText = false, $blnCountProperNouns = true)
    {
        $strText = $this->setText($strText);

        return Syllables::wordsWithThreeSyllables($strText, $blnCountProperNouns, $this->strEncoding);
    }
494284
func Syllables(word string) int {
	// See if we can leave early ...
	length := utf8.RuneCountInString(word)
	if length < 1 {
		return 0
	} else if length < 3 {
		return 1
	}

	// See if this is a known cornercase ...
	word = strings.ToLower(word)
	if syllables, ok := cornercases[word]; ok {
		return syllables
	}
	text, count := clean(word)

	// Count multiple vowels
	count += len(vowels.FindAllString(text, -1))

	count -= len(monosyllabicOne.FindAllString(text, -1))
	count -= len(monosyllabicTwo.FindAllString(text, -1))

	count += len(doubleSyllabicOne.FindAllString(text, -1))
	count += len(doubleSyllabicTwo.FindAllString(text, -1))
	count += len(doubleSyllabicThree.FindAllString(text, -1))
	count += len(doubleSyllabicFour.FindAllString(text, -1))

	if count < 1 {
		return 1
	}
	return count
}