normalize_for_search on words matched in the search

This commit is contained in:
Bofh 2022-12-11 19:32:50 +01:00
parent b223abb3ac
commit b733893d92
1 changed files with 3 additions and 2 deletions

View File

@ -384,6 +384,7 @@ function matches_comparing_expression($expr, $text) {
if (gettype($expr) === 'string')
$expr = parse_comparing_expression($expr);
$result = $expr['original'];
$text_words = explode(' ', $text);
foreach ($expr['parsed'] as $lvl => $exl) {
foreach ($exl as &$t) {
if (strpos($t, 'words ') === 0) {
@ -391,7 +392,7 @@ function matches_comparing_expression($expr, $text) {
$ws = explode(' ', trim(trim($w, '"')));
$haveall = true;
foreach ($ws as $w) {
if (strpos($text, $w) === false) {
if (!in_array(normalize_for_search($w), $text_words)) {
$haveall = false;
break;
}
@ -400,7 +401,7 @@ function matches_comparing_expression($expr, $text) {
} else if (strpos($t, 'contains ') === 0) {
$w = substr($t, strlen('contains')+1);
$w = trim(trim($w, '"'));
$contains = strpos($text, $w) !== false;
$contains = strpos($text, normalize_for_search($w)) !== false;
$result = str_replace($t, $contains ? 'true' : 'false', $result);
}
}