fix(receipt-import): strengthen bacon detection with OCR-tolerant rule signals
This commit is contained in:
@@ -252,7 +252,15 @@ export class ReceiptImportService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const byRule = this.ruleBasedCategorySuggestion(item.rawName, categories);
|
const signalText = [
|
||||||
|
item.rawName,
|
||||||
|
item.matchedProductName,
|
||||||
|
item.suggestedProductName,
|
||||||
|
]
|
||||||
|
.filter((v): v is string => typeof v === 'string' && v.trim().isNotEmpty)
|
||||||
|
.join(' ');
|
||||||
|
|
||||||
|
const byRule = this.ruleBasedCategorySuggestion(signalText || item.rawName, categories);
|
||||||
let nextSuggestion = item.categorySuggestion ?? null;
|
let nextSuggestion = item.categorySuggestion ?? null;
|
||||||
|
|
||||||
const isTrustedSuggestion =
|
const isTrustedSuggestion =
|
||||||
@@ -284,7 +292,7 @@ export class ReceiptImportService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const guardedSuggestion = nextSuggestion
|
const guardedSuggestion = nextSuggestion
|
||||||
? this.applyContradictionGuard(item.rawName, nextSuggestion, categories)
|
? this.applyContradictionGuard(signalText || item.rawName, nextSuggestion, categories)
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
enriched.push(
|
enriched.push(
|
||||||
@@ -337,6 +345,8 @@ export class ReceiptImportService {
|
|||||||
// ── Regel: Kött/chark (bacon/fläsk m.m.) ────────────────────────────
|
// ── Regel: Kött/chark (bacon/fläsk m.m.) ────────────────────────────
|
||||||
const hasPorkSignal =
|
const hasPorkSignal =
|
||||||
/\bbacon\b/.test(normalized) ||
|
/\bbacon\b/.test(normalized) ||
|
||||||
|
/\bbacn\b/.test(normalized) ||
|
||||||
|
/\bbaco\b/.test(normalized) ||
|
||||||
/\bsidflask\b/.test(normalized) ||
|
/\bsidflask\b/.test(normalized) ||
|
||||||
/\bpancetta\b/.test(normalized) ||
|
/\bpancetta\b/.test(normalized) ||
|
||||||
/\bflask\b/.test(normalized) ||
|
/\bflask\b/.test(normalized) ||
|
||||||
@@ -674,6 +684,8 @@ export class ReceiptImportService {
|
|||||||
const normalized = normalizeForRules(rawName);
|
const normalized = normalizeForRules(rawName);
|
||||||
const hasPorkSignal =
|
const hasPorkSignal =
|
||||||
/\bbacon\b/.test(normalized) ||
|
/\bbacon\b/.test(normalized) ||
|
||||||
|
/\bbacn\b/.test(normalized) ||
|
||||||
|
/\bbaco\b/.test(normalized) ||
|
||||||
/\bsidflask\b/.test(normalized) ||
|
/\bsidflask\b/.test(normalized) ||
|
||||||
/\bpancetta\b/.test(normalized) ||
|
/\bpancetta\b/.test(normalized) ||
|
||||||
/\bflask\b/.test(normalized) ||
|
/\bflask\b/.test(normalized) ||
|
||||||
|
|||||||
Reference in New Issue
Block a user