gpt4 book ai didi

php - 在两段文本之间寻找匹配的短语?

转载 作者:行者123 更新时间:2023-12-04 06:03:57 24 4
gpt4 key购买 nike

我的目标是从两段文本中找到相似的短语。

我知道常用词会有问题。例如,and the we are the .在这种情况下,我认为需要一个过滤器。

我想知道这是否是一个好方法?这使用递归,如果找到匹配项,则查看下一个单词是否也是匹配项,并继续直到没有匹配项为止。

  1. the cat is on the roof
2. a man is on the stage

A1 = [the, cat, is, on, the, roof]
A2 = [a, man, is, on, the, stage]

[the]: no match
[cat]: no match
[is]: match
[is, on]: match
[is, on, the]: match
[is, on, the, roof]: no match
[on]: match
[on, the]: match
[on, the, roof]: no match
[the]: match
[the, roof]: no match
[roof]: no match
-end-

最佳答案

在 Google 上快速搜索显示我 this website包含您的问题的解决方案:

It works by finding the longest sequence of words common to both strings, and recursively finding the longest sequences of the remainders of the string until the substrings have no words in common. At this point it adds the remaining new words as an insertion and the remaining old words as a deletion.

关于php - 在两段文本之间寻找匹配的短语?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8587582/

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