The same word, mistyped or inflected: "Heirarchy" for "heirarchie", "erklärt" for "erkläre".
(left: string, right: string)
| 29 | const 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". */ |
| 31 | function 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 | |
| 40 | export function echoAnswer(answer: string, question: string): boolean { |
| 41 | const words = wordsOf(answer); |
no test coverage detected