gpt4 book ai didi

php - PHP levenshtein() 函数有问题吗?

转载 作者:塔克拉玛干 更新时间:2023-11-03 06:05:42 24 4
gpt4 key购买 nike

在此页上 levenshtein() ,我正在使用带有以下变量的示例 #1:

// input misspelled word
$input = 'htc corporation';

// array of words to check against
$words = array('htc', 'Sprint Nextel', 'Sprint', 'banana', 'orange',
'radish', 'carrot', 'pea', 'bean');

有人能告诉我为什么预期结果是carrot而不是htc吗?谢谢

最佳答案

因为 htc corporation 的 levenshtein 距离是 12,而到 carrot 的距离只有 11。

levenshtein 函数计算它必须添加或替换多少个字符才能到达某个单词,因为 htc corporationhtc 多 12 个字符,它必须删除 12 以得到 htc。要从 htc corporation 获取单词 carrot,需要进行 11 次更改。

关于php - PHP levenshtein() 函数有问题吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18021186/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com