当前位置: 首页>>代码示例>>PHP>>正文


PHP Diff::levenshtein方法代码示例

本文整理汇总了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());
 }
开发者ID:yetanotherape,项目名称:diff-match-patch,代码行数:12,代码来源:DiffTest.php

示例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();
 }
开发者ID:yetanotherape,项目名称:diff-match-patch,代码行数:12,代码来源:DiffMatchPatch.php


注:本文中的Diff::levenshtein方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。