kordoc 4.24.78 → 4.24.79
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/{-3INLR7KZ.js → -WCLMRO7B.js} +22 -22
- package/dist/{chunk-ELOZVH5S.cjs → chunk-22L7WGJE.cjs} +8 -8
- package/dist/{chunk-ELOZVH5S.cjs.map → chunk-22L7WGJE.cjs.map} +1 -1
- package/dist/{chunk-PNKLL5TE.js → chunk-2DJI6DDM.js} +2 -2
- package/dist/{chunk-VEIPW7QU.js → chunk-3CQGKB62.js} +13 -10
- package/dist/chunk-3CQGKB62.js.map +1 -0
- package/dist/{chunk-MQYI7KWD.js → chunk-3G2BXR34.js} +2 -2
- package/dist/{chunk-QRNA3W7B.cjs → chunk-42P53WKD.cjs} +3 -3
- package/dist/{chunk-QRNA3W7B.cjs.map → chunk-42P53WKD.cjs.map} +1 -1
- package/dist/{chunk-KK77Q5NA.js → chunk-4DA67IZR.js} +2 -2
- package/dist/{chunk-HBKSG62C.js → chunk-7B6W4I3A.js} +2 -2
- package/dist/{chunk-SJF2ZMOH.js → chunk-7DD7G4BI.js} +2 -2
- package/dist/{chunk-V5JHID6L.js → chunk-A6KTEOXE.js} +3 -3
- package/dist/{chunk-ZE4OZOSO.js → chunk-ADPVFTTT.js} +12 -10
- package/dist/chunk-ADPVFTTT.js.map +1 -0
- package/dist/{chunk-TFKBIIDY.js → chunk-B6IV3WVP.js} +16 -16
- package/dist/{chunk-6RJGAVYA.js → chunk-B6OD2Z3R.js} +2 -2
- package/dist/{chunk-7BAKREYA.cjs → chunk-BJ365LX3.cjs} +3 -3
- package/dist/{chunk-7BAKREYA.cjs.map → chunk-BJ365LX3.cjs.map} +1 -1
- package/dist/{chunk-36KS4PDO.js → chunk-BWD4IPFG.js} +2 -2
- package/dist/{chunk-AEQJOD3U.js → chunk-CKOSQJCH.js} +2 -2
- package/dist/{chunk-EQO6PYJF.cjs → chunk-CKVPN66T.cjs} +33 -31
- package/dist/chunk-CKVPN66T.cjs.map +1 -0
- package/dist/{chunk-ENUL3MLZ.js → chunk-CY3JNBY7.js} +3 -3
- package/dist/{chunk-H6ZJK5KA.js → chunk-D6PDKX72.js} +2 -2
- package/dist/{chunk-7ASPTCTD.js → chunk-DKIBSCFV.js} +2 -2
- package/dist/{chunk-YDONOMUK.js → chunk-E4D3HKPN.js} +2 -2
- package/dist/{chunk-PLF5QVIR.cjs → chunk-E7ZG5NBU.cjs} +6 -6
- package/dist/{chunk-PLF5QVIR.cjs.map → chunk-E7ZG5NBU.cjs.map} +1 -1
- package/dist/{chunk-LVRS6HPA.js → chunk-EEUN7GWB.js} +6 -6
- package/dist/{chunk-KM5P2HJ2.js → chunk-FI4SFNUZ.js} +2 -2
- package/dist/{chunk-3JZINNV6.cjs → chunk-FOYPUNFB.cjs} +104 -104
- package/dist/{chunk-3JZINNV6.cjs.map → chunk-FOYPUNFB.cjs.map} +1 -1
- package/dist/{chunk-DJVCW5YA.js → chunk-FPJAA7GO.js} +12 -9
- package/dist/chunk-FPJAA7GO.js.map +1 -0
- package/dist/{chunk-Y2NIFMWC.js → chunk-GSBMOVCF.js} +7 -7
- package/dist/{chunk-F5RCXSUO.js → chunk-HNTRTZ2J.js} +2 -2
- package/dist/{chunk-7YAXU4XB.js → chunk-I5PYUR3W.js} +11 -11
- package/dist/{chunk-QXAQIVOI.js → chunk-IPAKNA6R.js} +2 -2
- package/dist/{chunk-DSUKSIMD.js → chunk-IZFALQLA.js} +6 -6
- package/dist/{chunk-7RQDJ63R.js → chunk-JEVINS5E.js} +11 -9
- package/dist/chunk-JEVINS5E.js.map +1 -0
- package/dist/{chunk-WENH6GSY.cjs → chunk-LPLU7527.cjs} +58 -58
- package/dist/{chunk-WENH6GSY.cjs.map → chunk-LPLU7527.cjs.map} +1 -1
- package/dist/{chunk-5JKGN6YF.js → chunk-MALK5PX5.js} +2 -2
- package/dist/{chunk-Q62ZOF73.js → chunk-PSYI2EYA.js} +2 -2
- package/dist/{chunk-ZOOI4PGA.js → chunk-Q2QT6AL6.js} +2 -2
- package/dist/{chunk-BXNK6DQL.js → chunk-RDDRHUSA.js} +2 -2
- package/dist/{chunk-Z4RKJYK4.js → chunk-RO577YPX.js} +10 -10
- package/dist/{chunk-YRYL75TY.js → chunk-TEWYIAFY.js} +2 -2
- package/dist/{chunk-XMNGFHK6.cjs → chunk-UP3KRRVN.cjs} +2 -2
- package/dist/{chunk-XMNGFHK6.cjs.map → chunk-UP3KRRVN.cjs.map} +1 -1
- package/dist/{chunk-VZRUNNZ2.js → chunk-VS5FCFDX.js} +2 -2
- package/dist/{chunk-PGTOBYRX.js → chunk-VTXPEJDA.js} +5 -5
- package/dist/{chunk-FAJO643G.js → chunk-W5FLEZV4.js} +5 -5
- package/dist/{chunk-PSWNPOWW.js → chunk-WHQXWZZK.js} +2 -2
- package/dist/{chunk-NWAA7CP7.js → chunk-XLR77IOC.js} +3 -3
- package/dist/{chunk-M5VCRPXU.js → chunk-Y3X53MRF.js} +5 -5
- package/dist/{chunk-EU7LGFMR.cjs → chunk-ZLHHSW2T.cjs} +97 -94
- package/dist/chunk-ZLHHSW2T.cjs.map +1 -0
- package/dist/chunks-6UAF6SYV.js +11 -0
- package/dist/cli.js +46 -46
- package/dist/{formula-X4J6TPFE.cjs → formula-HECGAXCQ.cjs} +9 -9
- package/dist/{formula-X4J6TPFE.cjs.map → formula-HECGAXCQ.cjs.map} +1 -1
- package/dist/{formula-OVW7R4O5.js → formula-JYXL5ZDG.js} +3 -3
- package/dist/{formula-OYCTBHT6.js → formula-NBB34N4Y.js} +4 -4
- package/dist/generator-AZ3APW7A.js +11 -0
- package/dist/generator-FSH6G2BY.cjs +12 -0
- package/dist/{generator-BCGW5ITF.cjs.map → generator-FSH6G2BY.cjs.map} +1 -1
- package/dist/generator-WTZZ2OSI.js +18 -0
- package/dist/{hancom-KYUZYWLO.js → hancom-GSUBPFCZ.js} +2 -2
- package/dist/{hancom-O4E5BLIX.js → hancom-GXUGVC5L.js} +2 -2
- package/dist/{hancom-WH7WXXZH.cjs → hancom-UUFWDLTN.cjs} +5 -5
- package/dist/{hancom-WH7WXXZH.cjs.map → hancom-UUFWDLTN.cjs.map} +1 -1
- package/dist/{image-ocr-OPDOCCLA.js → image-ocr-62D6HIBB.js} +11 -11
- package/dist/{image-ocr-GY4K5NOY.js → image-ocr-XSKOCOW7.js} +8 -8
- package/dist/{image-ocr-5ZFMCHZL.cjs → image-ocr-ZVU4TCW7.cjs} +36 -36
- package/dist/{image-ocr-5ZFMCHZL.cjs.map → image-ocr-ZVU4TCW7.cjs.map} +1 -1
- package/dist/index.cjs +1113 -1113
- package/dist/index.js +10 -10
- package/dist/mcp.js +37 -37
- package/dist/memo-A4PUH3YJ.js +17 -0
- package/dist/{model-bundle-VGXIVXVT.js → model-bundle-DPTHBESJ.js} +5 -5
- package/dist/{models-TUSHH7AR.js → models-O7M5SDJV.js} +5 -5
- package/dist/{parse-worker-v2-Z3XGSG52.js → parse-worker-v2-3ILBPY7P.js} +23 -23
- package/dist/{parser-OAQ2QNB6.js → parser-EIOKEMXD.js} +21 -15
- package/dist/parser-EIOKEMXD.js.map +1 -0
- package/dist/{parser-ZMBMSI3G.js → parser-LGJVHF2C.js} +18 -12
- package/dist/parser-LGJVHF2C.js.map +1 -0
- package/dist/{parser-EQTJOS7W.cjs → parser-TGMBU6NM.cjs} +173 -167
- package/dist/parser-TGMBU6NM.cjs.map +1 -0
- package/dist/{pdf-ocr-WRJDDC57.js → pdf-ocr-OU7XVMJW.js} +9 -9
- package/dist/pdf-ocr-VKZPLCS7.cjs +43 -0
- package/dist/{pdf-ocr-YGAPGMHW.cjs.map → pdf-ocr-VKZPLCS7.cjs.map} +1 -1
- package/dist/{pdf-ocr-3CUUB3YV.js → pdf-ocr-VQGNNEFT.js} +6 -6
- package/dist/{profile-io-IOVBPV7R.js → profile-io-AEG7M5KV.js} +3 -3
- package/dist/{rasterize-ZJZKZF5R.js → rasterize-2TX6CRQY.js} +3 -3
- package/dist/{redact-doc-NPMUDPQZ.js → redact-doc-UWXE2D52.js} +22 -22
- package/dist/{render-F43PBJAG.js → render-3TPZAAY3.js} +12 -12
- package/dist/{rewrite-fallback-RITELBHU.js → rewrite-fallback-FVI3MVUH.js} +13 -13
- package/dist/seal-ZNN4P4IN.js +16 -0
- package/dist/{setup-J7I3KFRD.js → setup-5SZWEMHX.js} +3 -3
- package/dist/to-hwpx-KHSK7PL3.cjs +16 -0
- package/dist/{to-hwpx-ACL6I6I7.cjs.map → to-hwpx-KHSK7PL3.cjs.map} +1 -1
- package/dist/{to-hwpx-M7W7O47H.js → to-hwpx-KVCLOFIT.js} +4 -4
- package/dist/{to-hwpx-6JBBYURE.js → to-hwpx-UNNR4Y7K.js} +7 -7
- package/dist/visual-UDZERIUK.js +40 -0
- package/dist/{watch-YILY6776.js → watch-YCNXUIJL.js} +23 -23
- package/package.json +1 -1
- package/dist/chunk-7RQDJ63R.js.map +0 -1
- package/dist/chunk-DJVCW5YA.js.map +0 -1
- package/dist/chunk-EQO6PYJF.cjs.map +0 -1
- package/dist/chunk-EU7LGFMR.cjs.map +0 -1
- package/dist/chunk-VEIPW7QU.js.map +0 -1
- package/dist/chunk-ZE4OZOSO.js.map +0 -1
- package/dist/chunks-QN3OZOZA.js +0 -11
- package/dist/generator-BCGW5ITF.cjs +0 -12
- package/dist/generator-GJJMS4RD.js +0 -11
- package/dist/generator-ZWGWYDPM.js +0 -18
- package/dist/memo-7BFDELVU.js +0 -17
- package/dist/parser-EQTJOS7W.cjs.map +0 -1
- package/dist/parser-OAQ2QNB6.js.map +0 -1
- package/dist/parser-ZMBMSI3G.js.map +0 -1
- package/dist/pdf-ocr-YGAPGMHW.cjs +0 -43
- package/dist/seal-BEVAF3RV.js +0 -16
- package/dist/to-hwpx-ACL6I6I7.cjs +0 -16
- package/dist/visual-EG4OBDUG.js +0 -40
- /package/dist/{-3INLR7KZ.js.map → -WCLMRO7B.js.map} +0 -0
- /package/dist/{chunk-PNKLL5TE.js.map → chunk-2DJI6DDM.js.map} +0 -0
- /package/dist/{chunk-MQYI7KWD.js.map → chunk-3G2BXR34.js.map} +0 -0
- /package/dist/{chunk-KK77Q5NA.js.map → chunk-4DA67IZR.js.map} +0 -0
- /package/dist/{chunk-HBKSG62C.js.map → chunk-7B6W4I3A.js.map} +0 -0
- /package/dist/{chunk-SJF2ZMOH.js.map → chunk-7DD7G4BI.js.map} +0 -0
- /package/dist/{chunk-V5JHID6L.js.map → chunk-A6KTEOXE.js.map} +0 -0
- /package/dist/{chunk-TFKBIIDY.js.map → chunk-B6IV3WVP.js.map} +0 -0
- /package/dist/{chunk-6RJGAVYA.js.map → chunk-B6OD2Z3R.js.map} +0 -0
- /package/dist/{chunk-36KS4PDO.js.map → chunk-BWD4IPFG.js.map} +0 -0
- /package/dist/{chunk-AEQJOD3U.js.map → chunk-CKOSQJCH.js.map} +0 -0
- /package/dist/{chunk-ENUL3MLZ.js.map → chunk-CY3JNBY7.js.map} +0 -0
- /package/dist/{chunk-H6ZJK5KA.js.map → chunk-D6PDKX72.js.map} +0 -0
- /package/dist/{chunk-7ASPTCTD.js.map → chunk-DKIBSCFV.js.map} +0 -0
- /package/dist/{chunk-YDONOMUK.js.map → chunk-E4D3HKPN.js.map} +0 -0
- /package/dist/{chunk-LVRS6HPA.js.map → chunk-EEUN7GWB.js.map} +0 -0
- /package/dist/{chunk-KM5P2HJ2.js.map → chunk-FI4SFNUZ.js.map} +0 -0
- /package/dist/{chunk-Y2NIFMWC.js.map → chunk-GSBMOVCF.js.map} +0 -0
- /package/dist/{chunk-F5RCXSUO.js.map → chunk-HNTRTZ2J.js.map} +0 -0
- /package/dist/{chunk-7YAXU4XB.js.map → chunk-I5PYUR3W.js.map} +0 -0
- /package/dist/{chunk-QXAQIVOI.js.map → chunk-IPAKNA6R.js.map} +0 -0
- /package/dist/{chunk-DSUKSIMD.js.map → chunk-IZFALQLA.js.map} +0 -0
- /package/dist/{chunk-5JKGN6YF.js.map → chunk-MALK5PX5.js.map} +0 -0
- /package/dist/{chunk-Q62ZOF73.js.map → chunk-PSYI2EYA.js.map} +0 -0
- /package/dist/{chunk-ZOOI4PGA.js.map → chunk-Q2QT6AL6.js.map} +0 -0
- /package/dist/{chunk-BXNK6DQL.js.map → chunk-RDDRHUSA.js.map} +0 -0
- /package/dist/{chunk-Z4RKJYK4.js.map → chunk-RO577YPX.js.map} +0 -0
- /package/dist/{chunk-YRYL75TY.js.map → chunk-TEWYIAFY.js.map} +0 -0
- /package/dist/{chunk-VZRUNNZ2.js.map → chunk-VS5FCFDX.js.map} +0 -0
- /package/dist/{chunk-PGTOBYRX.js.map → chunk-VTXPEJDA.js.map} +0 -0
- /package/dist/{chunk-FAJO643G.js.map → chunk-W5FLEZV4.js.map} +0 -0
- /package/dist/{chunk-PSWNPOWW.js.map → chunk-WHQXWZZK.js.map} +0 -0
- /package/dist/{chunk-NWAA7CP7.js.map → chunk-XLR77IOC.js.map} +0 -0
- /package/dist/{chunk-M5VCRPXU.js.map → chunk-Y3X53MRF.js.map} +0 -0
- /package/dist/{chunks-QN3OZOZA.js.map → chunks-6UAF6SYV.js.map} +0 -0
- /package/dist/{formula-OVW7R4O5.js.map → formula-JYXL5ZDG.js.map} +0 -0
- /package/dist/{formula-OYCTBHT6.js.map → formula-NBB34N4Y.js.map} +0 -0
- /package/dist/{generator-GJJMS4RD.js.map → generator-AZ3APW7A.js.map} +0 -0
- /package/dist/{generator-ZWGWYDPM.js.map → generator-WTZZ2OSI.js.map} +0 -0
- /package/dist/{hancom-KYUZYWLO.js.map → hancom-GSUBPFCZ.js.map} +0 -0
- /package/dist/{hancom-O4E5BLIX.js.map → hancom-GXUGVC5L.js.map} +0 -0
- /package/dist/{image-ocr-OPDOCCLA.js.map → image-ocr-62D6HIBB.js.map} +0 -0
- /package/dist/{image-ocr-GY4K5NOY.js.map → image-ocr-XSKOCOW7.js.map} +0 -0
- /package/dist/{memo-7BFDELVU.js.map → memo-A4PUH3YJ.js.map} +0 -0
- /package/dist/{model-bundle-VGXIVXVT.js.map → model-bundle-DPTHBESJ.js.map} +0 -0
- /package/dist/{models-TUSHH7AR.js.map → models-O7M5SDJV.js.map} +0 -0
- /package/dist/{parse-worker-v2-Z3XGSG52.js.map → parse-worker-v2-3ILBPY7P.js.map} +0 -0
- /package/dist/{pdf-ocr-3CUUB3YV.js.map → pdf-ocr-OU7XVMJW.js.map} +0 -0
- /package/dist/{pdf-ocr-WRJDDC57.js.map → pdf-ocr-VQGNNEFT.js.map} +0 -0
- /package/dist/{profile-io-IOVBPV7R.js.map → profile-io-AEG7M5KV.js.map} +0 -0
- /package/dist/{rasterize-ZJZKZF5R.js.map → rasterize-2TX6CRQY.js.map} +0 -0
- /package/dist/{redact-doc-NPMUDPQZ.js.map → redact-doc-UWXE2D52.js.map} +0 -0
- /package/dist/{render-F43PBJAG.js.map → render-3TPZAAY3.js.map} +0 -0
- /package/dist/{rewrite-fallback-RITELBHU.js.map → rewrite-fallback-FVI3MVUH.js.map} +0 -0
- /package/dist/{seal-BEVAF3RV.js.map → seal-ZNN4P4IN.js.map} +0 -0
- /package/dist/{setup-J7I3KFRD.js.map → setup-5SZWEMHX.js.map} +0 -0
- /package/dist/{to-hwpx-6JBBYURE.js.map → to-hwpx-KVCLOFIT.js.map} +0 -0
- /package/dist/{to-hwpx-M7W7O47H.js.map → to-hwpx-UNNR4Y7K.js.map} +0 -0
- /package/dist/{visual-EG4OBDUG.js.map → visual-UDZERIUK.js.map} +0 -0
- /package/dist/{watch-YILY6776.js.map → watch-YCNXUIJL.js.map} +0 -0
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
|
|
38
38
|
|
|
39
39
|
|
|
40
|
-
var
|
|
40
|
+
var _chunkCKVPN66Tcjs = require('./chunk-CKVPN66T.cjs');
|
|
41
41
|
|
|
42
42
|
|
|
43
43
|
var _chunkMMK32GPDcjs = require('./chunk-MMK32GPD.cjs');
|
|
@@ -50,7 +50,7 @@ var _chunk64H2FCYFcjs = require('./chunk-64H2FCYF.cjs');
|
|
|
50
50
|
|
|
51
51
|
|
|
52
52
|
|
|
53
|
-
var
|
|
53
|
+
var _chunkUP3KRRVNcjs = require('./chunk-UP3KRRVN.cjs');
|
|
54
54
|
|
|
55
55
|
// src/ocr/ocr-stacked-rows.ts
|
|
56
56
|
var NUMERIC = /^[-+−△▲▽▼]?[\d.,]+[%p원]?$|^[-–—·∼~]원?$|^\([-+−△▲▽▼]?[\d.,]+%?\)$/;
|
|
@@ -479,8 +479,11 @@ function detectRulingLines(rgba, width, height, scale) {
|
|
|
479
479
|
const startsAt = (x, y) => verticals.some((p) => Math.abs(p.x1 - x) <= tol && Math.abs(p.y1 - y) <= tol * 2 && p.y2 > y + tol);
|
|
480
480
|
const sameSpan = (a, b, x) => a.some((p) => b.some((q) => Math.abs(p.x1 - q.x1) <= tol && Math.abs(p.x2 - q.x2) <= tol && p.x2 - p.x1 >= boxMin && Math.abs(x - (p.x1 + p.x2) / 2) <= (p.x2 - p.x1) * 0.25 && !sides(p.x1, p.y1, q.y1) && !sides(p.x2, p.y1, q.y1) && endsAt(p.x1, p.y1) && endsAt(p.x2, p.y1) && startsAt(q.x1, q.y1) && startsAt(q.x2, q.y1)));
|
|
481
481
|
const shortV = detectBands(ink, width, height, maxThickPx, true, (m, base, step, span) => solidRuns(m, base, step, span, bridgeMin)).filter((v) => v.y2 - v.y1 + 1 < minLenPx);
|
|
482
|
+
const long = verticals.filter((p) => p.y2 - p.y1 + 1 >= minLenPx);
|
|
483
|
+
const inside = (x, y) => endsOn(x, y).some((h) => h.x1 < x - 3 * tol && h.x2 > x + 3 * tol);
|
|
482
484
|
for (const v of shortV) {
|
|
483
|
-
|
|
485
|
+
const column = inside(v.x1, v.y1) && inside(v.x1, v.y2) && long.some((p) => Math.abs(p.x1 - v.x1) <= tol && p.y2 <= v.y1 + tol) && long.some((p) => Math.abs(p.x1 - v.x1) <= tol && p.y1 >= v.y2 - tol);
|
|
486
|
+
if (!column && !sameSpan(endsOn(v.x1, v.y1), endsOn(v.x1, v.y2), v.x1)) continue;
|
|
484
487
|
if (!verticals.some((p) => Math.abs(p.x1 - v.x1) <= tol && p.y1 <= v.y1 + tol && p.y2 >= v.y2 - tol)) verticals.push(v);
|
|
485
488
|
}
|
|
486
489
|
const allH = [...horizontals, ...dotH], allV = [...verticals, ...dotV];
|
|
@@ -499,11 +502,11 @@ function detectRulingLines(rgba, width, height, scale) {
|
|
|
499
502
|
const chainEnd = Math.round(FILL_CHAIN_END_PT * scale);
|
|
500
503
|
for (const [y, segs] of rows) {
|
|
501
504
|
for (const p of ruleH) {
|
|
502
|
-
const
|
|
503
|
-
if (
|
|
504
|
-
const lo = Math.min(...
|
|
505
|
-
const cover =
|
|
506
|
-
if (lo - p.x1 <= chainEnd && p.x2 - hi <= chainEnd && cover >= (p.x2 - p.x1) * 0.5) fillH.push({ ...
|
|
505
|
+
const inside2 = segs.filter((a) => a.x1 >= p.x1 - tol && a.x2 <= p.x2 + tol);
|
|
506
|
+
if (inside2.length < 2 || fillH.some((f) => Math.abs(f.y1 - y) <= tol && f.x1 <= p.x1 + tol && f.x2 >= p.x2 - tol)) continue;
|
|
507
|
+
const lo = Math.min(...inside2.map((a) => a.x1)), hi = Math.max(...inside2.map((a) => a.x2));
|
|
508
|
+
const cover = inside2.reduce((n, a) => n + a.x2 - a.x1, 0);
|
|
509
|
+
if (lo - p.x1 <= chainEnd && p.x2 - hi <= chainEnd && cover >= (p.x2 - p.x1) * 0.5) fillH.push({ ...inside2[0], x1: p.x1, x2: p.x2 });
|
|
507
510
|
}
|
|
508
511
|
}
|
|
509
512
|
for (const a of fill.horizontals) {
|
|
@@ -849,8 +852,8 @@ var INKLESS_DELTA = 32;
|
|
|
849
852
|
function ringAsks(rgba, pageW, box, text, steps, stepPx) {
|
|
850
853
|
const chars = [...text];
|
|
851
854
|
if (chars.length !== steps.length || !/[가-힣]/.test(text)) return [];
|
|
852
|
-
const gray =
|
|
853
|
-
const rings =
|
|
855
|
+
const gray = _chunkCKVPN66Tcjs.grayCrop.call(void 0, rgba, pageW, box);
|
|
856
|
+
const rings = _chunkCKVPN66Tcjs.ringBoxes.call(void 0, gray, box.w, box.h, _chunkCKVPN66Tcjs.inkStats.call(void 0, gray));
|
|
854
857
|
const owner = ringOwners(chars, (i) => (steps[i] + 0.5) * stepPx, rings);
|
|
855
858
|
return rings.flatMap((r, k) => {
|
|
856
859
|
const at = owner.indexOf(k);
|
|
@@ -890,8 +893,8 @@ function ringGlyph(read, jamo = null, confidence = 1) {
|
|
|
890
893
|
function restoreGlyphs(rgba, pageW, box, text, steps, stepPx, note = {}, rings = []) {
|
|
891
894
|
const chars = [...text];
|
|
892
895
|
if (chars.length !== steps.length) return text;
|
|
893
|
-
const gray =
|
|
894
|
-
const c = { chars, cx: (i) => (steps[i] + 0.5) * stepPx, gray, w: box.w, h: box.h, ink:
|
|
896
|
+
const gray = _chunkCKVPN66Tcjs.grayCrop.call(void 0, rgba, pageW, box);
|
|
897
|
+
const c = { chars, cx: (i) => (steps[i] + 0.5) * stepPx, gray, w: box.w, h: box.h, ink: _chunkCKVPN66Tcjs.inkStats.call(void 0, gray) };
|
|
895
898
|
if (/[[\]]/.test(text)) brackets(c);
|
|
896
899
|
if (text.includes("'")) cornerQuotes(c);
|
|
897
900
|
if (/['"]/.test(text)) quotes(c);
|
|
@@ -921,7 +924,7 @@ function restoreGlyphs(rgba, pageW, box, text, steps, stepPx, note = {}, rings =
|
|
|
921
924
|
function trimInklessEnds(rgba, pageW, box, text, steps, stepPx) {
|
|
922
925
|
const chars = [...text], { w, h } = box;
|
|
923
926
|
if (chars.length !== steps.length || steps.some((s) => (s + 0.5) * stepPx > w + stepPx)) return { text, steps };
|
|
924
|
-
const gray =
|
|
927
|
+
const gray = _chunkCKVPN66Tcjs.grayCrop.call(void 0, rgba, pageW, box);
|
|
925
928
|
const hist = new Uint32Array(256);
|
|
926
929
|
for (const v of gray) hist[v]++;
|
|
927
930
|
let bg = 0;
|
|
@@ -952,8 +955,8 @@ function cornerCommas({ chars, cx, gray, w, h, ink }) {
|
|
|
952
955
|
continue;
|
|
953
956
|
}
|
|
954
957
|
if (open > 0) {
|
|
955
|
-
const f =
|
|
956
|
-
if (f &&
|
|
958
|
+
const f = _chunkCKVPN66Tcjs.bracketFeatures.call(void 0, gray, w, h, ink, cx(i));
|
|
959
|
+
if (f && _chunkCKVPN66Tcjs.bracketShape.call(void 0, f, true) === "\u300D") {
|
|
957
960
|
chars[i] = "\u300D";
|
|
958
961
|
open--;
|
|
959
962
|
}
|
|
@@ -963,12 +966,12 @@ function cornerCommas({ chars, cx, gray, w, h, ink }) {
|
|
|
963
966
|
function cornerQuotes({ chars, cx, gray, w, h, ink }) {
|
|
964
967
|
for (let i = 0; i < chars.length; i++) {
|
|
965
968
|
if (chars[i] !== "'" || !/^[가-힣]/.test(_nullishCoalesce(chars[i + 1], () => ( "")))) continue;
|
|
966
|
-
const f =
|
|
967
|
-
if (!f || f.ch < f.charH * 0.45 ||
|
|
969
|
+
const f = _chunkCKVPN66Tcjs.bracketFeatures.call(void 0, gray, w, h, ink, cx(i));
|
|
970
|
+
if (!f || f.ch < f.charH * 0.45 || _chunkCKVPN66Tcjs.bracketShape.call(void 0, f, false) !== "\u300C") continue;
|
|
968
971
|
const rest = chars.slice(i + 1), end = rest.findIndex((c) => c === "'" || c === "\u300D" || c === ",");
|
|
969
972
|
const pair = end >= 0 && rest[end] !== "'" && (rest[end] === "\u300D" || (() => {
|
|
970
|
-
const g =
|
|
971
|
-
return !!g &&
|
|
973
|
+
const g = _chunkCKVPN66Tcjs.bracketFeatures.call(void 0, gray, w, h, ink, cx(i + 1 + end));
|
|
974
|
+
return !!g && _chunkCKVPN66Tcjs.bracketShape.call(void 0, g, true) === "\u300D";
|
|
972
975
|
})());
|
|
973
976
|
if (pair) chars[i] = "\u300C";
|
|
974
977
|
}
|
|
@@ -976,8 +979,8 @@ function cornerQuotes({ chars, cx, gray, w, h, ink }) {
|
|
|
976
979
|
function brackets({ chars, cx, gray, w, h, ink }) {
|
|
977
980
|
const shape = chars.map((c, i) => {
|
|
978
981
|
if (c !== "[" && c !== "]") return null;
|
|
979
|
-
const f =
|
|
980
|
-
return f &&
|
|
982
|
+
const f = _chunkCKVPN66Tcjs.bracketFeatures.call(void 0, gray, w, h, ink, cx(i));
|
|
983
|
+
return f && _chunkCKVPN66Tcjs.bracketShape.call(void 0, f, c === "]");
|
|
981
984
|
});
|
|
982
985
|
for (let i = 0; i < chars.length; i++) {
|
|
983
986
|
if (chars[i] !== "[") continue;
|
|
@@ -1009,7 +1012,7 @@ function quotes({ chars, cx, gray, w, h, ink }) {
|
|
|
1009
1012
|
continue;
|
|
1010
1013
|
}
|
|
1011
1014
|
if (!year(i) && !single[kind]) continue;
|
|
1012
|
-
const r =
|
|
1015
|
+
const r = _chunkCKVPN66Tcjs.quoteHead.call(void 0, gray, w, h, ink, cx(i));
|
|
1013
1016
|
if (r !== null && r >= 0.47) {
|
|
1014
1017
|
chars[i] = kind === "'" ? "\u2018" : "\u201C";
|
|
1015
1018
|
open[kind] = true;
|
|
@@ -1020,7 +1023,7 @@ function dashes({ chars, cx, gray, w, h, ink }) {
|
|
|
1020
1023
|
const head = chars.findIndex((c) => c.trim()), letters = chars.some((c) => /[가-힣A-Za-z]/.test(c));
|
|
1021
1024
|
for (let i = 0; i < chars.length; i++) {
|
|
1022
1025
|
if (!/^[-\u2013\u2014]$/.test(chars[i])) continue;
|
|
1023
|
-
const r =
|
|
1026
|
+
const r = _chunkCKVPN66Tcjs.dashRatio.call(void 0, gray, w, h, ink, cx(i));
|
|
1024
1027
|
if (r === null) continue;
|
|
1025
1028
|
if (r < 0.65) chars[i] = "-";
|
|
1026
1029
|
else if (r > 0.75 && i === head && letters) chars[i] = "\u2014";
|
|
@@ -1030,7 +1033,7 @@ function circled({ chars, cx, gray, w, h, ink }) {
|
|
|
1030
1033
|
const alone = (re, i) => re.test(chars[i]) && !re.test(_nullishCoalesce(chars[i - 1], () => ( ""))) && !re.test(_nullishCoalesce(chars[i + 1], () => ( "")));
|
|
1031
1034
|
const at = chars.flatMap((_, i) => alone(/^\d$/, i) && chars[i] !== "0" || alone(/^[ㄱ-ㅎ]$/, i) || alone(/^[A-Za-z]$/, i) && /[a-zCSUVWXZ]/.test(chars[i]) ? [i] : []);
|
|
1032
1035
|
if (!at.length) return;
|
|
1033
|
-
const hit =
|
|
1036
|
+
const hit = _chunkCKVPN66Tcjs.circledAt.call(void 0, gray, w, h, ink, at.map(cx));
|
|
1034
1037
|
const JAMO = "\u3131\u3134\u3137\u3139\u3141\u3142\u3145\u3147\u3148\u314A\u314B\u314C\u314D\u314E";
|
|
1035
1038
|
at.forEach((i, k) => {
|
|
1036
1039
|
if (!hit[k]) return;
|
|
@@ -1043,16 +1046,16 @@ function stars({ chars, cx, gray, w, h, ink }) {
|
|
|
1043
1046
|
if (chars[i] !== "*" || chars[i - 1] === "*") continue;
|
|
1044
1047
|
let e = i;
|
|
1045
1048
|
while (chars[e + 1] === "*") e++;
|
|
1046
|
-
const n =
|
|
1049
|
+
const n = _chunkCKVPN66Tcjs.starRun.call(void 0, gray, w, h, ink, cx(i));
|
|
1047
1050
|
if (n > e - i + 1 && n <= 4) chars[e] += "*".repeat(n - (e - i + 1));
|
|
1048
1051
|
i = e;
|
|
1049
1052
|
}
|
|
1050
1053
|
}
|
|
1051
1054
|
function discs({ chars, cx, gray, w, h, ink }) {
|
|
1052
|
-
for (let i = 0; i < chars.length; i++) if (/^[\u00b7\u2022]$/.test(chars[i]) &&
|
|
1055
|
+
for (let i = 0; i < chars.length; i++) if (/^[\u00b7\u2022]$/.test(chars[i]) && _chunkCKVPN66Tcjs.discAt.call(void 0, gray, w, h, ink, cx(i))) chars[i] = "\u25CF";
|
|
1053
1056
|
}
|
|
1054
1057
|
function gaps({ chars, cx, gray, w, h, ink }) {
|
|
1055
|
-
const { glyphs, bandH } =
|
|
1058
|
+
const { glyphs, bandH } = _chunkCKVPN66Tcjs.gapGlyphs.call(void 0, gray, w, h, ink);
|
|
1056
1059
|
if (!glyphs.length) return;
|
|
1057
1060
|
const live = chars.map((c, i) => i).filter((i) => chars[i].trim());
|
|
1058
1061
|
if (!live.length) return;
|
|
@@ -1123,18 +1126,18 @@ function ring({ chars, cx, gray, w, h, ink }) {
|
|
|
1123
1126
|
const rest = chars.slice(k + 1).join("").trimStart();
|
|
1124
1127
|
const live = chars.map((c, i) => i).filter((i) => chars[i].trim());
|
|
1125
1128
|
if (live.length <= 3 && live.every((i) => /^[Oo]$/.test(chars[i]))) {
|
|
1126
|
-
if (_optionalChain([
|
|
1127
|
-
if (!live.every((i) =>
|
|
1129
|
+
if (_optionalChain([_chunkCKVPN66Tcjs.leadingBullet.call(void 0, gray, w, h, ink, cx(live[0])), 'optionalAccess', _11 => _11.mark]) === "\u25CE") return false;
|
|
1130
|
+
if (!live.every((i) => _chunkCKVPN66Tcjs.ringBullet.call(void 0, gray, w, h, ink, cx(i)) === "\u25CB")) return false;
|
|
1128
1131
|
for (const i of live) chars[i] = "\u25CB";
|
|
1129
1132
|
return true;
|
|
1130
1133
|
}
|
|
1131
1134
|
if (/^[A-Z]{2,}/.test(rest) && /^[Oo0]$/.test(chars[k])) {
|
|
1132
|
-
if (
|
|
1135
|
+
if (_chunkCKVPN66Tcjs.ringBullet.call(void 0, gray, w, h, ink, cx(k)) !== "\u25CB") return false;
|
|
1133
1136
|
chars[k] = chars[k + 1] === " " ? "\u25CB" : "\u25CB ";
|
|
1134
1137
|
return true;
|
|
1135
1138
|
}
|
|
1136
1139
|
if (!/^[(\[「【<]?\d*[가-힣]/.test(rest)) return false;
|
|
1137
|
-
const r =
|
|
1140
|
+
const r = _chunkCKVPN66Tcjs.ringBullet.call(void 0, gray, w, h, ink, cx(k));
|
|
1138
1141
|
if (/^[Cc]$/.test(chars[k]) && r !== "\u25CB") return false;
|
|
1139
1142
|
if (r) chars[k] = r;
|
|
1140
1143
|
return r !== null;
|
|
@@ -1151,7 +1154,7 @@ function parallels({ chars, cx, gray, w, h, ink }) {
|
|
|
1151
1154
|
let p = s - 1, q = e + 1;
|
|
1152
1155
|
while (p >= 0 && !chars[p].trim()) p--;
|
|
1153
1156
|
while (q < chars.length && !chars[q].trim()) q++;
|
|
1154
|
-
if (
|
|
1157
|
+
if (_chunkCKVPN66Tcjs.slantedPair.call(void 0, gray, w, h, ink, p >= 0 ? cx(p) : -Infinity, q < chars.length ? cx(q) : Infinity)) {
|
|
1155
1158
|
chars[s] = "\u2225";
|
|
1156
1159
|
for (let k = s + 1; k <= e; k++) chars[k] = "";
|
|
1157
1160
|
}
|
|
@@ -1163,7 +1166,7 @@ function roman({ chars, cx, gray, w, h, ink }) {
|
|
|
1163
1166
|
const ROMAN = /^[IⅠ-Ⅲ]$/, LATIN = /[A-Za-z]$/;
|
|
1164
1167
|
for (let i = 0; i < chars.length; i++) {
|
|
1165
1168
|
if (chars[i] !== "1" || /[\dA-Za-z]$/.test(_nullishCoalesce(chars[i - 1], () => ( ""))) || /^[\dA-Za-z,]/.test(_nullishCoalesce(chars[i + 1], () => ( "")))) continue;
|
|
1166
|
-
if (
|
|
1169
|
+
if (_chunkCKVPN66Tcjs.serifOne.call(void 0, gray, w, h, ink, cx(i))) chars[i] = "\u2160";
|
|
1167
1170
|
}
|
|
1168
1171
|
for (let i = 0; i < chars.length; i++) {
|
|
1169
1172
|
const hangul = /^[파피]$/.test(chars[i]);
|
|
@@ -1173,13 +1176,13 @@ function roman({ chars, cx, gray, w, h, ink }) {
|
|
|
1173
1176
|
while (q < chars.length && !chars[q].trim()) q++;
|
|
1174
1177
|
const glued = hangul ? chars[p] === "(" && chars[q] === "-" : /[가-힣]$/.test(_nullishCoalesce(chars[i - 1], () => ( ""))) || (_nullishCoalesce(chars[i + 1], () => ( ""))) === "." || chars[p] === "-" && chars[q] === "-";
|
|
1175
1178
|
if (!glued) continue;
|
|
1176
|
-
const n =
|
|
1179
|
+
const n = _chunkCKVPN66Tcjs.romanStems.call(void 0, gray, w, h, ink, p >= 0 ? cx(p) : -Infinity, q < chars.length ? cx(q) : Infinity, /[가-힣]$/.test(_nullishCoalesce(chars[p], () => ( ""))));
|
|
1177
1180
|
if (n) chars[i] = String.fromCharCode(8543 + n);
|
|
1178
1181
|
}
|
|
1179
1182
|
const inRoman = (i) => ROMAN.test(chars[i]) || chars[i] === "1" && (ROMAN.test(_nullishCoalesce(chars[i - 1], () => ( ""))) || ROMAN.test(_nullishCoalesce(chars[i + 1], () => ( ""))));
|
|
1180
1183
|
const k = chars.findIndex((c) => c.trim());
|
|
1181
1184
|
if (chars[k] === "." && chars.slice(k + 1).some((c) => /[가-힣A-Za-z0-9]/.test(c))) {
|
|
1182
|
-
const n =
|
|
1185
|
+
const n = _chunkCKVPN66Tcjs.romanStems.call(void 0, gray, w, h, ink, -Infinity, cx(k));
|
|
1183
1186
|
if (n) chars[k] = String.fromCharCode(8543 + n) + chars[k];
|
|
1184
1187
|
}
|
|
1185
1188
|
for (let s = 0; s < chars.length; ) {
|
|
@@ -1197,7 +1200,7 @@ function roman({ chars, cx, gray, w, h, ink }) {
|
|
|
1197
1200
|
let p = s - 1, q = e;
|
|
1198
1201
|
while (p >= 0 && !chars[p].trim()) p--;
|
|
1199
1202
|
while (q < chars.length && !chars[q].trim()) q++;
|
|
1200
|
-
const n =
|
|
1203
|
+
const n = _chunkCKVPN66Tcjs.romanStems.call(void 0, gray, w, h, ink, p >= 0 ? cx(p) : -Infinity, q < chars.length ? cx(q) : Infinity, /[가-힣]$/.test(_nullishCoalesce(chars[p], () => ( ""))));
|
|
1201
1204
|
const canon = n ? [["\u2160", "I"], ["\u2161", "II"], ["\u2162", "III"]][n - 1] : null;
|
|
1202
1205
|
if (canon && !canon.includes(tok)) {
|
|
1203
1206
|
chars[s] = canon[0];
|
|
@@ -1626,8 +1629,8 @@ function joinGapLeaders(rgba, width, items) {
|
|
|
1626
1629
|
if (g1 - g0 < h * 3) continue;
|
|
1627
1630
|
const pad = Math.round(h * 0.25), y = Math.max(0, Math.min(left.y, num.y) - pad), x = Math.max(0, Math.round(g0 - h));
|
|
1628
1631
|
const box = { x, y, w: Math.min(width, Math.round(g1 + h)) - x, h: Math.min(Math.floor(rgba.length / 4 / width), Math.max(left.y + left.h, num.y + num.h) + pad) - y };
|
|
1629
|
-
const gray =
|
|
1630
|
-
const runs =
|
|
1632
|
+
const gray = _chunkCKVPN66Tcjs.grayCrop.call(void 0, rgba, width, box);
|
|
1633
|
+
const runs = _chunkCKVPN66Tcjs.leaderRuns.call(void 0, gray, box.w, box.h, _chunkCKVPN66Tcjs.inkStats.call(void 0, gray), LEADER_MIN_DOTS);
|
|
1631
1634
|
const cover = runs.reduce((k, [a, b]) => k + Math.max(0, Math.min(b, g1 - box.x) - Math.max(a, g0 - box.x)), 0);
|
|
1632
1635
|
if (cover < (g1 - g0) * 0.6) continue;
|
|
1633
1636
|
for (const o of items) if (junk(o) && sameLine(o, num) && o.x >= g0 - 2 && o.x + o.w <= g1 + 2) gone.add(o);
|
|
@@ -1910,7 +1913,7 @@ var OcrEngine = class _OcrEngine {
|
|
|
1910
1913
|
this.ort = parts.ort;
|
|
1911
1914
|
this.sharp = parts.sharp;
|
|
1912
1915
|
}
|
|
1913
|
-
static async create(models =
|
|
1916
|
+
static async create(models = _chunkCKVPN66Tcjs.DEFAULT_OCR_MODELS) {
|
|
1914
1917
|
_chunkTK3FDAEEcjs.disableOrtTelemetry.call(void 0, );
|
|
1915
1918
|
const [ortMod, sharpModRaw] = await Promise.all([
|
|
1916
1919
|
tryImport("onnxruntime-node", () => Promise.resolve().then(() => _interopRequireWildcard(require("onnxruntime-node")))),
|
|
@@ -1930,16 +1933,16 @@ var OcrEngine = class _OcrEngine {
|
|
|
1930
1933
|
const local = (s) => "spec" in s ? Promise.resolve(null) : verifiedBytes(s);
|
|
1931
1934
|
const [detBytes, recBytes, dictBytes] = await Promise.all([local(models.det), local(models.rec), local(models.dict)]);
|
|
1932
1935
|
const session = (s, bytes) => bytes ? ortMod.InferenceSession.create(bytes, sessionOpts).catch(() => {
|
|
1933
|
-
throw new (0,
|
|
1934
|
-
}) : ortMod.InferenceSession.create(
|
|
1936
|
+
throw new (0, _chunkUP3KRRVNcjs.KordocError)(`OCR \uBAA8\uB378\uC744 \uC5F4\uC9C0 \uBABB\uD588\uC2B5\uB2C8\uB2E4: ${_path.basename.call(void 0, _chunkCKVPN66Tcjs.ocrSourcePath.call(void 0, s))} \u2014 ONNX \uBAA8\uB378\uC774 \uC544\uB2C8\uAC70\uB098 \uC190\uC0C1\uB410\uC2B5\uB2C8\uB2E4`);
|
|
1937
|
+
}) : ortMod.InferenceSession.create(_chunkCKVPN66Tcjs.ocrSourcePath.call(void 0, s), sessionOpts);
|
|
1935
1938
|
const [det, rec, dictYml] = await Promise.all([
|
|
1936
1939
|
session(models.det, detBytes),
|
|
1937
1940
|
session(models.rec, recBytes),
|
|
1938
|
-
dictBytes ? new TextDecoder().decode(dictBytes) : _promises.readFile.call(void 0,
|
|
1941
|
+
dictBytes ? new TextDecoder().decode(dictBytes) : _promises.readFile.call(void 0, _chunkCKVPN66Tcjs.ocrSourcePath.call(void 0, models.dict), "utf-8")
|
|
1939
1942
|
]);
|
|
1940
|
-
const dict =
|
|
1943
|
+
const dict = _chunkCKVPN66Tcjs.parseCharacterDict.call(void 0, dictYml);
|
|
1941
1944
|
if (dict.length === 0) {
|
|
1942
|
-
throw "spec" in models.dict ? new Error("OCR \uC0AC\uC804 \uD30C\uC2F1 \uC2E4\uD328 \u2014 \uBAA8\uB378 \uCE90\uC2DC\uB97C \uC0AD\uC81C \uD6C4 \uC7AC\uB2E4\uC6B4\uB85C\uB4DC\uD558\uC138\uC694") : new (0,
|
|
1945
|
+
throw "spec" in models.dict ? new Error("OCR \uC0AC\uC804 \uD30C\uC2F1 \uC2E4\uD328 \u2014 \uBAA8\uB378 \uCE90\uC2DC\uB97C \uC0AD\uC81C \uD6C4 \uC7AC\uB2E4\uC6B4\uB85C\uB4DC\uD558\uC138\uC694") : new (0, _chunkUP3KRRVNcjs.KordocError)(`OCR \uC0AC\uC804 \uD30C\uC2F1 \uC2E4\uD328 \u2014 ${_path.basename.call(void 0, models.dict.file.path)} \uC5D0 PostProcess.character_dict \uBAA9\uB85D\uC774 \uC5C6\uC2B5\uB2C8\uB2E4`);
|
|
1943
1946
|
}
|
|
1944
1947
|
return new _OcrEngine({ det, rec, dict, ort: ortMod, sharp: sharpMod });
|
|
1945
1948
|
}
|
|
@@ -1971,10 +1974,10 @@ var OcrEngine = class _OcrEngine {
|
|
|
1971
1974
|
if (it.x - x < it.h * 0.8) return;
|
|
1972
1975
|
if (items.some((o) => o !== it && o.x < it.x && o.x + o.w > x && o.y < it.y + it.h && o.y + o.h > it.y)) return;
|
|
1973
1976
|
const box = { x, y: it.y, w: it.x + it.w - x, h: it.h };
|
|
1974
|
-
const g =
|
|
1975
|
-
const b =
|
|
1977
|
+
const g = _chunkCKVPN66Tcjs.grayCrop.call(void 0, rgba, width, box);
|
|
1978
|
+
const b = _chunkCKVPN66Tcjs.leadingBullet.call(void 0, g, box.w, box.h, _chunkCKVPN66Tcjs.inkStats.call(void 0, g), it.x - x, 1.05);
|
|
1976
1979
|
if (_optionalChain([b, 'optionalAccess', _36 => _36.mark]) !== "\u25A1" || b.covers) return;
|
|
1977
|
-
const ink =
|
|
1980
|
+
const ink = _chunkCKVPN66Tcjs.inkStats.call(void 0, g), on = (v) => ink.darkInk ? v <= ink.threshold : v > ink.threshold;
|
|
1978
1981
|
let left = 0;
|
|
1979
1982
|
while (left < it.x - x && !Array.from({ length: box.h }, (_, y) => g[y * box.w + left]).some(on)) left++;
|
|
1980
1983
|
it.text = "\u25A1 " + it.text;
|
|
@@ -2006,12 +2009,12 @@ var OcrEngine = class _OcrEngine {
|
|
|
2006
2009
|
const joins = [];
|
|
2007
2010
|
let group = 0;
|
|
2008
2011
|
for (const b of boxes) {
|
|
2009
|
-
const gray =
|
|
2010
|
-
const ink =
|
|
2012
|
+
const gray = _chunkCKVPN66Tcjs.grayCrop.call(void 0, rgba, width, b);
|
|
2013
|
+
const ink = _chunkCKVPN66Tcjs.inkStats.call(void 0, gray);
|
|
2011
2014
|
if (tuning.minInkContrast > 0 && ink.contrast < tuning.minInkContrast) continue;
|
|
2012
2015
|
if (tuning.minInkContrast > 0 && ink.inkRatio < MIN_INK_RATIO) continue;
|
|
2013
2016
|
if (tuning.splitTall && b.h >= b.w * TALL_RATIO) {
|
|
2014
|
-
const bands =
|
|
2017
|
+
const bands = _chunkCKVPN66Tcjs.splitRowBands.call(void 0, gray, b.w, b.h, ink, 0.45);
|
|
2015
2018
|
if (bands.length >= 2) {
|
|
2016
2019
|
for (const sub of bandBoxes(b, bands, height)) jobs.push({ box: sub, rot: 0, group: group++ });
|
|
2017
2020
|
continue;
|
|
@@ -2035,9 +2038,9 @@ var OcrEngine = class _OcrEngine {
|
|
|
2035
2038
|
continue;
|
|
2036
2039
|
}
|
|
2037
2040
|
}
|
|
2038
|
-
const trim = tuning.trimEdges ?
|
|
2041
|
+
const trim = tuning.trimEdges ? _chunkCKVPN66Tcjs.edgeTrim.call(void 0, gray, b.w, b.h, ink) : null;
|
|
2039
2042
|
const keep = trim ? { ...trim, bg: median(gray) } : void 0;
|
|
2040
|
-
const leaders = tuning.splitLeaders ?
|
|
2043
|
+
const leaders = tuning.splitLeaders ? _chunkCKVPN66Tcjs.leaderRuns.call(void 0, gray, b.w, b.h, ink, LEADER_MIN_DOTS) : [];
|
|
2041
2044
|
if (leaders.length) {
|
|
2042
2045
|
const join = joins.length;
|
|
2043
2046
|
joins.push({ box: b, parts: [], trailDots: false });
|
|
@@ -2046,7 +2049,7 @@ var OcrEngine = class _OcrEngine {
|
|
|
2046
2049
|
const bare = { x: b.x + x0, y: b.y, w: a - x0, h: b.h };
|
|
2047
2050
|
const end = c > a ? Math.min(c, a + Math.round(b.h * LEADER_CONTEXT)) : a;
|
|
2048
2051
|
x0 = c;
|
|
2049
|
-
if (bare.w >= DET_MIN_SIZE &&
|
|
2052
|
+
if (bare.w >= DET_MIN_SIZE && _chunkCKVPN66Tcjs.inkStats.call(void 0, _chunkCKVPN66Tcjs.grayCrop.call(void 0, rgba, width, bare)).contrast >= Math.max(1, tuning.minInkContrast)) {
|
|
2050
2053
|
jobs.push({ box: { ...bare, w: end - (bare.x - b.x) }, rot: 0, group: group++, join, dotsBefore: dots, trimDots: end > a });
|
|
2051
2054
|
dots = false;
|
|
2052
2055
|
}
|
|
@@ -2095,15 +2098,15 @@ var OcrEngine = class _OcrEngine {
|
|
|
2095
2098
|
let text = tuning.postprocess ? restoreSymbols(raw.trim(), note.ringLead) : raw;
|
|
2096
2099
|
if (!text.trim()) continue;
|
|
2097
2100
|
if (tuning.postprocess && job.rot === 0 && text !== "/" && /^[(:;/)]+$/.test(text) && text.includes("/")) {
|
|
2098
|
-
const g =
|
|
2099
|
-
if (
|
|
2101
|
+
const g = _chunkCKVPN66Tcjs.grayCrop.call(void 0, rgba, width, job.box);
|
|
2102
|
+
if (_chunkCKVPN66Tcjs.tallInkCount.call(void 0, g, job.box.w, job.box.h, _chunkCKVPN66Tcjs.inkStats.call(void 0, g)) === 1) text = "/";
|
|
2100
2103
|
}
|
|
2101
2104
|
let ringByShape = false;
|
|
2102
2105
|
if (tuning.postprocess && job.rot === 0 && !/^[◎●▪□■▣❐❏○ㅇ◆◇◈]/.test(text)) {
|
|
2103
2106
|
const chars = [...read], k = chars.findIndex((c) => c.trim());
|
|
2104
2107
|
if (k >= 0 && steps.length === chars.length) {
|
|
2105
|
-
const g =
|
|
2106
|
-
const b =
|
|
2108
|
+
const g = _chunkCKVPN66Tcjs.grayCrop.call(void 0, rgba, width, job.box);
|
|
2109
|
+
const b = _chunkCKVPN66Tcjs.leadingBullet.call(void 0, g, job.box.w, job.box.h, _chunkCKVPN66Tcjs.inkStats.call(void 0, g), (steps[k] + 0.5) * stepPx);
|
|
2107
2110
|
const body = (_nullishCoalesce(text.match(/[가-힣]/g), () => ( []))).length >= 4;
|
|
2108
2111
|
const miss = /^[Oo0•·ㆍ∙‧○]/.test(text);
|
|
2109
2112
|
if (_optionalChain([b, 'optionalAccess', _39 => _39.mark]) === "\u25CE" && b.covers && /^[Oo0○©]/.test(text)) {
|
|
@@ -2118,17 +2121,17 @@ var OcrEngine = class _OcrEngine {
|
|
|
2118
2121
|
} else if (_optionalChain([b, 'optionalAccess', _46 => _46.mark]) === "\u2750" || _optionalChain([b, 'optionalAccess', _47 => _47.mark]) === "\u274F") {
|
|
2119
2122
|
if (b.covers ? /^[ㅁ口]/.test(text) : body) text = b.covers ? b.mark + text.slice(1) : b.mark + " " + text;
|
|
2120
2123
|
} else if (b && b.mark !== "\u25CE" && body) text = b.covers ? miss ? b.mark + " " + text.slice(1).trimStart() : text : b.mark + " " + text;
|
|
2121
|
-
else if (!b && body && /^[가-힣]/.test(chars[k]) &&
|
|
2124
|
+
else if (!b && body && /^[가-힣]/.test(chars[k]) && _chunkCKVPN66Tcjs.leadingRing.call(void 0, g, job.box.w, job.box.h, _chunkCKVPN66Tcjs.inkStats.call(void 0, g), (steps[k] + 0.5) * stepPx)) text = "\u25CB " + text;
|
|
2122
2125
|
}
|
|
2123
2126
|
}
|
|
2124
2127
|
if (tuning.postprocess && /^\d/.test(text) && job.rot === 0) {
|
|
2125
|
-
const g =
|
|
2126
|
-
const tri =
|
|
2128
|
+
const g = _chunkCKVPN66Tcjs.grayCrop.call(void 0, rgba, width, job.box);
|
|
2129
|
+
const tri = _chunkCKVPN66Tcjs.leadingTriangle.call(void 0, g, job.box.w, job.box.h, _chunkCKVPN66Tcjs.inkStats.call(void 0, g));
|
|
2127
2130
|
if (tri) text = tri + text;
|
|
2128
2131
|
}
|
|
2129
2132
|
if (tuning.postprocess && text === "\u2192" && job.rot === 0 && job.join === void 0) {
|
|
2130
|
-
const g =
|
|
2131
|
-
text = _nullishCoalesce(
|
|
2133
|
+
const g = _chunkCKVPN66Tcjs.grayCrop.call(void 0, rgba, width, job.box);
|
|
2134
|
+
text = _nullishCoalesce(_chunkCKVPN66Tcjs.arrowGlyph.call(void 0, g, job.box.w, job.box.h, _chunkCKVPN66Tcjs.inkStats.call(void 0, g)), () => ( text));
|
|
2132
2135
|
}
|
|
2133
2136
|
if (job.footer) {
|
|
2134
2137
|
if (!/^[-\u2013\u2014]?\s*(?:\d{1,4}|[ivxIVXⅰ-ⅹⅠ-Ⅹ]{1,4})\s*[-\u2013\u2014]?$/.test(text.trim())) continue;
|
|
@@ -2152,7 +2155,7 @@ var OcrEngine = class _OcrEngine {
|
|
|
2152
2155
|
continue;
|
|
2153
2156
|
}
|
|
2154
2157
|
const item = { text, ...this.itemBox(rgba, width, job.box, tuning), confidence };
|
|
2155
|
-
if (job.rot === 0)
|
|
2158
|
+
if (job.rot === 0) _chunkCKVPN66Tcjs.rememberOcrTextGaps.call(void 0, item, _chunkCKVPN66Tcjs.findOcrTextGaps.call(void 0, rgba, width, job.box, read, text, steps, stepPx));
|
|
2156
2159
|
if (job.rot === 0 && job.keep === void 0) boxOf.set(item, job.box);
|
|
2157
2160
|
items.push(item);
|
|
2158
2161
|
}
|
|
@@ -2166,7 +2169,7 @@ var OcrEngine = class _OcrEngine {
|
|
|
2166
2169
|
const merged = rereadNumberText(it.text, r.text);
|
|
2167
2170
|
if (merged === null) return;
|
|
2168
2171
|
it.text = merged;
|
|
2169
|
-
|
|
2172
|
+
_chunkCKVPN66Tcjs.rememberOcrTextGaps.call(void 0, it, _chunkCKVPN66Tcjs.findOcrTextGaps.call(void 0, rgba, width, boxOf.get(it), r.text, it.text, r.steps, r.stepPx));
|
|
2170
2173
|
});
|
|
2171
2174
|
}
|
|
2172
2175
|
const pairs = tuning.postprocess ? items.filter((it) => boxOf.has(it) && NUMBER_PAIR.test(it.text.trim())) : [];
|
|
@@ -2194,8 +2197,8 @@ var OcrEngine = class _OcrEngine {
|
|
|
2194
2197
|
const halves = [];
|
|
2195
2198
|
for (const it of tall) {
|
|
2196
2199
|
const b = boxOf.get(it);
|
|
2197
|
-
const gray =
|
|
2198
|
-
const cut = _nullishCoalesce(midBlankRow(gray, b.w, b.h,
|
|
2200
|
+
const gray = _chunkCKVPN66Tcjs.grayCrop.call(void 0, rgba, width, b);
|
|
2201
|
+
const cut = _nullishCoalesce(midBlankRow(gray, b.w, b.h, _chunkCKVPN66Tcjs.inkStats.call(void 0, gray)), () => ( valleyRow(gray, b.w, b.h, _chunkCKVPN66Tcjs.inkStats.call(void 0, gray))));
|
|
2199
2202
|
if (cut) halves.push({ it, top: { ...b, h: cut[0] }, bottom: { ...b, y: b.y + cut[1], h: b.h - cut[1] } });
|
|
2200
2203
|
}
|
|
2201
2204
|
const res = halves.length ? await this.recognizeJobs(rgba, width, halves.flatMap((hv, k) => [{ box: hv.top, rot: 0, group: 2 * k }, { box: hv.bottom, rot: 0, group: 2 * k + 1 }]), tuning.recBatch) : [];
|
|
@@ -2216,15 +2219,15 @@ var OcrEngine = class _OcrEngine {
|
|
|
2216
2219
|
const subs = [];
|
|
2217
2220
|
const stacks = [];
|
|
2218
2221
|
for (const b of [...retry, ...blank2]) {
|
|
2219
|
-
const gray =
|
|
2220
|
-
const ink =
|
|
2222
|
+
const gray = _chunkCKVPN66Tcjs.grayCrop.call(void 0, rgba, width, b);
|
|
2223
|
+
const ink = _chunkCKVPN66Tcjs.inkStats.call(void 0, gray);
|
|
2221
2224
|
const cut = retry.includes(b) ? midBlankRow(gray, b.w, b.h, ink) : null;
|
|
2222
2225
|
const inCell = cellRules.some((r) => r.x1 <= b.x + 2 && r.y1 <= b.y && r.y2 >= b.y + b.h) && cellRules.some((r) => r.x1 >= b.x + b.w - 2 && r.y1 <= b.y && r.y2 >= b.y + b.h);
|
|
2223
2226
|
if (cut && b.w >= (inCell ? 2 : 3) * Math.max(cut[0], b.h - cut[1])) {
|
|
2224
2227
|
subs.push({ ...b, h: cut[0] }, { ...b, y: b.y + cut[1], h: b.h - cut[1] });
|
|
2225
2228
|
continue;
|
|
2226
2229
|
}
|
|
2227
|
-
const bands =
|
|
2230
|
+
const bands = _chunkCKVPN66Tcjs.stackedGlyphBands.call(void 0, gray, b.w, b.h, ink);
|
|
2228
2231
|
if (bands) stacks.push({ box: b, parts: bandBoxes(b, bands, height), word: bands.every((x, i) => i === 0 || x.y0 - bands[i - 1].y1 <= STACK_WORD_GAP * Math.max(x.y1 - x.y0, bands[i - 1].y1 - bands[i - 1].y0)) });
|
|
2229
2232
|
}
|
|
2230
2233
|
const overlap = (a, o) => Math.max(0, Math.min(a.x + a.w, o.x + o.w) - Math.max(a.x, o.x)) * Math.max(0, Math.min(a.y + a.h, o.y + o.h) - Math.max(a.y, o.y));
|
|
@@ -2303,8 +2306,8 @@ var OcrEngine = class _OcrEngine {
|
|
|
2303
2306
|
/** 결과 좌표 — det 박스 그대로 또는 박스 안 잉크 외곽 (tightBoxes) */
|
|
2304
2307
|
itemBox(rgba, width, b, tuning) {
|
|
2305
2308
|
if (!tuning.tightBoxes) return b;
|
|
2306
|
-
const gray =
|
|
2307
|
-
const t =
|
|
2309
|
+
const gray = _chunkCKVPN66Tcjs.grayCrop.call(void 0, rgba, width, b);
|
|
2310
|
+
const t = _chunkCKVPN66Tcjs.inkBounds.call(void 0, gray, b.w, b.h, _chunkCKVPN66Tcjs.inkStats.call(void 0, gray));
|
|
2308
2311
|
return { x: b.x + t.x0, y: b.y + t.y0, w: t.x1 - t.x0, h: t.y1 - t.y0 };
|
|
2309
2312
|
}
|
|
2310
2313
|
// ─── det ─────────────────────────────────────────────
|
|
@@ -2375,7 +2378,7 @@ var OcrEngine = class _OcrEngine {
|
|
|
2375
2378
|
const out = await this.rec.run({ [this.rec.inputNames[0]]: tensor });
|
|
2376
2379
|
const logits = out[this.rec.outputNames[0]];
|
|
2377
2380
|
const [, T, C] = logits.dims;
|
|
2378
|
-
if (C !== this.dict.length + 2) throw new (0,
|
|
2381
|
+
if (C !== this.dict.length + 2) throw new (0, _chunkUP3KRRVNcjs.KordocError)(`OCR rec \uCD9C\uB825 \uD074\uB798\uC2A4 ${C}\uAC1C\uAC00 \uC0AC\uC804 ${this.dict.length}\uC790 + 2 \uC640 \uB2E4\uB985\uB2C8\uB2E4 \u2014 \uBAA8\uB378\uC5D0 \uB9DE\uB294 \uC0AC\uC804(ocrRecDict)\uC744 \uC9C0\uC815\uD558\uC138\uC694`);
|
|
2379
2382
|
const data = logits.data;
|
|
2380
2383
|
idx.forEach((ci, k) => {
|
|
2381
2384
|
const r = ctcDecode(data.subarray(k * T * C, (k + 1) * T * C), T, C, this.dict);
|
|
@@ -2385,9 +2388,9 @@ var OcrEngine = class _OcrEngine {
|
|
|
2385
2388
|
const chars = r ? [...r.text] : [];
|
|
2386
2389
|
if (r && job.rot === 0 && chars.length === r.steps.length && r.steps.some((t) => t > last) && !r.text.includes("(cid:")) {
|
|
2387
2390
|
const tallCh = (c) => !/[\s.,:;\u00b7\u2026'"\u2018-\u201d`\-_~]/.test(c);
|
|
2388
|
-
const g =
|
|
2391
|
+
const g = _chunkCKVPN66Tcjs.grayCrop.call(void 0, rgba, pageW, job.box);
|
|
2389
2392
|
const inside = chars.filter((c, i) => r.steps[i] <= last && tallCh(c)).length;
|
|
2390
|
-
let budget = inside <= 2 ?
|
|
2393
|
+
let budget = inside <= 2 ? _chunkCKVPN66Tcjs.tallInkCount.call(void 0, g, job.box.w, job.box.h, _chunkCKVPN66Tcjs.inkStats.call(void 0, g)) - inside : Infinity;
|
|
2391
2394
|
const keep = chars.map((c, i) => r.steps[i] <= last || !tallCh(c) || budget-- > 0);
|
|
2392
2395
|
if (!keep.every(Boolean)) kept = { ...r, text: chars.filter((_, i) => keep[i]).join(""), steps: r.steps.filter((_, i) => keep[i]) };
|
|
2393
2396
|
}
|
|
@@ -2498,13 +2501,13 @@ async function tryImport(name, loader) {
|
|
|
2498
2501
|
return await loader();
|
|
2499
2502
|
} catch (e) {
|
|
2500
2503
|
throw new Error(
|
|
2501
|
-
`\uB0B4\uC7A5 OCR \uC744 \uC0AC\uC6A9\uD558\uB824\uBA74 optional dependency '${name}' \uC774 \uD544\uC694\uD569\uB2C8\uB2E4. \`npm install ${name}\` \uD6C4 \uB2E4\uC2DC \uC2E4\uD589\uD558\uC138\uC694.${
|
|
2504
|
+
`\uB0B4\uC7A5 OCR \uC744 \uC0AC\uC6A9\uD558\uB824\uBA74 optional dependency '${name}' \uC774 \uD544\uC694\uD569\uB2C8\uB2E4. \`npm install ${name}\` \uD6C4 \uB2E4\uC2DC \uC2E4\uD589\uD558\uC138\uC694.${_chunkUP3KRRVNcjs.OPTIONAL_DEP_INSTALL_HINT} \uC6D0\uC778: ${e.message}`
|
|
2502
2505
|
);
|
|
2503
2506
|
}
|
|
2504
2507
|
}
|
|
2505
2508
|
async function verifiedBytes(s) {
|
|
2506
2509
|
const name = _path.basename.call(void 0, s.file.path);
|
|
2507
|
-
const fail = (why2) => new (0,
|
|
2510
|
+
const fail = (why2) => new (0, _chunkUP3KRRVNcjs.KordocError)(`OCR \uBAA8\uB378 \uD30C\uC77C\uC744 \uC77D\uC9C0 \uBABB\uD588\uC2B5\uB2C8\uB2E4: ${name} (${why2})`);
|
|
2508
2511
|
const why = (e) => {
|
|
2509
2512
|
const code = e.code;
|
|
2510
2513
|
return code === "ENOENT" ? "\uD30C\uC77C\uC774 \uC5C6\uC74C" : code === "EACCES" || code === "EPERM" ? "\uAD8C\uD55C \uC5C6\uC74C" : "\uC77D\uAE30 \uC2E4\uD328";
|
|
@@ -2525,13 +2528,13 @@ async function verifiedBytes(s) {
|
|
|
2525
2528
|
}
|
|
2526
2529
|
const actual = _crypto.createHash.call(void 0, "sha256").update(bytes).digest("hex");
|
|
2527
2530
|
if (actual !== s.file.sha256) {
|
|
2528
|
-
throw new (0,
|
|
2531
|
+
throw new (0, _chunkUP3KRRVNcjs.KordocError)(`OCR \uBAA8\uB378 SHA256 mismatch: ${_path.basename.call(void 0, s.file.path)} \u2014 expected ${s.file.sha256}, got ${actual} (\uB85C\uB4DC \uAC70\uBD80)`);
|
|
2529
2532
|
}
|
|
2530
2533
|
return bytes;
|
|
2531
2534
|
}
|
|
2532
2535
|
var engines = /* @__PURE__ */ new Map();
|
|
2533
|
-
function getOcrEngine(models =
|
|
2534
|
-
const key =
|
|
2536
|
+
function getOcrEngine(models = _chunkCKVPN66Tcjs.DEFAULT_OCR_MODELS) {
|
|
2537
|
+
const key = _chunkCKVPN66Tcjs.ocrSelectionKey.call(void 0, models);
|
|
2535
2538
|
let p = engines.get(key);
|
|
2536
2539
|
if (!p) {
|
|
2537
2540
|
p = OcrEngine.create(models).catch((err) => {
|
|
@@ -3007,20 +3010,20 @@ var REDETECT = { minDropped: 15, minShare: 0.15, scale: 5 / 3 };
|
|
|
3007
3010
|
var AUTO_REC = { pageConf: 0.9, gain: 0.06 };
|
|
3008
3011
|
var DEFAULT_AUTO_REC = { pageConf: 0.9, gain: 0.08, altConf: 0.95, sureGain: 0.1, minDiff: 0.08, minChars: 80, lazy: true };
|
|
3009
3012
|
var DEFAULT_BUILTIN_OCR = Object.freeze({
|
|
3010
|
-
models:
|
|
3013
|
+
models: _chunkCKVPN66Tcjs.DEFAULT_OCR_MODELS,
|
|
3011
3014
|
tuning: DEFAULT_OCR_TUNING,
|
|
3012
|
-
handwriting:
|
|
3015
|
+
handwriting: _chunkCKVPN66Tcjs.handwritingFallbackModels.call(void 0, _chunkCKVPN66Tcjs.DEFAULT_OCR_MODELS),
|
|
3013
3016
|
autoRec: DEFAULT_AUTO_REC
|
|
3014
3017
|
});
|
|
3015
3018
|
var DEFAULT_BUILTIN_OCR_FETCH = Object.freeze({ ...DEFAULT_BUILTIN_OCR, autoRec: { ...DEFAULT_AUTO_REC, fetch: true } });
|
|
3016
3019
|
function builtinOcrConfig(o) {
|
|
3017
3020
|
if (!o || o.ocrDet === void 0 && o.ocrDetLongSide === void 0 && o.ocrRec === void 0 && o.ocrRecDict === void 0 && !o.ocrLines) return _optionalChain([o, 'optionalAccess', _78 => _78.ocr]) ? DEFAULT_BUILTIN_OCR_FETCH : DEFAULT_BUILTIN_OCR;
|
|
3018
3021
|
const bad = _chunkMMK32GPDcjs.validateOcrOptions.call(void 0, o);
|
|
3019
|
-
if (bad) throw new (0,
|
|
3020
|
-
const models =
|
|
3022
|
+
if (bad) throw new (0, _chunkUP3KRRVNcjs.KordocError)(bad);
|
|
3023
|
+
const models = _chunkCKVPN66Tcjs.resolveOcrModels.call(void 0, o);
|
|
3021
3024
|
return {
|
|
3022
3025
|
models,
|
|
3023
|
-
...o.ocrRec === "auto" ? { handwriting:
|
|
3026
|
+
...o.ocrRec === "auto" ? { handwriting: _chunkCKVPN66Tcjs.handwritingFallbackModels.call(void 0, models), autoRec: AUTO_REC } : o.ocrRec === void 0 ? { handwriting: _chunkCKVPN66Tcjs.handwritingFallbackModels.call(void 0, models), autoRec: o.ocr ? { ...DEFAULT_AUTO_REC, fetch: true } : DEFAULT_AUTO_REC } : {},
|
|
3024
3027
|
tuning: o.ocrDetLongSide === void 0 ? DEFAULT_OCR_TUNING : { ...DEFAULT_OCR_TUNING, detLongSide: o.ocrDetLongSide },
|
|
3025
3028
|
lines: o.ocrLines === "all" ? "all" : o.ocrLines ? "kept" : void 0
|
|
3026
3029
|
};
|
|
@@ -3046,8 +3049,8 @@ async function withHandwritingRec(items, config, tuning, rgba, width, height, st
|
|
|
3046
3049
|
const altStats = { droppedLowConf: 0, ...stats.dropped ? { dropped: [] } : {} };
|
|
3047
3050
|
let alt;
|
|
3048
3051
|
try {
|
|
3049
|
-
if (auto.lazy && !auto.fetch && !await
|
|
3050
|
-
if (auto.lazy) await
|
|
3052
|
+
if (auto.lazy && !auto.fetch && !await _chunkCKVPN66Tcjs.ocrModelsCached.call(void 0, config.handwriting)) return items;
|
|
3053
|
+
if (auto.lazy) await _chunkCKVPN66Tcjs.ensureOcrModelsFor.call(void 0, config.handwriting, reportModelDownload);
|
|
3051
3054
|
alt = await (await getOcrEngine(config.handwriting)).recognizePage(rgba, width, height, altStats, tuning, cellRules, rowRules);
|
|
3052
3055
|
} catch (e) {
|
|
3053
3056
|
if (!auto.lazy) throw e;
|
|
@@ -3093,8 +3096,8 @@ async function runPdfOcr(buffer, targets, mode, warnings, onProgress, detectTabl
|
|
|
3093
3096
|
"@hyzyla/pdfium",
|
|
3094
3097
|
() => Promise.resolve().then(() => _interopRequireWildcard(require("@hyzyla/pdfium")))
|
|
3095
3098
|
);
|
|
3096
|
-
if (mode === "builtin") await
|
|
3097
|
-
if (mode === "builtin" && config.handwriting && !_optionalChain([config, 'access', _79 => _79.autoRec, 'optionalAccess', _80 => _80.lazy])) await
|
|
3099
|
+
if (mode === "builtin") await _chunkCKVPN66Tcjs.ensureOcrModelsFor.call(void 0, config.models, reportModelDownload);
|
|
3100
|
+
if (mode === "builtin" && config.handwriting && !_optionalChain([config, 'access', _79 => _79.autoRec, 'optionalAccess', _80 => _80.lazy])) await _chunkCKVPN66Tcjs.ensureOcrModelsFor.call(void 0, config.handwriting, reportModelDownload);
|
|
3098
3101
|
const engine = mode === "builtin" ? await getOcrEngine(config.models) : null;
|
|
3099
3102
|
const pdfium = await pdfiumMod.PDFiumLibrary.init();
|
|
3100
3103
|
const doc = await pdfium.loadDocument(new Uint8Array(buffer));
|
|
@@ -3207,7 +3210,7 @@ async function ocrOnePage(page, pageNo, mode, engine, warnings, detectTables, ve
|
|
|
3207
3210
|
const x1 = r.x1 * scale - 2, x2 = r.x2 * scale + 2, y1 = (pdfH - r.y2) * scale - 2, y2 = (pdfH - r.y1) * scale + 2;
|
|
3208
3211
|
const columnRules = _nullishCoalesce(_optionalChain([ruling, 'optionalAccess', _89 => _89.verticals, 'access', _90 => _90.filter, 'call', _91 => _91((s) => Math.min(s.x1, s.x2) >= x1 && Math.max(s.x1, s.x2) <= x2 && Math.min(s.y1, s.y2) >= y1 && Math.max(s.y1, s.y2) <= y2), 'access', _92 => _92.length]), () => ( 0));
|
|
3209
3212
|
if (columnRules < 2) {
|
|
3210
|
-
for (const b of blocks) if (b.type === "table")
|
|
3213
|
+
for (const b of blocks) if (b.type === "table") _chunkCKVPN66Tcjs.UNRULED_REGION_TABLES.add(b);
|
|
3211
3214
|
}
|
|
3212
3215
|
return blocks;
|
|
3213
3216
|
});
|
|
@@ -3279,7 +3282,7 @@ async function closerReads(rgba, rw, rh, pdfH, hi, regions, engine, tuning = REG
|
|
|
3279
3282
|
const items = await engine.recognizePage(crop, cw, ch, void 0, tuning);
|
|
3280
3283
|
out.push(items.map((it) => {
|
|
3281
3284
|
const placed = { ...it, x: (it.x + x0) / 2, y: (it.y + y0) / 2, w: it.w / 2, h: it.h / 2 };
|
|
3282
|
-
|
|
3285
|
+
_chunkCKVPN66Tcjs.copyOcrTextGaps.call(void 0, it, placed, 0.5, x0 / 2);
|
|
3283
3286
|
return placed;
|
|
3284
3287
|
}));
|
|
3285
3288
|
}
|
|
@@ -3371,7 +3374,7 @@ function ocrItemsToBlocks(items, pageNumber, pdfW, pdfH, scale, extraLines, dete
|
|
|
3371
3374
|
isHidden: false,
|
|
3372
3375
|
...xs[i].space ? { hasSpaceBefore: true } : {}
|
|
3373
3376
|
};
|
|
3374
|
-
|
|
3377
|
+
_chunkCKVPN66Tcjs.copyOcrTextGaps.call(void 0, it, normalized, 1 / scale);
|
|
3375
3378
|
return normalized;
|
|
3376
3379
|
}).filter((it) => it.text);
|
|
3377
3380
|
if (_optionalChain([extraLines, 'optionalAccess', _96 => _96.verticals, 'access', _97 => _97.length]) && items.length) {
|
|
@@ -3387,7 +3390,7 @@ function ocrItemsToBlocks(items, pageNumber, pdfW, pdfH, scale, extraLines, dete
|
|
|
3387
3390
|
})
|
|
3388
3391
|
};
|
|
3389
3392
|
}
|
|
3390
|
-
const laid = unframeOcrLayoutTables(splitOcrJoinedHeaders(splitOcrContactColumns(splitOcrNameValueColumns(splitStackedOcrRows(
|
|
3393
|
+
const laid = unframeOcrLayoutTables(splitOcrJoinedHeaders(splitOcrContactColumns(splitOcrNameValueColumns(splitStackedOcrRows(_chunkCKVPN66Tcjs.extractPageBlocksWithLines.call(void 0, norm, pageNumber, opList, pdfW, pdfH, extraLines, detectTables))))), pdfH);
|
|
3391
3394
|
const blocks = figureRegion ? laid : splitOcrProseRows(laid);
|
|
3392
3395
|
if (!figureRegion) markOcrHeadings(blocks);
|
|
3393
3396
|
return blocks;
|
|
@@ -3448,7 +3451,7 @@ async function tryImport2(name, loader) {
|
|
|
3448
3451
|
return await loader();
|
|
3449
3452
|
} catch (e) {
|
|
3450
3453
|
throw new Error(
|
|
3451
|
-
`OCR \uC744 \uC0AC\uC6A9\uD558\uB824\uBA74 optional dependency '${name}' \uC774 \uD544\uC694\uD569\uB2C8\uB2E4. \`npm install ${name}\` \uD6C4 \uB2E4\uC2DC \uC2E4\uD589\uD558\uC138\uC694.${
|
|
3454
|
+
`OCR \uC744 \uC0AC\uC6A9\uD558\uB824\uBA74 optional dependency '${name}' \uC774 \uD544\uC694\uD569\uB2C8\uB2E4. \`npm install ${name}\` \uD6C4 \uB2E4\uC2DC \uC2E4\uD589\uD558\uC138\uC694.${_chunkUP3KRRVNcjs.OPTIONAL_DEP_INSTALL_HINT} \uC6D0\uC778: ${e.message}`
|
|
3452
3455
|
);
|
|
3453
3456
|
}
|
|
3454
3457
|
}
|
|
@@ -3501,4 +3504,4 @@ function bgraToRgba(bgra) {
|
|
|
3501
3504
|
|
|
3502
3505
|
|
|
3503
3506
|
exports.rescueEmptyCells = rescueEmptyCells; exports.getOcrEngine = getOcrEngine; exports.detectRulingLines = detectRulingLines; exports.rulingToPdfLines = rulingToPdfLines; exports.deskewPage = deskewPage; exports.rotateQuarter = rotateQuarter; exports.MAX_OCR_PIXELS = MAX_OCR_PIXELS; exports.DEFAULT_BUILTIN_OCR = DEFAULT_BUILTIN_OCR; exports.builtinOcrConfig = builtinOcrConfig; exports.recognizeOcrPage = recognizeOcrPage; exports.reportModelDownload = reportModelDownload; exports.toOcrLine = toOcrLine; exports.pageLines = pageLines; exports.cellEdgeVerticals = cellEdgeVerticals; exports.cellEdgeHorizontals = cellEdgeHorizontals; exports.runPdfOcr = runPdfOcr; exports.ocrOnePage = ocrOnePage; exports.stretchFaintCrop = stretchFaintCrop; exports.groupOcrLines = groupOcrLines; exports.ocrItemsToBlocks = ocrItemsToBlocks; exports.markOcrHeadings = markOcrHeadings;
|
|
3504
|
-
//# sourceMappingURL=chunk-
|
|
3507
|
+
//# sourceMappingURL=chunk-ZLHHSW2T.cjs.map
|