本文整理匯總了PHP中CString::levenDist方法的典型用法代碼示例。如果您正苦於以下問題:PHP CString::levenDist方法的具體用法?PHP CString::levenDist怎麽用?PHP CString::levenDist使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類CString
的用法示例。
在下文中一共展示了CString::levenDist方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: metaphoneDist
/**
* Returns the Levenshtein distance calculated between the Metaphone keys of two strings.
*
* For any two strings, the [Levenshtein distance](http://en.wikipedia.org/wiki/Levenshtein_distance) is the total
* number of insert, replace, and delete operations required to transform the first string into the second one. The
* algorithm used to render the [Metaphone](http://en.wikipedia.org/wiki/Metaphone) keys is the first-generation
* one.
*
* @param string $string The first string for comparison.
* @param string $toString The second string for comparison.
* @param bool $transliterate **OPTIONAL. Default is** `true`. Tells whether to transliterate the strings into
* the Latin script and then flatten them to ASCII before generating the keys. Since neither the Metaphone or
* Levenshtein algorithm is Unicode-aware, the touch of transliteration is something that any arbitrary Unicode
* strings would wish for. For example, "こんにちは" is transliterated to "kon'nichiha".
*
* @return int The Levenshtein distance between the Metaphone keys of the two strings.
*/
public static function metaphoneDist($string, $toString, $transliterate = true)
{
assert('is_cstring($string) && is_cstring($toString) && is_bool($transliterate)', vs(isset($this), get_defined_vars()));
return CString::levenDist(self::metaphoneKey($string, $transliterate), self::metaphoneKey($toString, $transliterate));
}