我正在尝试根据在行中找到的查询中的单词数对匹配项进行评分。我盯着这样做:
SELECT Text, MATCH(`Text`) AGAINST ('$s') AS Grade
但很快我意识到这不起作用,因为Grade
它基于很多东西,例如单词的顺序,每个单词的长度等等。
我只想知道连续出现的单词的百分比。
例如:
$s = 'i want pizza'
`Text` = 'pizza I want' // In this case Grade should be 100 as all words are found
其他示例:
Text | Grade
pizza I want too | 100 // All words were found, It doesn't matter if there are extra words
pizza I want | 100
i want | 66 // Only 66% of the words are present
want want want | 33 // Only 33% of the words are present