Fourstore commited on
Commit
240baa3
Β·
verified Β·
1 Parent(s): 540b62f

Update endpoints/antibot.js

Browse files
Files changed (1) hide show
  1. endpoints/antibot.js +23 -39
endpoints/antibot.js CHANGED
@@ -175,20 +175,30 @@ function evaluateSimpleMath(expression) {
175
  function parseSoalText(text) {
176
  console.log(`πŸ“ DEBUG parseSoalText: Input text: "${text}"`);
177
 
178
- const ignoreWords = ['hi', 'how', 'are', 'you', 'hello', 'hey'];
 
 
 
 
 
 
179
 
180
  const delimiters = /[.,:;\\/\s]+/;
181
  let parts = text.split(delimiters)
182
  .filter(part => part.trim() !== '')
183
  .filter(part => !ignoreWords.includes(part.toLowerCase()));
184
 
185
- if (parts.length === 1) {
186
  parts = text.split(/\s+/)
187
  .filter(part => part.trim() !== '')
188
  .filter(part => !ignoreWords.includes(part.toLowerCase()));
189
  }
190
 
191
- console.log(`πŸ“ DEBUG parseSoalText: Filtered parts:`, parts);
 
 
 
 
192
  return parts;
193
  }
194
 
@@ -255,27 +265,15 @@ async function antibot(data) {
255
  console.log('πŸ” DEBUG: Starting matching process...');
256
  const result = [];
257
  const usedIds = new Set();
258
-
259
- const botAnswerCounts = {};
260
- botResults.forEach(bot => {
261
- if (bot.value && bot.value.trim() !== '') {
262
- const answers = bot.value.split(/[\s,]+/).filter(a => a.trim() !== '');
263
- botAnswerCounts[bot.id] = answers.length;
264
- console.log(`πŸ”’ DEBUG Bot ${bot.id}: ${answers.length} jawaban - [${answers.join(', ')}]`);
265
- } else {
266
- botAnswerCounts[bot.id] = 0;
267
- console.log(`πŸ”’ DEBUG Bot ${bot.id}: 0 jawaban`);
268
- }
269
- });
270
-
271
  let matchedCount = 0;
 
272
  for (let i = 0; i < soalArray.length; i++) {
273
  const targetSoal = soalArray[i];
274
  console.log(`🎯 DEBUG: Matching soal "${targetSoal}"`);
275
  let foundId = null;
276
 
277
  for (const bot of botResults) {
278
- if (!usedIds.has(bot.id) && botAnswerCounts[bot.id] >= 2 && bot.value && bot.value.trim() !== '' &&
279
  isValueMatch(bot.value, targetSoal)) {
280
  foundId = bot.id;
281
  usedIds.add(bot.id);
@@ -294,35 +292,22 @@ async function antibot(data) {
294
 
295
  console.log(`πŸ“Š DEBUG: Initial matches: ${matchedCount}/${soalArray.length}`);
296
 
297
- const qualifiedBots = botResults.filter(bot => botAnswerCounts[bot.id] >= 2 && !usedIds.has(bot.id));
298
- console.log(`βž• DEBUG: Qualified bots to add: ${qualifiedBots.length}`);
299
-
300
- for (const bot of qualifiedBots) {
301
- result.push({
302
- id: bot.id,
303
- soal: '',
304
- matchType: 'qualified'
305
- });
306
- usedIds.add(bot.id);
307
- console.log(`βž• DEBUG: Added qualified bot ${bot.id} to result`);
308
- }
309
 
310
- const invalidBots = botResults.filter(bot => botAnswerCounts[bot.id] === 1 && !usedIds.has(bot.id));
311
- console.log(`❌ DEBUG: Invalid bots (1 jawaban): ${invalidBots.length}`);
312
-
313
- for (const bot of invalidBots) {
314
  result.push({
315
  id: bot.id,
316
  soal: '',
317
- matchType: 'invalid'
318
  });
319
  usedIds.add(bot.id);
320
- console.log(`❌ DEBUG: Added invalid bot ${bot.id} to result`);
321
  }
322
 
323
- const noAnswerBots = botResults.filter(bot => botAnswerCounts[bot.id] === 0 && !usedIds.has(bot.id));
324
  console.log(`❌ DEBUG: No answer bots: ${noAnswerBots.length}`);
325
-
326
  for (const bot of noAnswerBots) {
327
  result.push({
328
  id: bot.id,
@@ -351,8 +336,7 @@ async function antibot(data) {
351
  soal: r.soal
352
  })),
353
  totalMatches: matchedCount,
354
- totalResults: result.length,
355
- answerCounts: botAnswerCounts
356
  }
357
  }
358
  };
 
175
  function parseSoalText(text) {
176
  console.log(`πŸ“ DEBUG parseSoalText: Input text: "${text}"`);
177
 
178
+ const ignoreWords = [
179
+ 'hi', 'how', 'are', 'you', 'hello', 'hey',
180
+ 'tentu', 'berikut', 'adalah', 'teks', 'dari', 'gambar',
181
+ 'dipisahkan', 'sesuai', 'permintaan', 'anda', 'hanya',
182
+ 'berikan', 'jangan', 'tambahkan', 'kata', 'apapun', 'seperti',
183
+ 'atau', 'penjelasan', 'lain', 'saja'
184
+ ];
185
 
186
  const delimiters = /[.,:;\\/\s]+/;
187
  let parts = text.split(delimiters)
188
  .filter(part => part.trim() !== '')
189
  .filter(part => !ignoreWords.includes(part.toLowerCase()));
190
 
191
+ if (parts.length === 0) {
192
  parts = text.split(/\s+/)
193
  .filter(part => part.trim() !== '')
194
  .filter(part => !ignoreWords.includes(part.toLowerCase()));
195
  }
196
 
197
+ parts = parts.filter(part => part.length <= 3 || !isNaN(part));
198
+
199
+ parts = parts.slice(0, 3);
200
+
201
+ console.log(`πŸ“ DEBUG parseSoalText: Filtered parts (max 3):`, parts);
202
  return parts;
203
  }
204
 
 
265
  console.log('πŸ” DEBUG: Starting matching process...');
266
  const result = [];
267
  const usedIds = new Set();
 
 
 
 
 
 
 
 
 
 
 
 
 
268
  let matchedCount = 0;
269
+
270
  for (let i = 0; i < soalArray.length; i++) {
271
  const targetSoal = soalArray[i];
272
  console.log(`🎯 DEBUG: Matching soal "${targetSoal}"`);
273
  let foundId = null;
274
 
275
  for (const bot of botResults) {
276
+ if (!usedIds.has(bot.id) && bot.value && bot.value.trim() !== '' &&
277
  isValueMatch(bot.value, targetSoal)) {
278
  foundId = bot.id;
279
  usedIds.add(bot.id);
 
292
 
293
  console.log(`πŸ“Š DEBUG: Initial matches: ${matchedCount}/${soalArray.length}`);
294
 
295
+ const unmatchedBots = botResults.filter(bot => !usedIds.has(bot.id) && bot.value && bot.value.trim() !== '');
296
+ console.log(`βž• DEBUG: Unmatched bots with answers: ${unmatchedBots.length}`);
 
 
 
 
 
 
 
 
 
 
297
 
298
+ for (const bot of unmatchedBots) {
 
 
 
299
  result.push({
300
  id: bot.id,
301
  soal: '',
302
+ matchType: 'unmatched'
303
  });
304
  usedIds.add(bot.id);
305
+ console.log(`βž• DEBUG: Added unmatched bot ${bot.id} to result`);
306
  }
307
 
308
+ const noAnswerBots = botResults.filter(bot => !usedIds.has(bot.id));
309
  console.log(`❌ DEBUG: No answer bots: ${noAnswerBots.length}`);
310
+
311
  for (const bot of noAnswerBots) {
312
  result.push({
313
  id: bot.id,
 
336
  soal: r.soal
337
  })),
338
  totalMatches: matchedCount,
339
+ totalResults: result.length
 
340
  }
341
  }
342
  };