Update endpoints/antibot.js
Browse files- endpoints/antibot.js +19 -1
endpoints/antibot.js
CHANGED
|
@@ -184,11 +184,29 @@ function mapAnswer(soalArray, jawaban, botIndex) {
|
|
| 184 |
return jawaban;
|
| 185 |
}
|
| 186 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 187 |
module.exports = {
|
| 188 |
extractTextFromBuffer,
|
| 189 |
mapAnswer,
|
| 190 |
normalizeText,
|
| 191 |
isValueMatch,
|
| 192 |
levenshtein,
|
| 193 |
-
similarity
|
|
|
|
|
|
|
|
|
|
| 194 |
};
|
|
|
|
| 184 |
return jawaban;
|
| 185 |
}
|
| 186 |
|
| 187 |
+
// --- Integrated helper from userscript: countPairs ---
|
| 188 |
+
function countPairs(s1 = '', s2 = '') {
|
| 189 |
+
s1 = safeString(s1).toLowerCase().replace(/[^a-z]/g, '');
|
| 190 |
+
s2 = safeString(s2).toLowerCase().replace(/[^a-z]/g, '');
|
| 191 |
+
const n1 = s1.length, n2 = s2.length;
|
| 192 |
+
const freq1 = Array(26).fill(0);
|
| 193 |
+
const freq2 = Array(26).fill(0);
|
| 194 |
+
for (let i = 0; i < n1; i++) freq1[s1.charCodeAt(i) - 97] = (freq1[s1.charCodeAt(i) - 97] || 0) + 1;
|
| 195 |
+
for (let i = 0; i < n2; i++) freq2[s2.charCodeAt(i) - 97] = (freq2[s2.charCodeAt(i) - 97] || 0) + 1;
|
| 196 |
+
let count = 0;
|
| 197 |
+
for (let i = 0; i < 26; i++) count += Math.min(freq1[i], freq2[i]);
|
| 198 |
+
return count;
|
| 199 |
+
}
|
| 200 |
+
|
| 201 |
+
// Export utilities
|
| 202 |
module.exports = {
|
| 203 |
extractTextFromBuffer,
|
| 204 |
mapAnswer,
|
| 205 |
normalizeText,
|
| 206 |
isValueMatch,
|
| 207 |
levenshtein,
|
| 208 |
+
similarity,
|
| 209 |
+
NUMBER_WORDS,
|
| 210 |
+
LEET_MAP,
|
| 211 |
+
countPairs
|
| 212 |
};
|