Spaces:
Sleeping
Sleeping
milwright
commited on
Commit
Β·
2ecb883
1
Parent(s):
c8c14f2
remove word logging from console for cleaner debugging output
Browse files- src/aiService.js +2 -18
- src/clozeGameEngine.js +2 -7
src/aiService.js
CHANGED
|
@@ -372,7 +372,6 @@ Passage: "${passage}"`
|
|
| 372 |
const validWords = words.filter(word => {
|
| 373 |
// First check if the word contains at least one letter
|
| 374 |
if (!/[a-zA-Z]/.test(word)) {
|
| 375 |
-
console.log(`β Rejecting non-alphabetic word: "${word}"`);
|
| 376 |
return false;
|
| 377 |
}
|
| 378 |
|
|
@@ -380,13 +379,11 @@ Passage: "${passage}"`
|
|
| 380 |
|
| 381 |
// If cleanWord is empty after removing non-letters, reject
|
| 382 |
if (cleanWord.length === 0) {
|
| 383 |
-
console.log(`β Rejecting word with no letters: "${word}"`);
|
| 384 |
return false;
|
| 385 |
}
|
| 386 |
|
| 387 |
// Check if word exists as non-capitalized word after position 10 (matches game engine)
|
| 388 |
if (!passageWordMap.has(cleanWord.toLowerCase())) {
|
| 389 |
-
console.log(`β Rejecting word not matchable in passage: "${word}" (capitalized or in first 10 words)`);
|
| 390 |
return false;
|
| 391 |
}
|
| 392 |
|
|
@@ -401,10 +398,9 @@ Passage: "${passage}"`
|
|
| 401 |
});
|
| 402 |
|
| 403 |
if (validWords.length > 0) {
|
| 404 |
-
console.log(`β
Level ${level} word validation: ${validWords.length}/${words.length} words passed`);
|
| 405 |
return validWords.slice(0, count);
|
| 406 |
} else {
|
| 407 |
-
console.warn(
|
| 408 |
throw new Error(`No valid words for level ${level}`);
|
| 409 |
}
|
| 410 |
}
|
|
@@ -436,7 +432,6 @@ Passage: "${passage}"`
|
|
| 436 |
const validWords = words.filter(word => {
|
| 437 |
// First check if the word contains at least one letter
|
| 438 |
if (!/[a-zA-Z]/.test(word)) {
|
| 439 |
-
console.log(`β Rejecting non-alphabetic word: "${word}"`);
|
| 440 |
return false;
|
| 441 |
}
|
| 442 |
|
|
@@ -444,13 +439,11 @@ Passage: "${passage}"`
|
|
| 444 |
|
| 445 |
// If cleanWord is empty after removing non-letters, reject
|
| 446 |
if (cleanWord.length === 0) {
|
| 447 |
-
console.log(`β Rejecting word with no letters: "${word}"`);
|
| 448 |
return false;
|
| 449 |
}
|
| 450 |
|
| 451 |
// Check if word exists as non-capitalized word after position 10 (matches game engine)
|
| 452 |
if (!passageWordMap.has(cleanWord.toLowerCase())) {
|
| 453 |
-
console.log(`β Rejecting word not matchable in passage: "${word}" (capitalized or in first 10 words)`);
|
| 454 |
return false;
|
| 455 |
}
|
| 456 |
|
|
@@ -672,7 +665,6 @@ Return JSON: {"passage1": {"words": [${blanksPerPassage} words], "context": "one
|
|
| 672 |
return words.filter(word => {
|
| 673 |
// First check if the word contains at least one letter
|
| 674 |
if (!/[a-zA-Z]/.test(word)) {
|
| 675 |
-
console.log(`β Rejecting non-alphabetic word: "${word}"`);
|
| 676 |
return false;
|
| 677 |
}
|
| 678 |
|
|
@@ -680,19 +672,16 @@ Return JSON: {"passage1": {"words": [${blanksPerPassage} words], "context": "one
|
|
| 680 |
|
| 681 |
// If cleanWord is empty after removing non-letters, reject
|
| 682 |
if (cleanWord.length === 0) {
|
| 683 |
-
console.log(`β Rejecting word with no letters: "${word}"`);
|
| 684 |
return false;
|
| 685 |
}
|
| 686 |
|
| 687 |
// Check if word exists as non-capitalized word after position 10 (matches game engine)
|
| 688 |
if (!passageWordMap.has(cleanWord.toLowerCase())) {
|
| 689 |
-
console.log(`β Rejecting word not matchable in passage: "${word}" (capitalized or in first 10 words)`);
|
| 690 |
return false;
|
| 691 |
}
|
| 692 |
|
| 693 |
// Check if word appears in all caps in the passage (like "VOLUME")
|
| 694 |
if (passageText.includes(word.toUpperCase()) && word === word.toUpperCase()) {
|
| 695 |
-
console.log(`Skipping all-caps word: ${word}`);
|
| 696 |
return false;
|
| 697 |
}
|
| 698 |
|
|
@@ -707,14 +696,9 @@ Return JSON: {"passage1": {"words": [${blanksPerPassage} words], "context": "one
|
|
| 707 |
});
|
| 708 |
};
|
| 709 |
|
| 710 |
-
const originalP1Count = parsed.passage1.words.length;
|
| 711 |
-
const originalP2Count = parsed.passage2.words.length;
|
| 712 |
-
|
| 713 |
parsed.passage1.words = validateWords(parsed.passage1.words, passage1);
|
| 714 |
parsed.passage2.words = validateWords(parsed.passage2.words, passage2);
|
| 715 |
-
|
| 716 |
-
console.log(`β
Level ${level} batch validation: P1 ${parsed.passage1.words.length}/${originalP1Count}, P2 ${parsed.passage2.words.length}/${originalP2Count} words passed`);
|
| 717 |
-
|
| 718 |
return parsed;
|
| 719 |
} catch (e) {
|
| 720 |
console.error('Failed to parse batch response:', e);
|
|
|
|
| 372 |
const validWords = words.filter(word => {
|
| 373 |
// First check if the word contains at least one letter
|
| 374 |
if (!/[a-zA-Z]/.test(word)) {
|
|
|
|
| 375 |
return false;
|
| 376 |
}
|
| 377 |
|
|
|
|
| 379 |
|
| 380 |
// If cleanWord is empty after removing non-letters, reject
|
| 381 |
if (cleanWord.length === 0) {
|
|
|
|
| 382 |
return false;
|
| 383 |
}
|
| 384 |
|
| 385 |
// Check if word exists as non-capitalized word after position 10 (matches game engine)
|
| 386 |
if (!passageWordMap.has(cleanWord.toLowerCase())) {
|
|
|
|
| 387 |
return false;
|
| 388 |
}
|
| 389 |
|
|
|
|
| 398 |
});
|
| 399 |
|
| 400 |
if (validWords.length > 0) {
|
|
|
|
| 401 |
return validWords.slice(0, count);
|
| 402 |
} else {
|
| 403 |
+
console.warn(`No words met requirements for level ${level}`);
|
| 404 |
throw new Error(`No valid words for level ${level}`);
|
| 405 |
}
|
| 406 |
}
|
|
|
|
| 432 |
const validWords = words.filter(word => {
|
| 433 |
// First check if the word contains at least one letter
|
| 434 |
if (!/[a-zA-Z]/.test(word)) {
|
|
|
|
| 435 |
return false;
|
| 436 |
}
|
| 437 |
|
|
|
|
| 439 |
|
| 440 |
// If cleanWord is empty after removing non-letters, reject
|
| 441 |
if (cleanWord.length === 0) {
|
|
|
|
| 442 |
return false;
|
| 443 |
}
|
| 444 |
|
| 445 |
// Check if word exists as non-capitalized word after position 10 (matches game engine)
|
| 446 |
if (!passageWordMap.has(cleanWord.toLowerCase())) {
|
|
|
|
| 447 |
return false;
|
| 448 |
}
|
| 449 |
|
|
|
|
| 665 |
return words.filter(word => {
|
| 666 |
// First check if the word contains at least one letter
|
| 667 |
if (!/[a-zA-Z]/.test(word)) {
|
|
|
|
| 668 |
return false;
|
| 669 |
}
|
| 670 |
|
|
|
|
| 672 |
|
| 673 |
// If cleanWord is empty after removing non-letters, reject
|
| 674 |
if (cleanWord.length === 0) {
|
|
|
|
| 675 |
return false;
|
| 676 |
}
|
| 677 |
|
| 678 |
// Check if word exists as non-capitalized word after position 10 (matches game engine)
|
| 679 |
if (!passageWordMap.has(cleanWord.toLowerCase())) {
|
|
|
|
| 680 |
return false;
|
| 681 |
}
|
| 682 |
|
| 683 |
// Check if word appears in all caps in the passage (like "VOLUME")
|
| 684 |
if (passageText.includes(word.toUpperCase()) && word === word.toUpperCase()) {
|
|
|
|
| 685 |
return false;
|
| 686 |
}
|
| 687 |
|
|
|
|
| 696 |
});
|
| 697 |
};
|
| 698 |
|
|
|
|
|
|
|
|
|
|
| 699 |
parsed.passage1.words = validateWords(parsed.passage1.words, passage1);
|
| 700 |
parsed.passage2.words = validateWords(parsed.passage2.words, passage2);
|
| 701 |
+
|
|
|
|
|
|
|
| 702 |
return parsed;
|
| 703 |
} catch (e) {
|
| 704 |
console.error('Failed to parse batch response:', e);
|
src/clozeGameEngine.js
CHANGED
|
@@ -160,7 +160,6 @@ class ClozeGame {
|
|
| 160 |
// Debug logging for caps detection
|
| 161 |
if (capsCount > 5) {
|
| 162 |
console.log(`High caps count detected: ${capsCount}/${totalWords} words (${Math.round((capsCount/totalWords) * 100)}%)`);
|
| 163 |
-
console.log(`Sample caps words:`, capsWords.slice(0, 10));
|
| 164 |
}
|
| 165 |
|
| 166 |
// Count excessive dashes (n-dashes, m-dashes, hyphens in sequence)
|
|
@@ -334,11 +333,11 @@ class ClozeGame {
|
|
| 334 |
numberOfBlanks,
|
| 335 |
this.currentLevel
|
| 336 |
);
|
| 337 |
-
console.log('AI
|
| 338 |
} catch (error) {
|
| 339 |
console.warn('AI word selection failed, using manual fallback:', error);
|
| 340 |
significantWords = this.selectWordsManually(words, numberOfBlanks);
|
| 341 |
-
console.log('Manual
|
| 342 |
}
|
| 343 |
|
| 344 |
// Ensure we have valid words
|
|
@@ -390,8 +389,6 @@ class ClozeGame {
|
|
| 390 |
}
|
| 391 |
});
|
| 392 |
|
| 393 |
-
// Log the matching results
|
| 394 |
-
console.log(`Found ${selectedIndices.length} of ${significantWords.length} words in passage`);
|
| 395 |
|
| 396 |
// If no words were matched, fall back to manual selection
|
| 397 |
if (selectedIndices.length === 0) {
|
|
@@ -412,7 +409,6 @@ class ClozeGame {
|
|
| 412 |
}
|
| 413 |
});
|
| 414 |
|
| 415 |
-
console.log(`After manual fallback: ${selectedIndices.length} words found`);
|
| 416 |
}
|
| 417 |
|
| 418 |
// Sort indices for easier processing
|
|
@@ -426,7 +422,6 @@ class ClozeGame {
|
|
| 426 |
.slice(0, numberOfBlanks);
|
| 427 |
|
| 428 |
selectedIndices.push(...contentWords.map(item => item.idx));
|
| 429 |
-
console.log(`Emergency fallback selected ${selectedIndices.length} words`);
|
| 430 |
}
|
| 431 |
|
| 432 |
// Create blanks array and cloze text
|
|
|
|
| 160 |
// Debug logging for caps detection
|
| 161 |
if (capsCount > 5) {
|
| 162 |
console.log(`High caps count detected: ${capsCount}/${totalWords} words (${Math.round((capsCount/totalWords) * 100)}%)`);
|
|
|
|
| 163 |
}
|
| 164 |
|
| 165 |
// Count excessive dashes (n-dashes, m-dashes, hyphens in sequence)
|
|
|
|
| 333 |
numberOfBlanks,
|
| 334 |
this.currentLevel
|
| 335 |
);
|
| 336 |
+
console.log('AI word selection complete');
|
| 337 |
} catch (error) {
|
| 338 |
console.warn('AI word selection failed, using manual fallback:', error);
|
| 339 |
significantWords = this.selectWordsManually(words, numberOfBlanks);
|
| 340 |
+
console.log('Manual word selection complete');
|
| 341 |
}
|
| 342 |
|
| 343 |
// Ensure we have valid words
|
|
|
|
| 389 |
}
|
| 390 |
});
|
| 391 |
|
|
|
|
|
|
|
| 392 |
|
| 393 |
// If no words were matched, fall back to manual selection
|
| 394 |
if (selectedIndices.length === 0) {
|
|
|
|
| 409 |
}
|
| 410 |
});
|
| 411 |
|
|
|
|
| 412 |
}
|
| 413 |
|
| 414 |
// Sort indices for easier processing
|
|
|
|
| 422 |
.slice(0, numberOfBlanks);
|
| 423 |
|
| 424 |
selectedIndices.push(...contentWords.map(item => item.idx));
|
|
|
|
| 425 |
}
|
| 426 |
|
| 427 |
// Create blanks array and cloze text
|