Clean up decision logic

This commit is contained in:
Nicolas Mowen 2025-10-21 16:03:08 -06:00
parent 6d662151de
commit 7c0a97520a

View File

@ -197,18 +197,24 @@ export function GroupedClassificationCard({
let best: undefined | ClassificationItemData = undefined; let best: undefined | ClassificationItemData = undefined;
group.forEach((item) => { group.forEach((item) => {
if (best?.score == undefined || (item.score && best.score < item.score)) { if (item?.name != undefined && item.name != "none") {
if (
best?.score == undefined ||
(item.score && best.score < item.score)
) {
best = item; best = item;
} }
}
}); });
if (!best) { if (!best) {
return undefined; return group[0];
} }
const bestTyped: ClassificationItemData = best; const bestTyped: ClassificationItemData = best;
return { return {
...bestTyped, ...bestTyped,
name: event?.sub_label || bestTyped.name,
score: event?.data?.sub_label_score || bestTyped.score, score: event?.data?.sub_label_score || bestTyped.score,
}; };
}, [group, event]); }, [group, event]);