Improve OCR preprocessing and normalize merchant names

This commit is contained in:
2026-08-11 19:18:46 +03:00
parent 77c597dfd8
commit de41230b9b
3 changed files with 36 additions and 2 deletions
+8
View File
@@ -12,6 +12,13 @@ import {
rectFromPoints,
resolveFieldRect,
} from "../src/parser.js";
import { isWhiteTextPixel } from "../src/vision.js";
test("keeps white text pixels and removes colored or dark pixels", () => {
assert.equal(isWhiteTextPixel(220, 215, 195), true);
assert.equal(isWhiteTextPixel(210, 165, 80), false);
assert.equal(isWhiteTextPixel(120, 120, 120), false);
});
test("keeps only letters, digits and spaces in OCR item names", () => {
assert.equal(cleanItemName(" ~~ Soulshot: S-grade ` "), "Soulshot S grade");
@@ -139,5 +146,6 @@ test("parses trade side and merchant from the store header", () => {
merchant: "Dwa",
rawText: "Private Store({Sell) - Dwa",
});
assert.equal(parseStoreHeaderText("Private Store(Buy) - Hik vision")?.merchant, "Hikvision");
assert.equal(parseStoreHeaderText("Items on Sale"), null);
});