feat(vocab): refine vocabulary filtering to exclude invalid exercise pairs

This commit is contained in:
Torsten Schulz (local)
2026-08-26 14:05:40 +02:00
parent 4d478df181
commit 71f0e15bb7

View File

@@ -3663,7 +3663,13 @@ export default {
_buildMixedPool() { _buildMixedPool() {
if (!this.previousVocab || this.previousVocab.length === 0) return []; if (!this.previousVocab || this.previousVocab.length === 0) return [];
const currentKeys = new Set(this.trainableLessonVocab.map(v => this.getVocabKey(v))); const currentKeys = new Set(this.trainableLessonVocab.map(v => this.getVocabKey(v)));
const filtered = this.previousVocab.filter(v => !currentKeys.has(this.getVocabKey(v))); // Older generated exercises can contain a single word paired with a full
// sentence (e.g. "Haus" → "Naa ko sa balay"). Such pairs are neither
// valid vocabulary cards nor valid review questions.
const filtered = this.previousVocab.filter((v) => (
this.isTrainableLessonVocabPair(v?.learning, v?.reference)
&& !currentKeys.has(this.getVocabKey(v))
));
const filteredByKey = new Map(filtered.map((v) => [this.getVocabKey(v), v])); const filteredByKey = new Map(filtered.map((v) => [this.getVocabKey(v), v]));
const weakMap = new Map(); const weakMap = new Map();