MCPcopy Create free account
hub / github.com/QodeXcli/QodeX / tokenizeForSearch

Function tokenizeForSearch

src/context/hybrid-search.ts:33–49  ·  view source on GitHub ↗
(text: string)

Source from the content-addressed store, hash-verified

31 * query "user id" matches an identifier "getUserById" / "user_id". Lowercased.
32 */
33export function tokenizeForSearch(text: string): string[] {
34 const out: string[] = [];
35 // First split on non-alphanumeric, then break camelCase within each piece.
36 const rawTokens = text.split(/[^A-Za-z0-9]+/).filter(Boolean);
37 for (const raw of rawTokens) {
38 out.push(raw.toLowerCase());
39 // camelCase / PascalCase → sub-words (getUserById → get, user, by, id)
40 const camelParts = raw.replace(/([a-z0-9])([A-Z])/g, '$1 $2').split(/\s+/).filter(Boolean);
41 if (camelParts.length > 1) {
42 for (const p of camelParts) {
43 const lower = p.toLowerCase();
44 if (lower !== raw.toLowerCase()) out.push(lower);
45 }
46 }
47 }
48 return out;
49}
50
51// ── BM25 ─────────────────────────────────────────────────────────────────────
52

Callers 3

buildBm25IndexFunction · 0.85
bm25ScoresFunction · 0.85

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected