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:
@@ -369,23 +369,24 @@ export default {
|
|||||||
const question = qData.question || qData.text || '';
|
const question = qData.question || qData.text || '';
|
||||||
console.log(`[importantVocab] Frage:`, question);
|
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(/['"]([^'"]+)['"]/);
|
let match = question.match(/['"]([^'"]+)['"]/);
|
||||||
if (match) {
|
if (match) {
|
||||||
const germanWord = match[1];
|
const nativeWord = match[1]; // Das Wort in der Muttersprache
|
||||||
console.log(`[importantVocab] Pattern 1 gefunden - Bisaya:`, correctAnswer, `Deutsch:`, germanWord);
|
console.log(`[importantVocab] Pattern 1 gefunden - Muttersprache:`, nativeWord, `Bisaya:`, correctAnswer);
|
||||||
vocabMap.set(correctAnswer, { learning: correctAnswer, reference: germanWord });
|
// learning = Muttersprache (was man lernt), reference = Bisaya (Zielsprache)
|
||||||
|
vocabMap.set(`${nativeWord}-${correctAnswer}`, { learning: nativeWord, reference: correctAnswer });
|
||||||
} else {
|
} 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 ['"]([^'"]+)['"]/);
|
match = question.match(/Was bedeutet ['"]([^'"]+)['"]/);
|
||||||
if (match) {
|
if (match) {
|
||||||
const bisayaWord = match[1];
|
const bisayaWord = match[1];
|
||||||
console.log(`[importantVocab] Pattern 2 gefunden - Bisaya:`, bisayaWord, `Deutsch:`, correctAnswer);
|
console.log(`[importantVocab] Pattern 2 gefunden - Bisaya:`, bisayaWord, `Muttersprache:`, correctAnswer);
|
||||||
vocabMap.set(bisayaWord, { learning: bisayaWord, reference: correctAnswer });
|
// learning = Muttersprache (was man lernt), reference = Bisaya (Zielsprache)
|
||||||
|
vocabMap.set(`${correctAnswer}-${bisayaWord}`, { learning: correctAnswer, reference: bisayaWord });
|
||||||
} else {
|
} else {
|
||||||
console.log(`[importantVocab] Kein Pattern gefunden, Fallback`);
|
console.log(`[importantVocab] Kein Pattern gefunden, Überspringe diese Übung`);
|
||||||
// Fallback: Verwende die richtige Antwort als Lernwort
|
// Überspringe, wenn wir die Richtung nicht erkennen können
|
||||||
vocabMap.set(correctAnswer, { learning: correctAnswer, reference: correctAnswer });
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -397,12 +398,17 @@ export default {
|
|||||||
console.log(`[importantVocab] Gap Fill - answers:`, answers);
|
console.log(`[importantVocab] Gap Fill - answers:`, answers);
|
||||||
if (answers.length > 0) {
|
if (answers.length > 0) {
|
||||||
// Versuche aus dem Text Kontext zu extrahieren
|
// Versuche aus dem Text Kontext zu extrahieren
|
||||||
|
// Gap Fill hat normalerweise Format: "{gap} (Muttersprache) | {gap} (Muttersprache) | ..."
|
||||||
const text = qData.text || '';
|
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) => {
|
answers.forEach((answer, index) => {
|
||||||
if (answer && answer.trim()) {
|
if (answer && answer.trim()) {
|
||||||
// Erstelle einen eindeutigen Key
|
const nativeWord = nativeWords[index] || answer; // Falls keine Klammer, verwende answer
|
||||||
const key = `${answer}-${index}`;
|
// Die answer ist normalerweise Bisaya, nativeWord ist Muttersprache
|
||||||
vocabMap.set(key, { learning: answer, reference: answer });
|
vocabMap.set(`${nativeWord}-${answer}`, { learning: nativeWord, reference: answer });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user