fix: rank a console first for its own name

The PlayStation 2 page holds every word of "playstation bios" and pagefind ignores the words a page has that the query lacks, so its own body matches put it first. A console whose every word another system page's consoles also hold is now written again in an `exact` field (weight 20). File names reach the `files` field as their parts: whole names let "ds" reach twelve dsi_* names on the DSi page. `consoles` weighs 100 so an emulator named after its console (Saturn.emu) comes second, and `aliases` 10 so the Nintendo page keeps "gba bios". The gate runs both directions of the PlayStation, Game Boy, DS and Wii pairs and Saturn.
This commit is contained in:
Abdessamad Derraz committed 2026-10-27 06:54:08 +01:00
1 parent 6a611cd77a
commit 07f785cfd7
9 files changed
+191 -25

No files matched your search

+25 -14
View File
@@ -108,26 +108,37 @@ export default defineConfig({
// ten times its text, so "dolphin" finds Dolphin, and the file names of
// a system page (its `files` field, written by sitestarlight.py) count
// half, so "scph5501" finds the Sony page without a file name winning
// every other query. Two fields name the page's subject in other words
// and weigh half a title: `aliases`, the ids setups file a system under
// (psx, dreamcast, gba), and `devices`, the handhelds and boxes a
// setup's own site names (R36S, Miyoo Mini). `consoles`, the consoles a
// manufacturer page holds (Neo Geo, WonderSwan Color), weighs as much
// as a title. `terms`, the words of a task or a message on screen (bios
// not found, which mame version, check my dump), weighs three times
// that: a field match scores below a title match, and the cards of a
// part page keep their own weight, so below 30 the MAME parts, whose
// card titles name MAME files, came before the version table for
// "which mame version". All of them are
// attributes on an empty element, so no text of theirs reaches an
// excerpt.
// every other query. `devices`, the handhelds and boxes a setup's own
// site names (R36S, Miyoo Mini), weighs half a title. `aliases`, the ids
// setups file a system under (psx, dreamcast, gba), weighs a title: with
// file names written as their parts, half a title put GBA.emu and two
// more emulators above the Nintendo page for "gba bios". `terms`, the
// words of a task or a message on screen (bios not found, which mame
// version, check my dump), weighs three titles: a field match scores
// below a title match, and the cards of a part page keep their own
// weight, so below 30 the MAME parts, whose card titles name MAME files,
// came before the version table for "which mame version".
//
// A field adds the same score to every page whose field holds the
// word, whatever else the field holds, and a query word also matches
// the start of a longer one. `consoles`, the consoles a system page
// answers for, weighs ten titles: below that an emulator named after
// its console (Saturn.emu, BK, PIECE) came before the console. The
// PlayStation 2 page holds every word of "playstation bios", so
// `exact` repeats, on its own page, a console whose every word another
// page's consoles hold (PlayStation, Nintendo DS, Nintendo Super
// System). It weighs two titles: enough over the other page, and less
// than the "3" of "playstation 3 bios" adds to the Sony page. Measured
// on the "<console> bios" query of every system page and on
// tools/search_gate.py. All of them are attributes on an empty
// element, so no text of theirs reaches an excerpt.
pagefind: {
ranking: {
pageLength: 0.1,
termFrequency: 0.5,
termSaturation: 1.4,
termSimilarity: 9,
metaWeights: { title: 10, files: 0.5, aliases: 5, devices: 5, consoles: 10, terms: 30 },
metaWeights: { title: 10, files: 0.5, aliases: 10, devices: 5, consoles: 100, exact: 20, terms: 30 },
},
},
plugins: [
+2 -2
View File
@@ -784,11 +784,11 @@ const hashLookupRow = (drawer: HTMLElement, value: string) => {
// Pagefind lists a page's title twice: once for the page and once for the
// anchor of its h1 (#_top). The second title is hidden, its excerpt kept.
// The `files`, `aliases`, `devices`, `consoles` and `terms` fields weigh in
// The `files`, `aliases`, `devices`, `consoles`, `exact` and `terms` fields weigh in
// the ranking and are never shown: a result is not a list of 120 names. Pagefind reuses
// its nodes from one query to the next, so both are worked out again on
// every change.
const UNSHOWN_FIELDS = new Set(['files', 'aliases', 'devices', 'consoles', 'terms']);
const UNSHOWN_FIELDS = new Set(['files', 'aliases', 'devices', 'consoles', 'exact', 'terms']);
const tidyResults = (root: Element) => {
for (const title of root.querySelectorAll<HTMLElement>('.pagefind-ui__result-nested > .pagefind-ui__result-title')) {
+13
View File
@@ -70,6 +70,19 @@ QUERIES: dict[str, tuple[tuple[str, ...], int]] = {
"gamecube bios": (("systems/nintendo-gamecube/",), 1),
"game boy bios": (("systems/nintendo-game-boy/",), 1),
"3ds bios": (("systems/nintendo-3ds/",), 1),
# A console another one's name begins with, both ways: the longer name's
# page holds every word of the shorter query. GBA, GBC and the
# PlayStation 3 are sections of their maker's page; Saturn.emu is an
# emulator named after its console.
"playstation 2 bios": (("systems/sony-playstation-2/",), 1),
"playstation 3 bios": (("systems/sony/",), 1),
"game boy advance bios": (("systems/nintendo/",), 1),
"game boy color bios": (("systems/nintendo/",), 1),
"nintendo ds bios": (("systems/nintendo-nintendo-ds/",), 1),
"nintendo dsi bios": (("systems/nintendo-nintendo-dsi/",), 1),
"wii bios": (("systems/nintendo/",), 1),
"wii u bios": (("systems/nintendo-wii-u/",), 1),
"saturn bios": (("systems/sega-saturn/",), 1),
# The words an emulator prints, and the page that answers them.
"bios not found": (("wiki/troubleshooting/",), 3),
"please insert playstation cd-rom": (("wiki/troubleshooting/",), 3),