Suggest words from database using cakephp
is it possible to suggest similar or matching words given a set of words using cakephp.
For example, I have saved a word 'Soccer' in my database. CakePHP will then automatically use this word 'Soccer' and suggest all relevant words matching or similar and extract these words from the entire database and display them.
Cakephp 1.3 is the framework I am using currently to develop my application. The database am using is MySQL (PHPmyadmin).
I currently hav开发者_StackOverflow社区e a registration page which takes in a keyword from the user which will then be used to match or find similar keywords.
I am unaware of the logic of creating this Matching/Similar feature.
PHP, true to form, has several ways to do some simple similarity testing for strings:
- levenshtein (this computes the Levenshtein edit distance between two strings
- similar_text
- soundex (this tries to phonetically compare strings, so two similar-sounding words should have the same result from this function)
MySQL also has some features you could use for something like this, like full-text search, which can sort results by relevance or similarity, or SOUNDEX() and SOUNDS_LIKE.
精彩评论