Levenshtein在多个列上多个单词

发布于 2025-01-20 16:02:37 字数 1255 浏览 2 评论 0原文

我正在尝试使搜索更加友好,并希望利用Levenshtein距离。这效果很好,但是如果列中的值长25个字符,则只有3个字符的距离太远。在这种情况下,它的性能比喜欢方法更糟。我通过使用regexp_split_to_table将所有单词分为自己的行来解决此问题。这很好,但是如果我有多个单词作为输入,仍然无法使用。

例如:

让数据看起来如下

ID IDcol1col2
1一三2二2
2
house43
househouse3

使用regexp_split_to_table会将其转换为

IDcol
1col 1 col
1 1
1
2
2二1三2
2两个
3
3
4房子
43

如果我搜索一棵树,我想将一个与每个单词进行比较,但也比较tree tree 使用每个单词,然后按两个距离的总和进行排序。

我不知道从哪里开始。我也不知道这是否是这样做的最佳方法(似乎有些过分,但我也不是专家)。也许我也想过这个。我很高兴暗示正确的方向:)。

I'm trying to make search a bit more friendly and wanted to exploit the Levenshtein distance. This works great but if a value in a column has a length of 25 characters long, the distance to only 3 characters is too far. In this case, it performs worse than the LIKE method. I solved this by splitting all words into their own rows using regexp_split_to_table. This is nice, but it's still not working if I have multiple words as input.

For example:

Let the data look as following

idcol1col2
1one twothree
2twoone
3horsetree
4housethree

using regexp_split_to_table would transform this to

idcol
1one
1two
1three
2one
2two
2two
3horse
3tree
4house
4three

If I search for one tree, I'd like to compare one with each word but also compare tree with each word and then order by the sum of both distances.

I have no idea where to start. I also do not know if this is the best approach to do this (it seems somewhat excessive but I'm also not an expert). Maybe I'm also overthinking this. I'd appreciate a hint into the right direction :).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文