/**
  * @param \Absolvent\FuzzyText\WordListInterface $first
  * @param \Absolvent\FuzzyText\WordListInterface $second
  * @param float $threshold
  * @return float number between 0 and 1
  */
 function oneWayWordListsCompare(WordListInterface $first, WordListInterface $second, $threshold = self::DEFAULT_LOWER_THRESHOLD)
 {
     $matchedWords = 0;
     foreach ($first as $firstWord) {
         if ($second->hasWord($firstWord)) {
             $matchedWords += 1;
         }
     }
     $firstCount = count($first);
     if ($firstCount < 1) {
         return 0;
     }
     return (double) $matchedWords / $firstCount;
 }
コード例 #2
0
 /**
  * @param \Absolvent\FuzzyText\WordListInterface $otherWordList
  * @return void
  */
 public function isCoveredByWordList(WordListInterface $otherWordList)
 {
     foreach ($this->wordsByCount as $word => $wordCount) {
         if ($otherWordList->countWordOccurences($word) < $wordCount) {
             return false;
         }
     }
     return true;
 }