MYSQL找到两个文本字段是不同的? [英] MYSQL find how different two text fields are?
问题描述
我正在将数据库中的电子邮件的HTML内容存储在我的数据库中。
I'm storing the HTML content of emails in my database.
如果我在数据库中存储了两个相同的电子邮件,那只是有点不同,因为个人化(可能会说你好斯蒂芬,谢谢订阅...,另一个你好安德鲁,谢谢订阅...)。
If I store two of the same emails in my database, that are only a little different because of personalization (one might say "Hello Stephen, thank you for subscribing...", and the other "Hello Andrew, thank you for subscribing...").
我如何知道这些文本字段只是稍有不同? (可能得到一个百分比,说他们是95%一样)。
How can I tell that these text fields are only slightly different? (maybe get a percentage saying they're 95% alike).
推荐答案
这是一个很好的起点MySQL:
http://www.artfulsoftware.com/infotree/queries.php#552
Here's a good starting point for MySQL: http://www.artfulsoftware.com/infotree/queries.php#552
Levenshtein距离是将一个字符串转换为另一个字符串所需的编辑次数。你可能会把这个距离除以字符串的长度来得到一个百分比。
A Levenshtein distance is the number of edits required to turn one string into another. You could probably mess with dividing that distance by the length of the string to get a percentage of sorts.
对于PHP,有一个内置的Levenshtein函数: http://www.php.net/manual/en/function.levenshtein.php
For PHP, there is a builtin Levenshtein function: http://www.php.net/manual/en/function.levenshtein.php
这篇关于MYSQL找到两个文本字段是不同的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!