mirror of
https://github.com/sbrl/Pepperminty-Wiki.git
synced 2024-11-22 04:23:01 +00:00
Transliterate in the suggest-pages action too
This commit is contained in:
parent
49b91aa6f9
commit
93494b6729
3 changed files with 14 additions and 4 deletions
|
@ -396,7 +396,7 @@ if($settings->sessionprefix == "auto")
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
/** The version of Pepperminty Wiki currently running. */
|
/** The version of Pepperminty Wiki currently running. */
|
||||||
$version = "v0.17-dev";
|
$version = "v0.17-dev";
|
||||||
$commit = "bdf47a2540bdbb36bd69869fd2a1b90d033d9966";
|
$commit = "49b91aa6f999409dbcf6d165f379ebb95fec7dcb";
|
||||||
/// Environment ///
|
/// Environment ///
|
||||||
/** Holds information about the current request environment. */
|
/** Holds information about the current request environment. */
|
||||||
$env = new stdClass();
|
$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");
|
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
|
// Rank each page name
|
||||||
$results = [];
|
$results = [];
|
||||||
foreach($pageindex as $pageName => $entry) {
|
foreach($pageindex as $pageName => $entry) {
|
||||||
$results[] = [
|
$results[] = [
|
||||||
"pagename" => $pageName,
|
"pagename" => $pageName,
|
||||||
// Costs: Insert: 1, Replace: 8, Delete: 6
|
// 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)
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -104,7 +104,7 @@
|
||||||
"author": "Starbeamrainbowlabs",
|
"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.",
|
"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",
|
"id": "feature-search",
|
||||||
"lastupdate": 1529963426,
|
"lastupdate": 1529964034,
|
||||||
"optional": false
|
"optional": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -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");
|
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
|
// Rank each page name
|
||||||
$results = [];
|
$results = [];
|
||||||
foreach($pageindex as $pageName => $entry) {
|
foreach($pageindex as $pageName => $entry) {
|
||||||
$results[] = [
|
$results[] = [
|
||||||
"pagename" => $pageName,
|
"pagename" => $pageName,
|
||||||
// Costs: Insert: 1, Replace: 8, Delete: 6
|
// 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)
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue