diff --git a/build/index.php b/build/index.php index 9201045..03bcd4c 100644 --- a/build/index.php +++ b/build/index.php @@ -396,7 +396,7 @@ if($settings->sessionprefix == "auto") ///////////////////////////////////////////////////////////////////////////// /** The version of Pepperminty Wiki currently running. */ $version = "v0.17-dev"; -$commit = "bdf47a2540bdbb36bd69869fd2a1b90d033d9966"; +$commit = "49b91aa6f999409dbcf6d165f379ebb95fec7dcb"; /// Environment /// /** Holds information about the current request environment. */ $env = new stdClass(); @@ -4021,13 +4021,18 @@ register_module([ exit("Error: The type '$type' is not one of the supported output types. Available values: json, opensearch. Default: json"); } + $literator = Transliterator::createFromRules(':: Any-Latin; :: Latin-ASCII; :: NFD; :: [:Nonspacing Mark:] Remove; :: Lower(); :: NFC;', Transliterator::FORWARD); + + $query = $literator->transliterate($_GET["query"]); + + // Rank each page name $results = []; foreach($pageindex as $pageName => $entry) { $results[] = [ "pagename" => $pageName, // Costs: Insert: 1, Replace: 8, Delete: 6 - "distance" => levenshtein(mb_strtolower($_GET["query"]), mb_strtolower($pageName), 1, 8, 6) + "distance" => levenshtein($query, $literator->transliterate($pageName), 1, 8, 6) ]; } diff --git a/module_index.json b/module_index.json index f763b2c..581de26 100755 --- a/module_index.json +++ b/module_index.json @@ -104,7 +104,7 @@ "author": "Starbeamrainbowlabs", "description": "Adds proper search functionality to Pepperminty Wiki using an inverted index to provide a full text search engine. If pages don't show up, then you might have hit a stop word. If not, try requesting the `invindex-rebuild` action to rebuild the inverted index from scratch.", "id": "feature-search", - "lastupdate": 1529963426, + "lastupdate": 1529964034, "optional": false }, { diff --git a/modules/feature-search.php b/modules/feature-search.php index c31fd29..c8b7a3f 100644 --- a/modules/feature-search.php +++ b/modules/feature-search.php @@ -378,13 +378,18 @@ register_module([ exit("Error: The type '$type' is not one of the supported output types. Available values: json, opensearch. Default: json"); } + $literator = Transliterator::createFromRules(':: Any-Latin; :: Latin-ASCII; :: NFD; :: [:Nonspacing Mark:] Remove; :: Lower(); :: NFC;', Transliterator::FORWARD); + + $query = $literator->transliterate($_GET["query"]); + + // Rank each page name $results = []; foreach($pageindex as $pageName => $entry) { $results[] = [ "pagename" => $pageName, // Costs: Insert: 1, Replace: 8, Delete: 6 - "distance" => levenshtein(mb_strtolower($_GET["query"]), mb_strtolower($pageName), 1, 8, 6) + "distance" => levenshtein($query, $literator->transliterate($pageName), 1, 8, 6) ]; }