/** * Returns the number of unique words NOT on the Spache easy word list * @param boolean|string $strText Text to be measured * @return int */ public function spacheDifficultWordCount($strText = false) { $strText = $this->setText($strText); $intDifficultWords = 0; $arrWords = explode(' ', strtolower(preg_replace('`[^A-za-z\' ]`', '', $strText))); // Fetch Spache Words $wordsCounted = array(); // Get the Spache word list $arrSpache = Resource::fetchSpacheWordList(); for ($i = 0, $intWordCount = count($arrWords); $i < $intWordCount; $i++) { // Single letters are counted as easy if (strlen(trim($arrWords[$i])) < 2) { continue; } $singularWord = Pluralise::getSingular($arrWords[$i]); if (!in_array(Pluralise::getPlural($arrWords[$i]), $arrSpache) && !in_array($singularWord, $arrSpache)) { if (!in_array($singularWord, $wordsCounted)) { $intDifficultWords++; $wordsCounted[] = $singularWord; } } } return $intDifficultWords; }