本文整理汇总了PHP中Diff::levenshtein方法的典型用法代码示例。如果您正苦于以下问题:PHP Diff::levenshtein方法的具体用法?PHP Diff::levenshtein怎么用?PHP Diff::levenshtein使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Diff
的用法示例。
在下文中一共展示了Diff::levenshtein方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testLevenshtein
public function testLevenshtein()
{
// Levenshtein with trailing equality.
$this->d->setChanges(array(array(Diff::DELETE, "abc"), array(Diff::INSERT, "1234"), array(Diff::EQUAL, "xyz")));
$this->assertEquals(4, $this->d->levenshtein());
// Levenshtein with leading equality.
$this->d->setChanges(array(array(Diff::EQUAL, "xyz"), array(Diff::DELETE, "abc"), array(Diff::INSERT, "1234")));
$this->assertEquals(4, $this->d->levenshtein());
// Levenshtein with middle equality.
$this->d->setChanges(array(array(Diff::DELETE, "abc"), array(Diff::EQUAL, "xyz"), array(Diff::INSERT, "1234")));
$this->assertEquals(7, $this->d->levenshtein());
}
示例2: diff_levenshtein
/**
* Compute the Levenshtein distance; the number of inserted, deleted or substituted characters.
*
* @param array $diffs Array of diff arrays.
*
* @return int Number of changes.
*/
public function diff_levenshtein($diffs)
{
$this->diff->setChanges($diffs);
return $this->diff->levenshtein();
}