Search Evolution Explorer

Level 2 · Query normalization

src/domain/levels/level-1-normalization.ts · 44 lines
Back to search

Meet the seller halfway on words

Keep the word table, change what is looked up: before lookup, normaliseRewrite a word into a standard form before looking it up, for example cut the ending or collapse 'mid century' to 'midcentury'. each query word. Cut its ending, add words with the same meaning, collapse spelling variantsTreat 'mid-century', 'mid century' and 'midcentury' as the same word.. The order stays newest first.

Where to look: match turns each query word into a group of equivalent words and looks the groups up in the inverted indexA table built once, ahead of time: for every word, the list of listings that contain it. Like the index at the back of a book. A query then looks up its words instead of scanning every listing.. score is passed through unchanged from chapter 1, so the order is still newest first.

Guided example

carpetvs chapter 1

Synonym expansion widens chapter 1: the area rug enters the top 10 for 'carpet' although its title writes 'rug', not 'carpet'. The carpeted chair mat at rank 1 is the precision this recall costs.

Prerequisites

Reuses the ranking fromChapter 1
Foundation · Inverted indexbuilt at start
Declared artifactsready
src/domain/levels/level-1-normalization.ts44 linessame module the pipeline ran

Widen chapter 1 with the recallThe share of all good listings that were found at all (here: in the first 50). Recall asks: did we find them? levers: each query word becomes a group of equivalent words. The order stays newest first.

import { levelNormalizationContent } from "../../content/levels/level-normalization.ts";
import { } from "../index/inverted-index.ts";
import { } from "../query-understanding/understand.ts";
import { } from "../text/analyze-query.ts";
import type { EvolutionLevel, LevelDeps, LevelRanker } from "../types/level.ts";
import { as } from "./level-1-recency.ts";
/** Widen chapter 1 candidates with the recall levers; the order stays newest first. */
export function createRanker(deps: LevelDeps): LevelRanker {
const previous = (deps);
return {
match(understanding) {
previous.match(understanding);
const matching = (understanding);
return (deps.index, (matching, deps.levers.synonymGroups));
},
score: (understanding, candidate) => previous.score(understanding, candidate),
};
}
a numbered note, explained on the righta function you can open heredefined further down in this filewhere level 1 joins