kordoc 4.24.62 → 4.24.63
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/{-THTBNQ5Y.js → -JKJWVZ7E.js} +21 -21
- package/dist/{chunk-GO54TANI.js → chunk-3R4LS2QM.js} +57 -16
- package/dist/chunk-3R4LS2QM.js.map +1 -0
- package/dist/{chunk-JGQE6QI5.cjs → chunk-4J7PCDT5.cjs} +28 -3
- package/dist/chunk-4J7PCDT5.cjs.map +1 -0
- package/dist/{chunk-3GHNP4YF.js → chunk-55QH5LSM.js} +25 -7
- package/dist/chunk-55QH5LSM.js.map +1 -0
- package/dist/{chunk-JYM2MSUJ.js → chunk-7OBVSSAQ.js} +34 -7
- package/dist/chunk-7OBVSSAQ.js.map +1 -0
- package/dist/{chunk-FHUEJWZL.js → chunk-A73BTJH5.js} +4 -4
- package/dist/{chunk-5RRLMFPB.js → chunk-AKMBPYRU.js} +5 -5
- package/dist/{chunk-KQHO2DUH.js → chunk-B7JISVV7.js} +2 -2
- package/dist/{chunk-T52EPT77.js → chunk-BW2KS7VQ.js} +37 -10
- package/dist/chunk-BW2KS7VQ.js.map +1 -0
- package/dist/{chunk-YQ7SSNXP.cjs → chunk-CB365CYO.cjs} +109 -88
- package/dist/chunk-CB365CYO.cjs.map +1 -0
- package/dist/{chunk-GD4DHA2U.js → chunk-CD7YHKSF.js} +11 -11
- package/dist/{chunk-QQN4LZLX.js → chunk-CL2GZ7JO.js} +2 -2
- package/dist/{chunk-2KMS4LSR.js → chunk-DQEZVDKS.js} +27 -2
- package/dist/chunk-DQEZVDKS.js.map +1 -0
- package/dist/{chunk-WACUI2XZ.js → chunk-E3IGBNLD.js} +2 -2
- package/dist/{chunk-N2VSP3PP.js → chunk-FIKCNQ5Q.js} +2 -2
- package/dist/{chunk-VJZ6TVEG.js → chunk-FZNNNXEW.js} +5 -5
- package/dist/{chunk-OKUO5X5Z.js → chunk-HG6K7PDG.js} +2 -2
- package/dist/{chunk-Q3GESJGN.js → chunk-JCNNDOOW.js} +2 -2
- package/dist/{chunk-CGOWSDCT.cjs → chunk-JIH23K74.cjs} +58 -58
- package/dist/{chunk-CGOWSDCT.cjs.map → chunk-JIH23K74.cjs.map} +1 -1
- package/dist/{chunk-ULMPRHSC.js → chunk-JMYWAW2S.js} +7 -7
- package/dist/{chunk-X4DZCB3U.js → chunk-KWISIIRJ.js} +2 -2
- package/dist/{chunk-72JZ2QE2.cjs → chunk-MKH2CVD2.cjs} +3 -3
- package/dist/{chunk-72JZ2QE2.cjs.map → chunk-MKH2CVD2.cjs.map} +1 -1
- package/dist/{chunk-6RQWHFEZ.js → chunk-MQNJY7II.js} +2 -2
- package/dist/{chunk-CZAGX76E.js → chunk-NCI5VSUC.js} +2 -2
- package/dist/{chunk-XALE4HY2.js → chunk-PEDFVAXJ.js} +24 -3
- package/dist/chunk-PEDFVAXJ.js.map +1 -0
- package/dist/{chunk-6PQL2BGI.js → chunk-PTWPZYBM.js} +11 -11
- package/dist/{chunk-6PQL2BGI.js.map → chunk-PTWPZYBM.js.map} +1 -1
- package/dist/{chunk-UF6ZDIPI.js → chunk-Q2ZKAVNU.js} +25 -4
- package/dist/chunk-Q2ZKAVNU.js.map +1 -0
- package/dist/{chunk-UYO6HP4Z.js → chunk-ROHCAUUO.js} +3 -3
- package/dist/{chunk-EQWU5IAR.js → chunk-SPEEZYS4.js} +6 -6
- package/dist/{chunk-KPN4F3DO.cjs → chunk-SQT5Z35B.cjs} +25 -25
- package/dist/{chunk-KPN4F3DO.cjs.map → chunk-SQT5Z35B.cjs.map} +1 -1
- package/dist/{chunk-UC7KD3VI.js → chunk-SUMSKQ43.js} +2 -2
- package/dist/{chunk-6FFGCPG2.js → chunk-SUXFV3AL.js} +5 -5
- package/dist/{chunk-QGCSYIUV.js → chunk-TFEQHER2.js} +2 -2
- package/dist/{chunk-QGCSYIUV.js.map → chunk-TFEQHER2.js.map} +1 -1
- package/dist/{chunk-OWNA5FR2.js → chunk-UMF44YJH.js} +2 -2
- package/dist/{chunk-PI3R3KRN.js → chunk-UZDSVTD4.js} +2 -2
- package/dist/{chunk-PDYDMIHJ.cjs → chunk-WB4LZYGW.cjs} +129 -102
- package/dist/chunk-WB4LZYGW.cjs.map +1 -0
- package/dist/{chunk-KM6S5SKE.cjs → chunk-WDFJGFAH.cjs} +3 -3
- package/dist/{chunk-KM6S5SKE.cjs.map → chunk-WDFJGFAH.cjs.map} +1 -1
- package/dist/{chunk-DCY4MZWB.js → chunk-WIPBQVIK.js} +3 -3
- package/dist/{chunk-T472IK5V.js → chunk-X4PFJ3S3.js} +27 -2
- package/dist/chunk-X4PFJ3S3.js.map +1 -0
- package/dist/{chunk-DFEHSLNA.js → chunk-XABC4RKP.js} +2 -2
- package/dist/{chunk-QCT23BII.js → chunk-XIJH4QF7.js} +25 -7
- package/dist/chunk-XIJH4QF7.js.map +1 -0
- package/dist/{chunk-NVMLYTJ7.cjs → chunk-XYMBGOXH.cjs} +30 -12
- package/dist/chunk-XYMBGOXH.cjs.map +1 -0
- package/dist/{chunk-7U4KDW4H.js → chunk-YRMVLAYZ.js} +2 -2
- package/dist/{chunk-AA5M6DA2.js → chunk-ZVUZZFGY.js} +3 -3
- package/dist/chunks-XCTKHHQF.js +11 -0
- package/dist/cli.js +49 -46
- package/dist/cli.js.map +1 -1
- package/dist/{formula-6KWYDTHQ.js → formula-DNS3KV3C.js} +4 -4
- package/dist/{formula-IVEXGWTS.js → formula-VKUUIOIT.js} +3 -3
- package/dist/{formula-Y3YXFE2K.cjs → formula-WTTPNY2I.cjs} +9 -9
- package/dist/{formula-Y3YXFE2K.cjs.map → formula-WTTPNY2I.cjs.map} +1 -1
- package/dist/generator-B7BQ7GSG.js +11 -0
- package/dist/generator-NDQUC266.cjs +12 -0
- package/dist/{generator-2Y7IQWGL.cjs.map → generator-NDQUC266.cjs.map} +1 -1
- package/dist/generator-SBFQTDAS.js +18 -0
- package/dist/{hancom-ESZFNI2E.js → hancom-IBHKEOO5.js} +2 -2
- package/dist/{hancom-BNZ4RKKJ.cjs → hancom-JYQQYZPV.cjs} +5 -5
- package/dist/{hancom-BNZ4RKKJ.cjs.map → hancom-JYQQYZPV.cjs.map} +1 -1
- package/dist/{hancom-OGPHOPDG.js → hancom-QGPXR2US.js} +2 -2
- package/dist/{image-ocr-T3RZGPNO.js → image-ocr-6O6E6XIZ.js} +7 -7
- package/dist/{image-ocr-BPEHDIDO.cjs → image-ocr-OHVXCHWL.cjs} +28 -28
- package/dist/{image-ocr-BPEHDIDO.cjs.map → image-ocr-OHVXCHWL.cjs.map} +1 -1
- package/dist/{image-ocr-AOMJNQAY.js → image-ocr-TKWNXWUY.js} +10 -10
- package/dist/index.cjs +1163 -1124
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +50 -11
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +36 -36
- package/dist/memo-TRWRHDYB.js +17 -0
- package/dist/{model-bundle-XCNGV2TZ.js → model-bundle-ICW2B75K.js} +5 -5
- package/dist/{models-2RZY4GJP.js → models-ZIAOV7EN.js} +5 -5
- package/dist/{parse-worker-v2-A5KZLAJ2.js → parse-worker-v2-QBMUV2FV.js} +23 -22
- package/dist/parse-worker-v2-QBMUV2FV.js.map +1 -0
- package/dist/{parser-7FV3T72F.js → parser-7SXRUERF.js} +9 -9
- package/dist/{parser-5WN44OJ5.cjs → parser-FIVOMRFD.cjs} +166 -166
- package/dist/{parser-5WN44OJ5.cjs.map → parser-FIVOMRFD.cjs.map} +1 -1
- package/dist/{parser-L5CTEVGS.js → parser-IYDEYLT2.js} +12 -12
- package/dist/{pdf-ocr-26I4EGEK.js → pdf-ocr-L2FDPW4J.js} +9 -9
- package/dist/{pdf-ocr-ZOJBTE6Y.js → pdf-ocr-NJAOCNPW.js} +6 -6
- package/dist/pdf-ocr-YVLMXFYG.cjs +43 -0
- package/dist/{pdf-ocr-KZHIINRN.cjs.map → pdf-ocr-YVLMXFYG.cjs.map} +1 -1
- package/dist/{profile-io-MC6IUVMK.js → profile-io-ZFFUBVD7.js} +3 -3
- package/dist/{rasterize-GN2L3JMX.js → rasterize-73LPY77L.js} +3 -3
- package/dist/{redact-doc-MVQFRD2M.js → redact-doc-PMLOYY4I.js} +21 -21
- package/dist/{render-VILHFOHS.js → render-6IUG73FB.js} +12 -12
- package/dist/{rewrite-fallback-LMQ4LCUY.js → rewrite-fallback-MLILIZUH.js} +13 -13
- package/dist/seal-KDPRMM4D.js +16 -0
- package/dist/{setup-A5KRXMHQ.js → setup-GOFOC4YG.js} +3 -3
- package/dist/{to-hwpx-7DO3UM4O.js → to-hwpx-3LMSUQTA.js} +7 -7
- package/dist/to-hwpx-OPZN5DZY.cjs +16 -0
- package/dist/{to-hwpx-F3CYK3SQ.cjs.map → to-hwpx-OPZN5DZY.cjs.map} +1 -1
- package/dist/{to-hwpx-3ANHUBYN.js → to-hwpx-Y3MXBDML.js} +4 -4
- package/dist/visual-VI4WYIWM.js +38 -0
- package/dist/{watch-SQMT2LDX.js → watch-WHMWDPKY.js} +22 -22
- package/package.json +1 -1
- package/dist/chunk-2KMS4LSR.js.map +0 -1
- package/dist/chunk-3GHNP4YF.js.map +0 -1
- package/dist/chunk-GO54TANI.js.map +0 -1
- package/dist/chunk-JGQE6QI5.cjs.map +0 -1
- package/dist/chunk-JYM2MSUJ.js.map +0 -1
- package/dist/chunk-NVMLYTJ7.cjs.map +0 -1
- package/dist/chunk-PDYDMIHJ.cjs.map +0 -1
- package/dist/chunk-QCT23BII.js.map +0 -1
- package/dist/chunk-T472IK5V.js.map +0 -1
- package/dist/chunk-T52EPT77.js.map +0 -1
- package/dist/chunk-UF6ZDIPI.js.map +0 -1
- package/dist/chunk-XALE4HY2.js.map +0 -1
- package/dist/chunk-YQ7SSNXP.cjs.map +0 -1
- package/dist/chunks-ECKR45UF.js +0 -11
- package/dist/generator-2Y7IQWGL.cjs +0 -12
- package/dist/generator-B74MB4RN.js +0 -11
- package/dist/generator-LLV6FI2D.js +0 -18
- package/dist/memo-TIVIVQB3.js +0 -17
- package/dist/parse-worker-v2-A5KZLAJ2.js.map +0 -1
- package/dist/pdf-ocr-KZHIINRN.cjs +0 -43
- package/dist/seal-N4JZWLYT.js +0 -16
- package/dist/to-hwpx-F3CYK3SQ.cjs +0 -16
- package/dist/visual-46D6XVJE.js +0 -38
- /package/dist/{-THTBNQ5Y.js.map → -JKJWVZ7E.js.map} +0 -0
- /package/dist/{chunk-FHUEJWZL.js.map → chunk-A73BTJH5.js.map} +0 -0
- /package/dist/{chunk-5RRLMFPB.js.map → chunk-AKMBPYRU.js.map} +0 -0
- /package/dist/{chunk-KQHO2DUH.js.map → chunk-B7JISVV7.js.map} +0 -0
- /package/dist/{chunk-GD4DHA2U.js.map → chunk-CD7YHKSF.js.map} +0 -0
- /package/dist/{chunk-QQN4LZLX.js.map → chunk-CL2GZ7JO.js.map} +0 -0
- /package/dist/{chunk-WACUI2XZ.js.map → chunk-E3IGBNLD.js.map} +0 -0
- /package/dist/{chunk-N2VSP3PP.js.map → chunk-FIKCNQ5Q.js.map} +0 -0
- /package/dist/{chunk-VJZ6TVEG.js.map → chunk-FZNNNXEW.js.map} +0 -0
- /package/dist/{chunk-OKUO5X5Z.js.map → chunk-HG6K7PDG.js.map} +0 -0
- /package/dist/{chunk-Q3GESJGN.js.map → chunk-JCNNDOOW.js.map} +0 -0
- /package/dist/{chunk-ULMPRHSC.js.map → chunk-JMYWAW2S.js.map} +0 -0
- /package/dist/{chunk-X4DZCB3U.js.map → chunk-KWISIIRJ.js.map} +0 -0
- /package/dist/{chunk-6RQWHFEZ.js.map → chunk-MQNJY7II.js.map} +0 -0
- /package/dist/{chunk-CZAGX76E.js.map → chunk-NCI5VSUC.js.map} +0 -0
- /package/dist/{chunk-UYO6HP4Z.js.map → chunk-ROHCAUUO.js.map} +0 -0
- /package/dist/{chunk-EQWU5IAR.js.map → chunk-SPEEZYS4.js.map} +0 -0
- /package/dist/{chunk-UC7KD3VI.js.map → chunk-SUMSKQ43.js.map} +0 -0
- /package/dist/{chunk-6FFGCPG2.js.map → chunk-SUXFV3AL.js.map} +0 -0
- /package/dist/{chunk-OWNA5FR2.js.map → chunk-UMF44YJH.js.map} +0 -0
- /package/dist/{chunk-PI3R3KRN.js.map → chunk-UZDSVTD4.js.map} +0 -0
- /package/dist/{chunk-DCY4MZWB.js.map → chunk-WIPBQVIK.js.map} +0 -0
- /package/dist/{chunk-DFEHSLNA.js.map → chunk-XABC4RKP.js.map} +0 -0
- /package/dist/{chunk-7U4KDW4H.js.map → chunk-YRMVLAYZ.js.map} +0 -0
- /package/dist/{chunk-AA5M6DA2.js.map → chunk-ZVUZZFGY.js.map} +0 -0
- /package/dist/{chunks-ECKR45UF.js.map → chunks-XCTKHHQF.js.map} +0 -0
- /package/dist/{formula-6KWYDTHQ.js.map → formula-DNS3KV3C.js.map} +0 -0
- /package/dist/{formula-IVEXGWTS.js.map → formula-VKUUIOIT.js.map} +0 -0
- /package/dist/{generator-B74MB4RN.js.map → generator-B7BQ7GSG.js.map} +0 -0
- /package/dist/{generator-LLV6FI2D.js.map → generator-SBFQTDAS.js.map} +0 -0
- /package/dist/{hancom-ESZFNI2E.js.map → hancom-IBHKEOO5.js.map} +0 -0
- /package/dist/{hancom-OGPHOPDG.js.map → hancom-QGPXR2US.js.map} +0 -0
- /package/dist/{image-ocr-T3RZGPNO.js.map → image-ocr-6O6E6XIZ.js.map} +0 -0
- /package/dist/{image-ocr-AOMJNQAY.js.map → image-ocr-TKWNXWUY.js.map} +0 -0
- /package/dist/{memo-TIVIVQB3.js.map → memo-TRWRHDYB.js.map} +0 -0
- /package/dist/{model-bundle-XCNGV2TZ.js.map → model-bundle-ICW2B75K.js.map} +0 -0
- /package/dist/{models-2RZY4GJP.js.map → models-ZIAOV7EN.js.map} +0 -0
- /package/dist/{parser-7FV3T72F.js.map → parser-7SXRUERF.js.map} +0 -0
- /package/dist/{parser-L5CTEVGS.js.map → parser-IYDEYLT2.js.map} +0 -0
- /package/dist/{pdf-ocr-26I4EGEK.js.map → pdf-ocr-L2FDPW4J.js.map} +0 -0
- /package/dist/{pdf-ocr-ZOJBTE6Y.js.map → pdf-ocr-NJAOCNPW.js.map} +0 -0
- /package/dist/{profile-io-MC6IUVMK.js.map → profile-io-ZFFUBVD7.js.map} +0 -0
- /package/dist/{rasterize-GN2L3JMX.js.map → rasterize-73LPY77L.js.map} +0 -0
- /package/dist/{redact-doc-MVQFRD2M.js.map → redact-doc-PMLOYY4I.js.map} +0 -0
- /package/dist/{render-VILHFOHS.js.map → render-6IUG73FB.js.map} +0 -0
- /package/dist/{rewrite-fallback-LMQ4LCUY.js.map → rewrite-fallback-MLILIZUH.js.map} +0 -0
- /package/dist/{seal-N4JZWLYT.js.map → seal-KDPRMM4D.js.map} +0 -0
- /package/dist/{setup-A5KRXMHQ.js.map → setup-GOFOC4YG.js.map} +0 -0
- /package/dist/{to-hwpx-3ANHUBYN.js.map → to-hwpx-3LMSUQTA.js.map} +0 -0
- /package/dist/{to-hwpx-7DO3UM4O.js.map → to-hwpx-Y3MXBDML.js.map} +0 -0
- /package/dist/{visual-46D6XVJE.js.map → visual-VI4WYIWM.js.map} +0 -0
- /package/dist/{watch-SQMT2LDX.js.map → watch-WHMWDPKY.js.map} +0 -0
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
|
|
38
38
|
|
|
39
39
|
|
|
40
|
-
var
|
|
40
|
+
var _chunkSQT5Z35Bcjs = require('./chunk-SQT5Z35B.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 _chunk4J7PCDT5cjs = require('./chunk-4J7PCDT5.cjs');
|
|
54
54
|
|
|
55
55
|
// src/ocr/ocr-stacked-rows.ts
|
|
56
56
|
var NUMERIC = /^[-+−△▲▽▼]?[\d.,]+[%p원]?$|^[-–—·∼~]원?$|^\([-+−△▲▽▼]?[\d.,]+%?\)$/;
|
|
@@ -302,6 +302,7 @@ var FILL_FLAT_RATIO = 0.8;
|
|
|
302
302
|
var FILL_DIV_DELTA = 20;
|
|
303
303
|
var FILL_CHAIN_END_PT = 8;
|
|
304
304
|
var FILL_DIV_SIDE = 2;
|
|
305
|
+
var FILL_GAP_PT = 1.5;
|
|
305
306
|
function detectRulingLines(rgba, width, height, scale) {
|
|
306
307
|
const minLenPx = Math.round(MIN_LINE_LENGTH_PT * scale);
|
|
307
308
|
const maxThickPx = Math.max(1, Math.floor(MAX_LINE_WIDTH_PT * scale));
|
|
@@ -474,6 +475,26 @@ function detectRulingLines(rgba, width, height, scale) {
|
|
|
474
475
|
const depthPx = Math.round(FILL_MIN_DEPTH_PT * scale);
|
|
475
476
|
if (fill.verticals.some((v) => Math.abs(v.x1 - loose) <= tol * 2 && Math.abs(v.y1 - a.y1) <= tol * 2 && v.y2 - v.y1 >= depthPx * 4)) fillH.push({ ...a, x1: p.x1, x2: p.x2 });
|
|
476
477
|
}
|
|
478
|
+
const fillGap = Math.max(2, Math.round(FILL_GAP_PT * scale));
|
|
479
|
+
const sideV = [...inkV, ...fill.verticals];
|
|
480
|
+
const onV = (x, y) => sideV.some((v) => Math.abs(v.x1 - x) <= tol * 2 && v.y1 <= y + tol * 2 && v.y2 >= y - tol * 2);
|
|
481
|
+
for (const a of fill.horizontals) {
|
|
482
|
+
const b = fill.horizontals.find((b2) => b2 !== a && b2.y1 > a.y1 && b2.y1 - a.y1 <= fillGap * 2 && Math.abs(b2.x1 - a.x1) <= tol && Math.abs(b2.x2 - a.x2) <= tol);
|
|
483
|
+
if (!b || a.x2 - a.x1 < tol * 4) continue;
|
|
484
|
+
const y = (a.y1 + b.y1) / 2;
|
|
485
|
+
if (!onV(a.x1, y) || !onV(a.x2, y) || horizontals.some((h) => Math.abs(h.y1 - y) <= tol && h.x1 <= a.x1 + tol && h.x2 >= a.x2 - tol)) continue;
|
|
486
|
+
horizontals.push({ x1: a.x1, y1: y, x2: a.x2, y2: y, thicknessPx: 1 });
|
|
487
|
+
}
|
|
488
|
+
for (const p of ruleH) {
|
|
489
|
+
for (const side of [-1, 1]) {
|
|
490
|
+
const end = side < 0 ? p.x1 : p.x2;
|
|
491
|
+
const a = fill.horizontals.find((a2) => Math.abs(a2.y1 - p.y1) <= fillGap && Math.abs((side < 0 ? a2.x2 : a2.x1) - end) <= tol * 3 && a2.x2 - a2.x1 >= tol * 4);
|
|
492
|
+
if (!a) continue;
|
|
493
|
+
const far = side < 0 ? a.x1 : a.x2;
|
|
494
|
+
if (!onV(far, p.y1) || horizontals.some((h) => Math.abs(h.y1 - p.y1) <= tol && h.x1 <= Math.min(far, end) + tol && h.x2 >= Math.max(far, end) - tol)) continue;
|
|
495
|
+
horizontals.push({ ...p, x1: Math.min(far, end), x2: Math.max(far, end) });
|
|
496
|
+
}
|
|
497
|
+
}
|
|
477
498
|
horizontals.push(...fillH);
|
|
478
499
|
const edgeH = [...ruleH, ...fillH];
|
|
479
500
|
const depth = Math.round(FILL_MIN_DEPTH_PT * scale);
|
|
@@ -783,8 +804,8 @@ var INKLESS_DELTA = 32;
|
|
|
783
804
|
function ringAsks(rgba, pageW, box, text, steps, stepPx) {
|
|
784
805
|
const chars = [...text];
|
|
785
806
|
if (chars.length !== steps.length || !/[가-힣]/.test(text)) return [];
|
|
786
|
-
const gray =
|
|
787
|
-
const rings =
|
|
807
|
+
const gray = _chunkSQT5Z35Bcjs.grayCrop.call(void 0, rgba, pageW, box);
|
|
808
|
+
const rings = _chunkSQT5Z35Bcjs.ringBoxes.call(void 0, gray, box.w, box.h, _chunkSQT5Z35Bcjs.inkStats.call(void 0, gray));
|
|
788
809
|
const owner = ringOwners(chars, (i) => (steps[i] + 0.5) * stepPx, rings);
|
|
789
810
|
return rings.flatMap((r, k) => {
|
|
790
811
|
const at = owner.indexOf(k);
|
|
@@ -824,8 +845,8 @@ function ringGlyph(read, jamo = null, confidence = 1) {
|
|
|
824
845
|
function restoreGlyphs(rgba, pageW, box, text, steps, stepPx, note = {}, rings = []) {
|
|
825
846
|
const chars = [...text];
|
|
826
847
|
if (chars.length !== steps.length) return text;
|
|
827
|
-
const gray =
|
|
828
|
-
const c = { chars, cx: (i) => (steps[i] + 0.5) * stepPx, gray, w: box.w, h: box.h, ink:
|
|
848
|
+
const gray = _chunkSQT5Z35Bcjs.grayCrop.call(void 0, rgba, pageW, box);
|
|
849
|
+
const c = { chars, cx: (i) => (steps[i] + 0.5) * stepPx, gray, w: box.w, h: box.h, ink: _chunkSQT5Z35Bcjs.inkStats.call(void 0, gray) };
|
|
829
850
|
if (/[[\]]/.test(text)) brackets(c);
|
|
830
851
|
if (text.includes("'")) cornerQuotes(c);
|
|
831
852
|
if (/['"]/.test(text)) quotes(c);
|
|
@@ -855,7 +876,7 @@ function restoreGlyphs(rgba, pageW, box, text, steps, stepPx, note = {}, rings =
|
|
|
855
876
|
function trimInklessEnds(rgba, pageW, box, text, steps, stepPx) {
|
|
856
877
|
const chars = [...text], { w, h } = box;
|
|
857
878
|
if (chars.length !== steps.length || steps.some((s) => (s + 0.5) * stepPx > w + stepPx)) return { text, steps };
|
|
858
|
-
const gray =
|
|
879
|
+
const gray = _chunkSQT5Z35Bcjs.grayCrop.call(void 0, rgba, pageW, box);
|
|
859
880
|
const hist = new Uint32Array(256);
|
|
860
881
|
for (const v of gray) hist[v]++;
|
|
861
882
|
let bg = 0;
|
|
@@ -886,8 +907,8 @@ function cornerCommas({ chars, cx, gray, w, h, ink }) {
|
|
|
886
907
|
continue;
|
|
887
908
|
}
|
|
888
909
|
if (open > 0) {
|
|
889
|
-
const f =
|
|
890
|
-
if (f &&
|
|
910
|
+
const f = _chunkSQT5Z35Bcjs.bracketFeatures.call(void 0, gray, w, h, ink, cx(i));
|
|
911
|
+
if (f && _chunkSQT5Z35Bcjs.bracketShape.call(void 0, f, true) === "\u300D") {
|
|
891
912
|
chars[i] = "\u300D";
|
|
892
913
|
open--;
|
|
893
914
|
}
|
|
@@ -897,12 +918,12 @@ function cornerCommas({ chars, cx, gray, w, h, ink }) {
|
|
|
897
918
|
function cornerQuotes({ chars, cx, gray, w, h, ink }) {
|
|
898
919
|
for (let i = 0; i < chars.length; i++) {
|
|
899
920
|
if (chars[i] !== "'" || !/^[가-힣]/.test(_nullishCoalesce(chars[i + 1], () => ( "")))) continue;
|
|
900
|
-
const f =
|
|
901
|
-
if (!f || f.ch < f.charH * 0.45 ||
|
|
921
|
+
const f = _chunkSQT5Z35Bcjs.bracketFeatures.call(void 0, gray, w, h, ink, cx(i));
|
|
922
|
+
if (!f || f.ch < f.charH * 0.45 || _chunkSQT5Z35Bcjs.bracketShape.call(void 0, f, false) !== "\u300C") continue;
|
|
902
923
|
const rest = chars.slice(i + 1), end = rest.findIndex((c) => c === "'" || c === "\u300D" || c === ",");
|
|
903
924
|
const pair = end >= 0 && rest[end] !== "'" && (rest[end] === "\u300D" || (() => {
|
|
904
|
-
const g =
|
|
905
|
-
return !!g &&
|
|
925
|
+
const g = _chunkSQT5Z35Bcjs.bracketFeatures.call(void 0, gray, w, h, ink, cx(i + 1 + end));
|
|
926
|
+
return !!g && _chunkSQT5Z35Bcjs.bracketShape.call(void 0, g, true) === "\u300D";
|
|
906
927
|
})());
|
|
907
928
|
if (pair) chars[i] = "\u300C";
|
|
908
929
|
}
|
|
@@ -910,8 +931,8 @@ function cornerQuotes({ chars, cx, gray, w, h, ink }) {
|
|
|
910
931
|
function brackets({ chars, cx, gray, w, h, ink }) {
|
|
911
932
|
const shape = chars.map((c, i) => {
|
|
912
933
|
if (c !== "[" && c !== "]") return null;
|
|
913
|
-
const f =
|
|
914
|
-
return f &&
|
|
934
|
+
const f = _chunkSQT5Z35Bcjs.bracketFeatures.call(void 0, gray, w, h, ink, cx(i));
|
|
935
|
+
return f && _chunkSQT5Z35Bcjs.bracketShape.call(void 0, f, c === "]");
|
|
915
936
|
});
|
|
916
937
|
for (let i = 0; i < chars.length; i++) {
|
|
917
938
|
if (chars[i] !== "[") continue;
|
|
@@ -943,7 +964,7 @@ function quotes({ chars, cx, gray, w, h, ink }) {
|
|
|
943
964
|
continue;
|
|
944
965
|
}
|
|
945
966
|
if (!year(i) && !single[kind]) continue;
|
|
946
|
-
const r =
|
|
967
|
+
const r = _chunkSQT5Z35Bcjs.quoteHead.call(void 0, gray, w, h, ink, cx(i));
|
|
947
968
|
if (r !== null && r >= 0.47) {
|
|
948
969
|
chars[i] = kind === "'" ? "\u2018" : "\u201C";
|
|
949
970
|
open[kind] = true;
|
|
@@ -954,7 +975,7 @@ function dashes({ chars, cx, gray, w, h, ink }) {
|
|
|
954
975
|
const head = chars.findIndex((c) => c.trim()), letters = chars.some((c) => /[가-힣A-Za-z]/.test(c));
|
|
955
976
|
for (let i = 0; i < chars.length; i++) {
|
|
956
977
|
if (!/^[-\u2013\u2014]$/.test(chars[i])) continue;
|
|
957
|
-
const r =
|
|
978
|
+
const r = _chunkSQT5Z35Bcjs.dashRatio.call(void 0, gray, w, h, ink, cx(i));
|
|
958
979
|
if (r === null) continue;
|
|
959
980
|
if (r < 0.65) chars[i] = "-";
|
|
960
981
|
else if (r > 0.75 && i === head && letters) chars[i] = "\u2014";
|
|
@@ -964,7 +985,7 @@ function circled({ chars, cx, gray, w, h, ink }) {
|
|
|
964
985
|
const alone = (re, i) => re.test(chars[i]) && !re.test(_nullishCoalesce(chars[i - 1], () => ( ""))) && !re.test(_nullishCoalesce(chars[i + 1], () => ( "")));
|
|
965
986
|
const at = chars.flatMap((_, i) => alone(/^\d$/, i) && chars[i] !== "0" || alone(/^[ㄱ-ㅎ]$/, i) || alone(/^[A-Za-z]$/, i) && /[a-zCSUVWXZ]/.test(chars[i]) ? [i] : []);
|
|
966
987
|
if (!at.length) return;
|
|
967
|
-
const hit =
|
|
988
|
+
const hit = _chunkSQT5Z35Bcjs.circledAt.call(void 0, gray, w, h, ink, at.map(cx));
|
|
968
989
|
const JAMO = "\u3131\u3134\u3137\u3139\u3141\u3142\u3145\u3147\u3148\u314A\u314B\u314C\u314D\u314E";
|
|
969
990
|
at.forEach((i, k) => {
|
|
970
991
|
if (!hit[k]) return;
|
|
@@ -977,16 +998,16 @@ function stars({ chars, cx, gray, w, h, ink }) {
|
|
|
977
998
|
if (chars[i] !== "*" || chars[i - 1] === "*") continue;
|
|
978
999
|
let e = i;
|
|
979
1000
|
while (chars[e + 1] === "*") e++;
|
|
980
|
-
const n =
|
|
1001
|
+
const n = _chunkSQT5Z35Bcjs.starRun.call(void 0, gray, w, h, ink, cx(i));
|
|
981
1002
|
if (n > e - i + 1 && n <= 4) chars[e] += "*".repeat(n - (e - i + 1));
|
|
982
1003
|
i = e;
|
|
983
1004
|
}
|
|
984
1005
|
}
|
|
985
1006
|
function discs({ chars, cx, gray, w, h, ink }) {
|
|
986
|
-
for (let i = 0; i < chars.length; i++) if (/^[\u00b7\u2022]$/.test(chars[i]) &&
|
|
1007
|
+
for (let i = 0; i < chars.length; i++) if (/^[\u00b7\u2022]$/.test(chars[i]) && _chunkSQT5Z35Bcjs.discAt.call(void 0, gray, w, h, ink, cx(i))) chars[i] = "\u25CF";
|
|
987
1008
|
}
|
|
988
1009
|
function gaps({ chars, cx, gray, w, h, ink }) {
|
|
989
|
-
const { glyphs, bandH } =
|
|
1010
|
+
const { glyphs, bandH } = _chunkSQT5Z35Bcjs.gapGlyphs.call(void 0, gray, w, h, ink);
|
|
990
1011
|
if (!glyphs.length) return;
|
|
991
1012
|
const live = chars.map((c, i) => i).filter((i) => chars[i].trim());
|
|
992
1013
|
if (!live.length) return;
|
|
@@ -1057,18 +1078,18 @@ function ring({ chars, cx, gray, w, h, ink }) {
|
|
|
1057
1078
|
const rest = chars.slice(k + 1).join("").trimStart();
|
|
1058
1079
|
const live = chars.map((c, i) => i).filter((i) => chars[i].trim());
|
|
1059
1080
|
if (live.length <= 3 && live.every((i) => /^[Oo]$/.test(chars[i]))) {
|
|
1060
|
-
if (_optionalChain([
|
|
1061
|
-
if (!live.every((i) =>
|
|
1081
|
+
if (_optionalChain([_chunkSQT5Z35Bcjs.leadingBullet.call(void 0, gray, w, h, ink, cx(live[0])), 'optionalAccess', _11 => _11.mark]) === "\u25CE") return false;
|
|
1082
|
+
if (!live.every((i) => _chunkSQT5Z35Bcjs.ringBullet.call(void 0, gray, w, h, ink, cx(i)) === "\u25CB")) return false;
|
|
1062
1083
|
for (const i of live) chars[i] = "\u25CB";
|
|
1063
1084
|
return true;
|
|
1064
1085
|
}
|
|
1065
1086
|
if (/^[A-Z]{2,}/.test(rest) && /^[Oo0]$/.test(chars[k])) {
|
|
1066
|
-
if (
|
|
1087
|
+
if (_chunkSQT5Z35Bcjs.ringBullet.call(void 0, gray, w, h, ink, cx(k)) !== "\u25CB") return false;
|
|
1067
1088
|
chars[k] = chars[k + 1] === " " ? "\u25CB" : "\u25CB ";
|
|
1068
1089
|
return true;
|
|
1069
1090
|
}
|
|
1070
1091
|
if (!/^[(\[「【<]?\d*[가-힣]/.test(rest)) return false;
|
|
1071
|
-
const r =
|
|
1092
|
+
const r = _chunkSQT5Z35Bcjs.ringBullet.call(void 0, gray, w, h, ink, cx(k));
|
|
1072
1093
|
if (/^[Cc]$/.test(chars[k]) && r !== "\u25CB") return false;
|
|
1073
1094
|
if (r) chars[k] = r;
|
|
1074
1095
|
return r !== null;
|
|
@@ -1085,7 +1106,7 @@ function parallels({ chars, cx, gray, w, h, ink }) {
|
|
|
1085
1106
|
let p = s - 1, q = e + 1;
|
|
1086
1107
|
while (p >= 0 && !chars[p].trim()) p--;
|
|
1087
1108
|
while (q < chars.length && !chars[q].trim()) q++;
|
|
1088
|
-
if (
|
|
1109
|
+
if (_chunkSQT5Z35Bcjs.slantedPair.call(void 0, gray, w, h, ink, p >= 0 ? cx(p) : -Infinity, q < chars.length ? cx(q) : Infinity)) {
|
|
1089
1110
|
chars[s] = "\u2225";
|
|
1090
1111
|
for (let k = s + 1; k <= e; k++) chars[k] = "";
|
|
1091
1112
|
}
|
|
@@ -1097,7 +1118,7 @@ function roman({ chars, cx, gray, w, h, ink }) {
|
|
|
1097
1118
|
const ROMAN = /^[IⅠ-Ⅲ]$/, LATIN = /[A-Za-z]$/;
|
|
1098
1119
|
for (let i = 0; i < chars.length; i++) {
|
|
1099
1120
|
if (chars[i] !== "1" || /[\dA-Za-z]$/.test(_nullishCoalesce(chars[i - 1], () => ( ""))) || /^[\dA-Za-z,]/.test(_nullishCoalesce(chars[i + 1], () => ( "")))) continue;
|
|
1100
|
-
if (
|
|
1121
|
+
if (_chunkSQT5Z35Bcjs.serifOne.call(void 0, gray, w, h, ink, cx(i))) chars[i] = "\u2160";
|
|
1101
1122
|
}
|
|
1102
1123
|
for (let i = 0; i < chars.length; i++) {
|
|
1103
1124
|
const hangul = /^[파피]$/.test(chars[i]);
|
|
@@ -1107,13 +1128,13 @@ function roman({ chars, cx, gray, w, h, ink }) {
|
|
|
1107
1128
|
while (q < chars.length && !chars[q].trim()) q++;
|
|
1108
1129
|
const glued = hangul ? chars[p] === "(" && chars[q] === "-" : /[가-힣]$/.test(_nullishCoalesce(chars[i - 1], () => ( ""))) || (_nullishCoalesce(chars[i + 1], () => ( ""))) === "." || chars[p] === "-" && chars[q] === "-";
|
|
1109
1130
|
if (!glued) continue;
|
|
1110
|
-
const n =
|
|
1131
|
+
const n = _chunkSQT5Z35Bcjs.romanStems.call(void 0, gray, w, h, ink, p >= 0 ? cx(p) : -Infinity, q < chars.length ? cx(q) : Infinity, /[가-힣]$/.test(_nullishCoalesce(chars[p], () => ( ""))));
|
|
1111
1132
|
if (n) chars[i] = String.fromCharCode(8543 + n);
|
|
1112
1133
|
}
|
|
1113
1134
|
const inRoman = (i) => ROMAN.test(chars[i]) || chars[i] === "1" && (ROMAN.test(_nullishCoalesce(chars[i - 1], () => ( ""))) || ROMAN.test(_nullishCoalesce(chars[i + 1], () => ( ""))));
|
|
1114
1135
|
const k = chars.findIndex((c) => c.trim());
|
|
1115
1136
|
if (chars[k] === "." && chars.slice(k + 1).some((c) => /[가-힣A-Za-z0-9]/.test(c))) {
|
|
1116
|
-
const n =
|
|
1137
|
+
const n = _chunkSQT5Z35Bcjs.romanStems.call(void 0, gray, w, h, ink, -Infinity, cx(k));
|
|
1117
1138
|
if (n) chars[k] = String.fromCharCode(8543 + n) + chars[k];
|
|
1118
1139
|
}
|
|
1119
1140
|
for (let s = 0; s < chars.length; ) {
|
|
@@ -1131,7 +1152,7 @@ function roman({ chars, cx, gray, w, h, ink }) {
|
|
|
1131
1152
|
let p = s - 1, q = e;
|
|
1132
1153
|
while (p >= 0 && !chars[p].trim()) p--;
|
|
1133
1154
|
while (q < chars.length && !chars[q].trim()) q++;
|
|
1134
|
-
const n =
|
|
1155
|
+
const n = _chunkSQT5Z35Bcjs.romanStems.call(void 0, gray, w, h, ink, p >= 0 ? cx(p) : -Infinity, q < chars.length ? cx(q) : Infinity, /[가-힣]$/.test(_nullishCoalesce(chars[p], () => ( ""))));
|
|
1135
1156
|
const canon = n ? [["\u2160", "I"], ["\u2161", "II"], ["\u2162", "III"]][n - 1] : null;
|
|
1136
1157
|
if (canon && !canon.includes(tok)) {
|
|
1137
1158
|
chars[s] = canon[0];
|
|
@@ -1560,8 +1581,8 @@ function joinGapLeaders(rgba, width, items) {
|
|
|
1560
1581
|
if (g1 - g0 < h * 3) continue;
|
|
1561
1582
|
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));
|
|
1562
1583
|
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 };
|
|
1563
|
-
const gray =
|
|
1564
|
-
const runs =
|
|
1584
|
+
const gray = _chunkSQT5Z35Bcjs.grayCrop.call(void 0, rgba, width, box);
|
|
1585
|
+
const runs = _chunkSQT5Z35Bcjs.leaderRuns.call(void 0, gray, box.w, box.h, _chunkSQT5Z35Bcjs.inkStats.call(void 0, gray), LEADER_MIN_DOTS);
|
|
1565
1586
|
const cover = runs.reduce((k, [a, b]) => k + Math.max(0, Math.min(b, g1 - box.x) - Math.max(a, g0 - box.x)), 0);
|
|
1566
1587
|
if (cover < (g1 - g0) * 0.6) continue;
|
|
1567
1588
|
for (const o of items) if (junk(o) && sameLine(o, num) && o.x >= g0 - 2 && o.x + o.w <= g1 + 2) gone.add(o);
|
|
@@ -1844,7 +1865,7 @@ var OcrEngine = class _OcrEngine {
|
|
|
1844
1865
|
this.ort = parts.ort;
|
|
1845
1866
|
this.sharp = parts.sharp;
|
|
1846
1867
|
}
|
|
1847
|
-
static async create(models =
|
|
1868
|
+
static async create(models = _chunkSQT5Z35Bcjs.DEFAULT_OCR_MODELS) {
|
|
1848
1869
|
_chunkTK3FDAEEcjs.disableOrtTelemetry.call(void 0, );
|
|
1849
1870
|
const [ortMod, sharpModRaw] = await Promise.all([
|
|
1850
1871
|
tryImport("onnxruntime-node", () => Promise.resolve().then(() => _interopRequireWildcard(require("onnxruntime-node")))),
|
|
@@ -1864,16 +1885,16 @@ var OcrEngine = class _OcrEngine {
|
|
|
1864
1885
|
const local = (s) => "spec" in s ? Promise.resolve(null) : verifiedBytes(s);
|
|
1865
1886
|
const [detBytes, recBytes, dictBytes] = await Promise.all([local(models.det), local(models.rec), local(models.dict)]);
|
|
1866
1887
|
const session = (s, bytes) => bytes ? ortMod.InferenceSession.create(bytes, sessionOpts).catch(() => {
|
|
1867
|
-
throw new (0,
|
|
1868
|
-
}) : ortMod.InferenceSession.create(
|
|
1888
|
+
throw new (0, _chunk4J7PCDT5cjs.KordocError)(`OCR \uBAA8\uB378\uC744 \uC5F4\uC9C0 \uBABB\uD588\uC2B5\uB2C8\uB2E4: ${_path.basename.call(void 0, _chunkSQT5Z35Bcjs.ocrSourcePath.call(void 0, s))} \u2014 ONNX \uBAA8\uB378\uC774 \uC544\uB2C8\uAC70\uB098 \uC190\uC0C1\uB410\uC2B5\uB2C8\uB2E4`);
|
|
1889
|
+
}) : ortMod.InferenceSession.create(_chunkSQT5Z35Bcjs.ocrSourcePath.call(void 0, s), sessionOpts);
|
|
1869
1890
|
const [det, rec, dictYml] = await Promise.all([
|
|
1870
1891
|
session(models.det, detBytes),
|
|
1871
1892
|
session(models.rec, recBytes),
|
|
1872
|
-
dictBytes ? new TextDecoder().decode(dictBytes) : _promises.readFile.call(void 0,
|
|
1893
|
+
dictBytes ? new TextDecoder().decode(dictBytes) : _promises.readFile.call(void 0, _chunkSQT5Z35Bcjs.ocrSourcePath.call(void 0, models.dict), "utf-8")
|
|
1873
1894
|
]);
|
|
1874
|
-
const dict =
|
|
1895
|
+
const dict = _chunkSQT5Z35Bcjs.parseCharacterDict.call(void 0, dictYml);
|
|
1875
1896
|
if (dict.length === 0) {
|
|
1876
|
-
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,
|
|
1897
|
+
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, _chunk4J7PCDT5cjs.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`);
|
|
1877
1898
|
}
|
|
1878
1899
|
return new _OcrEngine({ det, rec, dict, ort: ortMod, sharp: sharpMod });
|
|
1879
1900
|
}
|
|
@@ -1905,10 +1926,10 @@ var OcrEngine = class _OcrEngine {
|
|
|
1905
1926
|
if (it.x - x < it.h * 0.8) return;
|
|
1906
1927
|
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;
|
|
1907
1928
|
const box = { x, y: it.y, w: it.x + it.w - x, h: it.h };
|
|
1908
|
-
const g =
|
|
1909
|
-
const b =
|
|
1929
|
+
const g = _chunkSQT5Z35Bcjs.grayCrop.call(void 0, rgba, width, box);
|
|
1930
|
+
const b = _chunkSQT5Z35Bcjs.leadingBullet.call(void 0, g, box.w, box.h, _chunkSQT5Z35Bcjs.inkStats.call(void 0, g), it.x - x, 1.05);
|
|
1910
1931
|
if (_optionalChain([b, 'optionalAccess', _36 => _36.mark]) !== "\u25A1" || b.covers) return;
|
|
1911
|
-
const ink =
|
|
1932
|
+
const ink = _chunkSQT5Z35Bcjs.inkStats.call(void 0, g), on = (v) => ink.darkInk ? v <= ink.threshold : v > ink.threshold;
|
|
1912
1933
|
let left = 0;
|
|
1913
1934
|
while (left < it.x - x && !Array.from({ length: box.h }, (_, y) => g[y * box.w + left]).some(on)) left++;
|
|
1914
1935
|
it.text = "\u25A1 " + it.text;
|
|
@@ -1940,12 +1961,12 @@ var OcrEngine = class _OcrEngine {
|
|
|
1940
1961
|
const joins = [];
|
|
1941
1962
|
let group = 0;
|
|
1942
1963
|
for (const b of boxes) {
|
|
1943
|
-
const gray =
|
|
1944
|
-
const ink =
|
|
1964
|
+
const gray = _chunkSQT5Z35Bcjs.grayCrop.call(void 0, rgba, width, b);
|
|
1965
|
+
const ink = _chunkSQT5Z35Bcjs.inkStats.call(void 0, gray);
|
|
1945
1966
|
if (tuning.minInkContrast > 0 && ink.contrast < tuning.minInkContrast) continue;
|
|
1946
1967
|
if (tuning.minInkContrast > 0 && ink.inkRatio < MIN_INK_RATIO) continue;
|
|
1947
1968
|
if (tuning.splitTall && b.h >= b.w * TALL_RATIO) {
|
|
1948
|
-
const bands =
|
|
1969
|
+
const bands = _chunkSQT5Z35Bcjs.splitRowBands.call(void 0, gray, b.w, b.h, ink, 0.45);
|
|
1949
1970
|
if (bands.length >= 2) {
|
|
1950
1971
|
for (const sub of bandBoxes(b, bands, height)) jobs.push({ box: sub, rot: 0, group: group++ });
|
|
1951
1972
|
continue;
|
|
@@ -1969,9 +1990,9 @@ var OcrEngine = class _OcrEngine {
|
|
|
1969
1990
|
continue;
|
|
1970
1991
|
}
|
|
1971
1992
|
}
|
|
1972
|
-
const trim = tuning.trimEdges ?
|
|
1993
|
+
const trim = tuning.trimEdges ? _chunkSQT5Z35Bcjs.edgeTrim.call(void 0, gray, b.w, b.h, ink) : null;
|
|
1973
1994
|
const keep = trim ? { ...trim, bg: median(gray) } : void 0;
|
|
1974
|
-
const leaders = tuning.splitLeaders ?
|
|
1995
|
+
const leaders = tuning.splitLeaders ? _chunkSQT5Z35Bcjs.leaderRuns.call(void 0, gray, b.w, b.h, ink, LEADER_MIN_DOTS) : [];
|
|
1975
1996
|
if (leaders.length) {
|
|
1976
1997
|
const join = joins.length;
|
|
1977
1998
|
joins.push({ box: b, parts: [], trailDots: false });
|
|
@@ -1980,7 +2001,7 @@ var OcrEngine = class _OcrEngine {
|
|
|
1980
2001
|
const bare = { x: b.x + x0, y: b.y, w: a - x0, h: b.h };
|
|
1981
2002
|
const end = c > a ? Math.min(c, a + Math.round(b.h * LEADER_CONTEXT)) : a;
|
|
1982
2003
|
x0 = c;
|
|
1983
|
-
if (bare.w >= DET_MIN_SIZE &&
|
|
2004
|
+
if (bare.w >= DET_MIN_SIZE && _chunkSQT5Z35Bcjs.inkStats.call(void 0, _chunkSQT5Z35Bcjs.grayCrop.call(void 0, rgba, width, bare)).contrast >= Math.max(1, tuning.minInkContrast)) {
|
|
1984
2005
|
jobs.push({ box: { ...bare, w: end - (bare.x - b.x) }, rot: 0, group: group++, join, dotsBefore: dots, trimDots: end > a });
|
|
1985
2006
|
dots = false;
|
|
1986
2007
|
}
|
|
@@ -2029,15 +2050,15 @@ var OcrEngine = class _OcrEngine {
|
|
|
2029
2050
|
let text = tuning.postprocess ? restoreSymbols(raw.trim(), note.ringLead) : raw;
|
|
2030
2051
|
if (!text.trim()) continue;
|
|
2031
2052
|
if (tuning.postprocess && job.rot === 0 && text !== "/" && /^[(:;/)]+$/.test(text) && text.includes("/")) {
|
|
2032
|
-
const g =
|
|
2033
|
-
if (
|
|
2053
|
+
const g = _chunkSQT5Z35Bcjs.grayCrop.call(void 0, rgba, width, job.box);
|
|
2054
|
+
if (_chunkSQT5Z35Bcjs.tallInkCount.call(void 0, g, job.box.w, job.box.h, _chunkSQT5Z35Bcjs.inkStats.call(void 0, g)) === 1) text = "/";
|
|
2034
2055
|
}
|
|
2035
2056
|
let ringByShape = false;
|
|
2036
2057
|
if (tuning.postprocess && job.rot === 0 && !/^[◎●▪□■▣❐❏○ㅇ◆◇◈]/.test(text)) {
|
|
2037
2058
|
const chars = [...read], k = chars.findIndex((c) => c.trim());
|
|
2038
2059
|
if (k >= 0 && steps.length === chars.length) {
|
|
2039
|
-
const g =
|
|
2040
|
-
const b =
|
|
2060
|
+
const g = _chunkSQT5Z35Bcjs.grayCrop.call(void 0, rgba, width, job.box);
|
|
2061
|
+
const b = _chunkSQT5Z35Bcjs.leadingBullet.call(void 0, g, job.box.w, job.box.h, _chunkSQT5Z35Bcjs.inkStats.call(void 0, g), (steps[k] + 0.5) * stepPx);
|
|
2041
2062
|
const body = (_nullishCoalesce(text.match(/[가-힣]/g), () => ( []))).length >= 4;
|
|
2042
2063
|
const miss = /^[Oo0•·ㆍ∙‧○]/.test(text);
|
|
2043
2064
|
if (_optionalChain([b, 'optionalAccess', _39 => _39.mark]) === "\u25CE" && b.covers && /^[Oo0○©]/.test(text)) {
|
|
@@ -2052,17 +2073,17 @@ var OcrEngine = class _OcrEngine {
|
|
|
2052
2073
|
} else if (_optionalChain([b, 'optionalAccess', _46 => _46.mark]) === "\u2750" || _optionalChain([b, 'optionalAccess', _47 => _47.mark]) === "\u274F") {
|
|
2053
2074
|
if (b.covers ? /^[ㅁ口]/.test(text) : body) text = b.covers ? b.mark + text.slice(1) : b.mark + " " + text;
|
|
2054
2075
|
} else if (b && b.mark !== "\u25CE" && body) text = b.covers ? miss ? b.mark + " " + text.slice(1).trimStart() : text : b.mark + " " + text;
|
|
2055
|
-
else if (!b && body && /^[가-힣]/.test(chars[k]) &&
|
|
2076
|
+
else if (!b && body && /^[가-힣]/.test(chars[k]) && _chunkSQT5Z35Bcjs.leadingRing.call(void 0, g, job.box.w, job.box.h, _chunkSQT5Z35Bcjs.inkStats.call(void 0, g), (steps[k] + 0.5) * stepPx)) text = "\u25CB " + text;
|
|
2056
2077
|
}
|
|
2057
2078
|
}
|
|
2058
2079
|
if (tuning.postprocess && /^\d/.test(text) && job.rot === 0) {
|
|
2059
|
-
const g =
|
|
2060
|
-
const tri =
|
|
2080
|
+
const g = _chunkSQT5Z35Bcjs.grayCrop.call(void 0, rgba, width, job.box);
|
|
2081
|
+
const tri = _chunkSQT5Z35Bcjs.leadingTriangle.call(void 0, g, job.box.w, job.box.h, _chunkSQT5Z35Bcjs.inkStats.call(void 0, g));
|
|
2061
2082
|
if (tri) text = tri + text;
|
|
2062
2083
|
}
|
|
2063
2084
|
if (tuning.postprocess && text === "\u2192" && job.rot === 0 && job.join === void 0) {
|
|
2064
|
-
const g =
|
|
2065
|
-
text = _nullishCoalesce(
|
|
2085
|
+
const g = _chunkSQT5Z35Bcjs.grayCrop.call(void 0, rgba, width, job.box);
|
|
2086
|
+
text = _nullishCoalesce(_chunkSQT5Z35Bcjs.arrowGlyph.call(void 0, g, job.box.w, job.box.h, _chunkSQT5Z35Bcjs.inkStats.call(void 0, g)), () => ( text));
|
|
2066
2087
|
}
|
|
2067
2088
|
if (job.footer) {
|
|
2068
2089
|
if (!/^[-\u2013\u2014]?\s*(?:\d{1,4}|[ivxIVXⅰ-ⅹⅠ-Ⅹ]{1,4})\s*[-\u2013\u2014]?$/.test(text.trim())) continue;
|
|
@@ -2086,7 +2107,7 @@ var OcrEngine = class _OcrEngine {
|
|
|
2086
2107
|
continue;
|
|
2087
2108
|
}
|
|
2088
2109
|
const item = { text, ...this.itemBox(rgba, width, job.box, tuning), confidence };
|
|
2089
|
-
if (job.rot === 0)
|
|
2110
|
+
if (job.rot === 0) _chunkSQT5Z35Bcjs.rememberOcrTextGaps.call(void 0, item, _chunkSQT5Z35Bcjs.findOcrTextGaps.call(void 0, rgba, width, job.box, read, text, steps, stepPx));
|
|
2090
2111
|
if (job.rot === 0 && job.keep === void 0) boxOf.set(item, job.box);
|
|
2091
2112
|
items.push(item);
|
|
2092
2113
|
}
|
|
@@ -2100,7 +2121,7 @@ var OcrEngine = class _OcrEngine {
|
|
|
2100
2121
|
const merged = rereadNumberText(it.text, r.text);
|
|
2101
2122
|
if (merged === null) return;
|
|
2102
2123
|
it.text = merged;
|
|
2103
|
-
|
|
2124
|
+
_chunkSQT5Z35Bcjs.rememberOcrTextGaps.call(void 0, it, _chunkSQT5Z35Bcjs.findOcrTextGaps.call(void 0, rgba, width, boxOf.get(it), r.text, it.text, r.steps, r.stepPx));
|
|
2104
2125
|
});
|
|
2105
2126
|
}
|
|
2106
2127
|
const pairs = tuning.postprocess ? items.filter((it) => boxOf.has(it) && NUMBER_PAIR.test(it.text.trim())) : [];
|
|
@@ -2128,8 +2149,8 @@ var OcrEngine = class _OcrEngine {
|
|
|
2128
2149
|
const halves = [];
|
|
2129
2150
|
for (const it of tall) {
|
|
2130
2151
|
const b = boxOf.get(it);
|
|
2131
|
-
const gray =
|
|
2132
|
-
const cut = _nullishCoalesce(midBlankRow(gray, b.w, b.h,
|
|
2152
|
+
const gray = _chunkSQT5Z35Bcjs.grayCrop.call(void 0, rgba, width, b);
|
|
2153
|
+
const cut = _nullishCoalesce(midBlankRow(gray, b.w, b.h, _chunkSQT5Z35Bcjs.inkStats.call(void 0, gray)), () => ( valleyRow(gray, b.w, b.h, _chunkSQT5Z35Bcjs.inkStats.call(void 0, gray))));
|
|
2133
2154
|
if (cut) halves.push({ it, top: { ...b, h: cut[0] }, bottom: { ...b, y: b.y + cut[1], h: b.h - cut[1] } });
|
|
2134
2155
|
}
|
|
2135
2156
|
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) : [];
|
|
@@ -2150,14 +2171,14 @@ var OcrEngine = class _OcrEngine {
|
|
|
2150
2171
|
const subs = [];
|
|
2151
2172
|
const stacks = [];
|
|
2152
2173
|
for (const b of [...retry, ...blank2]) {
|
|
2153
|
-
const gray =
|
|
2154
|
-
const ink =
|
|
2174
|
+
const gray = _chunkSQT5Z35Bcjs.grayCrop.call(void 0, rgba, width, b);
|
|
2175
|
+
const ink = _chunkSQT5Z35Bcjs.inkStats.call(void 0, gray);
|
|
2155
2176
|
const cut = retry.includes(b) ? midBlankRow(gray, b.w, b.h, ink) : null;
|
|
2156
2177
|
if (cut && b.w >= 3 * Math.max(cut[0], b.h - cut[1])) {
|
|
2157
2178
|
subs.push({ ...b, h: cut[0] }, { ...b, y: b.y + cut[1], h: b.h - cut[1] });
|
|
2158
2179
|
continue;
|
|
2159
2180
|
}
|
|
2160
|
-
const bands =
|
|
2181
|
+
const bands = _chunkSQT5Z35Bcjs.stackedGlyphBands.call(void 0, gray, b.w, b.h, ink);
|
|
2161
2182
|
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)) });
|
|
2162
2183
|
}
|
|
2163
2184
|
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));
|
|
@@ -2236,8 +2257,8 @@ var OcrEngine = class _OcrEngine {
|
|
|
2236
2257
|
/** 결과 좌표 — det 박스 그대로 또는 박스 안 잉크 외곽 (tightBoxes) */
|
|
2237
2258
|
itemBox(rgba, width, b, tuning) {
|
|
2238
2259
|
if (!tuning.tightBoxes) return b;
|
|
2239
|
-
const gray =
|
|
2240
|
-
const t =
|
|
2260
|
+
const gray = _chunkSQT5Z35Bcjs.grayCrop.call(void 0, rgba, width, b);
|
|
2261
|
+
const t = _chunkSQT5Z35Bcjs.inkBounds.call(void 0, gray, b.w, b.h, _chunkSQT5Z35Bcjs.inkStats.call(void 0, gray));
|
|
2241
2262
|
return { x: b.x + t.x0, y: b.y + t.y0, w: t.x1 - t.x0, h: t.y1 - t.y0 };
|
|
2242
2263
|
}
|
|
2243
2264
|
// ─── det ─────────────────────────────────────────────
|
|
@@ -2308,7 +2329,7 @@ var OcrEngine = class _OcrEngine {
|
|
|
2308
2329
|
const out = await this.rec.run({ [this.rec.inputNames[0]]: tensor });
|
|
2309
2330
|
const logits = out[this.rec.outputNames[0]];
|
|
2310
2331
|
const [, T, C] = logits.dims;
|
|
2311
|
-
if (C !== this.dict.length + 2) throw new (0,
|
|
2332
|
+
if (C !== this.dict.length + 2) throw new (0, _chunk4J7PCDT5cjs.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`);
|
|
2312
2333
|
const data = logits.data;
|
|
2313
2334
|
idx.forEach((ci, k) => {
|
|
2314
2335
|
const r = ctcDecode(data.subarray(k * T * C, (k + 1) * T * C), T, C, this.dict);
|
|
@@ -2318,9 +2339,9 @@ var OcrEngine = class _OcrEngine {
|
|
|
2318
2339
|
const chars = r ? [...r.text] : [];
|
|
2319
2340
|
if (r && job.rot === 0 && chars.length === r.steps.length && r.steps.some((t) => t > last) && !r.text.includes("(cid:")) {
|
|
2320
2341
|
const tallCh = (c) => !/[\s.,:;\u00b7\u2026'"\u2018-\u201d`\-_~]/.test(c);
|
|
2321
|
-
const g =
|
|
2342
|
+
const g = _chunkSQT5Z35Bcjs.grayCrop.call(void 0, rgba, pageW, job.box);
|
|
2322
2343
|
const inside = chars.filter((c, i) => r.steps[i] <= last && tallCh(c)).length;
|
|
2323
|
-
let budget = inside <= 2 ?
|
|
2344
|
+
let budget = inside <= 2 ? _chunkSQT5Z35Bcjs.tallInkCount.call(void 0, g, job.box.w, job.box.h, _chunkSQT5Z35Bcjs.inkStats.call(void 0, g)) - inside : Infinity;
|
|
2324
2345
|
const keep = chars.map((c, i) => r.steps[i] <= last || !tallCh(c) || budget-- > 0);
|
|
2325
2346
|
if (!keep.every(Boolean)) kept = { ...r, text: chars.filter((_, i) => keep[i]).join(""), steps: r.steps.filter((_, i) => keep[i]) };
|
|
2326
2347
|
}
|
|
@@ -2431,13 +2452,13 @@ async function tryImport(name, loader) {
|
|
|
2431
2452
|
return await loader();
|
|
2432
2453
|
} catch (e) {
|
|
2433
2454
|
throw new Error(
|
|
2434
|
-
`\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.${
|
|
2455
|
+
`\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.${_chunk4J7PCDT5cjs.OPTIONAL_DEP_INSTALL_HINT} \uC6D0\uC778: ${e.message}`
|
|
2435
2456
|
);
|
|
2436
2457
|
}
|
|
2437
2458
|
}
|
|
2438
2459
|
async function verifiedBytes(s) {
|
|
2439
2460
|
const name = _path.basename.call(void 0, s.file.path);
|
|
2440
|
-
const fail = (why2) => new (0,
|
|
2461
|
+
const fail = (why2) => new (0, _chunk4J7PCDT5cjs.KordocError)(`OCR \uBAA8\uB378 \uD30C\uC77C\uC744 \uC77D\uC9C0 \uBABB\uD588\uC2B5\uB2C8\uB2E4: ${name} (${why2})`);
|
|
2441
2462
|
const why = (e) => {
|
|
2442
2463
|
const code = e.code;
|
|
2443
2464
|
return code === "ENOENT" ? "\uD30C\uC77C\uC774 \uC5C6\uC74C" : code === "EACCES" || code === "EPERM" ? "\uAD8C\uD55C \uC5C6\uC74C" : "\uC77D\uAE30 \uC2E4\uD328";
|
|
@@ -2458,13 +2479,13 @@ async function verifiedBytes(s) {
|
|
|
2458
2479
|
}
|
|
2459
2480
|
const actual = _crypto.createHash.call(void 0, "sha256").update(bytes).digest("hex");
|
|
2460
2481
|
if (actual !== s.file.sha256) {
|
|
2461
|
-
throw new (0,
|
|
2482
|
+
throw new (0, _chunk4J7PCDT5cjs.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)`);
|
|
2462
2483
|
}
|
|
2463
2484
|
return bytes;
|
|
2464
2485
|
}
|
|
2465
2486
|
var engines = /* @__PURE__ */ new Map();
|
|
2466
|
-
function getOcrEngine(models =
|
|
2467
|
-
const key =
|
|
2487
|
+
function getOcrEngine(models = _chunkSQT5Z35Bcjs.DEFAULT_OCR_MODELS) {
|
|
2488
|
+
const key = _chunkSQT5Z35Bcjs.ocrSelectionKey.call(void 0, models);
|
|
2468
2489
|
let p = engines.get(key);
|
|
2469
2490
|
if (!p) {
|
|
2470
2491
|
p = OcrEngine.create(models).catch((err) => {
|
|
@@ -2896,20 +2917,20 @@ var REDETECT = { minDropped: 15, minShare: 0.15, scale: 5 / 3 };
|
|
|
2896
2917
|
var AUTO_REC = { pageConf: 0.9, gain: 0.06 };
|
|
2897
2918
|
var DEFAULT_AUTO_REC = { pageConf: 0.9, gain: 0.08, altConf: 0.95, sureGain: 0.1, minDiff: 0.08, minChars: 80, lazy: true };
|
|
2898
2919
|
var DEFAULT_BUILTIN_OCR = Object.freeze({
|
|
2899
|
-
models:
|
|
2920
|
+
models: _chunkSQT5Z35Bcjs.DEFAULT_OCR_MODELS,
|
|
2900
2921
|
tuning: DEFAULT_OCR_TUNING,
|
|
2901
|
-
handwriting:
|
|
2922
|
+
handwriting: _chunkSQT5Z35Bcjs.handwritingFallbackModels.call(void 0, _chunkSQT5Z35Bcjs.DEFAULT_OCR_MODELS),
|
|
2902
2923
|
autoRec: DEFAULT_AUTO_REC
|
|
2903
2924
|
});
|
|
2904
2925
|
var DEFAULT_BUILTIN_OCR_FETCH = Object.freeze({ ...DEFAULT_BUILTIN_OCR, autoRec: { ...DEFAULT_AUTO_REC, fetch: true } });
|
|
2905
2926
|
function builtinOcrConfig(o) {
|
|
2906
2927
|
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;
|
|
2907
2928
|
const bad = _chunkMMK32GPDcjs.validateOcrOptions.call(void 0, o);
|
|
2908
|
-
if (bad) throw new (0,
|
|
2909
|
-
const models =
|
|
2929
|
+
if (bad) throw new (0, _chunk4J7PCDT5cjs.KordocError)(bad);
|
|
2930
|
+
const models = _chunkSQT5Z35Bcjs.resolveOcrModels.call(void 0, o);
|
|
2910
2931
|
return {
|
|
2911
2932
|
models,
|
|
2912
|
-
...o.ocrRec === "auto" ? { handwriting:
|
|
2933
|
+
...o.ocrRec === "auto" ? { handwriting: _chunkSQT5Z35Bcjs.handwritingFallbackModels.call(void 0, models), autoRec: AUTO_REC } : o.ocrRec === void 0 ? { handwriting: _chunkSQT5Z35Bcjs.handwritingFallbackModels.call(void 0, models), autoRec: o.ocr ? { ...DEFAULT_AUTO_REC, fetch: true } : DEFAULT_AUTO_REC } : {},
|
|
2913
2934
|
tuning: o.ocrDetLongSide === void 0 ? DEFAULT_OCR_TUNING : { ...DEFAULT_OCR_TUNING, detLongSide: o.ocrDetLongSide },
|
|
2914
2935
|
lines: o.ocrLines === "all" ? "all" : o.ocrLines ? "kept" : void 0
|
|
2915
2936
|
};
|
|
@@ -2935,8 +2956,8 @@ async function withHandwritingRec(items, config, tuning, rgba, width, height, st
|
|
|
2935
2956
|
const altStats = { droppedLowConf: 0, ...stats.dropped ? { dropped: [] } : {} };
|
|
2936
2957
|
let alt;
|
|
2937
2958
|
try {
|
|
2938
|
-
if (auto.lazy && !auto.fetch && !await
|
|
2939
|
-
if (auto.lazy) await
|
|
2959
|
+
if (auto.lazy && !auto.fetch && !await _chunkSQT5Z35Bcjs.ocrModelsCached.call(void 0, config.handwriting)) return items;
|
|
2960
|
+
if (auto.lazy) await _chunkSQT5Z35Bcjs.ensureOcrModelsFor.call(void 0, config.handwriting, reportModelDownload);
|
|
2940
2961
|
alt = await (await getOcrEngine(config.handwriting)).recognizePage(rgba, width, height, altStats, tuning, cellRules, rowRules);
|
|
2941
2962
|
} catch (e) {
|
|
2942
2963
|
if (!auto.lazy) throw e;
|
|
@@ -2982,8 +3003,8 @@ async function runPdfOcr(buffer, targets, mode, warnings, onProgress, detectTabl
|
|
|
2982
3003
|
"@hyzyla/pdfium",
|
|
2983
3004
|
() => Promise.resolve().then(() => _interopRequireWildcard(require("@hyzyla/pdfium")))
|
|
2984
3005
|
);
|
|
2985
|
-
if (mode === "builtin") await
|
|
2986
|
-
if (mode === "builtin" && config.handwriting && !_optionalChain([config, 'access', _79 => _79.autoRec, 'optionalAccess', _80 => _80.lazy])) await
|
|
3006
|
+
if (mode === "builtin") await _chunkSQT5Z35Bcjs.ensureOcrModelsFor.call(void 0, config.models, reportModelDownload);
|
|
3007
|
+
if (mode === "builtin" && config.handwriting && !_optionalChain([config, 'access', _79 => _79.autoRec, 'optionalAccess', _80 => _80.lazy])) await _chunkSQT5Z35Bcjs.ensureOcrModelsFor.call(void 0, config.handwriting, reportModelDownload);
|
|
2987
3008
|
const engine = mode === "builtin" ? await getOcrEngine(config.models) : null;
|
|
2988
3009
|
const pdfium = await pdfiumMod.PDFiumLibrary.init();
|
|
2989
3010
|
const doc = await pdfium.loadDocument(new Uint8Array(buffer));
|
|
@@ -3095,7 +3116,7 @@ async function ocrOnePage(page, pageNo, mode, engine, warnings, detectTables, ve
|
|
|
3095
3116
|
const x1 = r.x1 * scale - 2, x2 = r.x2 * scale + 2, y1 = (pdfH - r.y2) * scale - 2, y2 = (pdfH - r.y1) * scale + 2;
|
|
3096
3117
|
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));
|
|
3097
3118
|
if (columnRules < 2) {
|
|
3098
|
-
for (const b of blocks) if (b.type === "table")
|
|
3119
|
+
for (const b of blocks) if (b.type === "table") _chunkSQT5Z35Bcjs.UNRULED_REGION_TABLES.add(b);
|
|
3099
3120
|
}
|
|
3100
3121
|
return blocks;
|
|
3101
3122
|
});
|
|
@@ -3167,7 +3188,7 @@ async function closerReads(rgba, rw, rh, pdfH, hi, regions, engine, tuning = REG
|
|
|
3167
3188
|
const items = await engine.recognizePage(crop, cw, ch, void 0, tuning);
|
|
3168
3189
|
out.push(items.map((it) => {
|
|
3169
3190
|
const placed = { ...it, x: (it.x + x0) / 2, y: (it.y + y0) / 2, w: it.w / 2, h: it.h / 2 };
|
|
3170
|
-
|
|
3191
|
+
_chunkSQT5Z35Bcjs.copyOcrTextGaps.call(void 0, it, placed, 0.5, x0 / 2);
|
|
3171
3192
|
return placed;
|
|
3172
3193
|
}));
|
|
3173
3194
|
}
|
|
@@ -3259,7 +3280,7 @@ function ocrItemsToBlocks(items, pageNumber, pdfW, pdfH, scale, extraLines, dete
|
|
|
3259
3280
|
isHidden: false,
|
|
3260
3281
|
...xs[i].space ? { hasSpaceBefore: true } : {}
|
|
3261
3282
|
};
|
|
3262
|
-
|
|
3283
|
+
_chunkSQT5Z35Bcjs.copyOcrTextGaps.call(void 0, it, normalized, 1 / scale);
|
|
3263
3284
|
return normalized;
|
|
3264
3285
|
}).filter((it) => it.text);
|
|
3265
3286
|
if (_optionalChain([extraLines, 'optionalAccess', _96 => _96.verticals, 'access', _97 => _97.length]) && items.length) {
|
|
@@ -3275,7 +3296,7 @@ function ocrItemsToBlocks(items, pageNumber, pdfW, pdfH, scale, extraLines, dete
|
|
|
3275
3296
|
})
|
|
3276
3297
|
};
|
|
3277
3298
|
}
|
|
3278
|
-
const laid = unframeOcrLayoutTables(splitOcrJoinedHeaders(splitOcrContactColumns(splitOcrNameValueColumns(splitStackedOcrRows(
|
|
3299
|
+
const laid = unframeOcrLayoutTables(splitOcrJoinedHeaders(splitOcrContactColumns(splitOcrNameValueColumns(splitStackedOcrRows(_chunkSQT5Z35Bcjs.extractPageBlocksWithLines.call(void 0, norm, pageNumber, opList, pdfW, pdfH, extraLines, detectTables))))), pdfH);
|
|
3279
3300
|
const blocks = figureRegion ? laid : splitOcrProseRows(laid);
|
|
3280
3301
|
if (!figureRegion) markOcrHeadings(blocks);
|
|
3281
3302
|
return blocks;
|
|
@@ -3336,7 +3357,7 @@ async function tryImport2(name, loader) {
|
|
|
3336
3357
|
return await loader();
|
|
3337
3358
|
} catch (e) {
|
|
3338
3359
|
throw new Error(
|
|
3339
|
-
`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.${
|
|
3360
|
+
`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.${_chunk4J7PCDT5cjs.OPTIONAL_DEP_INSTALL_HINT} \uC6D0\uC778: ${e.message}`
|
|
3340
3361
|
);
|
|
3341
3362
|
}
|
|
3342
3363
|
}
|
|
@@ -3389,4 +3410,4 @@ function bgraToRgba(bgra) {
|
|
|
3389
3410
|
|
|
3390
3411
|
|
|
3391
3412
|
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;
|
|
3392
|
-
//# sourceMappingURL=chunk-
|
|
3413
|
+
//# sourceMappingURL=chunk-CB365CYO.cjs.map
|