Skip to content

Commit 85834f2

Browse files
committed
style: drop the explanatory comments added during review
1 parent 7c75ed8 commit 85834f2

5 files changed

Lines changed: 1 addition & 19 deletions

File tree

__tests__/hybridRetrieval.test.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -587,8 +587,6 @@ describe('hybridRetrieve', () => {
587587
});
588588

589589
it('covers a de-diacriticised document from a diacriticised query, as FTS would', async () => {
590-
// Similarity sits below the semantic threshold and the top-keep floor, and
591-
// there is no keyword hit, so this chunk qualifies on term coverage alone.
592590
const vectorResults = [
593591
{
594592
id: '1:0',

database/keywordIndex.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,6 @@ export const ensureKeywordIndex = async (db: DB): Promise<boolean> => {
3636
return ftsAvailable;
3737
};
3838

39-
// Indexes every chunk the index is missing, not just the initial empty case: a
40-
// single swallowed insert (see addChunkToKeywordIndex) would otherwise leave a
41-
// chunk searchable by vector but never by keyword, with nothing to repair it.
4239
const backfillKeywordIndex = async (db: DB): Promise<void> => {
4340
let rows: Record<string, Scalar>[];
4441
try {

utils/hybridRetrieval.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,8 +248,6 @@ export const hybridRetrieve = async ({
248248
}
249249

250250
const terms = extractQueryTerms(prompt);
251-
// Folded the same way the keyword index folds, so coverage agrees with what
252-
// FTS actually matched instead of missing every de-diacriticised document.
253251
const coverageTerms = new Set(
254252
[...terms].map((term) => stemPrefix(foldForMatching(term)))
255253
);

utils/queryTerms.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,5 @@ const FOLD_MAP: Record<string, string> = {
131131
ż: 'z',
132132
};
133133

134-
// The keyword index compares text after two foldings: ł by hand (unicode61's
135-
// remove_diacritics leaves that stroke letter alone) and the tokenizer's own
136-
// diacritic stripping. Layers that match in JS rather than through SQLite have
137-
// to fold the same way, or "płatność" stops matching "platnosc" on one side
138-
// only. Explicit map instead of NFD normalize, which Hermes does not guarantee.
139134
export const foldForMatching = (text: string): string =>
140135
text.toLowerCase().replace(/[ąćęłńóśźż]/g, (char) => FOLD_MAP[char] ?? char);

utils/rankFusion.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,7 @@ export const reciprocalRankFusion = (
3131
};
3232

3333
// Cosine similarity; normalises internally (LFM2.5 embeddings are non-unit-length).
34-
// Returns 0 when either vector is empty or zero-length, and when the two differ
35-
// in length — mismatched dimensions mean the vectors came from different
36-
// embedding models, and truncating to the shorter one would answer with a
37-
// plausible-looking number instead of surfacing that.
34+
// Returns 0 when either vector is empty or zero-length, or when they differ in length.
3835
export const cosineSimilarity = (a: number[], b: number[]): number => {
3936
const len = a.length;
4037
if (len === 0 || b.length !== len) return 0;
@@ -137,9 +134,6 @@ export const maximalMarginalRelevance = (
137134
};
138135

139136
// Keep leading items until relevance drops below `dropRatio × previous`; at least `minKeep`.
140-
// Scores must be non-negative — the cut is a ratio, which says nothing about
141-
// negative scales such as raw BM25. A zero score keeps everything after it,
142-
// since nothing below zero can follow in a descending non-negative list.
143137
export const adaptiveKeepCount = (
144138
sortedScoresDesc: number[],
145139
minKeep = 1,

0 commit comments

Comments
 (0)