I need MySQL code for checking similarity percentage between text submitted via form against a number of texts stored in MySQL database.
I am looking for MySQL stored procedure that will work the like PHP's similar_text()
function. There is already MySQL Levenshtein distance procedure but it's not sufficient.
When the user submits the text the algorithm should return any entry in database with given percentage of similarity to the text submitted (it will compare only one column in database), e.g return all entries from database that have similarity > 40% with the text submitted by the user.
E.g table
TABLE - Articles
id, article_body, article_title
Code should return all rows that have similarity percentage > 40% (or other given value) with the text (article_body) the user have submitted.
I'd do it in the application.
Maybe result of SOUNDEX function will help you -
SELECT SOUNDEX('Hello'), SOUNDEX('Hello world'), SOUNDEX('hellboy');
+------------------+------------------------+--------------------+
| SOUNDEX('Hello') | SOUNDEX('Hello world') | SOUNDEX('hellboy') |
+------------------+------------------------+--------------------+
| H400 | H4643 | H410 |
+------------------+------------------------+--------------------+
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With