加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails – 如何在sqlite where子句中使用Levenshtein距离

发布时间:2020-12-17 02:19:51 所属栏目:百科 来源:网络整理
导读:我正在努力实现“你的意思吗?”一种搜索功能. 我正在尝试使用levenshtein函数进行查询,该函数是用ruby编写的.我想知道如何在sqlite3查询中使用此函数.我在想它可能是这样的: @results = the_db.where(‘levenshtein(name,?) = 3',searchphrase) 但我不知
我正在努力实现“你的意思吗?”一种搜索功能.

我正在尝试使用levenshtein函数进行查询,该函数是用ruby编写的.我想知道如何在sqlite3查询中使用此函数.我在想它可能是这样的:

@results = the_db.where(‘levenshtein(name,?)< = 3',searchphrase) 但我不知道如何让它发挥作用.有人可以帮帮我吗?

解决方法

尝试editdist3函数:

The editdist3 algorithm is a function that computes the minimum edit
distance (a.k.a. the Levenshtein distance) between two input strings.

> http://www.sqlite.org/spellfix1.html

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读