问题描述
我有一个表dictionary
,其中包含类似单词的列表:
I have a table dictionary
which contains a list of words Like:
ID|word
---------
1|hello
2|google
3|similar
...
所以我想如果有人写这样的文本
so i want if somebody writes a text like
"hela iam正在为gogle寻找类似引擎".
"helo iam looking for simlar engines for gogle".
现在我要检查数据库中是否存在每个单词,如果不存在,应该给我一个类似的词.例如:helo = hello, simlar = similar, gogle = google
.好吧,我想修复拼写错误.在我的数据库中,我有所有英语单词的完整词典.我找不到任何对我有帮助的mysql函数. LIKE
对我的情况没有帮助.
Now I want to check every word if it exists in the database, if not it shouldget me the similar word for the word. For example: helo = hello, simlar = similar, gogle = google
.Well, i want to fix the spelling errors. In my database i have a full dictionary of all english words. I coudn't find any mysql function which helps me. LIKE
isn't helpfull in my situation.
推荐答案
有一个函数确实可以满足您的要求,但是它非常耗时,会降低查询速度.您可能可以在您的情况下使用,我之前已经使用过.叫做Levenshtein.您可以在这里如何在mysql中添加levenshtein函数?
There is a function that does roughly want you want, but it's intensive and will slow queries down. You might be able to use in your circumstances, I have used it before. It's called Levenshtein. You can get it here How to add levenshtein function in mysql?
这篇关于MYSQL搜索正确的单词|修正拼写错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!