0.16.1-3 Playlist Fix

This commit is contained in:
2026-04-29 10:54:31 +00:00
parent edbe291389
commit 044ece0387
7 changed files with 44 additions and 10 deletions
+35 -1
View File
@@ -563,16 +563,50 @@ function buildEvaluationLabel(metrics) {
return 'wahrscheinlich korrekt (lineare Segmentfolge)';
}
function normalizeRelativeScore(value, maxValue) {
const numericValue = Number(value || 0);
const numericMax = Number(maxValue || 0);
if (!Number.isFinite(numericValue) || numericValue <= 0) {
return 0;
}
if (!Number.isFinite(numericMax) || numericMax <= 0) {
return 0;
}
return Math.min(1, Math.max(0, numericValue / numericMax));
}
function scoreCandidates(groupTitles) {
const titles = Array.isArray(groupTitles) ? groupTitles : [];
if (titles.length === 0) {
return [];
}
const maxDurationSeconds = titles.reduce(
(max, title) => Math.max(max, Number(title?.durationSeconds || 0)),
0
);
const maxAudioTrackCount = titles.reduce(
(max, title) => Math.max(max, Number(title?.audioTrackCount || 0)),
0
);
const maxChapterCount = titles.reduce(
(max, title) => Math.max(max, Number(title?.chapters || 0)),
0
);
return titles
.map((title) => {
const metrics = computeSegmentMetrics(title.segmentNumbers);
const structureScore = Number(metrics.score || 0);
const durationScore = normalizeRelativeScore(title.durationSeconds, maxDurationSeconds) * 20;
const audioScore = normalizeRelativeScore(title.audioTrackCount, maxAudioTrackCount) * 4;
const chapterScore = normalizeRelativeScore(title.chapters, maxChapterCount) * 6;
const totalScore = structureScore + durationScore + audioScore + chapterScore;
const reasons = [
`structure_score=${structureScore.toFixed(2)}`,
`duration_score=${durationScore.toFixed(2)}`,
`audio_score=${audioScore.toFixed(2)}`,
`chapter_score=${chapterScore.toFixed(2)}`,
`sequence_steps=${metrics.directSequenceSteps}`,
`sequence_coherence=${metrics.sequenceCoherence.toFixed(3)}`,
`backward_jumps=${metrics.backwardJumps}`,
@@ -582,7 +616,7 @@ function scoreCandidates(groupTitles) {
return {
...title,
score: Number(metrics.score || 0),
score: Number(totalScore.toFixed(4)),
reasons,
structuralMetrics: metrics,
evaluationLabel: buildEvaluationLabel(metrics)