如何做模糊字符串搜索没有一个沉重的数据库? [英] How to do fuzzy string search without a heavy database?

查看:123
本文介绍了如何做模糊字符串搜索没有一个沉重的数据库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个目录号码与产品名称的映射:

I have a mapping of catalog numbers to product names:

35  cozy comforter
35  warm blanket
67  pillow

需要搜索会发现拼写错误, cmfrter

我们有使用edit-distance(difflib)的代码,但它可能不会扩展到18000个名称。

We have code using edit-distance (difflib), but it probably won't scale to the 18000 names.

我实现了与Lucene类似的东西,但因为 PyLucene 只包裹

I achieved something similar with Lucene, but as PyLucene only wraps Java that would complicate deployment to end-users.

SQLite通常不会编写全文或评分。

SQLite doesn't usually have full-text or scoring compiled in.

Xapian绑定与C ++类似,并有一些学习曲线。

The Xapian bindings are like C++ and have some learning curve.

Whoosh 尚未详细记录,但包括可滥用的法术 -

Whoosh is not yet well-documented but includes an abusable spell-checker.

还有什么?

推荐答案

代替写另一个n元语法搜索或改进Whogy中的一个,我们现在保留一个词索引,检索具有与查询共同的至少一个(正确拼写)单词的所有条目,并使用difflib对它们进行排名。在这种情况下工作得很好。

Instead of writing another n-gram search or improving the one in Whoosh we now keep a word index, retrieve all entries that have at least one (correctly spelled) word in common with the query, and use difflib to rank those. Works well enough in this case.

这篇关于如何做模糊字符串搜索没有一个沉重的数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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