multiple receipts in a trip
This commit is contained in:
@@ -132,20 +132,19 @@ class ReceiptParseConfig {
|
||||
|
||||
/// True if [line] matches a config keyword.
|
||||
///
|
||||
/// Short tokens (3 characters or fewer) use a word boundary so `PIN` does
|
||||
/// not match `SPINAZIE`. Longer tokens use a case-insensitive substring,
|
||||
/// and a letter-only compact form so OCR splits like `Betaal d:` still
|
||||
/// match `BETAALD`.
|
||||
/// Always uses word boundaries so `CHIP` does not match `CHIPS` and `PIN`
|
||||
/// does not match `SPINAZIE`. A letter-only compact form is a fallback for
|
||||
/// OCR splits like `Betaal d:` → `BETAALD` (only for keywords of length ≥ 5,
|
||||
/// so short tokens like `CHIP` cannot match inside longer product words).
|
||||
bool matchesKeyword(String line, String keyword) {
|
||||
final upper = line.toUpperCase();
|
||||
final key = keyword.toUpperCase();
|
||||
if (key.length <= 3) {
|
||||
return RegExp('\\b${RegExp.escape(key)}\\b').hasMatch(upper);
|
||||
if (RegExp('\\b${RegExp.escape(key)}\\b').hasMatch(upper)) {
|
||||
return true;
|
||||
}
|
||||
if (upper.contains(key)) return true;
|
||||
final compactLine = upper.replaceAll(RegExp(r'[^A-Z0-9]'), '');
|
||||
final compactKey = key.replaceAll(RegExp(r'[^A-Z0-9]'), '');
|
||||
return compactKey.length >= 4 && compactLine.contains(compactKey);
|
||||
return compactKey.length >= 5 && compactLine.contains(compactKey);
|
||||
}
|
||||
|
||||
bool isStandaloneKeywordLine(String line, List<String> keywords) {
|
||||
|
||||
Reference in New Issue
Block a user