Class_generator/test-extraction-direct.js
StillHammer fe7153d28b Fix compatibility system and improve UX
- Add intelligent content-game compatibility system with visual badges
- Fix Adventure Reader to work with Dragon's Pearl content structure
- Implement multi-column games grid for faster navigation
- Add pronunciation display for Chinese vocabulary and sentences
- Fix navigation breadcrumb to show proper hierarchy (Home > Levels > Content)
- Add back buttons to all navigation pages
- Improve JSONContentLoader to preserve story structure
- Add comprehensive debugging and diagnostic tools

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-18 19:29:21 +08:00

87 lines
3.3 KiB
JavaScript

// === TEST EXTRACTION DIRECT ===
// Script pour tester l'extraction des phrases de Dragon's Pearl
// À copier-coller dans la console
function testExtractionDirect() {
console.log('🔬 Test extraction direct Dragon\\'s Pearl');
// 1. Récupérer le module
const dragonModule = window.ContentModules?.ChineseLongStory;
console.log('\\n📦 Module Dragon\\'s Pearl:', !!dragonModule);
if (!dragonModule) {
console.error('❌ Module non trouvé !');
return;
}
// 2. Tester la structure
console.log('\\n🔍 Structure du module:');
console.log(' story:', !!dragonModule.story);
console.log(' story.chapters:', !!dragonModule.story?.chapters);
console.log(' Nombre de chapitres:', dragonModule.story?.chapters?.length || 0);
if (dragonModule.story?.chapters?.[0]) {
const firstChapter = dragonModule.story.chapters[0];
console.log('\\n📖 Premier chapitre:');
console.log(' Titre:', firstChapter.title);
console.log(' Sentences:', !!firstChapter.sentences);
console.log(' Nombre phrases:', firstChapter.sentences?.length || 0);
if (firstChapter.sentences?.[0]) {
const firstSentence = firstChapter.sentences[0];
console.log('\\n💬 Première phrase:');
console.log(' original:', firstSentence.original);
console.log(' translation:', firstSentence.translation);
console.log(' id:', firstSentence.id);
}
}
// 3. Tester l'extraction manuellement
console.log('\\n🧪 Test extraction manuelle:');
const sentences = [];
if (dragonModule.story && dragonModule.story.chapters && Array.isArray(dragonModule.story.chapters)) {
dragonModule.story.chapters.forEach(chapter => {
console.log(` Traitement chapitre: ${chapter.title}`);
if (chapter.sentences && Array.isArray(chapter.sentences)) {
console.log(` ${chapter.sentences.length} phrases dans ce chapitre`);
chapter.sentences.forEach(sentence => {
if (sentence.original && sentence.translation) {
sentences.push({
original_language: sentence.original,
user_language: sentence.translation,
pronunciation: sentence.pronunciation || '',
chapter: chapter.title || '',
id: sentence.id || sentences.length
});
} else {
console.warn(' ⚠️ Phrase ignorée:', sentence);
}
});
} else {
console.warn(` ⚠️ Pas de sentences dans ${chapter.title}`);
}
});
} else {
console.error(' ❌ Structure story.chapters introuvable');
}
console.log('\\n📊 Résultat extraction:');
console.log(' Phrases extraites:', sentences.length);
if (sentences.length > 0) {
console.log(' Première phrase extraite:', sentences[0]);
console.log(' Dernière phrase extraite:', sentences[sentences.length - 1]);
} else {
console.error(' ❌ Aucune phrase extraite !');
}
return sentences;
}
// Auto-exécution
const results = testExtractionDirect();