kordoc 4.24.48 → 4.24.49
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 +3 -3
- package/dist/{-3EMVBTE7.js → -22V6D2US.js} +42 -42
- package/dist/{chunk-TOOOWCKQ.cjs → chunk-2UWWWM4Q.cjs} +98 -98
- package/dist/{chunk-TOOOWCKQ.cjs.map → chunk-2UWWWM4Q.cjs.map} +1 -1
- package/dist/{chunk-MHAPDR6T.cjs → chunk-367WLMPO.cjs} +59 -67
- package/dist/chunk-367WLMPO.cjs.map +1 -0
- package/dist/{chunk-WVUR3HYW.js → chunk-4HJKBRZJ.js} +129 -40
- package/dist/chunk-4HJKBRZJ.js.map +1 -0
- package/dist/{chunk-7F5SKDUG.js → chunk-4MWUBTAE.js} +2 -2
- package/dist/{chunk-4N2ESXR2.js → chunk-67GSFYG7.js} +2 -2
- package/dist/{chunk-WICMTKWR.js → chunk-6BFWLS7E.js} +3 -3
- package/dist/{chunk-LBH4KAQM.cjs → chunk-6NZ32OTX.cjs} +8 -3
- package/dist/chunk-6NZ32OTX.cjs.map +1 -0
- package/dist/{chunk-JC2TMUU5.js → chunk-7KKL3PRK.js} +5 -13
- package/dist/chunk-7KKL3PRK.js.map +1 -0
- package/dist/{chunk-7EL6BCO5.js → chunk-AUAJVQQK.js} +2 -2
- package/dist/{chunk-QJBVP2BS.js → chunk-AXW2FMVR.js} +2 -2
- package/dist/{chunk-SUOJQHIN.js → chunk-CCQMSIZQ.js} +19 -19
- package/dist/{chunk-OUUI7I5V.js → chunk-DA5AXURC.js} +52 -4
- package/dist/chunk-DA5AXURC.js.map +1 -0
- package/dist/{chunk-3UY7ARXP.js → chunk-DAAJO62F.js} +2 -2
- package/dist/{chunk-QM65ELZE.js → chunk-EUJX7HTR.js} +32 -10
- package/dist/chunk-EUJX7HTR.js.map +1 -0
- package/dist/{chunk-E47LO7XG.js → chunk-EYSXMDA7.js} +17 -17
- package/dist/{chunk-TQ4QOCKT.js → chunk-FU6ZDWCI.js} +7 -2
- package/dist/chunk-FU6ZDWCI.js.map +1 -0
- package/dist/{chunk-MHLTZ3VI.js → chunk-HETGOJ6V.js} +2 -2
- package/dist/{chunk-OQPIN2OY.js → chunk-HW7WVYBF.js} +2 -2
- package/dist/{chunk-LHZL52HO.cjs → chunk-IRAZCKQ6.cjs} +3 -3
- package/dist/{chunk-LHZL52HO.cjs.map → chunk-IRAZCKQ6.cjs.map} +1 -1
- package/dist/{chunk-AC7FZDVP.js → chunk-KB4ORA7M.js} +2 -2
- package/dist/{chunk-SHYNOLL6.js → chunk-KXHUHGMC.js} +2 -2
- package/dist/{chunk-WO6PZMMB.js → chunk-L3JP55ZY.js} +2 -2
- package/dist/{chunk-OBNOOHAW.js → chunk-LCRSRVFJ.js} +2 -2
- package/dist/{chunk-OBNOOHAW.js.map → chunk-LCRSRVFJ.js.map} +1 -1
- package/dist/{chunk-OO4DHHTG.js → chunk-LFFARZYZ.js} +2 -2
- package/dist/{chunk-OO4DHHTG.js.map → chunk-LFFARZYZ.js.map} +1 -1
- package/dist/{chunk-NLPIXQOV.js → chunk-LOSCIAHY.js} +2 -2
- package/dist/{chunk-HW3DZ7TY.js → chunk-M5RQ2PNP.js} +6 -14
- package/dist/chunk-M5RQ2PNP.js.map +1 -0
- package/dist/{chunk-GFWCBYAI.js → chunk-MIJTZKWF.js} +2 -2
- package/dist/{chunk-PHU4VSNF.js → chunk-MLBX6KQM.js} +37 -3
- package/dist/chunk-MLBX6KQM.js.map +1 -0
- package/dist/{chunk-D4TKVZKB.js → chunk-OAETOHH3.js} +3 -3
- package/dist/{chunk-SI3GXM7Z.js → chunk-PMGJQWSW.js} +2 -2
- package/dist/{chunk-QOBWIFJA.cjs → chunk-PVV6OY4M.cjs} +135 -87
- package/dist/{chunk-QOBWIFJA.cjs.map → chunk-PVV6OY4M.cjs.map} +1 -1
- package/dist/{chunk-VXHZPUMS.cjs → chunk-PW7MQZI4.cjs} +2 -2
- package/dist/{chunk-VXHZPUMS.cjs.map → chunk-PW7MQZI4.cjs.map} +1 -1
- package/dist/{chunk-MYIRYP6D.js → chunk-Q7FDPJUS.js} +10 -10
- package/dist/{chunk-N6B5BINC.js → chunk-R2RLNUNK.js} +6 -6
- package/dist/{chunk-FQMPHPHE.js → chunk-RQLEGKEV.js} +2 -2
- package/dist/{chunk-KTGOULMH.js → chunk-S54DZB2Z.js} +51 -3
- package/dist/chunk-S54DZB2Z.js.map +1 -0
- package/dist/{chunk-D7SOY3VR.js → chunk-TAHS42ED.js} +33 -11
- package/dist/chunk-TAHS42ED.js.map +1 -0
- package/dist/{chunk-YFTD6WOP.cjs → chunk-TQOAPKLU.cjs} +6 -6
- package/dist/{chunk-YFTD6WOP.cjs.map → chunk-TQOAPKLU.cjs.map} +1 -1
- package/dist/{chunk-A6EOKPKG.cjs → chunk-UBY2PLKR.cjs} +54 -32
- package/dist/chunk-UBY2PLKR.cjs.map +1 -0
- package/dist/{chunk-UN2F6EKQ.js → chunk-UJELMNOU.js} +7 -2
- package/dist/chunk-UJELMNOU.js.map +1 -0
- package/dist/{chunk-REERG473.js → chunk-UU54HN5I.js} +6 -6
- package/dist/{chunk-E5RJLP2S.js → chunk-VMOUAWGD.js} +7 -7
- package/dist/{chunk-6YUMHSBG.js → chunk-WLFZOBZR.js} +3 -3
- package/dist/{chunk-SJXTCW7I.cjs → chunk-Y4MFHEK4.cjs} +40 -6
- package/dist/chunk-Y4MFHEK4.cjs.map +1 -0
- package/dist/{chunk-UJ3TZF4Y.js → chunk-Y6QW3FJQ.js} +2 -2
- package/dist/{chunk-GOYAJVR6.js → chunk-ZF24SO45.js} +37 -3
- package/dist/chunk-ZF24SO45.js.map +1 -0
- package/dist/chunks-Q7242OJE.js +11 -0
- package/dist/cli.js +73 -53
- package/dist/cli.js.map +1 -1
- package/dist/{formula-DUHNPES2.js → formula-BYEDWWZU.js} +4 -4
- package/dist/{formula-XNCKOV6K.js → formula-FQLMMBDP.js} +3 -3
- package/dist/{formula-7RJOEJHX.cjs → formula-QJEOIVKR.cjs} +9 -9
- package/dist/{formula-7RJOEJHX.cjs.map → formula-QJEOIVKR.cjs.map} +1 -1
- package/dist/generator-FTM6GOGB.cjs +11 -0
- package/dist/{generator-XXVCF6TG.cjs.map → generator-FTM6GOGB.cjs.map} +1 -1
- package/dist/generator-Q3L7RNUY.js +17 -0
- package/dist/generator-SU73HZHR.js +10 -0
- package/dist/{image-ocr-PYOXD5K4.js → image-ocr-7Y3FCGRR.js} +12 -10
- package/dist/image-ocr-7Y3FCGRR.js.map +1 -0
- package/dist/{image-ocr-NFCTNIL5.js → image-ocr-VIGZE4YL.js} +9 -7
- package/dist/image-ocr-VIGZE4YL.js.map +1 -0
- package/dist/{image-ocr-ZLAPJMES.cjs → image-ocr-WRILL3WO.cjs} +29 -27
- package/dist/image-ocr-WRILL3WO.cjs.map +1 -0
- package/dist/index.cjs +1250 -1161
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +13 -5
- package/dist/index.d.ts +13 -5
- package/dist/index.js +207 -118
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +42 -43
- package/dist/mcp.js.map +1 -1
- package/dist/memo-T5ZQEXEA.js +17 -0
- package/dist/{model-bundle-TIHWFIN5.js → model-bundle-UJRQPYUU.js} +5 -5
- package/dist/{models-YBHBEM6J.js → models-64YLAWTI.js} +5 -5
- package/dist/{parse-worker-v2-Q7ST3SDO.js → parse-worker-v2-QWQZKFQO.js} +25 -24
- package/dist/parse-worker-v2-QWQZKFQO.js.map +1 -0
- package/dist/{parser-7JSQYNLS.js → parser-JPWANPLM.js} +77 -32
- package/dist/parser-JPWANPLM.js.map +1 -0
- package/dist/{parser-A76QS3VJ.cjs → parser-RB6CBNAM.cjs} +259 -214
- package/dist/parser-RB6CBNAM.cjs.map +1 -0
- package/dist/{parser-V25GYLBJ.js → parser-XFU3VRWM.js} +80 -35
- package/dist/parser-XFU3VRWM.js.map +1 -0
- package/dist/pdf-ocr-NOJHEH4M.cjs +42 -0
- package/dist/{pdf-ocr-5YCDSSLG.cjs.map → pdf-ocr-NOJHEH4M.cjs.map} +1 -1
- package/dist/{pdf-ocr-IJXT6ZJR.js → pdf-ocr-XTZZEYKJ.js} +6 -6
- package/dist/{pdf-ocr-GEAW23FB.js → pdf-ocr-ZV3KYIIE.js} +9 -9
- package/dist/{profile-io-Y7SMMS2R.js → profile-io-FAJORRD2.js} +3 -3
- package/dist/{rasterize-MLEHT6PU.js → rasterize-4ZJUA2DZ.js} +3 -3
- package/dist/{redact-doc-GPO2UTTJ.js → redact-doc-JPNROEH6.js} +30 -30
- package/dist/{render-TNWY53S4.js → render-D4WBOBKI.js} +13 -13
- package/dist/{rewrite-fallback-AHGTN757.js → rewrite-fallback-OF3QI6CX.js} +14 -14
- package/dist/seal-DQWEHIAM.js +16 -0
- package/dist/{setup-TJ57DQ6I.js → setup-YC25YCQB.js} +3 -3
- package/dist/to-hwpx-D7OMPDUQ.js +21 -0
- package/dist/to-hwpx-LUA6F5RR.cjs +16 -0
- package/dist/{to-hwpx-XLQUY2L2.cjs.map → to-hwpx-LUA6F5RR.cjs.map} +1 -1
- package/dist/{to-hwpx-DLVARUND.js → to-hwpx-ZWN64NCQ.js} +5 -5
- package/dist/visual-SW7NPY6K.js +37 -0
- package/dist/{watch-6CHDQ355.js → watch-ZU576VSR.js} +24 -24
- package/package.json +1 -1
- package/dist/chunk-A6EOKPKG.cjs.map +0 -1
- package/dist/chunk-D7SOY3VR.js.map +0 -1
- package/dist/chunk-GOYAJVR6.js.map +0 -1
- package/dist/chunk-HW3DZ7TY.js.map +0 -1
- package/dist/chunk-JC2TMUU5.js.map +0 -1
- package/dist/chunk-KTGOULMH.js.map +0 -1
- package/dist/chunk-LBH4KAQM.cjs.map +0 -1
- package/dist/chunk-MHAPDR6T.cjs.map +0 -1
- package/dist/chunk-OUUI7I5V.js.map +0 -1
- package/dist/chunk-PHU4VSNF.js.map +0 -1
- package/dist/chunk-QM65ELZE.js.map +0 -1
- package/dist/chunk-SJXTCW7I.cjs.map +0 -1
- package/dist/chunk-TQ4QOCKT.js.map +0 -1
- package/dist/chunk-UN2F6EKQ.js.map +0 -1
- package/dist/chunk-WVUR3HYW.js.map +0 -1
- package/dist/chunks-QTVEFJOS.js +0 -11
- package/dist/generator-6BFIABTF.js +0 -10
- package/dist/generator-XJLIBYDJ.js +0 -17
- package/dist/generator-XXVCF6TG.cjs +0 -11
- package/dist/hancom-7F53R77A.cjs +0 -85
- package/dist/hancom-7F53R77A.cjs.map +0 -1
- package/dist/hancom-D4E3WBPI.js +0 -84
- package/dist/hancom-D4E3WBPI.js.map +0 -1
- package/dist/hancom-IPF6HM5F.js +0 -85
- package/dist/hancom-IPF6HM5F.js.map +0 -1
- package/dist/image-ocr-NFCTNIL5.js.map +0 -1
- package/dist/image-ocr-PYOXD5K4.js.map +0 -1
- package/dist/image-ocr-ZLAPJMES.cjs.map +0 -1
- package/dist/memo-CNW6ZJFE.js +0 -17
- package/dist/parse-worker-v2-Q7ST3SDO.js.map +0 -1
- package/dist/parser-7JSQYNLS.js.map +0 -1
- package/dist/parser-A76QS3VJ.cjs.map +0 -1
- package/dist/parser-V25GYLBJ.js.map +0 -1
- package/dist/pdf-ocr-5YCDSSLG.cjs +0 -42
- package/dist/seal-7HBR3HBQ.js +0 -16
- package/dist/to-hwpx-6JF6Q2TZ.js +0 -21
- package/dist/to-hwpx-XLQUY2L2.cjs +0 -16
- package/dist/visual-VBDQUUKP.js +0 -37
- /package/dist/{-3EMVBTE7.js.map → -22V6D2US.js.map} +0 -0
- /package/dist/{chunk-7F5SKDUG.js.map → chunk-4MWUBTAE.js.map} +0 -0
- /package/dist/{chunk-4N2ESXR2.js.map → chunk-67GSFYG7.js.map} +0 -0
- /package/dist/{chunk-WICMTKWR.js.map → chunk-6BFWLS7E.js.map} +0 -0
- /package/dist/{chunk-7EL6BCO5.js.map → chunk-AUAJVQQK.js.map} +0 -0
- /package/dist/{chunk-QJBVP2BS.js.map → chunk-AXW2FMVR.js.map} +0 -0
- /package/dist/{chunk-SUOJQHIN.js.map → chunk-CCQMSIZQ.js.map} +0 -0
- /package/dist/{chunk-3UY7ARXP.js.map → chunk-DAAJO62F.js.map} +0 -0
- /package/dist/{chunk-E47LO7XG.js.map → chunk-EYSXMDA7.js.map} +0 -0
- /package/dist/{chunk-MHLTZ3VI.js.map → chunk-HETGOJ6V.js.map} +0 -0
- /package/dist/{chunk-OQPIN2OY.js.map → chunk-HW7WVYBF.js.map} +0 -0
- /package/dist/{chunk-AC7FZDVP.js.map → chunk-KB4ORA7M.js.map} +0 -0
- /package/dist/{chunk-SHYNOLL6.js.map → chunk-KXHUHGMC.js.map} +0 -0
- /package/dist/{chunk-WO6PZMMB.js.map → chunk-L3JP55ZY.js.map} +0 -0
- /package/dist/{chunk-NLPIXQOV.js.map → chunk-LOSCIAHY.js.map} +0 -0
- /package/dist/{chunk-GFWCBYAI.js.map → chunk-MIJTZKWF.js.map} +0 -0
- /package/dist/{chunk-D4TKVZKB.js.map → chunk-OAETOHH3.js.map} +0 -0
- /package/dist/{chunk-SI3GXM7Z.js.map → chunk-PMGJQWSW.js.map} +0 -0
- /package/dist/{chunk-MYIRYP6D.js.map → chunk-Q7FDPJUS.js.map} +0 -0
- /package/dist/{chunk-N6B5BINC.js.map → chunk-R2RLNUNK.js.map} +0 -0
- /package/dist/{chunk-FQMPHPHE.js.map → chunk-RQLEGKEV.js.map} +0 -0
- /package/dist/{chunk-REERG473.js.map → chunk-UU54HN5I.js.map} +0 -0
- /package/dist/{chunk-E5RJLP2S.js.map → chunk-VMOUAWGD.js.map} +0 -0
- /package/dist/{chunk-6YUMHSBG.js.map → chunk-WLFZOBZR.js.map} +0 -0
- /package/dist/{chunk-UJ3TZF4Y.js.map → chunk-Y6QW3FJQ.js.map} +0 -0
- /package/dist/{chunks-QTVEFJOS.js.map → chunks-Q7242OJE.js.map} +0 -0
- /package/dist/{formula-DUHNPES2.js.map → formula-BYEDWWZU.js.map} +0 -0
- /package/dist/{formula-XNCKOV6K.js.map → formula-FQLMMBDP.js.map} +0 -0
- /package/dist/{generator-6BFIABTF.js.map → generator-Q3L7RNUY.js.map} +0 -0
- /package/dist/{generator-XJLIBYDJ.js.map → generator-SU73HZHR.js.map} +0 -0
- /package/dist/{memo-CNW6ZJFE.js.map → memo-T5ZQEXEA.js.map} +0 -0
- /package/dist/{model-bundle-TIHWFIN5.js.map → model-bundle-UJRQPYUU.js.map} +0 -0
- /package/dist/{models-YBHBEM6J.js.map → models-64YLAWTI.js.map} +0 -0
- /package/dist/{pdf-ocr-GEAW23FB.js.map → pdf-ocr-XTZZEYKJ.js.map} +0 -0
- /package/dist/{pdf-ocr-IJXT6ZJR.js.map → pdf-ocr-ZV3KYIIE.js.map} +0 -0
- /package/dist/{profile-io-Y7SMMS2R.js.map → profile-io-FAJORRD2.js.map} +0 -0
- /package/dist/{rasterize-MLEHT6PU.js.map → rasterize-4ZJUA2DZ.js.map} +0 -0
- /package/dist/{redact-doc-GPO2UTTJ.js.map → redact-doc-JPNROEH6.js.map} +0 -0
- /package/dist/{render-TNWY53S4.js.map → render-D4WBOBKI.js.map} +0 -0
- /package/dist/{rewrite-fallback-AHGTN757.js.map → rewrite-fallback-OF3QI6CX.js.map} +0 -0
- /package/dist/{seal-7HBR3HBQ.js.map → seal-DQWEHIAM.js.map} +0 -0
- /package/dist/{setup-TJ57DQ6I.js.map → setup-YC25YCQB.js.map} +0 -0
- /package/dist/{to-hwpx-6JF6Q2TZ.js.map → to-hwpx-D7OMPDUQ.js.map} +0 -0
- /package/dist/{to-hwpx-DLVARUND.js.map → to-hwpx-ZWN64NCQ.js.map} +0 -0
- /package/dist/{visual-VBDQUUKP.js.map → visual-SW7NPY6K.js.map} +0 -0
- /package/dist/{watch-6CHDQ355.js.map → watch-ZU576VSR.js.map} +0 -0
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
|
|
38
38
|
|
|
39
39
|
|
|
40
|
-
var
|
|
40
|
+
var _chunkUBY2PLKRcjs = require('./chunk-UBY2PLKR.cjs');
|
|
41
41
|
|
|
42
42
|
|
|
43
43
|
var _chunkMMK32GPDcjs = require('./chunk-MMK32GPD.cjs');
|
|
@@ -47,7 +47,7 @@ var _chunkTK3FDAEEcjs = require('./chunk-TK3FDAEE.cjs');
|
|
|
47
47
|
|
|
48
48
|
|
|
49
49
|
|
|
50
|
-
var
|
|
50
|
+
var _chunkPW7MQZI4cjs = require('./chunk-PW7MQZI4.cjs');
|
|
51
51
|
|
|
52
52
|
// src/ocr/ocr-stacked-rows.ts
|
|
53
53
|
var NUMERIC = /^[-+−△▲▽▼]?[\d.,]+[%p]?$|^[-–—·∼~]$|^\([-+−△▲▽▼]?[\d.,]+%?\)$/;
|
|
@@ -628,8 +628,8 @@ var INKLESS_DELTA = 32;
|
|
|
628
628
|
function ringAsks(rgba, pageW, box, text, steps, stepPx) {
|
|
629
629
|
const chars = [...text];
|
|
630
630
|
if (chars.length !== steps.length || !/[가-힣]/.test(text)) return [];
|
|
631
|
-
const gray =
|
|
632
|
-
const rings =
|
|
631
|
+
const gray = _chunkUBY2PLKRcjs.grayCrop.call(void 0, rgba, pageW, box);
|
|
632
|
+
const rings = _chunkUBY2PLKRcjs.ringBoxes.call(void 0, gray, box.w, box.h, _chunkUBY2PLKRcjs.inkStats.call(void 0, gray));
|
|
633
633
|
const owner = ringOwners(chars, (i) => (steps[i] + 0.5) * stepPx, rings);
|
|
634
634
|
return rings.flatMap((r, k) => {
|
|
635
635
|
const at = owner.indexOf(k);
|
|
@@ -669,8 +669,8 @@ function ringGlyph(read, jamo = null, confidence = 1) {
|
|
|
669
669
|
function restoreGlyphs(rgba, pageW, box, text, steps, stepPx, note = {}, rings = []) {
|
|
670
670
|
const chars = [...text];
|
|
671
671
|
if (chars.length !== steps.length) return text;
|
|
672
|
-
const gray =
|
|
673
|
-
const c = { chars, cx: (i) => (steps[i] + 0.5) * stepPx, gray, w: box.w, h: box.h, ink:
|
|
672
|
+
const gray = _chunkUBY2PLKRcjs.grayCrop.call(void 0, rgba, pageW, box);
|
|
673
|
+
const c = { chars, cx: (i) => (steps[i] + 0.5) * stepPx, gray, w: box.w, h: box.h, ink: _chunkUBY2PLKRcjs.inkStats.call(void 0, gray) };
|
|
674
674
|
if (/[[\]]/.test(text)) brackets(c);
|
|
675
675
|
if (text.includes("'")) cornerQuotes(c);
|
|
676
676
|
if (/['"]/.test(text)) quotes(c);
|
|
@@ -700,7 +700,7 @@ function restoreGlyphs(rgba, pageW, box, text, steps, stepPx, note = {}, rings =
|
|
|
700
700
|
function trimInklessEnds(rgba, pageW, box, text, steps, stepPx) {
|
|
701
701
|
const chars = [...text], { w, h } = box;
|
|
702
702
|
if (chars.length !== steps.length || steps.some((s) => (s + 0.5) * stepPx > w + stepPx)) return { text, steps };
|
|
703
|
-
const gray =
|
|
703
|
+
const gray = _chunkUBY2PLKRcjs.grayCrop.call(void 0, rgba, pageW, box);
|
|
704
704
|
const hist = new Uint32Array(256);
|
|
705
705
|
for (const v of gray) hist[v]++;
|
|
706
706
|
let bg = 0;
|
|
@@ -731,8 +731,8 @@ function cornerCommas({ chars, cx, gray, w, h, ink }) {
|
|
|
731
731
|
continue;
|
|
732
732
|
}
|
|
733
733
|
if (open > 0) {
|
|
734
|
-
const f =
|
|
735
|
-
if (f &&
|
|
734
|
+
const f = _chunkUBY2PLKRcjs.bracketFeatures.call(void 0, gray, w, h, ink, cx(i));
|
|
735
|
+
if (f && _chunkUBY2PLKRcjs.bracketShape.call(void 0, f, true) === "\u300D") {
|
|
736
736
|
chars[i] = "\u300D";
|
|
737
737
|
open--;
|
|
738
738
|
}
|
|
@@ -742,12 +742,12 @@ function cornerCommas({ chars, cx, gray, w, h, ink }) {
|
|
|
742
742
|
function cornerQuotes({ chars, cx, gray, w, h, ink }) {
|
|
743
743
|
for (let i = 0; i < chars.length; i++) {
|
|
744
744
|
if (chars[i] !== "'" || !/^[가-힣]/.test(_nullishCoalesce(chars[i + 1], () => ( "")))) continue;
|
|
745
|
-
const f =
|
|
746
|
-
if (!f || f.ch < f.charH * 0.45 ||
|
|
745
|
+
const f = _chunkUBY2PLKRcjs.bracketFeatures.call(void 0, gray, w, h, ink, cx(i));
|
|
746
|
+
if (!f || f.ch < f.charH * 0.45 || _chunkUBY2PLKRcjs.bracketShape.call(void 0, f, false) !== "\u300C") continue;
|
|
747
747
|
const rest = chars.slice(i + 1), end = rest.findIndex((c) => c === "'" || c === "\u300D" || c === ",");
|
|
748
748
|
const pair = end >= 0 && rest[end] !== "'" && (rest[end] === "\u300D" || (() => {
|
|
749
|
-
const g =
|
|
750
|
-
return !!g &&
|
|
749
|
+
const g = _chunkUBY2PLKRcjs.bracketFeatures.call(void 0, gray, w, h, ink, cx(i + 1 + end));
|
|
750
|
+
return !!g && _chunkUBY2PLKRcjs.bracketShape.call(void 0, g, true) === "\u300D";
|
|
751
751
|
})());
|
|
752
752
|
if (pair) chars[i] = "\u300C";
|
|
753
753
|
}
|
|
@@ -755,8 +755,8 @@ function cornerQuotes({ chars, cx, gray, w, h, ink }) {
|
|
|
755
755
|
function brackets({ chars, cx, gray, w, h, ink }) {
|
|
756
756
|
const shape = chars.map((c, i) => {
|
|
757
757
|
if (c !== "[" && c !== "]") return null;
|
|
758
|
-
const f =
|
|
759
|
-
return f &&
|
|
758
|
+
const f = _chunkUBY2PLKRcjs.bracketFeatures.call(void 0, gray, w, h, ink, cx(i));
|
|
759
|
+
return f && _chunkUBY2PLKRcjs.bracketShape.call(void 0, f, c === "]");
|
|
760
760
|
});
|
|
761
761
|
for (let i = 0; i < chars.length; i++) {
|
|
762
762
|
if (chars[i] !== "[") continue;
|
|
@@ -788,7 +788,7 @@ function quotes({ chars, cx, gray, w, h, ink }) {
|
|
|
788
788
|
continue;
|
|
789
789
|
}
|
|
790
790
|
if (!year(i) && !single[kind]) continue;
|
|
791
|
-
const r =
|
|
791
|
+
const r = _chunkUBY2PLKRcjs.quoteHead.call(void 0, gray, w, h, ink, cx(i));
|
|
792
792
|
if (r !== null && r >= 0.47) {
|
|
793
793
|
chars[i] = kind === "'" ? "\u2018" : "\u201C";
|
|
794
794
|
open[kind] = true;
|
|
@@ -799,7 +799,7 @@ function dashes({ chars, cx, gray, w, h, ink }) {
|
|
|
799
799
|
const head = chars.findIndex((c) => c.trim()), letters = chars.some((c) => /[가-힣A-Za-z]/.test(c));
|
|
800
800
|
for (let i = 0; i < chars.length; i++) {
|
|
801
801
|
if (!/^[-\u2013\u2014]$/.test(chars[i])) continue;
|
|
802
|
-
const r =
|
|
802
|
+
const r = _chunkUBY2PLKRcjs.dashRatio.call(void 0, gray, w, h, ink, cx(i));
|
|
803
803
|
if (r === null) continue;
|
|
804
804
|
if (r < 0.65) chars[i] = "-";
|
|
805
805
|
else if (r > 0.75 && i === head && letters) chars[i] = "\u2014";
|
|
@@ -809,7 +809,7 @@ function circled({ chars, cx, gray, w, h, ink }) {
|
|
|
809
809
|
const alone = (re, i) => re.test(chars[i]) && !re.test(_nullishCoalesce(chars[i - 1], () => ( ""))) && !re.test(_nullishCoalesce(chars[i + 1], () => ( "")));
|
|
810
810
|
const at = chars.flatMap((_, i) => alone(/^\d$/, i) && chars[i] !== "0" || alone(/^[ㄱ-ㅎ]$/, i) || alone(/^[A-Za-z]$/, i) && /[a-zCSUVWXZ]/.test(chars[i]) ? [i] : []);
|
|
811
811
|
if (!at.length) return;
|
|
812
|
-
const hit =
|
|
812
|
+
const hit = _chunkUBY2PLKRcjs.circledAt.call(void 0, gray, w, h, ink, at.map(cx));
|
|
813
813
|
const JAMO = "\u3131\u3134\u3137\u3139\u3141\u3142\u3145\u3147\u3148\u314A\u314B\u314C\u314D\u314E";
|
|
814
814
|
at.forEach((i, k) => {
|
|
815
815
|
if (!hit[k]) return;
|
|
@@ -822,16 +822,16 @@ function stars({ chars, cx, gray, w, h, ink }) {
|
|
|
822
822
|
if (chars[i] !== "*" || chars[i - 1] === "*") continue;
|
|
823
823
|
let e = i;
|
|
824
824
|
while (chars[e + 1] === "*") e++;
|
|
825
|
-
const n =
|
|
825
|
+
const n = _chunkUBY2PLKRcjs.starRun.call(void 0, gray, w, h, ink, cx(i));
|
|
826
826
|
if (n > e - i + 1 && n <= 4) chars[e] += "*".repeat(n - (e - i + 1));
|
|
827
827
|
i = e;
|
|
828
828
|
}
|
|
829
829
|
}
|
|
830
830
|
function discs({ chars, cx, gray, w, h, ink }) {
|
|
831
|
-
for (let i = 0; i < chars.length; i++) if (/^[\u00b7\u2022]$/.test(chars[i]) &&
|
|
831
|
+
for (let i = 0; i < chars.length; i++) if (/^[\u00b7\u2022]$/.test(chars[i]) && _chunkUBY2PLKRcjs.discAt.call(void 0, gray, w, h, ink, cx(i))) chars[i] = "\u25CF";
|
|
832
832
|
}
|
|
833
833
|
function gaps({ chars, cx, gray, w, h, ink }) {
|
|
834
|
-
const { glyphs, bandH } =
|
|
834
|
+
const { glyphs, bandH } = _chunkUBY2PLKRcjs.gapGlyphs.call(void 0, gray, w, h, ink);
|
|
835
835
|
if (!glyphs.length) return;
|
|
836
836
|
const live = chars.map((c, i) => i).filter((i) => chars[i].trim());
|
|
837
837
|
if (!live.length) return;
|
|
@@ -902,18 +902,18 @@ function ring({ chars, cx, gray, w, h, ink }) {
|
|
|
902
902
|
const rest = chars.slice(k + 1).join("").trimStart();
|
|
903
903
|
const live = chars.map((c, i) => i).filter((i) => chars[i].trim());
|
|
904
904
|
if (live.length <= 3 && live.every((i) => /^[Oo]$/.test(chars[i]))) {
|
|
905
|
-
if (_optionalChain([
|
|
906
|
-
if (!live.every((i) =>
|
|
905
|
+
if (_optionalChain([_chunkUBY2PLKRcjs.leadingBullet.call(void 0, gray, w, h, ink, cx(live[0])), 'optionalAccess', _11 => _11.mark]) === "\u25CE") return false;
|
|
906
|
+
if (!live.every((i) => _chunkUBY2PLKRcjs.ringBullet.call(void 0, gray, w, h, ink, cx(i)) === "\u25CB")) return false;
|
|
907
907
|
for (const i of live) chars[i] = "\u25CB";
|
|
908
908
|
return true;
|
|
909
909
|
}
|
|
910
910
|
if (/^[A-Z]{2,}/.test(rest) && /^[Oo0]$/.test(chars[k])) {
|
|
911
|
-
if (
|
|
911
|
+
if (_chunkUBY2PLKRcjs.ringBullet.call(void 0, gray, w, h, ink, cx(k)) !== "\u25CB") return false;
|
|
912
912
|
chars[k] = chars[k + 1] === " " ? "\u25CB" : "\u25CB ";
|
|
913
913
|
return true;
|
|
914
914
|
}
|
|
915
915
|
if (!/^[(\[「【<]?\d*[가-힣]/.test(rest)) return false;
|
|
916
|
-
const r =
|
|
916
|
+
const r = _chunkUBY2PLKRcjs.ringBullet.call(void 0, gray, w, h, ink, cx(k));
|
|
917
917
|
if (/^[Cc]$/.test(chars[k]) && r !== "\u25CB") return false;
|
|
918
918
|
if (r) chars[k] = r;
|
|
919
919
|
return r !== null;
|
|
@@ -930,7 +930,7 @@ function parallels({ chars, cx, gray, w, h, ink }) {
|
|
|
930
930
|
let p = s - 1, q = e + 1;
|
|
931
931
|
while (p >= 0 && !chars[p].trim()) p--;
|
|
932
932
|
while (q < chars.length && !chars[q].trim()) q++;
|
|
933
|
-
if (
|
|
933
|
+
if (_chunkUBY2PLKRcjs.slantedPair.call(void 0, gray, w, h, ink, p >= 0 ? cx(p) : -Infinity, q < chars.length ? cx(q) : Infinity)) {
|
|
934
934
|
chars[s] = "\u2225";
|
|
935
935
|
for (let k = s + 1; k <= e; k++) chars[k] = "";
|
|
936
936
|
}
|
|
@@ -942,7 +942,7 @@ function roman({ chars, cx, gray, w, h, ink }) {
|
|
|
942
942
|
const ROMAN = /^[IⅠ-Ⅲ]$/, LATIN = /[A-Za-z]$/;
|
|
943
943
|
for (let i = 0; i < chars.length; i++) {
|
|
944
944
|
if (chars[i] !== "1" || /[\dA-Za-z]$/.test(_nullishCoalesce(chars[i - 1], () => ( ""))) || /^[\dA-Za-z,]/.test(_nullishCoalesce(chars[i + 1], () => ( "")))) continue;
|
|
945
|
-
if (
|
|
945
|
+
if (_chunkUBY2PLKRcjs.serifOne.call(void 0, gray, w, h, ink, cx(i))) chars[i] = "\u2160";
|
|
946
946
|
}
|
|
947
947
|
for (let i = 0; i < chars.length; i++) {
|
|
948
948
|
const hangul = /^[파피]$/.test(chars[i]);
|
|
@@ -952,13 +952,13 @@ function roman({ chars, cx, gray, w, h, ink }) {
|
|
|
952
952
|
while (q < chars.length && !chars[q].trim()) q++;
|
|
953
953
|
const glued = hangul ? chars[p] === "(" && chars[q] === "-" : /[가-힣]$/.test(_nullishCoalesce(chars[i - 1], () => ( ""))) || (_nullishCoalesce(chars[i + 1], () => ( ""))) === "." || chars[p] === "-" && chars[q] === "-";
|
|
954
954
|
if (!glued) continue;
|
|
955
|
-
const n =
|
|
955
|
+
const n = _chunkUBY2PLKRcjs.romanStems.call(void 0, gray, w, h, ink, p >= 0 ? cx(p) : -Infinity, q < chars.length ? cx(q) : Infinity, /[가-힣]$/.test(_nullishCoalesce(chars[p], () => ( ""))));
|
|
956
956
|
if (n) chars[i] = String.fromCharCode(8543 + n);
|
|
957
957
|
}
|
|
958
958
|
const inRoman = (i) => ROMAN.test(chars[i]) || chars[i] === "1" && (ROMAN.test(_nullishCoalesce(chars[i - 1], () => ( ""))) || ROMAN.test(_nullishCoalesce(chars[i + 1], () => ( ""))));
|
|
959
959
|
const k = chars.findIndex((c) => c.trim());
|
|
960
960
|
if (chars[k] === "." && chars.slice(k + 1).some((c) => /[가-힣A-Za-z0-9]/.test(c))) {
|
|
961
|
-
const n =
|
|
961
|
+
const n = _chunkUBY2PLKRcjs.romanStems.call(void 0, gray, w, h, ink, -Infinity, cx(k));
|
|
962
962
|
if (n) chars[k] = String.fromCharCode(8543 + n) + chars[k];
|
|
963
963
|
}
|
|
964
964
|
for (let s = 0; s < chars.length; ) {
|
|
@@ -976,7 +976,7 @@ function roman({ chars, cx, gray, w, h, ink }) {
|
|
|
976
976
|
let p = s - 1, q = e;
|
|
977
977
|
while (p >= 0 && !chars[p].trim()) p--;
|
|
978
978
|
while (q < chars.length && !chars[q].trim()) q++;
|
|
979
|
-
const n =
|
|
979
|
+
const n = _chunkUBY2PLKRcjs.romanStems.call(void 0, gray, w, h, ink, p >= 0 ? cx(p) : -Infinity, q < chars.length ? cx(q) : Infinity, /[가-힣]$/.test(_nullishCoalesce(chars[p], () => ( ""))));
|
|
980
980
|
const canon = n ? [["\u2160", "I"], ["\u2161", "II"], ["\u2162", "III"]][n - 1] : null;
|
|
981
981
|
if (canon && !canon.includes(tok)) {
|
|
982
982
|
chars[s] = canon[0];
|
|
@@ -1389,8 +1389,8 @@ function joinGapLeaders(rgba, width, items) {
|
|
|
1389
1389
|
if (g1 - g0 < h * 3) continue;
|
|
1390
1390
|
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));
|
|
1391
1391
|
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 };
|
|
1392
|
-
const gray =
|
|
1393
|
-
const runs =
|
|
1392
|
+
const gray = _chunkUBY2PLKRcjs.grayCrop.call(void 0, rgba, width, box);
|
|
1393
|
+
const runs = _chunkUBY2PLKRcjs.leaderRuns.call(void 0, gray, box.w, box.h, _chunkUBY2PLKRcjs.inkStats.call(void 0, gray), LEADER_MIN_DOTS);
|
|
1394
1394
|
const cover = runs.reduce((k, [a, b]) => k + Math.max(0, Math.min(b, g1 - box.x) - Math.max(a, g0 - box.x)), 0);
|
|
1395
1395
|
if (cover < (g1 - g0) * 0.6) continue;
|
|
1396
1396
|
for (const o of items) if (junk(o) && sameLine(o, num) && o.x >= g0 - 2 && o.x + o.w <= g1 + 2) gone.add(o);
|
|
@@ -1657,7 +1657,7 @@ var OcrEngine = class _OcrEngine {
|
|
|
1657
1657
|
this.ort = parts.ort;
|
|
1658
1658
|
this.sharp = parts.sharp;
|
|
1659
1659
|
}
|
|
1660
|
-
static async create(models =
|
|
1660
|
+
static async create(models = _chunkUBY2PLKRcjs.DEFAULT_OCR_MODELS) {
|
|
1661
1661
|
_chunkTK3FDAEEcjs.disableOrtTelemetry.call(void 0, );
|
|
1662
1662
|
const [ortMod, sharpModRaw] = await Promise.all([
|
|
1663
1663
|
tryImport("onnxruntime-node", () => Promise.resolve().then(() => _interopRequireWildcard(require("onnxruntime-node")))),
|
|
@@ -1677,16 +1677,16 @@ var OcrEngine = class _OcrEngine {
|
|
|
1677
1677
|
const local = (s) => "spec" in s ? Promise.resolve(null) : verifiedBytes(s);
|
|
1678
1678
|
const [detBytes, recBytes, dictBytes] = await Promise.all([local(models.det), local(models.rec), local(models.dict)]);
|
|
1679
1679
|
const session = (s, bytes) => bytes ? ortMod.InferenceSession.create(bytes, sessionOpts).catch(() => {
|
|
1680
|
-
throw new (0,
|
|
1681
|
-
}) : ortMod.InferenceSession.create(
|
|
1680
|
+
throw new (0, _chunkPW7MQZI4cjs.KordocError)(`OCR \uBAA8\uB378\uC744 \uC5F4\uC9C0 \uBABB\uD588\uC2B5\uB2C8\uB2E4: ${_path.basename.call(void 0, _chunkUBY2PLKRcjs.ocrSourcePath.call(void 0, s))} \u2014 ONNX \uBAA8\uB378\uC774 \uC544\uB2C8\uAC70\uB098 \uC190\uC0C1\uB410\uC2B5\uB2C8\uB2E4`);
|
|
1681
|
+
}) : ortMod.InferenceSession.create(_chunkUBY2PLKRcjs.ocrSourcePath.call(void 0, s), sessionOpts);
|
|
1682
1682
|
const [det, rec, dictYml] = await Promise.all([
|
|
1683
1683
|
session(models.det, detBytes),
|
|
1684
1684
|
session(models.rec, recBytes),
|
|
1685
|
-
dictBytes ? new TextDecoder().decode(dictBytes) : _promises.readFile.call(void 0,
|
|
1685
|
+
dictBytes ? new TextDecoder().decode(dictBytes) : _promises.readFile.call(void 0, _chunkUBY2PLKRcjs.ocrSourcePath.call(void 0, models.dict), "utf-8")
|
|
1686
1686
|
]);
|
|
1687
|
-
const dict =
|
|
1687
|
+
const dict = _chunkUBY2PLKRcjs.parseCharacterDict.call(void 0, dictYml);
|
|
1688
1688
|
if (dict.length === 0) {
|
|
1689
|
-
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,
|
|
1689
|
+
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, _chunkPW7MQZI4cjs.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`);
|
|
1690
1690
|
}
|
|
1691
1691
|
return new _OcrEngine({ det, rec, dict, ort: ortMod, sharp: sharpMod });
|
|
1692
1692
|
}
|
|
@@ -1718,10 +1718,10 @@ var OcrEngine = class _OcrEngine {
|
|
|
1718
1718
|
if (it.x - x < it.h * 0.8) return;
|
|
1719
1719
|
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;
|
|
1720
1720
|
const box = { x, y: it.y, w: it.x + it.w - x, h: it.h };
|
|
1721
|
-
const g =
|
|
1722
|
-
const b =
|
|
1721
|
+
const g = _chunkUBY2PLKRcjs.grayCrop.call(void 0, rgba, width, box);
|
|
1722
|
+
const b = _chunkUBY2PLKRcjs.leadingBullet.call(void 0, g, box.w, box.h, _chunkUBY2PLKRcjs.inkStats.call(void 0, g), it.x - x, 1.05);
|
|
1723
1723
|
if (_optionalChain([b, 'optionalAccess', _36 => _36.mark]) !== "\u25A1" || b.covers) return;
|
|
1724
|
-
const ink =
|
|
1724
|
+
const ink = _chunkUBY2PLKRcjs.inkStats.call(void 0, g), on = (v) => ink.darkInk ? v <= ink.threshold : v > ink.threshold;
|
|
1725
1725
|
let left = 0;
|
|
1726
1726
|
while (left < it.x - x && !Array.from({ length: box.h }, (_, y) => g[y * box.w + left]).some(on)) left++;
|
|
1727
1727
|
it.text = "\u25A1 " + it.text;
|
|
@@ -1753,12 +1753,12 @@ var OcrEngine = class _OcrEngine {
|
|
|
1753
1753
|
const joins = [];
|
|
1754
1754
|
let group = 0;
|
|
1755
1755
|
for (const b of boxes) {
|
|
1756
|
-
const gray =
|
|
1757
|
-
const ink =
|
|
1756
|
+
const gray = _chunkUBY2PLKRcjs.grayCrop.call(void 0, rgba, width, b);
|
|
1757
|
+
const ink = _chunkUBY2PLKRcjs.inkStats.call(void 0, gray);
|
|
1758
1758
|
if (tuning.minInkContrast > 0 && ink.contrast < tuning.minInkContrast) continue;
|
|
1759
1759
|
if (tuning.minInkContrast > 0 && ink.inkRatio < MIN_INK_RATIO) continue;
|
|
1760
1760
|
if (tuning.splitTall && b.h >= b.w * TALL_RATIO) {
|
|
1761
|
-
const bands =
|
|
1761
|
+
const bands = _chunkUBY2PLKRcjs.splitRowBands.call(void 0, gray, b.w, b.h, ink, 0.45);
|
|
1762
1762
|
if (bands.length >= 2) {
|
|
1763
1763
|
for (const sub of bandBoxes(b, bands, height)) jobs.push({ box: sub, rot: 0, group: group++ });
|
|
1764
1764
|
continue;
|
|
@@ -1769,9 +1769,9 @@ var OcrEngine = class _OcrEngine {
|
|
|
1769
1769
|
continue;
|
|
1770
1770
|
}
|
|
1771
1771
|
}
|
|
1772
|
-
const trim = tuning.trimEdges ?
|
|
1772
|
+
const trim = tuning.trimEdges ? _chunkUBY2PLKRcjs.edgeTrim.call(void 0, gray, b.w, b.h, ink) : null;
|
|
1773
1773
|
const keep = trim ? { ...trim, bg: median(gray) } : void 0;
|
|
1774
|
-
const leaders = tuning.splitLeaders ?
|
|
1774
|
+
const leaders = tuning.splitLeaders ? _chunkUBY2PLKRcjs.leaderRuns.call(void 0, gray, b.w, b.h, ink, LEADER_MIN_DOTS) : [];
|
|
1775
1775
|
if (leaders.length) {
|
|
1776
1776
|
const join = joins.length;
|
|
1777
1777
|
joins.push({ box: b, parts: [], trailDots: false });
|
|
@@ -1780,7 +1780,7 @@ var OcrEngine = class _OcrEngine {
|
|
|
1780
1780
|
const bare = { x: b.x + x0, y: b.y, w: a - x0, h: b.h };
|
|
1781
1781
|
const end = c > a ? Math.min(c, a + Math.round(b.h * LEADER_CONTEXT)) : a;
|
|
1782
1782
|
x0 = c;
|
|
1783
|
-
if (bare.w >= DET_MIN_SIZE &&
|
|
1783
|
+
if (bare.w >= DET_MIN_SIZE && _chunkUBY2PLKRcjs.inkStats.call(void 0, _chunkUBY2PLKRcjs.grayCrop.call(void 0, rgba, width, bare)).contrast >= Math.max(1, tuning.minInkContrast)) {
|
|
1784
1784
|
jobs.push({ box: { ...bare, w: end - (bare.x - b.x) }, rot: 0, group: group++, join, dotsBefore: dots, trimDots: end > a });
|
|
1785
1785
|
dots = false;
|
|
1786
1786
|
}
|
|
@@ -1828,15 +1828,15 @@ var OcrEngine = class _OcrEngine {
|
|
|
1828
1828
|
let text = tuning.postprocess ? restoreSymbols(raw.trim(), note.ringLead) : raw;
|
|
1829
1829
|
if (!text.trim()) continue;
|
|
1830
1830
|
if (tuning.postprocess && job.rot === 0 && text !== "/" && /^[(:;/)]+$/.test(text) && text.includes("/")) {
|
|
1831
|
-
const g =
|
|
1832
|
-
if (
|
|
1831
|
+
const g = _chunkUBY2PLKRcjs.grayCrop.call(void 0, rgba, width, job.box);
|
|
1832
|
+
if (_chunkUBY2PLKRcjs.tallInkCount.call(void 0, g, job.box.w, job.box.h, _chunkUBY2PLKRcjs.inkStats.call(void 0, g)) === 1) text = "/";
|
|
1833
1833
|
}
|
|
1834
1834
|
let ringByShape = false;
|
|
1835
1835
|
if (tuning.postprocess && job.rot === 0 && !/^[◎●▪□■▣❐❏○ㅇ◆◇◈]/.test(text)) {
|
|
1836
1836
|
const chars = [...read], k = chars.findIndex((c) => c.trim());
|
|
1837
1837
|
if (k >= 0 && steps.length === chars.length) {
|
|
1838
|
-
const g =
|
|
1839
|
-
const b =
|
|
1838
|
+
const g = _chunkUBY2PLKRcjs.grayCrop.call(void 0, rgba, width, job.box);
|
|
1839
|
+
const b = _chunkUBY2PLKRcjs.leadingBullet.call(void 0, g, job.box.w, job.box.h, _chunkUBY2PLKRcjs.inkStats.call(void 0, g), (steps[k] + 0.5) * stepPx);
|
|
1840
1840
|
const body = (_nullishCoalesce(text.match(/[가-힣]/g), () => ( []))).length >= 4;
|
|
1841
1841
|
const miss = /^[Oo0•·ㆍ∙‧○]/.test(text);
|
|
1842
1842
|
if (_optionalChain([b, 'optionalAccess', _39 => _39.mark]) === "\u25CE" && b.covers && /^[Oo0○©]/.test(text)) {
|
|
@@ -1851,17 +1851,17 @@ var OcrEngine = class _OcrEngine {
|
|
|
1851
1851
|
} else if (_optionalChain([b, 'optionalAccess', _46 => _46.mark]) === "\u2750" || _optionalChain([b, 'optionalAccess', _47 => _47.mark]) === "\u274F") {
|
|
1852
1852
|
if (b.covers ? /^[ㅁ口]/.test(text) : body) text = b.covers ? b.mark + text.slice(1) : b.mark + " " + text;
|
|
1853
1853
|
} else if (b && b.mark !== "\u25CE" && body) text = b.covers ? miss ? b.mark + " " + text.slice(1).trimStart() : text : b.mark + " " + text;
|
|
1854
|
-
else if (!b && body && /^[가-힣]/.test(chars[k]) &&
|
|
1854
|
+
else if (!b && body && /^[가-힣]/.test(chars[k]) && _chunkUBY2PLKRcjs.leadingRing.call(void 0, g, job.box.w, job.box.h, _chunkUBY2PLKRcjs.inkStats.call(void 0, g), (steps[k] + 0.5) * stepPx)) text = "\u25CB " + text;
|
|
1855
1855
|
}
|
|
1856
1856
|
}
|
|
1857
1857
|
if (tuning.postprocess && /^\d/.test(text) && job.rot === 0) {
|
|
1858
|
-
const g =
|
|
1859
|
-
const tri =
|
|
1858
|
+
const g = _chunkUBY2PLKRcjs.grayCrop.call(void 0, rgba, width, job.box);
|
|
1859
|
+
const tri = _chunkUBY2PLKRcjs.leadingTriangle.call(void 0, g, job.box.w, job.box.h, _chunkUBY2PLKRcjs.inkStats.call(void 0, g));
|
|
1860
1860
|
if (tri) text = tri + text;
|
|
1861
1861
|
}
|
|
1862
1862
|
if (tuning.postprocess && text === "\u2192" && job.rot === 0 && job.join === void 0) {
|
|
1863
|
-
const g =
|
|
1864
|
-
text = _nullishCoalesce(
|
|
1863
|
+
const g = _chunkUBY2PLKRcjs.grayCrop.call(void 0, rgba, width, job.box);
|
|
1864
|
+
text = _nullishCoalesce(_chunkUBY2PLKRcjs.arrowGlyph.call(void 0, g, job.box.w, job.box.h, _chunkUBY2PLKRcjs.inkStats.call(void 0, g)), () => ( text));
|
|
1865
1865
|
}
|
|
1866
1866
|
if (job.footer) {
|
|
1867
1867
|
if (!/^[-\u2013\u2014]?\s*(?:\d{1,4}|[ivxIVXⅰ-ⅹⅠ-Ⅹ]{1,4})\s*[-\u2013\u2014]?$/.test(text.trim())) continue;
|
|
@@ -1882,7 +1882,7 @@ var OcrEngine = class _OcrEngine {
|
|
|
1882
1882
|
continue;
|
|
1883
1883
|
}
|
|
1884
1884
|
const item = { text, ...this.itemBox(rgba, width, job.box, tuning), confidence };
|
|
1885
|
-
if (job.rot === 0)
|
|
1885
|
+
if (job.rot === 0) _chunkUBY2PLKRcjs.rememberOcrTextGaps.call(void 0, item, _chunkUBY2PLKRcjs.findOcrTextGaps.call(void 0, rgba, width, job.box, read, text, steps, stepPx));
|
|
1886
1886
|
if (job.rot === 0 && job.keep === void 0) boxOf.set(item, job.box);
|
|
1887
1887
|
items.push(item);
|
|
1888
1888
|
}
|
|
@@ -1896,7 +1896,7 @@ var OcrEngine = class _OcrEngine {
|
|
|
1896
1896
|
const merged = rereadNumberText(it.text, r.text);
|
|
1897
1897
|
if (merged === null) return;
|
|
1898
1898
|
it.text = merged;
|
|
1899
|
-
|
|
1899
|
+
_chunkUBY2PLKRcjs.rememberOcrTextGaps.call(void 0, it, _chunkUBY2PLKRcjs.findOcrTextGaps.call(void 0, rgba, width, boxOf.get(it), r.text, it.text, r.steps, r.stepPx));
|
|
1900
1900
|
});
|
|
1901
1901
|
}
|
|
1902
1902
|
const blank2 = tuning.postprocess ? jobs.filter((j) => j.rot === 0 && j.join === void 0 && !j.footer && !j.keep && !best.has(j.group)).map((j) => j.box) : [];
|
|
@@ -1904,14 +1904,14 @@ var OcrEngine = class _OcrEngine {
|
|
|
1904
1904
|
const subs = [];
|
|
1905
1905
|
const stacks = [];
|
|
1906
1906
|
for (const b of [...retry, ...blank2]) {
|
|
1907
|
-
const gray =
|
|
1908
|
-
const ink =
|
|
1907
|
+
const gray = _chunkUBY2PLKRcjs.grayCrop.call(void 0, rgba, width, b);
|
|
1908
|
+
const ink = _chunkUBY2PLKRcjs.inkStats.call(void 0, gray);
|
|
1909
1909
|
const cut = retry.includes(b) ? midBlankRow(gray, b.w, b.h, ink) : null;
|
|
1910
1910
|
if (cut && b.w >= 3 * Math.max(cut[0], b.h - cut[1])) {
|
|
1911
1911
|
subs.push({ ...b, h: cut[0] }, { ...b, y: b.y + cut[1], h: b.h - cut[1] });
|
|
1912
1912
|
continue;
|
|
1913
1913
|
}
|
|
1914
|
-
const bands =
|
|
1914
|
+
const bands = _chunkUBY2PLKRcjs.stackedGlyphBands.call(void 0, gray, b.w, b.h, ink);
|
|
1915
1915
|
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)) });
|
|
1916
1916
|
}
|
|
1917
1917
|
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));
|
|
@@ -1984,8 +1984,8 @@ var OcrEngine = class _OcrEngine {
|
|
|
1984
1984
|
/** 결과 좌표 — det 박스 그대로 또는 박스 안 잉크 외곽 (tightBoxes) */
|
|
1985
1985
|
itemBox(rgba, width, b, tuning) {
|
|
1986
1986
|
if (!tuning.tightBoxes) return b;
|
|
1987
|
-
const gray =
|
|
1988
|
-
const t =
|
|
1987
|
+
const gray = _chunkUBY2PLKRcjs.grayCrop.call(void 0, rgba, width, b);
|
|
1988
|
+
const t = _chunkUBY2PLKRcjs.inkBounds.call(void 0, gray, b.w, b.h, _chunkUBY2PLKRcjs.inkStats.call(void 0, gray));
|
|
1989
1989
|
return { x: b.x + t.x0, y: b.y + t.y0, w: t.x1 - t.x0, h: t.y1 - t.y0 };
|
|
1990
1990
|
}
|
|
1991
1991
|
// ─── det ─────────────────────────────────────────────
|
|
@@ -2056,7 +2056,7 @@ var OcrEngine = class _OcrEngine {
|
|
|
2056
2056
|
const out = await this.rec.run({ [this.rec.inputNames[0]]: tensor });
|
|
2057
2057
|
const logits = out[this.rec.outputNames[0]];
|
|
2058
2058
|
const [, T, C] = logits.dims;
|
|
2059
|
-
if (C !== this.dict.length + 2) throw new (0,
|
|
2059
|
+
if (C !== this.dict.length + 2) throw new (0, _chunkPW7MQZI4cjs.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`);
|
|
2060
2060
|
const data = logits.data;
|
|
2061
2061
|
idx.forEach((ci, k) => {
|
|
2062
2062
|
const r = ctcDecode(data.subarray(k * T * C, (k + 1) * T * C), T, C, this.dict);
|
|
@@ -2066,9 +2066,9 @@ var OcrEngine = class _OcrEngine {
|
|
|
2066
2066
|
const chars = r ? [...r.text] : [];
|
|
2067
2067
|
if (r && job.rot === 0 && chars.length === r.steps.length && r.steps.some((t) => t > last) && !r.text.includes("(cid:")) {
|
|
2068
2068
|
const tallCh = (c) => !/[\s.,:;\u00b7\u2026'"\u2018-\u201d`\-_~]/.test(c);
|
|
2069
|
-
const g =
|
|
2069
|
+
const g = _chunkUBY2PLKRcjs.grayCrop.call(void 0, rgba, pageW, job.box);
|
|
2070
2070
|
const inside = chars.filter((c, i) => r.steps[i] <= last && tallCh(c)).length;
|
|
2071
|
-
let budget = inside <= 2 ?
|
|
2071
|
+
let budget = inside <= 2 ? _chunkUBY2PLKRcjs.tallInkCount.call(void 0, g, job.box.w, job.box.h, _chunkUBY2PLKRcjs.inkStats.call(void 0, g)) - inside : Infinity;
|
|
2072
2072
|
const keep = chars.map((c, i) => r.steps[i] <= last || !tallCh(c) || budget-- > 0);
|
|
2073
2073
|
if (!keep.every(Boolean)) kept = { ...r, text: chars.filter((_, i) => keep[i]).join(""), steps: r.steps.filter((_, i) => keep[i]) };
|
|
2074
2074
|
}
|
|
@@ -2179,13 +2179,13 @@ async function tryImport(name, loader) {
|
|
|
2179
2179
|
return await loader();
|
|
2180
2180
|
} catch (e) {
|
|
2181
2181
|
throw new Error(
|
|
2182
|
-
`\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.${
|
|
2182
|
+
`\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.${_chunkPW7MQZI4cjs.OPTIONAL_DEP_INSTALL_HINT} \uC6D0\uC778: ${e.message}`
|
|
2183
2183
|
);
|
|
2184
2184
|
}
|
|
2185
2185
|
}
|
|
2186
2186
|
async function verifiedBytes(s) {
|
|
2187
2187
|
const name = _path.basename.call(void 0, s.file.path);
|
|
2188
|
-
const fail = (why2) => new (0,
|
|
2188
|
+
const fail = (why2) => new (0, _chunkPW7MQZI4cjs.KordocError)(`OCR \uBAA8\uB378 \uD30C\uC77C\uC744 \uC77D\uC9C0 \uBABB\uD588\uC2B5\uB2C8\uB2E4: ${name} (${why2})`);
|
|
2189
2189
|
const why = (e) => {
|
|
2190
2190
|
const code = e.code;
|
|
2191
2191
|
return code === "ENOENT" ? "\uD30C\uC77C\uC774 \uC5C6\uC74C" : code === "EACCES" || code === "EPERM" ? "\uAD8C\uD55C \uC5C6\uC74C" : "\uC77D\uAE30 \uC2E4\uD328";
|
|
@@ -2206,13 +2206,13 @@ async function verifiedBytes(s) {
|
|
|
2206
2206
|
}
|
|
2207
2207
|
const actual = _crypto.createHash.call(void 0, "sha256").update(bytes).digest("hex");
|
|
2208
2208
|
if (actual !== s.file.sha256) {
|
|
2209
|
-
throw new (0,
|
|
2209
|
+
throw new (0, _chunkPW7MQZI4cjs.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)`);
|
|
2210
2210
|
}
|
|
2211
2211
|
return bytes;
|
|
2212
2212
|
}
|
|
2213
2213
|
var engines = /* @__PURE__ */ new Map();
|
|
2214
|
-
function getOcrEngine(models =
|
|
2215
|
-
const key =
|
|
2214
|
+
function getOcrEngine(models = _chunkUBY2PLKRcjs.DEFAULT_OCR_MODELS) {
|
|
2215
|
+
const key = _chunkUBY2PLKRcjs.ocrSelectionKey.call(void 0, models);
|
|
2216
2216
|
let p = engines.get(key);
|
|
2217
2217
|
if (!p) {
|
|
2218
2218
|
p = OcrEngine.create(models).catch((err) => {
|
|
@@ -2460,6 +2460,52 @@ function splitOcrContactColumns(blocks) {
|
|
|
2460
2460
|
return blocks;
|
|
2461
2461
|
}
|
|
2462
2462
|
|
|
2463
|
+
// src/ocr/empty-cell-rescue.ts
|
|
2464
|
+
var MAX_CELLS = 60;
|
|
2465
|
+
var TOL = 3;
|
|
2466
|
+
var PAD = 16;
|
|
2467
|
+
async function rescueEmptyCells(engine, tuning, rgba, width, height, ruling, items) {
|
|
2468
|
+
const hs = ruling.horizontals, vs = ruling.verticals;
|
|
2469
|
+
if (hs.length < 2 || vs.length < 2) return [];
|
|
2470
|
+
const uniq = (vals) => {
|
|
2471
|
+
const out2 = [];
|
|
2472
|
+
for (const v of [...vals].sort((a, b) => a - b)) if (!out2.length || v - out2[out2.length - 1] > TOL) out2.push(v);
|
|
2473
|
+
return out2;
|
|
2474
|
+
};
|
|
2475
|
+
const ys = uniq(hs.map((h) => h.y1)), xs = uniq(vs.map((v) => v.x1));
|
|
2476
|
+
const hAt = (y, a, b) => hs.some((h) => Math.abs(h.y1 - y) <= TOL && Math.min(h.x1, h.x2) <= a + TOL && Math.max(h.x1, h.x2) >= b - TOL);
|
|
2477
|
+
const vAt = (x, a, b) => vs.some((v) => Math.abs(v.x1 - x) <= TOL && Math.min(v.y1, v.y2) <= a + TOL && Math.max(v.y1, v.y2) >= b - TOL);
|
|
2478
|
+
const cells = [];
|
|
2479
|
+
for (let j = 0; j + 1 < xs.length && cells.length < MAX_CELLS; j++) {
|
|
2480
|
+
for (let i = 0; i + 1 < ys.length && cells.length < MAX_CELLS; i++) {
|
|
2481
|
+
let k = i + 1;
|
|
2482
|
+
while (k + 1 < ys.length && !hAt(ys[k], xs[j], xs[j + 1])) k++;
|
|
2483
|
+
const [y1, y2, x1, x2] = [ys[i], ys[k], xs[j], xs[j + 1]];
|
|
2484
|
+
i = k - 1;
|
|
2485
|
+
if (y2 - y1 < 15 || x2 - x1 < 20 || (x2 - x1) * (y2 - y1) > width * height * 0.05) continue;
|
|
2486
|
+
if (!hAt(y1, x1, x2) || !hAt(y2, x1, x2) || !vAt(x1, y1, y2) || !vAt(x2, y1, y2)) continue;
|
|
2487
|
+
const bx = Math.ceil(x1 + 4), by = Math.ceil(y1 + 4), box = { x: bx, y: by, w: Math.floor(x2 - 4) - bx, h: Math.floor(y2 - 4) - by };
|
|
2488
|
+
if (box.w < 10 || box.h < 8) continue;
|
|
2489
|
+
if (items.some((it) => Math.min(it.x + it.w, box.x + box.w) > Math.max(it.x, box.x) && Math.min(it.y + it.h, box.y + box.h) > Math.max(it.y, box.y))) continue;
|
|
2490
|
+
let ink = 0;
|
|
2491
|
+
for (let y = box.y; y < box.y + box.h; y++) for (let x = box.x, p = (y * width + x) * 4; x < box.x + box.w; x++, p += 4) {
|
|
2492
|
+
if (rgba[p] * 77 + rgba[p + 1] * 150 + rgba[p + 2] * 29 < 128 * 256) ink++;
|
|
2493
|
+
}
|
|
2494
|
+
if (ink >= 40 && ink >= box.w * box.h * 0.01) cells.push(box);
|
|
2495
|
+
}
|
|
2496
|
+
}
|
|
2497
|
+
const out = [];
|
|
2498
|
+
for (const c of cells) {
|
|
2499
|
+
const w = c.w + PAD * 2, h = c.h + PAD * 2;
|
|
2500
|
+
const crop = new Uint8Array(w * h * 4).fill(255);
|
|
2501
|
+
for (let y = 0; y < c.h; y++) crop.set(rgba.subarray(((c.y + y) * width + c.x) * 4, ((c.y + y) * width + c.x + c.w) * 4), ((y + PAD) * w + PAD) * 4);
|
|
2502
|
+
const stats = { droppedLowConf: 0 };
|
|
2503
|
+
const found = await engine.recognizePage(crop, w, h, stats, { ...tuning, orientPage: false });
|
|
2504
|
+
for (const it of found) out.push({ ...it, x: it.x + c.x - PAD, y: it.y + c.y - PAD });
|
|
2505
|
+
}
|
|
2506
|
+
return out;
|
|
2507
|
+
}
|
|
2508
|
+
|
|
2463
2509
|
// src/ocr/pdf-ocr.ts
|
|
2464
2510
|
var OCR_RENDER_SCALE = 3;
|
|
2465
2511
|
var MAX_OCR_PIXELS = 24e6;
|
|
@@ -2467,20 +2513,20 @@ var PAGE_TIMEOUT_MS = 12e4;
|
|
|
2467
2513
|
var AUTO_REC = { pageConf: 0.9, gain: 0.06 };
|
|
2468
2514
|
var DEFAULT_AUTO_REC = { pageConf: 0.85, gain: 0.1, lazy: true };
|
|
2469
2515
|
var DEFAULT_BUILTIN_OCR = Object.freeze({
|
|
2470
|
-
models:
|
|
2516
|
+
models: _chunkUBY2PLKRcjs.DEFAULT_OCR_MODELS,
|
|
2471
2517
|
tuning: DEFAULT_OCR_TUNING,
|
|
2472
|
-
handwriting:
|
|
2518
|
+
handwriting: _chunkUBY2PLKRcjs.handwritingFallbackModels.call(void 0, _chunkUBY2PLKRcjs.DEFAULT_OCR_MODELS),
|
|
2473
2519
|
autoRec: DEFAULT_AUTO_REC
|
|
2474
2520
|
});
|
|
2475
2521
|
var DEFAULT_BUILTIN_OCR_FETCH = Object.freeze({ ...DEFAULT_BUILTIN_OCR, autoRec: { ...DEFAULT_AUTO_REC, fetch: true } });
|
|
2476
2522
|
function builtinOcrConfig(o) {
|
|
2477
2523
|
if (!o || o.ocrDet === void 0 && o.ocrDetLongSide === void 0 && o.ocrRec === void 0 && o.ocrRecDict === void 0 && !o.ocrLines) return _optionalChain([o, 'optionalAccess', _67 => _67.ocr]) ? DEFAULT_BUILTIN_OCR_FETCH : DEFAULT_BUILTIN_OCR;
|
|
2478
2524
|
const bad = _chunkMMK32GPDcjs.validateOcrOptions.call(void 0, o);
|
|
2479
|
-
if (bad) throw new (0,
|
|
2480
|
-
const models =
|
|
2525
|
+
if (bad) throw new (0, _chunkPW7MQZI4cjs.KordocError)(bad);
|
|
2526
|
+
const models = _chunkUBY2PLKRcjs.resolveOcrModels.call(void 0, o);
|
|
2481
2527
|
return {
|
|
2482
2528
|
models,
|
|
2483
|
-
...o.ocrRec === "auto" ? { handwriting:
|
|
2529
|
+
...o.ocrRec === "auto" ? { handwriting: _chunkUBY2PLKRcjs.handwritingFallbackModels.call(void 0, models), autoRec: AUTO_REC } : o.ocrRec === void 0 ? { handwriting: _chunkUBY2PLKRcjs.handwritingFallbackModels.call(void 0, models), autoRec: o.ocr ? { ...DEFAULT_AUTO_REC, fetch: true } : DEFAULT_AUTO_REC } : {},
|
|
2484
2530
|
tuning: o.ocrDetLongSide === void 0 ? DEFAULT_OCR_TUNING : { ...DEFAULT_OCR_TUNING, detLongSide: o.ocrDetLongSide },
|
|
2485
2531
|
lines: o.ocrLines === "all" ? "all" : o.ocrLines ? "kept" : void 0
|
|
2486
2532
|
};
|
|
@@ -2494,8 +2540,8 @@ async function recognizeOcrPage(engine, config, tuning, rgba, width, height, sta
|
|
|
2494
2540
|
const altStats = { droppedLowConf: 0, ...stats.dropped ? { dropped: [] } : {} };
|
|
2495
2541
|
let alt;
|
|
2496
2542
|
try {
|
|
2497
|
-
if (auto.lazy && !auto.fetch && !await
|
|
2498
|
-
if (auto.lazy) await
|
|
2543
|
+
if (auto.lazy && !auto.fetch && !await _chunkUBY2PLKRcjs.ocrModelsCached.call(void 0, config.handwriting)) return items;
|
|
2544
|
+
if (auto.lazy) await _chunkUBY2PLKRcjs.ensureOcrModelsFor.call(void 0, config.handwriting, reportModelDownload);
|
|
2499
2545
|
alt = await (await getOcrEngine(config.handwriting)).recognizePage(rgba, width, height, altStats, tuning, cellRules, rowRules);
|
|
2500
2546
|
} catch (e) {
|
|
2501
2547
|
if (!auto.lazy) throw e;
|
|
@@ -2534,8 +2580,8 @@ async function runPdfOcr(buffer, targets, mode, warnings, onProgress, detectTabl
|
|
|
2534
2580
|
"@hyzyla/pdfium",
|
|
2535
2581
|
() => Promise.resolve().then(() => _interopRequireWildcard(require("@hyzyla/pdfium")))
|
|
2536
2582
|
);
|
|
2537
|
-
if (mode === "builtin") await
|
|
2538
|
-
if (mode === "builtin" && config.handwriting && !_optionalChain([config, 'access', _68 => _68.autoRec, 'optionalAccess', _69 => _69.lazy])) await
|
|
2583
|
+
if (mode === "builtin") await _chunkUBY2PLKRcjs.ensureOcrModelsFor.call(void 0, config.models, reportModelDownload);
|
|
2584
|
+
if (mode === "builtin" && config.handwriting && !_optionalChain([config, 'access', _68 => _68.autoRec, 'optionalAccess', _69 => _69.lazy])) await _chunkUBY2PLKRcjs.ensureOcrModelsFor.call(void 0, config.handwriting, reportModelDownload);
|
|
2539
2585
|
const engine = mode === "builtin" ? await getOcrEngine(config.models) : null;
|
|
2540
2586
|
const pdfium = await pdfiumMod.PDFiumLibrary.init();
|
|
2541
2587
|
const doc = await pdfium.loadDocument(new Uint8Array(buffer));
|
|
@@ -2613,6 +2659,7 @@ async function ocrOnePage(page, pageNo, mode, engine, warnings, detectTables, ve
|
|
|
2613
2659
|
cellEdgeHorizontals(ruling)
|
|
2614
2660
|
);
|
|
2615
2661
|
}
|
|
2662
|
+
if (ruling && !regions && !vectorOps && config.tuning.postprocess) items = [...items, ...await rescueEmptyCells(engine, tuning, upright, rw, rh, ruling, items)];
|
|
2616
2663
|
if (stats.droppedLowConf > 0) {
|
|
2617
2664
|
warnings.push({
|
|
2618
2665
|
page: pageNo,
|
|
@@ -2646,7 +2693,7 @@ async function ocrOnePage(page, pageNo, mode, engine, warnings, detectTables, ve
|
|
|
2646
2693
|
const x1 = r.x1 * scale - 2, x2 = r.x2 * scale + 2, y1 = (pdfH - r.y2) * scale - 2, y2 = (pdfH - r.y1) * scale + 2;
|
|
2647
2694
|
const columnRules = _nullishCoalesce(_optionalChain([ruling, 'optionalAccess', _78 => _78.verticals, 'access', _79 => _79.filter, 'call', _80 => _80((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', _81 => _81.length]), () => ( 0));
|
|
2648
2695
|
if (columnRules < 2) {
|
|
2649
|
-
for (const b of blocks) if (b.type === "table")
|
|
2696
|
+
for (const b of blocks) if (b.type === "table") _chunkUBY2PLKRcjs.UNRULED_REGION_TABLES.add(b);
|
|
2650
2697
|
}
|
|
2651
2698
|
return blocks;
|
|
2652
2699
|
});
|
|
@@ -2718,7 +2765,7 @@ async function closerReads(rgba, rw, rh, pdfH, hi, regions, engine, tuning = REG
|
|
|
2718
2765
|
const items = await engine.recognizePage(crop, cw, ch, void 0, tuning);
|
|
2719
2766
|
out.push(items.map((it) => {
|
|
2720
2767
|
const placed = { ...it, x: (it.x + x0) / 2, y: (it.y + y0) / 2, w: it.w / 2, h: it.h / 2 };
|
|
2721
|
-
|
|
2768
|
+
_chunkUBY2PLKRcjs.copyOcrTextGaps.call(void 0, it, placed, 0.5, x0 / 2);
|
|
2722
2769
|
return placed;
|
|
2723
2770
|
}));
|
|
2724
2771
|
}
|
|
@@ -2810,10 +2857,10 @@ function ocrItemsToBlocks(items, pageNumber, pdfW, pdfH, scale, extraLines, dete
|
|
|
2810
2857
|
isHidden: false,
|
|
2811
2858
|
...xs[i].space ? { hasSpaceBefore: true } : {}
|
|
2812
2859
|
};
|
|
2813
|
-
|
|
2860
|
+
_chunkUBY2PLKRcjs.copyOcrTextGaps.call(void 0, it, normalized, 1 / scale);
|
|
2814
2861
|
return normalized;
|
|
2815
2862
|
}).filter((it) => it.text);
|
|
2816
|
-
const blocks = unframeOcrLayoutTables(splitOcrContactColumns(splitOcrNameValueColumns(splitStackedOcrRows(
|
|
2863
|
+
const blocks = unframeOcrLayoutTables(splitOcrContactColumns(splitOcrNameValueColumns(splitStackedOcrRows(_chunkUBY2PLKRcjs.extractPageBlocksWithLines.call(void 0, norm, pageNumber, opList, pdfW, pdfH, extraLines, detectTables)))), pdfH);
|
|
2817
2864
|
if (!figureRegion) markOcrHeadings(blocks);
|
|
2818
2865
|
return blocks;
|
|
2819
2866
|
}
|
|
@@ -2872,7 +2919,7 @@ async function tryImport2(name, loader) {
|
|
|
2872
2919
|
return await loader();
|
|
2873
2920
|
} catch (e) {
|
|
2874
2921
|
throw new Error(
|
|
2875
|
-
`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.${
|
|
2922
|
+
`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.${_chunkPW7MQZI4cjs.OPTIONAL_DEP_INSTALL_HINT} \uC6D0\uC778: ${e.message}`
|
|
2876
2923
|
);
|
|
2877
2924
|
}
|
|
2878
2925
|
}
|
|
@@ -2923,5 +2970,6 @@ function bgraToRgba(bgra) {
|
|
|
2923
2970
|
|
|
2924
2971
|
|
|
2925
2972
|
|
|
2926
|
-
|
|
2927
|
-
|
|
2973
|
+
|
|
2974
|
+
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;
|
|
2975
|
+
//# sourceMappingURL=chunk-PVV6OY4M.cjs.map
|