/** * @param mixed $wordList * @param float $threshold parameter between 0 and 1 * @return \Absolvent\FuzzyText\WordListInterface */ public function normalizeWordList($wordList, $threshold = self::DEFAULT_WORD_LIST_THRESHOLD) { $wordList = WordList::fromAnything($wordList); $normalizedWordList = new WordList(); foreach ($wordList as $word) { $word = $this->normalizeWord($word); $normalizedWordList->addWord($word); } return $normalizedWordList; }
public function testTwoWayWordListCompareWithNoDifferences() { $wordListCoverageComparator = new FullCoverageWordListComparator(); $first = WordList::fromArray(['one']); $second = WordList::fromArray(['one']); $result = $wordListCoverageComparator->twoWayWordListsCompare($first, $second); $this->assertSame(1.0, $result); }
public function testFindingLongestWord() { $wordList = new WordList(); $wordList->addWord('a'); $wordList->addWord('bb'); $wordList->addWord('c'); $wordList->addWord('ddd'); $wordList->addWord('eeee'); $wordList->addWord('f'); $this->assertsame('eeee', $wordList->getLongestWord()); }