实施智能搜索/模糊字符串比较 [英] Implement smart search / Fuzzy string comparison

查看:58
本文介绍了实施智能搜索/模糊字符串比较的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在ASP.NET MVC应用程序上有一个网页,客户可以在其中搜索供应商.供应商在网站上捕获自己的详细信息.客户端希望进行智能搜索".功能,即使供应商的拼写略有不同",他们也可以搜索供应商并找到他们.在搜索框中输入的内容.

I have a web page on an ASP.NET MVC application where customers search for suppliers. The suppliers capture their own details on the website. The client wants a "smart search" feature, where they could search for suppliers and find them even if the supplier spelling is "slightly different" to what is typed in the search box.

我不知道客户对稍有不同"的看法是什么.是.我一直在研究实现自定义的soundex算法.这将根据单词的发音将单词转换为数字.然后将该数字用于比较.

I have no idea what the client's notion of "slightly different" is. I've been looking into implementing a custom soundex algorithm. This converts a word into a number based on how it sounds. That number is then used for comparison.

例如:

扎克

扎克

将编码为相同的值.我还有其他可能的选择吗?

will encode to the same value. Are there any other options I could possible look into?

推荐答案

您可以使用 Levenshtein距离与数据库中供应商"上的标签"字段结合使用,以实现智能搜索"样式功能.

You can use Levenshtein distance combined with a 'tags' field on Suppliers in your database for 'smart search' style functionality.

这是非常基本的,但适用于诸如"Zack/Zach"之类的情况.

It's pretty basic but works for well for cases such as 'Zack/Zach'.

在数据库中添加标签使您可以处理人们可能会使用缩写词或其他俗称来搜索供应商的情况.

Adding tags in your database allows you to handle situations where people may search for a supplier by their acronym or other colloquial name.

请参见如何计算给定2个字符串的距离相似性度量?

See How to calculate distance similarity measure of given 2 strings? and http://www.dotnetperls.com/levenshtein for implementation details.

这篇关于实施智能搜索/模糊字符串比较的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆