Update VocabLessonView to enhance vocabulary mapping and logging for language exercises

- Refined vocabulary mapping logic to better reflect the relationship between native words and their translations, improving clarity in exercise generation.
- Enhanced console logging to provide more detailed insights into the vocabulary patterns being processed, aiding in debugging and user feedback.
- Updated comments to clarify the purpose of each pattern and the expected input/output, ensuring better maintainability of the code.
This commit is contained in:
Torsten Schulz (local)
2026-01-19 23:14:18 +01:00
parent 202002358a
commit cf1b5e7f71

View File

@@ -369,23 +369,24 @@ export default {
const question = qData.question || qData.text || '';
console.log(`[importantVocab] Frage:`, question);
// Pattern 1: "Wie sagt man 'X' auf Bisaya?" -> X ist Deutsch, correctAnswer ist Bisaya
// Pattern 1: "Wie sagt man 'X' auf Bisaya?" -> X ist Muttersprache (z.B. "Großmutter"), correctAnswer ist Bisaya (z.B. "Lola")
let match = question.match(/['"]([^'"]+)['"]/);
if (match) {
const germanWord = match[1];
console.log(`[importantVocab] Pattern 1 gefunden - Bisaya:`, correctAnswer, `Deutsch:`, germanWord);
vocabMap.set(correctAnswer, { learning: correctAnswer, reference: germanWord });
const nativeWord = match[1]; // Das Wort in der Muttersprache
console.log(`[importantVocab] Pattern 1 gefunden - Muttersprache:`, nativeWord, `Bisaya:`, correctAnswer);
// learning = Muttersprache (was man lernt), reference = Bisaya (Zielsprache)
vocabMap.set(`${nativeWord}-${correctAnswer}`, { learning: nativeWord, reference: correctAnswer });
} else {
// Pattern 2: "Was bedeutet 'X'?" -> X ist Bisaya, correctAnswer ist Deutsch
// Pattern 2: "Was bedeutet 'X'?" -> X ist Bisaya, correctAnswer ist Muttersprache
match = question.match(/Was bedeutet ['"]([^'"]+)['"]/);
if (match) {
const bisayaWord = match[1];
console.log(`[importantVocab] Pattern 2 gefunden - Bisaya:`, bisayaWord, `Deutsch:`, correctAnswer);
vocabMap.set(bisayaWord, { learning: bisayaWord, reference: correctAnswer });
console.log(`[importantVocab] Pattern 2 gefunden - Bisaya:`, bisayaWord, `Muttersprache:`, correctAnswer);
// learning = Muttersprache (was man lernt), reference = Bisaya (Zielsprache)
vocabMap.set(`${correctAnswer}-${bisayaWord}`, { learning: correctAnswer, reference: bisayaWord });
} else {
console.log(`[importantVocab] Kein Pattern gefunden, Fallback`);
// Fallback: Verwende die richtige Antwort als Lernwort
vocabMap.set(correctAnswer, { learning: correctAnswer, reference: correctAnswer });
console.log(`[importantVocab] Kein Pattern gefunden, Überspringe diese Übung`);
// Überspringe, wenn wir die Richtung nicht erkennen können
}
}
}
@@ -397,12 +398,17 @@ export default {
console.log(`[importantVocab] Gap Fill - answers:`, answers);
if (answers.length > 0) {
// Versuche aus dem Text Kontext zu extrahieren
// Gap Fill hat normalerweise Format: "{gap} (Muttersprache) | {gap} (Muttersprache) | ..."
const text = qData.text || '';
// Extrahiere Wörter in Klammern als Muttersprache
const matches = text.matchAll(/\(([^)]+)\)/g);
const nativeWords = Array.from(matches, m => m[1]);
answers.forEach((answer, index) => {
if (answer && answer.trim()) {
// Erstelle einen eindeutigen Key
const key = `${answer}-${index}`;
vocabMap.set(key, { learning: answer, reference: answer });
const nativeWord = nativeWords[index] || answer; // Falls keine Klammer, verwende answer
// Die answer ist normalerweise Bisaya, nativeWord ist Muttersprache
vocabMap.set(`${nativeWord}-${answer}`, { learning: nativeWord, reference: answer });
}
});
}