[object Object]

← back to Dw Photo Capture

Scan: code numbers ONLY — drop name/prose candidates

8ddb73e810630fc242a73eafed5f319822f5fe77 · 2026-06-25 16:16:40 -0700 · Steve

Per Steve: never scan names or marketing text, only code numbers (SKU/model/lot).
/api/ocr now returns only alphanumeric-with-digit tokens, ranked largest-font
first then vendor-prefix score. A page with no code returns no candidates
(no name fallback). Verified: WDW2310 -> ['WDW2310']; logo-only -> [].

Files touched

Diff

commit 8ddb73e810630fc242a73eafed5f319822f5fe77
Author: Steve <steve@designerwallcoverings.com>
Date:   Thu Jun 25 16:16:40 2026 -0700

    Scan: code numbers ONLY — drop name/prose candidates
    
    Per Steve: never scan names or marketing text, only code numbers (SKU/model/lot).
    /api/ocr now returns only alphanumeric-with-digit tokens, ranked largest-font
    first then vendor-prefix score. A page with no code returns no candidates
    (no name fallback). Verified: WDW2310 -> ['WDW2310']; logo-only -> [].
---
 server.js | 25 +++++++++----------------
 1 file changed, 9 insertions(+), 16 deletions(-)

diff --git a/server.js b/server.js
index 532fe83..5b33d6e 100644
--- a/server.js
+++ b/server.js
@@ -568,26 +568,19 @@ const appHandler = (req, res) => {
           (t.includes('-') ? 12 : 0) +
           (/[A-Z]/.test(t) && /\d/.test(t) ? 20 : 0) +
           Math.min(t.length, 12);
-        const STOP = new Set(['GRASSCLOTH','WALLCOVERING','WALLPAPER','FENTUCCI','TWIL','YARD','YARDS','BOLT','ROLL','SINGLE','DOUBLE','NATURAL','PAPER','PRICED','COLOR','PATTERN','WIDTH','LENGTH','INCHES','THYBONY','WINFIELD']);
-        const seen = new Set(); const skus = []; const names = [];
-        // 1) SKU-like tokens, each tagged with the font height of the line it came from
+        // CODE NUMBERS ONLY — alphanumeric tokens that contain a digit (SKU / model / lot
+        // codes like WDW2310, GRS-26220, 5255-16). Plain names and any other prose on the
+        // label are intentionally ignored: scan the code, never the marketing text.
+        const seen = new Set(); const codes = [];
         for (const r of rows) {
           for (const t of (r.t.toUpperCase().match(/[A-Z0-9][A-Z0-9-]{2,13}/g) || [])) {
-            if (!/\d/.test(t) || t.length < 4 || seen.has(t)) continue;
-            seen.add(t); skus.push({ t, h: r.h, s: skuScore(t) });
+            if (!/\d/.test(t) || t.length < 4 || seen.has(t)) continue;   // must hold a digit, ≥4 chars
+            seen.add(t); codes.push({ t, h: r.h, s: skuScore(t) });
           }
         }
-        // 2) name words (≥4 alpha) so a printed PATTERN NAME also resolves — minus boilerplate
-        for (const r of rows) {
-          for (const w of (r.t.toUpperCase().match(/[A-Z]{4,}/g) || [])) {
-            if (STOP.has(w) || seen.has(w)) continue;
-            seen.add(w); names.push({ t: w, h: r.h });
-          }
-        }
-        // LARGEST LETTERS FIRST: sort by font height, then SKU-likeness, then length.
-        skus.sort((a, b) => (b.h - a.h) || (b.s - a.s) || (b.t.length - a.t.length));
-        names.sort((a, b) => (b.h - a.h) || (b.t.length - a.t.length));
-        const cand = [...skus.map(x => x.t), ...names.map(x => x.t)];
+        // LARGEST CODE FIRST: sort by font height, then SKU-likeness (vendor prefix), then length.
+        codes.sort((a, b) => (b.h - a.h) || (b.s - a.s) || (b.t.length - a.t.length));
+        const cand = codes.map(x => x.t);
         send(res, 200, { ok: true, text, candidates: cand, top: cand[0] || null });
       });
     });

← 3046f62 Scan ranks by font size first (largest letters), WD/Winfield  ·  back to Dw Photo Capture  ·  Add manufacturer-SKU resolver: scanned vendor codes resolve 47fbc5a →