yasd
All checks were successful
Deploy / deploy-staging (push) Successful in 33s
Deploy / deploy-production (push) Has been skipped

This commit is contained in:
2026-06-02 23:37:49 +02:00
parent 127a0e71e1
commit 56d85e417b
2 changed files with 33 additions and 4 deletions

View File

@@ -1949,9 +1949,11 @@
function renderSharedOcrPanel() { function renderSharedOcrPanel() {
const preview = normalizeOcrPreview(ocrPreview); const preview = normalizeOcrPreview(ocrPreview);
const isWalletPreview = preview.kind === 'wallet'; const isWalletPreview = preview.kind === 'wallet';
const hasMiningSuggestion = preview.suggested.coins_total !== '' && preview.suggested.coins_total !== null;
const hasWalletSuggestion = preview.suggested_wallet.wallet_balance !== '' && preview.suggested_wallet.wallet_balance !== null;
const hasUsableOcrSuggestion = isWalletPreview const hasUsableOcrSuggestion = isWalletPreview
? (preview.suggested_wallet.wallet_balance !== '' && preview.suggested_wallet.wallet_balance !== null) ? hasWalletSuggestion
: (preview.suggested.coins_total !== '' && preview.suggested.coins_total !== null); : hasMiningSuggestion;
const ocrStatus = getOcrStatusMessage(preview); const ocrStatus = getOcrStatusMessage(preview);
return panel('OCR Upload', 'Screenshot auswaehlen, Ergebnis direkt pruefen und speichern.', [ return panel('OCR Upload', 'Screenshot auswaehlen, Ergebnis direkt pruefen und speichern.', [
@@ -2014,6 +2016,24 @@
onClick: () => isWalletPreview ? submitWalletSnapshotFromPreview() : submitMeasurement(true), onClick: () => isWalletPreview ? submitWalletSnapshotFromPreview() : submitMeasurement(true),
disabled: saving || !hasUsableOcrSuggestion, disabled: saving || !hasUsableOcrSuggestion,
}, saving ? 'Speichert …' : 'Ergebnis speichern'), }, saving ? 'Speichert …' : 'Ergebnis speichern'),
isWalletPreview && hasMiningSuggestion
? h('button', {
key: 'force-mining',
type: 'button',
className: 'mc-button mc-button--ghost',
onClick: () => submitMeasurement(true),
disabled: saving,
}, 'Als Mining speichern')
: null,
!isWalletPreview && hasWalletSuggestion
? h('button', {
key: 'force-wallet',
type: 'button',
className: 'mc-button mc-button--ghost',
onClick: () => submitWalletSnapshotFromPreview(),
disabled: saving,
}, 'Als Wallet speichern')
: null,
]) ])
: h('div', { key: 'ocr-empty', className: 'mc-empty' }, : h('div', { key: 'ocr-empty', className: 'mc-empty' },
'Noch kein Screenshot ausgewaehlt.'), 'Noch kein Screenshot ausgewaehlt.'),

View File

@@ -437,6 +437,14 @@ final class OcrService
} }
} }
$measurementIndicators = 0;
$normalizedLower = strtolower($normalizedText);
foreach (['mining-guthaben', 'mining guthaben', 'mining-balance', 'mining balance', 'doge /', 'bonus', 'verlauf'] as $indicator) {
if (str_contains($normalizedLower, $indicator)) {
$measurementIndicators++;
}
}
$matchedFields = 0; $matchedFields = 0;
foreach ([$coinsTotal, $price, $currency] as $field) { foreach ([$coinsTotal, $price, $currency] as $field) {
if ($field !== null) { if ($field !== null) {
@@ -444,7 +452,8 @@ final class OcrService
} }
} }
$confidence = max(0.05, min(0.99, ($matchedFields / 3) - (count($flags) * 0.04))); $score = $matchedFields + min(3, $measurementIndicators);
$confidence = max(0.05, min(0.99, ($matchedFields / 3) + (min(3, $measurementIndicators) * 0.08) - (count($flags) * 0.04)));
return [ return [
'suggested' => [ 'suggested' => [
@@ -457,7 +466,7 @@ final class OcrService
], ],
'confidence' => round($confidence, 4), 'confidence' => round($confidence, 4),
'flags' => $flags, 'flags' => $flags,
'score' => $matchedFields, 'score' => $score,
]; ];
} }