gpt4 book ai didi

php - 获取 PHP 或 MySQL 中重叠字符的数量?

转载 作者:行者123 更新时间:2023-11-30 23:34:51 24 4
gpt4 key购买 nike

我想计算两个字符串比较中重叠字符的数量。假设您有这些比较:

       boel <-> baal
boel <-> bol
beestenboel <-> boelsten
beestenboel <-> baastenb
hallo <-> hello

结果一定是这样的:

BoeL         } b matches, o does not match,
BaaL } e does not match, l matches.
Result: overlap = 2

BOeL } b matches, o matches, l matches
BO L } e does not match (it's not present in the lower string).
Result: overlap = 3

B EeSTENboel } b matches, e matches (because o is only present in the lower
BoElSTEN } string), the second e is no longer present (since we have
already consumed an e from the lower string, l does not match,
s, t, e, n match successively.
(Notice that b, e, o and l from the upper string will be ignored,
since all characters from the lower string have already been
consumed.)
Result: overlap = 6

BeeSTENBoel } b matches, the two e's do not match with the two a's, and again,
BaaSTENB } s, t, e, n match.
Result: overlap = 6

HaLLO } h matches, a doesn't match
HeLLO } l, l and o match.
Result: overlap = 4

我怀疑我想得太复杂了...我怎样才能在 MySQL 或 PHP 中获得上述结果?

(我猜levenshtein算法和这个问题有关。)

最佳答案

这个描述让我想起了我在学习期间学到的所有 DNA 比对算法。我不太确定,你需要他们正在做的所有事情,但看看 Needleman-WunschSmith-Waterman .

关于php - 获取 PHP 或 MySQL 中重叠字符的数量?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8326437/

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