MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / same

Function same

graph-ui/src/browser-ai/echo-answer.ts:31–38  ·  view source on GitHub ↗

The same word, mistyped or inflected: "Heirarchy" for "heirarchie", "erklärt" for "erkläre".

(left: string, right: string)

Source from the content-addressed store, hash-verified

29const codeShaped = (word: string): boolean => /^`|\p{N}|_|[./:]|\p{Ll}\p{Lu}|\p{Lu}{2}\p{Ll}/u.test(word);
30/** The same word, mistyped or inflected: "Heirarchy" for "heirarchie", "erklärt" for "erkläre". */
31function same(left: string, right: string): boolean {
32 if (left === right) return true;
33 const longer = left.length >= right.length ? left : right, shorter = longer === left ? right : left;
34 if (shorter.length >= 4 && withinEdits(left, right, typoBudget(longer))) return true;
35 let prefix = 0;
36 while (prefix < shorter.length && left[prefix] === right[prefix]) prefix++;
37 return prefix >= 4 && prefix >= shorter.length - 2;
38}
39
40export function echoAnswer(answer: string, question: string): boolean {
41 const words = wordsOf(answer);

Callers 1

echoAnswerFunction · 0.70

Calls 2

withinEditsFunction · 0.90
typoBudgetFunction · 0.90

Tested by

no test coverage detected