Erweitere die Funktionalität zur Verarbeitung von Antwortvarianten; füge Unterstützung für Klammerinhalte und alternative Phrasen hinzu.
This commit is contained in:
@@ -1016,17 +1016,31 @@ export default {
|
||||
expandAnswerVariants(answer) {
|
||||
const base = String(answer || '').trim();
|
||||
if (!base) return [];
|
||||
const variants = new Set([base]);
|
||||
|
||||
const withoutParentheses = base.replace(/\s*\([^)]*\)\s*/g, ' ').replace(/\s+/g, ' ').trim();
|
||||
if (withoutParentheses) {
|
||||
variants.add(withoutParentheses);
|
||||
}
|
||||
|
||||
const parenMatches = base.match(/\(([^)]+)\)/g) || [];
|
||||
parenMatches.forEach((chunk) => {
|
||||
const content = chunk.replace(/[()]/g, '').trim();
|
||||
if (content) {
|
||||
variants.add(content);
|
||||
}
|
||||
});
|
||||
|
||||
// Handle full-answer alternatives like "A / B" as separate valid answers.
|
||||
// Word-level slash expansion alone does not cover this reliably.
|
||||
const phraseAlternatives = this.splitPhraseAlternatives(base);
|
||||
const phraseAlternatives = Array.from(variants).flatMap((entry) => this.splitPhraseAlternatives(entry));
|
||||
|
||||
if (phraseAlternatives.length >= 2) {
|
||||
const expanded = phraseAlternatives.flatMap((part) => this.expandSingleAnswerVariants(part));
|
||||
return [...new Set(expanded)];
|
||||
}
|
||||
|
||||
return this.expandSingleAnswerVariants(base);
|
||||
return this.expandSingleAnswerVariants(base).concat(withoutParentheses ? this.expandSingleAnswerVariants(withoutParentheses) : []);
|
||||
},
|
||||
computeWeight(item) {
|
||||
const st = this.perId[item.id] || { c: 0, w: 0, streak: 0, lastAsked: 0 };
|
||||
|
||||
Reference in New Issue
Block a user