diff --git a/content/pages/buscar.php.md b/content/pages/buscar.php.md index 35bd263..accc6d8 100644 --- a/content/pages/buscar.php.md +++ b/content/pages/buscar.php.md @@ -32,7 +32,7 @@ $STOP_WORDS = ['a', 'un', 'una', 'unas', 'unos', 'uno', 'sobre', 'todo', 'trabajas', 'trabaja', 'trabajamos', 'trabajais', 'trabajan', 'podria', 'podrias', 'podriamos', 'podrian', 'podriais', 'yo', 'aquel']; -$DESCRIPTION_LENGTH = 25; +$DESCRIPTION_LENGTH = 20; $HALF_DESCRIPTION_LENGTH = floor($DESCRIPTION_LENGTH / 2); $web_content = json_decode(file_get_contents('tipuesearch_content.json'), true); @@ -76,8 +76,12 @@ if (isset($_GET['q'])) { if (preg_match("/$word/i", $page['tags'])) { $score += 30; } - // It replaces upper case matches with lower case matches, but it's fine for now. - $page['text'] = preg_replace("/$word/i", '' . $word . '', $page['text'], -1, $match_count); + // It replaces uppercase matches with lowercase matches, but it's fine for now. + if ($stop_words_ignored == 1) { + $page['text'] = preg_replace("/$word/i", $word, $page['text'], -1, $match_count); + } else { + $page['text'] = preg_replace("/$word/i", '' . $word . '', $page['text'], -1, $match_count); + } if ($match_count > 0) { $score += 10 * $match_count; } @@ -96,7 +100,6 @@ if (isset($_GET['q'])) { } return ($a['score'] > $b['score']) ? -1 : 1; } - if ($stop_words_ignored) { printf('
%s