kordoc 4.24.63 → 4.24.65
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 +4 -4
- package/dist/{-JKJWVZ7E.js → -3Q26OZHW.js} +21 -21
- package/dist/{chunk-AKMBPYRU.js → chunk-27ZUZMQY.js} +5 -5
- package/dist/{chunk-PEDFVAXJ.js → chunk-3JHKWOVZ.js} +52 -7
- package/dist/chunk-3JHKWOVZ.js.map +1 -0
- package/dist/{chunk-XIJH4QF7.js → chunk-3Z7WJCP2.js} +5 -5
- package/dist/chunk-3Z7WJCP2.js.map +1 -0
- package/dist/{chunk-4J7PCDT5.cjs → chunk-4T4Y2WRR.cjs} +2 -2
- package/dist/{chunk-4J7PCDT5.cjs.map → chunk-4T4Y2WRR.cjs.map} +1 -1
- package/dist/{chunk-WDFJGFAH.cjs → chunk-6J5RTSBG.cjs} +3 -3
- package/dist/{chunk-WDFJGFAH.cjs.map → chunk-6J5RTSBG.cjs.map} +1 -1
- package/dist/{chunk-HG6K7PDG.js → chunk-6R4M2LVY.js} +2 -2
- package/dist/{chunk-E3IGBNLD.js → chunk-7DQI7BU6.js} +2 -2
- package/dist/{chunk-ROHCAUUO.js → chunk-7PTPUYYJ.js} +3 -3
- package/dist/{chunk-CL2GZ7JO.js → chunk-ABA2Z4LT.js} +2 -2
- package/dist/{chunk-FIKCNQ5Q.js → chunk-AKYUE4JE.js} +2 -2
- package/dist/{chunk-X4PFJ3S3.js → chunk-AX34AL6K.js} +2 -2
- package/dist/{chunk-CB365CYO.cjs → chunk-B4AKPVWA.cjs} +137 -92
- package/dist/chunk-B4AKPVWA.cjs.map +1 -0
- package/dist/{chunk-SQT5Z35B.cjs → chunk-B4ZNG3G7.cjs} +25 -25
- package/dist/{chunk-SQT5Z35B.cjs.map → chunk-B4ZNG3G7.cjs.map} +1 -1
- package/dist/{chunk-3R4LS2QM.js → chunk-BPNJBWKQ.js} +15 -15
- package/dist/{chunk-TFEQHER2.js → chunk-BRDRZHVC.js} +2 -2
- package/dist/{chunk-NCI5VSUC.js → chunk-BYTIJ226.js} +2 -2
- package/dist/{chunk-B7JISVV7.js → chunk-CLI5IIY3.js} +2 -2
- package/dist/{chunk-XABC4RKP.js → chunk-DKSSS4ED.js} +2 -2
- package/dist/{chunk-KWISIIRJ.js → chunk-DQQ6C7WA.js} +2 -2
- package/dist/{chunk-FZNNNXEW.js → chunk-EG47QXJE.js} +5 -5
- package/dist/{chunk-7OBVSSAQ.js → chunk-FTMDZ4Y5.js} +34 -29
- package/dist/chunk-FTMDZ4Y5.js.map +1 -0
- package/dist/{chunk-XYMBGOXH.cjs → chunk-GITPHKYL.cjs} +11 -11
- package/dist/chunk-GITPHKYL.cjs.map +1 -0
- package/dist/{chunk-SUXFV3AL.js → chunk-GZC4XIKW.js} +5 -5
- package/dist/{chunk-UMF44YJH.js → chunk-I2HHHJF5.js} +2 -2
- package/dist/{chunk-JMYWAW2S.js → chunk-JW6PNIXI.js} +7 -7
- package/dist/{chunk-BW2KS7VQ.js → chunk-KUAPGGQE.js} +37 -32
- package/dist/chunk-KUAPGGQE.js.map +1 -0
- package/dist/{chunk-YRMVLAYZ.js → chunk-LXRBEPYC.js} +2 -2
- package/dist/{chunk-SPEEZYS4.js → chunk-MTUGM4ZK.js} +6 -6
- package/dist/{chunk-MQNJY7II.js → chunk-NBBT2EYG.js} +2 -2
- package/dist/{chunk-ZVUZZFGY.js → chunk-NTMN5UKQ.js} +3 -3
- package/dist/{chunk-55QH5LSM.js → chunk-PWSUGKMS.js} +5 -5
- package/dist/{chunk-55QH5LSM.js.map → chunk-PWSUGKMS.js.map} +1 -1
- package/dist/{chunk-SUMSKQ43.js → chunk-RH6E2YVG.js} +2 -2
- package/dist/{chunk-MKH2CVD2.cjs → chunk-S5XPBZQ6.cjs} +3 -3
- package/dist/{chunk-MKH2CVD2.cjs.map → chunk-S5XPBZQ6.cjs.map} +1 -1
- package/dist/{chunk-CD7YHKSF.js → chunk-TN2C7M6Q.js} +11 -11
- package/dist/{chunk-DQEZVDKS.js → chunk-TYJFA5S7.js} +2 -2
- package/dist/{chunk-JCNNDOOW.js → chunk-U2TSYPPM.js} +2 -2
- package/dist/{chunk-WB4LZYGW.cjs → chunk-UJI2ZP6M.cjs} +113 -108
- package/dist/chunk-UJI2ZP6M.cjs.map +1 -0
- package/dist/{chunk-UZDSVTD4.js → chunk-UYEZER77.js} +2 -2
- package/dist/{chunk-Q2ZKAVNU.js → chunk-VMR3QMB5.js} +53 -8
- package/dist/chunk-VMR3QMB5.js.map +1 -0
- package/dist/{chunk-PTWPZYBM.js → chunk-VQZIP2UW.js} +10 -10
- package/dist/{chunk-WIPBQVIK.js → chunk-XS254L5R.js} +3 -3
- package/dist/{chunk-A73BTJH5.js → chunk-Y6UT3AYV.js} +4 -4
- package/dist/{chunk-JIH23K74.cjs → chunk-ZMJVWAH2.cjs} +58 -58
- package/dist/{chunk-JIH23K74.cjs.map → chunk-ZMJVWAH2.cjs.map} +1 -1
- package/dist/chunks-LAMEBTHT.js +11 -0
- package/dist/cli.js +45 -45
- package/dist/{formula-WTTPNY2I.cjs → formula-HNVGC323.cjs} +13 -9
- package/dist/formula-HNVGC323.cjs.map +1 -0
- package/dist/{formula-DNS3KV3C.js → formula-N6HZBMYV.js} +8 -4
- package/dist/formula-N6HZBMYV.js.map +1 -0
- package/dist/{formula-VKUUIOIT.js → formula-WDYM2TBT.js} +7 -3
- package/dist/formula-WDYM2TBT.js.map +1 -0
- package/dist/generator-GJID5Q4V.cjs +12 -0
- package/dist/{generator-NDQUC266.cjs.map → generator-GJID5Q4V.cjs.map} +1 -1
- package/dist/generator-LGSVRPVO.js +11 -0
- package/dist/generator-QQTCTEMZ.js +18 -0
- package/dist/{hancom-QGPXR2US.js → hancom-TJ2T5WD7.js} +2 -2
- package/dist/{hancom-IBHKEOO5.js → hancom-XNW5F3S5.js} +2 -2
- package/dist/{hancom-JYQQYZPV.cjs → hancom-Y4QJMNTG.cjs} +5 -5
- package/dist/{hancom-JYQQYZPV.cjs.map → hancom-Y4QJMNTG.cjs.map} +1 -1
- package/dist/{image-ocr-OHVXCHWL.cjs → image-ocr-2P6OUO7R.cjs} +28 -28
- package/dist/{image-ocr-OHVXCHWL.cjs.map → image-ocr-2P6OUO7R.cjs.map} +1 -1
- package/dist/{image-ocr-TKWNXWUY.js → image-ocr-EEI3UA36.js} +10 -10
- package/dist/{image-ocr-6O6E6XIZ.js → image-ocr-HXQV325C.js} +7 -7
- package/dist/index.cjs +1115 -1115
- package/dist/index.js +9 -9
- package/dist/mcp.js +36 -36
- package/dist/memo-JYBL4KYT.js +17 -0
- package/dist/{model-bundle-ICW2B75K.js → model-bundle-QMXOK6ML.js} +5 -5
- package/dist/{models-ZIAOV7EN.js → models-VRTWSRWY.js} +5 -5
- package/dist/{parse-worker-v2-QBMUV2FV.js → parse-worker-v2-4YEQVFDN.js} +22 -22
- package/dist/{parser-IYDEYLT2.js → parser-4FZWTV4P.js} +12 -12
- package/dist/{parser-FIVOMRFD.cjs → parser-5X3O5FMI.cjs} +166 -166
- package/dist/{parser-FIVOMRFD.cjs.map → parser-5X3O5FMI.cjs.map} +1 -1
- package/dist/{parser-7SXRUERF.js → parser-6ZIQHTU7.js} +9 -9
- package/dist/pdf-ocr-47CN4L3H.cjs +43 -0
- package/dist/{pdf-ocr-YVLMXFYG.cjs.map → pdf-ocr-47CN4L3H.cjs.map} +1 -1
- package/dist/{pdf-ocr-L2FDPW4J.js → pdf-ocr-HHWYGVYA.js} +9 -9
- package/dist/{pdf-ocr-NJAOCNPW.js → pdf-ocr-TIYXB6UN.js} +6 -6
- package/dist/{profile-io-ZFFUBVD7.js → profile-io-6FHN5UEA.js} +3 -3
- package/dist/{rasterize-73LPY77L.js → rasterize-JFBYSQSV.js} +3 -3
- package/dist/{redact-doc-PMLOYY4I.js → redact-doc-PYL7KZBW.js} +21 -21
- package/dist/{render-6IUG73FB.js → render-6V2YIVO3.js} +12 -12
- package/dist/{rewrite-fallback-MLILIZUH.js → rewrite-fallback-53SOLUTC.js} +13 -13
- package/dist/seal-KRIMAC4M.js +16 -0
- package/dist/{setup-GOFOC4YG.js → setup-LFIDDDUO.js} +3 -3
- package/dist/{to-hwpx-3LMSUQTA.js → to-hwpx-PVXV4MP3.js} +7 -7
- package/dist/to-hwpx-SNIR5XQE.cjs +16 -0
- package/dist/{to-hwpx-OPZN5DZY.cjs.map → to-hwpx-SNIR5XQE.cjs.map} +1 -1
- package/dist/{to-hwpx-Y3MXBDML.js → to-hwpx-VPIDINZP.js} +4 -4
- package/dist/visual-HKD7SS2K.js +38 -0
- package/dist/{watch-WHMWDPKY.js → watch-RDE5VTIX.js} +22 -22
- package/package.json +1 -1
- package/dist/chunk-7OBVSSAQ.js.map +0 -1
- package/dist/chunk-BW2KS7VQ.js.map +0 -1
- package/dist/chunk-CB365CYO.cjs.map +0 -1
- package/dist/chunk-PEDFVAXJ.js.map +0 -1
- package/dist/chunk-Q2ZKAVNU.js.map +0 -1
- package/dist/chunk-WB4LZYGW.cjs.map +0 -1
- package/dist/chunk-XIJH4QF7.js.map +0 -1
- package/dist/chunk-XYMBGOXH.cjs.map +0 -1
- package/dist/chunks-XCTKHHQF.js +0 -11
- package/dist/formula-DNS3KV3C.js.map +0 -1
- package/dist/formula-VKUUIOIT.js.map +0 -1
- package/dist/formula-WTTPNY2I.cjs.map +0 -1
- package/dist/generator-B7BQ7GSG.js +0 -11
- package/dist/generator-NDQUC266.cjs +0 -12
- package/dist/generator-SBFQTDAS.js +0 -18
- package/dist/memo-TRWRHDYB.js +0 -17
- package/dist/pdf-ocr-YVLMXFYG.cjs +0 -43
- package/dist/seal-KDPRMM4D.js +0 -16
- package/dist/to-hwpx-OPZN5DZY.cjs +0 -16
- package/dist/visual-VI4WYIWM.js +0 -38
- /package/dist/{-JKJWVZ7E.js.map → -3Q26OZHW.js.map} +0 -0
- /package/dist/{chunk-AKMBPYRU.js.map → chunk-27ZUZMQY.js.map} +0 -0
- /package/dist/{chunk-HG6K7PDG.js.map → chunk-6R4M2LVY.js.map} +0 -0
- /package/dist/{chunk-E3IGBNLD.js.map → chunk-7DQI7BU6.js.map} +0 -0
- /package/dist/{chunk-ROHCAUUO.js.map → chunk-7PTPUYYJ.js.map} +0 -0
- /package/dist/{chunk-CL2GZ7JO.js.map → chunk-ABA2Z4LT.js.map} +0 -0
- /package/dist/{chunk-FIKCNQ5Q.js.map → chunk-AKYUE4JE.js.map} +0 -0
- /package/dist/{chunk-X4PFJ3S3.js.map → chunk-AX34AL6K.js.map} +0 -0
- /package/dist/{chunk-3R4LS2QM.js.map → chunk-BPNJBWKQ.js.map} +0 -0
- /package/dist/{chunk-TFEQHER2.js.map → chunk-BRDRZHVC.js.map} +0 -0
- /package/dist/{chunk-NCI5VSUC.js.map → chunk-BYTIJ226.js.map} +0 -0
- /package/dist/{chunk-B7JISVV7.js.map → chunk-CLI5IIY3.js.map} +0 -0
- /package/dist/{chunk-XABC4RKP.js.map → chunk-DKSSS4ED.js.map} +0 -0
- /package/dist/{chunk-KWISIIRJ.js.map → chunk-DQQ6C7WA.js.map} +0 -0
- /package/dist/{chunk-FZNNNXEW.js.map → chunk-EG47QXJE.js.map} +0 -0
- /package/dist/{chunk-SUXFV3AL.js.map → chunk-GZC4XIKW.js.map} +0 -0
- /package/dist/{chunk-UMF44YJH.js.map → chunk-I2HHHJF5.js.map} +0 -0
- /package/dist/{chunk-JMYWAW2S.js.map → chunk-JW6PNIXI.js.map} +0 -0
- /package/dist/{chunk-YRMVLAYZ.js.map → chunk-LXRBEPYC.js.map} +0 -0
- /package/dist/{chunk-SPEEZYS4.js.map → chunk-MTUGM4ZK.js.map} +0 -0
- /package/dist/{chunk-MQNJY7II.js.map → chunk-NBBT2EYG.js.map} +0 -0
- /package/dist/{chunk-ZVUZZFGY.js.map → chunk-NTMN5UKQ.js.map} +0 -0
- /package/dist/{chunk-SUMSKQ43.js.map → chunk-RH6E2YVG.js.map} +0 -0
- /package/dist/{chunk-CD7YHKSF.js.map → chunk-TN2C7M6Q.js.map} +0 -0
- /package/dist/{chunk-DQEZVDKS.js.map → chunk-TYJFA5S7.js.map} +0 -0
- /package/dist/{chunk-JCNNDOOW.js.map → chunk-U2TSYPPM.js.map} +0 -0
- /package/dist/{chunk-UZDSVTD4.js.map → chunk-UYEZER77.js.map} +0 -0
- /package/dist/{chunk-PTWPZYBM.js.map → chunk-VQZIP2UW.js.map} +0 -0
- /package/dist/{chunk-WIPBQVIK.js.map → chunk-XS254L5R.js.map} +0 -0
- /package/dist/{chunk-A73BTJH5.js.map → chunk-Y6UT3AYV.js.map} +0 -0
- /package/dist/{chunks-XCTKHHQF.js.map → chunks-LAMEBTHT.js.map} +0 -0
- /package/dist/{generator-B7BQ7GSG.js.map → generator-LGSVRPVO.js.map} +0 -0
- /package/dist/{generator-SBFQTDAS.js.map → generator-QQTCTEMZ.js.map} +0 -0
- /package/dist/{hancom-QGPXR2US.js.map → hancom-TJ2T5WD7.js.map} +0 -0
- /package/dist/{hancom-IBHKEOO5.js.map → hancom-XNW5F3S5.js.map} +0 -0
- /package/dist/{image-ocr-TKWNXWUY.js.map → image-ocr-EEI3UA36.js.map} +0 -0
- /package/dist/{image-ocr-6O6E6XIZ.js.map → image-ocr-HXQV325C.js.map} +0 -0
- /package/dist/{memo-TRWRHDYB.js.map → memo-JYBL4KYT.js.map} +0 -0
- /package/dist/{model-bundle-ICW2B75K.js.map → model-bundle-QMXOK6ML.js.map} +0 -0
- /package/dist/{models-ZIAOV7EN.js.map → models-VRTWSRWY.js.map} +0 -0
- /package/dist/{parse-worker-v2-QBMUV2FV.js.map → parse-worker-v2-4YEQVFDN.js.map} +0 -0
- /package/dist/{parser-IYDEYLT2.js.map → parser-4FZWTV4P.js.map} +0 -0
- /package/dist/{parser-7SXRUERF.js.map → parser-6ZIQHTU7.js.map} +0 -0
- /package/dist/{pdf-ocr-L2FDPW4J.js.map → pdf-ocr-HHWYGVYA.js.map} +0 -0
- /package/dist/{pdf-ocr-NJAOCNPW.js.map → pdf-ocr-TIYXB6UN.js.map} +0 -0
- /package/dist/{profile-io-ZFFUBVD7.js.map → profile-io-6FHN5UEA.js.map} +0 -0
- /package/dist/{rasterize-73LPY77L.js.map → rasterize-JFBYSQSV.js.map} +0 -0
- /package/dist/{redact-doc-PMLOYY4I.js.map → redact-doc-PYL7KZBW.js.map} +0 -0
- /package/dist/{render-6IUG73FB.js.map → render-6V2YIVO3.js.map} +0 -0
- /package/dist/{rewrite-fallback-MLILIZUH.js.map → rewrite-fallback-53SOLUTC.js.map} +0 -0
- /package/dist/{seal-KDPRMM4D.js.map → seal-KRIMAC4M.js.map} +0 -0
- /package/dist/{setup-GOFOC4YG.js.map → setup-LFIDDDUO.js.map} +0 -0
- /package/dist/{to-hwpx-3LMSUQTA.js.map → to-hwpx-PVXV4MP3.js.map} +0 -0
- /package/dist/{to-hwpx-Y3MXBDML.js.map → to-hwpx-VPIDINZP.js.map} +0 -0
- /package/dist/{visual-VI4WYIWM.js.map → visual-HKD7SS2K.js.map} +0 -0
- /package/dist/{watch-WHMWDPKY.js.map → watch-RDE5VTIX.js.map} +0 -0
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
|
|
38
38
|
|
|
39
39
|
|
|
40
|
-
var
|
|
40
|
+
var _chunkB4ZNG3G7cjs = require('./chunk-B4ZNG3G7.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 _chunk4T4Y2WRRcjs = require('./chunk-4T4Y2WRR.cjs');
|
|
54
54
|
|
|
55
55
|
// src/ocr/ocr-stacked-rows.ts
|
|
56
56
|
var NUMERIC = /^[-+−△▲▽▼]?[\d.,]+[%p원]?$|^[-–—·∼~]원?$|^\([-+−△▲▽▼]?[\d.,]+%?\)$/;
|
|
@@ -483,7 +483,8 @@ function detectRulingLines(rgba, width, height, scale) {
|
|
|
483
483
|
if (!b || a.x2 - a.x1 < tol * 4) continue;
|
|
484
484
|
const y = (a.y1 + b.y1) / 2;
|
|
485
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
|
-
|
|
486
|
+
const p = ruleH.find((p2) => Math.abs(p2.y1 - y) <= fillGap && (Math.abs(p2.x1 - a.x2) <= tol * 3 || Math.abs(a.x1 - p2.x2) <= tol * 3));
|
|
487
|
+
horizontals.push(p ? { ...p, x1: Math.min(a.x1, p.x1), x2: Math.max(a.x2, p.x2) } : { x1: a.x1, y1: y, x2: a.x2, y2: y, thicknessPx: 1 });
|
|
487
488
|
}
|
|
488
489
|
for (const p of ruleH) {
|
|
489
490
|
for (const side of [-1, 1]) {
|
|
@@ -492,7 +493,7 @@ function detectRulingLines(rgba, width, height, scale) {
|
|
|
492
493
|
if (!a) continue;
|
|
493
494
|
const far = side < 0 ? a.x1 : a.x2;
|
|
494
495
|
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,
|
|
496
|
+
horizontals.push({ ...p, x1: Math.min(far, p.x1), x2: Math.max(far, p.x2) });
|
|
496
497
|
}
|
|
497
498
|
}
|
|
498
499
|
horizontals.push(...fillH);
|
|
@@ -804,8 +805,8 @@ var INKLESS_DELTA = 32;
|
|
|
804
805
|
function ringAsks(rgba, pageW, box, text, steps, stepPx) {
|
|
805
806
|
const chars = [...text];
|
|
806
807
|
if (chars.length !== steps.length || !/[가-힣]/.test(text)) return [];
|
|
807
|
-
const gray =
|
|
808
|
-
const rings =
|
|
808
|
+
const gray = _chunkB4ZNG3G7cjs.grayCrop.call(void 0, rgba, pageW, box);
|
|
809
|
+
const rings = _chunkB4ZNG3G7cjs.ringBoxes.call(void 0, gray, box.w, box.h, _chunkB4ZNG3G7cjs.inkStats.call(void 0, gray));
|
|
809
810
|
const owner = ringOwners(chars, (i) => (steps[i] + 0.5) * stepPx, rings);
|
|
810
811
|
return rings.flatMap((r, k) => {
|
|
811
812
|
const at = owner.indexOf(k);
|
|
@@ -845,8 +846,8 @@ function ringGlyph(read, jamo = null, confidence = 1) {
|
|
|
845
846
|
function restoreGlyphs(rgba, pageW, box, text, steps, stepPx, note = {}, rings = []) {
|
|
846
847
|
const chars = [...text];
|
|
847
848
|
if (chars.length !== steps.length) return text;
|
|
848
|
-
const gray =
|
|
849
|
-
const c = { chars, cx: (i) => (steps[i] + 0.5) * stepPx, gray, w: box.w, h: box.h, ink:
|
|
849
|
+
const gray = _chunkB4ZNG3G7cjs.grayCrop.call(void 0, rgba, pageW, box);
|
|
850
|
+
const c = { chars, cx: (i) => (steps[i] + 0.5) * stepPx, gray, w: box.w, h: box.h, ink: _chunkB4ZNG3G7cjs.inkStats.call(void 0, gray) };
|
|
850
851
|
if (/[[\]]/.test(text)) brackets(c);
|
|
851
852
|
if (text.includes("'")) cornerQuotes(c);
|
|
852
853
|
if (/['"]/.test(text)) quotes(c);
|
|
@@ -876,7 +877,7 @@ function restoreGlyphs(rgba, pageW, box, text, steps, stepPx, note = {}, rings =
|
|
|
876
877
|
function trimInklessEnds(rgba, pageW, box, text, steps, stepPx) {
|
|
877
878
|
const chars = [...text], { w, h } = box;
|
|
878
879
|
if (chars.length !== steps.length || steps.some((s) => (s + 0.5) * stepPx > w + stepPx)) return { text, steps };
|
|
879
|
-
const gray =
|
|
880
|
+
const gray = _chunkB4ZNG3G7cjs.grayCrop.call(void 0, rgba, pageW, box);
|
|
880
881
|
const hist = new Uint32Array(256);
|
|
881
882
|
for (const v of gray) hist[v]++;
|
|
882
883
|
let bg = 0;
|
|
@@ -907,8 +908,8 @@ function cornerCommas({ chars, cx, gray, w, h, ink }) {
|
|
|
907
908
|
continue;
|
|
908
909
|
}
|
|
909
910
|
if (open > 0) {
|
|
910
|
-
const f =
|
|
911
|
-
if (f &&
|
|
911
|
+
const f = _chunkB4ZNG3G7cjs.bracketFeatures.call(void 0, gray, w, h, ink, cx(i));
|
|
912
|
+
if (f && _chunkB4ZNG3G7cjs.bracketShape.call(void 0, f, true) === "\u300D") {
|
|
912
913
|
chars[i] = "\u300D";
|
|
913
914
|
open--;
|
|
914
915
|
}
|
|
@@ -918,12 +919,12 @@ function cornerCommas({ chars, cx, gray, w, h, ink }) {
|
|
|
918
919
|
function cornerQuotes({ chars, cx, gray, w, h, ink }) {
|
|
919
920
|
for (let i = 0; i < chars.length; i++) {
|
|
920
921
|
if (chars[i] !== "'" || !/^[가-힣]/.test(_nullishCoalesce(chars[i + 1], () => ( "")))) continue;
|
|
921
|
-
const f =
|
|
922
|
-
if (!f || f.ch < f.charH * 0.45 ||
|
|
922
|
+
const f = _chunkB4ZNG3G7cjs.bracketFeatures.call(void 0, gray, w, h, ink, cx(i));
|
|
923
|
+
if (!f || f.ch < f.charH * 0.45 || _chunkB4ZNG3G7cjs.bracketShape.call(void 0, f, false) !== "\u300C") continue;
|
|
923
924
|
const rest = chars.slice(i + 1), end = rest.findIndex((c) => c === "'" || c === "\u300D" || c === ",");
|
|
924
925
|
const pair = end >= 0 && rest[end] !== "'" && (rest[end] === "\u300D" || (() => {
|
|
925
|
-
const g =
|
|
926
|
-
return !!g &&
|
|
926
|
+
const g = _chunkB4ZNG3G7cjs.bracketFeatures.call(void 0, gray, w, h, ink, cx(i + 1 + end));
|
|
927
|
+
return !!g && _chunkB4ZNG3G7cjs.bracketShape.call(void 0, g, true) === "\u300D";
|
|
927
928
|
})());
|
|
928
929
|
if (pair) chars[i] = "\u300C";
|
|
929
930
|
}
|
|
@@ -931,8 +932,8 @@ function cornerQuotes({ chars, cx, gray, w, h, ink }) {
|
|
|
931
932
|
function brackets({ chars, cx, gray, w, h, ink }) {
|
|
932
933
|
const shape = chars.map((c, i) => {
|
|
933
934
|
if (c !== "[" && c !== "]") return null;
|
|
934
|
-
const f =
|
|
935
|
-
return f &&
|
|
935
|
+
const f = _chunkB4ZNG3G7cjs.bracketFeatures.call(void 0, gray, w, h, ink, cx(i));
|
|
936
|
+
return f && _chunkB4ZNG3G7cjs.bracketShape.call(void 0, f, c === "]");
|
|
936
937
|
});
|
|
937
938
|
for (let i = 0; i < chars.length; i++) {
|
|
938
939
|
if (chars[i] !== "[") continue;
|
|
@@ -964,7 +965,7 @@ function quotes({ chars, cx, gray, w, h, ink }) {
|
|
|
964
965
|
continue;
|
|
965
966
|
}
|
|
966
967
|
if (!year(i) && !single[kind]) continue;
|
|
967
|
-
const r =
|
|
968
|
+
const r = _chunkB4ZNG3G7cjs.quoteHead.call(void 0, gray, w, h, ink, cx(i));
|
|
968
969
|
if (r !== null && r >= 0.47) {
|
|
969
970
|
chars[i] = kind === "'" ? "\u2018" : "\u201C";
|
|
970
971
|
open[kind] = true;
|
|
@@ -975,7 +976,7 @@ function dashes({ chars, cx, gray, w, h, ink }) {
|
|
|
975
976
|
const head = chars.findIndex((c) => c.trim()), letters = chars.some((c) => /[가-힣A-Za-z]/.test(c));
|
|
976
977
|
for (let i = 0; i < chars.length; i++) {
|
|
977
978
|
if (!/^[-\u2013\u2014]$/.test(chars[i])) continue;
|
|
978
|
-
const r =
|
|
979
|
+
const r = _chunkB4ZNG3G7cjs.dashRatio.call(void 0, gray, w, h, ink, cx(i));
|
|
979
980
|
if (r === null) continue;
|
|
980
981
|
if (r < 0.65) chars[i] = "-";
|
|
981
982
|
else if (r > 0.75 && i === head && letters) chars[i] = "\u2014";
|
|
@@ -985,7 +986,7 @@ function circled({ chars, cx, gray, w, h, ink }) {
|
|
|
985
986
|
const alone = (re, i) => re.test(chars[i]) && !re.test(_nullishCoalesce(chars[i - 1], () => ( ""))) && !re.test(_nullishCoalesce(chars[i + 1], () => ( "")));
|
|
986
987
|
const at = chars.flatMap((_, i) => alone(/^\d$/, i) && chars[i] !== "0" || alone(/^[ㄱ-ㅎ]$/, i) || alone(/^[A-Za-z]$/, i) && /[a-zCSUVWXZ]/.test(chars[i]) ? [i] : []);
|
|
987
988
|
if (!at.length) return;
|
|
988
|
-
const hit =
|
|
989
|
+
const hit = _chunkB4ZNG3G7cjs.circledAt.call(void 0, gray, w, h, ink, at.map(cx));
|
|
989
990
|
const JAMO = "\u3131\u3134\u3137\u3139\u3141\u3142\u3145\u3147\u3148\u314A\u314B\u314C\u314D\u314E";
|
|
990
991
|
at.forEach((i, k) => {
|
|
991
992
|
if (!hit[k]) return;
|
|
@@ -998,16 +999,16 @@ function stars({ chars, cx, gray, w, h, ink }) {
|
|
|
998
999
|
if (chars[i] !== "*" || chars[i - 1] === "*") continue;
|
|
999
1000
|
let e = i;
|
|
1000
1001
|
while (chars[e + 1] === "*") e++;
|
|
1001
|
-
const n =
|
|
1002
|
+
const n = _chunkB4ZNG3G7cjs.starRun.call(void 0, gray, w, h, ink, cx(i));
|
|
1002
1003
|
if (n > e - i + 1 && n <= 4) chars[e] += "*".repeat(n - (e - i + 1));
|
|
1003
1004
|
i = e;
|
|
1004
1005
|
}
|
|
1005
1006
|
}
|
|
1006
1007
|
function discs({ chars, cx, gray, w, h, ink }) {
|
|
1007
|
-
for (let i = 0; i < chars.length; i++) if (/^[\u00b7\u2022]$/.test(chars[i]) &&
|
|
1008
|
+
for (let i = 0; i < chars.length; i++) if (/^[\u00b7\u2022]$/.test(chars[i]) && _chunkB4ZNG3G7cjs.discAt.call(void 0, gray, w, h, ink, cx(i))) chars[i] = "\u25CF";
|
|
1008
1009
|
}
|
|
1009
1010
|
function gaps({ chars, cx, gray, w, h, ink }) {
|
|
1010
|
-
const { glyphs, bandH } =
|
|
1011
|
+
const { glyphs, bandH } = _chunkB4ZNG3G7cjs.gapGlyphs.call(void 0, gray, w, h, ink);
|
|
1011
1012
|
if (!glyphs.length) return;
|
|
1012
1013
|
const live = chars.map((c, i) => i).filter((i) => chars[i].trim());
|
|
1013
1014
|
if (!live.length) return;
|
|
@@ -1078,18 +1079,18 @@ function ring({ chars, cx, gray, w, h, ink }) {
|
|
|
1078
1079
|
const rest = chars.slice(k + 1).join("").trimStart();
|
|
1079
1080
|
const live = chars.map((c, i) => i).filter((i) => chars[i].trim());
|
|
1080
1081
|
if (live.length <= 3 && live.every((i) => /^[Oo]$/.test(chars[i]))) {
|
|
1081
|
-
if (_optionalChain([
|
|
1082
|
-
if (!live.every((i) =>
|
|
1082
|
+
if (_optionalChain([_chunkB4ZNG3G7cjs.leadingBullet.call(void 0, gray, w, h, ink, cx(live[0])), 'optionalAccess', _11 => _11.mark]) === "\u25CE") return false;
|
|
1083
|
+
if (!live.every((i) => _chunkB4ZNG3G7cjs.ringBullet.call(void 0, gray, w, h, ink, cx(i)) === "\u25CB")) return false;
|
|
1083
1084
|
for (const i of live) chars[i] = "\u25CB";
|
|
1084
1085
|
return true;
|
|
1085
1086
|
}
|
|
1086
1087
|
if (/^[A-Z]{2,}/.test(rest) && /^[Oo0]$/.test(chars[k])) {
|
|
1087
|
-
if (
|
|
1088
|
+
if (_chunkB4ZNG3G7cjs.ringBullet.call(void 0, gray, w, h, ink, cx(k)) !== "\u25CB") return false;
|
|
1088
1089
|
chars[k] = chars[k + 1] === " " ? "\u25CB" : "\u25CB ";
|
|
1089
1090
|
return true;
|
|
1090
1091
|
}
|
|
1091
1092
|
if (!/^[(\[「【<]?\d*[가-힣]/.test(rest)) return false;
|
|
1092
|
-
const r =
|
|
1093
|
+
const r = _chunkB4ZNG3G7cjs.ringBullet.call(void 0, gray, w, h, ink, cx(k));
|
|
1093
1094
|
if (/^[Cc]$/.test(chars[k]) && r !== "\u25CB") return false;
|
|
1094
1095
|
if (r) chars[k] = r;
|
|
1095
1096
|
return r !== null;
|
|
@@ -1106,7 +1107,7 @@ function parallels({ chars, cx, gray, w, h, ink }) {
|
|
|
1106
1107
|
let p = s - 1, q = e + 1;
|
|
1107
1108
|
while (p >= 0 && !chars[p].trim()) p--;
|
|
1108
1109
|
while (q < chars.length && !chars[q].trim()) q++;
|
|
1109
|
-
if (
|
|
1110
|
+
if (_chunkB4ZNG3G7cjs.slantedPair.call(void 0, gray, w, h, ink, p >= 0 ? cx(p) : -Infinity, q < chars.length ? cx(q) : Infinity)) {
|
|
1110
1111
|
chars[s] = "\u2225";
|
|
1111
1112
|
for (let k = s + 1; k <= e; k++) chars[k] = "";
|
|
1112
1113
|
}
|
|
@@ -1118,7 +1119,7 @@ function roman({ chars, cx, gray, w, h, ink }) {
|
|
|
1118
1119
|
const ROMAN = /^[IⅠ-Ⅲ]$/, LATIN = /[A-Za-z]$/;
|
|
1119
1120
|
for (let i = 0; i < chars.length; i++) {
|
|
1120
1121
|
if (chars[i] !== "1" || /[\dA-Za-z]$/.test(_nullishCoalesce(chars[i - 1], () => ( ""))) || /^[\dA-Za-z,]/.test(_nullishCoalesce(chars[i + 1], () => ( "")))) continue;
|
|
1121
|
-
if (
|
|
1122
|
+
if (_chunkB4ZNG3G7cjs.serifOne.call(void 0, gray, w, h, ink, cx(i))) chars[i] = "\u2160";
|
|
1122
1123
|
}
|
|
1123
1124
|
for (let i = 0; i < chars.length; i++) {
|
|
1124
1125
|
const hangul = /^[파피]$/.test(chars[i]);
|
|
@@ -1128,13 +1129,13 @@ function roman({ chars, cx, gray, w, h, ink }) {
|
|
|
1128
1129
|
while (q < chars.length && !chars[q].trim()) q++;
|
|
1129
1130
|
const glued = hangul ? chars[p] === "(" && chars[q] === "-" : /[가-힣]$/.test(_nullishCoalesce(chars[i - 1], () => ( ""))) || (_nullishCoalesce(chars[i + 1], () => ( ""))) === "." || chars[p] === "-" && chars[q] === "-";
|
|
1130
1131
|
if (!glued) continue;
|
|
1131
|
-
const n =
|
|
1132
|
+
const n = _chunkB4ZNG3G7cjs.romanStems.call(void 0, gray, w, h, ink, p >= 0 ? cx(p) : -Infinity, q < chars.length ? cx(q) : Infinity, /[가-힣]$/.test(_nullishCoalesce(chars[p], () => ( ""))));
|
|
1132
1133
|
if (n) chars[i] = String.fromCharCode(8543 + n);
|
|
1133
1134
|
}
|
|
1134
1135
|
const inRoman = (i) => ROMAN.test(chars[i]) || chars[i] === "1" && (ROMAN.test(_nullishCoalesce(chars[i - 1], () => ( ""))) || ROMAN.test(_nullishCoalesce(chars[i + 1], () => ( ""))));
|
|
1135
1136
|
const k = chars.findIndex((c) => c.trim());
|
|
1136
1137
|
if (chars[k] === "." && chars.slice(k + 1).some((c) => /[가-힣A-Za-z0-9]/.test(c))) {
|
|
1137
|
-
const n =
|
|
1138
|
+
const n = _chunkB4ZNG3G7cjs.romanStems.call(void 0, gray, w, h, ink, -Infinity, cx(k));
|
|
1138
1139
|
if (n) chars[k] = String.fromCharCode(8543 + n) + chars[k];
|
|
1139
1140
|
}
|
|
1140
1141
|
for (let s = 0; s < chars.length; ) {
|
|
@@ -1152,7 +1153,7 @@ function roman({ chars, cx, gray, w, h, ink }) {
|
|
|
1152
1153
|
let p = s - 1, q = e;
|
|
1153
1154
|
while (p >= 0 && !chars[p].trim()) p--;
|
|
1154
1155
|
while (q < chars.length && !chars[q].trim()) q++;
|
|
1155
|
-
const n =
|
|
1156
|
+
const n = _chunkB4ZNG3G7cjs.romanStems.call(void 0, gray, w, h, ink, p >= 0 ? cx(p) : -Infinity, q < chars.length ? cx(q) : Infinity, /[가-힣]$/.test(_nullishCoalesce(chars[p], () => ( ""))));
|
|
1156
1157
|
const canon = n ? [["\u2160", "I"], ["\u2161", "II"], ["\u2162", "III"]][n - 1] : null;
|
|
1157
1158
|
if (canon && !canon.includes(tok)) {
|
|
1158
1159
|
chars[s] = canon[0];
|
|
@@ -1581,8 +1582,8 @@ function joinGapLeaders(rgba, width, items) {
|
|
|
1581
1582
|
if (g1 - g0 < h * 3) continue;
|
|
1582
1583
|
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));
|
|
1583
1584
|
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 };
|
|
1584
|
-
const gray =
|
|
1585
|
-
const runs =
|
|
1585
|
+
const gray = _chunkB4ZNG3G7cjs.grayCrop.call(void 0, rgba, width, box);
|
|
1586
|
+
const runs = _chunkB4ZNG3G7cjs.leaderRuns.call(void 0, gray, box.w, box.h, _chunkB4ZNG3G7cjs.inkStats.call(void 0, gray), LEADER_MIN_DOTS);
|
|
1586
1587
|
const cover = runs.reduce((k, [a, b]) => k + Math.max(0, Math.min(b, g1 - box.x) - Math.max(a, g0 - box.x)), 0);
|
|
1587
1588
|
if (cover < (g1 - g0) * 0.6) continue;
|
|
1588
1589
|
for (const o of items) if (junk(o) && sameLine(o, num) && o.x >= g0 - 2 && o.x + o.w <= g1 + 2) gone.add(o);
|
|
@@ -1865,7 +1866,7 @@ var OcrEngine = class _OcrEngine {
|
|
|
1865
1866
|
this.ort = parts.ort;
|
|
1866
1867
|
this.sharp = parts.sharp;
|
|
1867
1868
|
}
|
|
1868
|
-
static async create(models =
|
|
1869
|
+
static async create(models = _chunkB4ZNG3G7cjs.DEFAULT_OCR_MODELS) {
|
|
1869
1870
|
_chunkTK3FDAEEcjs.disableOrtTelemetry.call(void 0, );
|
|
1870
1871
|
const [ortMod, sharpModRaw] = await Promise.all([
|
|
1871
1872
|
tryImport("onnxruntime-node", () => Promise.resolve().then(() => _interopRequireWildcard(require("onnxruntime-node")))),
|
|
@@ -1885,16 +1886,16 @@ var OcrEngine = class _OcrEngine {
|
|
|
1885
1886
|
const local = (s) => "spec" in s ? Promise.resolve(null) : verifiedBytes(s);
|
|
1886
1887
|
const [detBytes, recBytes, dictBytes] = await Promise.all([local(models.det), local(models.rec), local(models.dict)]);
|
|
1887
1888
|
const session = (s, bytes) => bytes ? ortMod.InferenceSession.create(bytes, sessionOpts).catch(() => {
|
|
1888
|
-
throw new (0,
|
|
1889
|
-
}) : ortMod.InferenceSession.create(
|
|
1889
|
+
throw new (0, _chunk4T4Y2WRRcjs.KordocError)(`OCR \uBAA8\uB378\uC744 \uC5F4\uC9C0 \uBABB\uD588\uC2B5\uB2C8\uB2E4: ${_path.basename.call(void 0, _chunkB4ZNG3G7cjs.ocrSourcePath.call(void 0, s))} \u2014 ONNX \uBAA8\uB378\uC774 \uC544\uB2C8\uAC70\uB098 \uC190\uC0C1\uB410\uC2B5\uB2C8\uB2E4`);
|
|
1890
|
+
}) : ortMod.InferenceSession.create(_chunkB4ZNG3G7cjs.ocrSourcePath.call(void 0, s), sessionOpts);
|
|
1890
1891
|
const [det, rec, dictYml] = await Promise.all([
|
|
1891
1892
|
session(models.det, detBytes),
|
|
1892
1893
|
session(models.rec, recBytes),
|
|
1893
|
-
dictBytes ? new TextDecoder().decode(dictBytes) : _promises.readFile.call(void 0,
|
|
1894
|
+
dictBytes ? new TextDecoder().decode(dictBytes) : _promises.readFile.call(void 0, _chunkB4ZNG3G7cjs.ocrSourcePath.call(void 0, models.dict), "utf-8")
|
|
1894
1895
|
]);
|
|
1895
|
-
const dict =
|
|
1896
|
+
const dict = _chunkB4ZNG3G7cjs.parseCharacterDict.call(void 0, dictYml);
|
|
1896
1897
|
if (dict.length === 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,
|
|
1898
|
+
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, _chunk4T4Y2WRRcjs.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`);
|
|
1898
1899
|
}
|
|
1899
1900
|
return new _OcrEngine({ det, rec, dict, ort: ortMod, sharp: sharpMod });
|
|
1900
1901
|
}
|
|
@@ -1926,10 +1927,10 @@ var OcrEngine = class _OcrEngine {
|
|
|
1926
1927
|
if (it.x - x < it.h * 0.8) return;
|
|
1927
1928
|
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;
|
|
1928
1929
|
const box = { x, y: it.y, w: it.x + it.w - x, h: it.h };
|
|
1929
|
-
const g =
|
|
1930
|
-
const b =
|
|
1930
|
+
const g = _chunkB4ZNG3G7cjs.grayCrop.call(void 0, rgba, width, box);
|
|
1931
|
+
const b = _chunkB4ZNG3G7cjs.leadingBullet.call(void 0, g, box.w, box.h, _chunkB4ZNG3G7cjs.inkStats.call(void 0, g), it.x - x, 1.05);
|
|
1931
1932
|
if (_optionalChain([b, 'optionalAccess', _36 => _36.mark]) !== "\u25A1" || b.covers) return;
|
|
1932
|
-
const ink =
|
|
1933
|
+
const ink = _chunkB4ZNG3G7cjs.inkStats.call(void 0, g), on = (v) => ink.darkInk ? v <= ink.threshold : v > ink.threshold;
|
|
1933
1934
|
let left = 0;
|
|
1934
1935
|
while (left < it.x - x && !Array.from({ length: box.h }, (_, y) => g[y * box.w + left]).some(on)) left++;
|
|
1935
1936
|
it.text = "\u25A1 " + it.text;
|
|
@@ -1961,12 +1962,12 @@ var OcrEngine = class _OcrEngine {
|
|
|
1961
1962
|
const joins = [];
|
|
1962
1963
|
let group = 0;
|
|
1963
1964
|
for (const b of boxes) {
|
|
1964
|
-
const gray =
|
|
1965
|
-
const ink =
|
|
1965
|
+
const gray = _chunkB4ZNG3G7cjs.grayCrop.call(void 0, rgba, width, b);
|
|
1966
|
+
const ink = _chunkB4ZNG3G7cjs.inkStats.call(void 0, gray);
|
|
1966
1967
|
if (tuning.minInkContrast > 0 && ink.contrast < tuning.minInkContrast) continue;
|
|
1967
1968
|
if (tuning.minInkContrast > 0 && ink.inkRatio < MIN_INK_RATIO) continue;
|
|
1968
1969
|
if (tuning.splitTall && b.h >= b.w * TALL_RATIO) {
|
|
1969
|
-
const bands =
|
|
1970
|
+
const bands = _chunkB4ZNG3G7cjs.splitRowBands.call(void 0, gray, b.w, b.h, ink, 0.45);
|
|
1970
1971
|
if (bands.length >= 2) {
|
|
1971
1972
|
for (const sub of bandBoxes(b, bands, height)) jobs.push({ box: sub, rot: 0, group: group++ });
|
|
1972
1973
|
continue;
|
|
@@ -1990,9 +1991,9 @@ var OcrEngine = class _OcrEngine {
|
|
|
1990
1991
|
continue;
|
|
1991
1992
|
}
|
|
1992
1993
|
}
|
|
1993
|
-
const trim = tuning.trimEdges ?
|
|
1994
|
+
const trim = tuning.trimEdges ? _chunkB4ZNG3G7cjs.edgeTrim.call(void 0, gray, b.w, b.h, ink) : null;
|
|
1994
1995
|
const keep = trim ? { ...trim, bg: median(gray) } : void 0;
|
|
1995
|
-
const leaders = tuning.splitLeaders ?
|
|
1996
|
+
const leaders = tuning.splitLeaders ? _chunkB4ZNG3G7cjs.leaderRuns.call(void 0, gray, b.w, b.h, ink, LEADER_MIN_DOTS) : [];
|
|
1996
1997
|
if (leaders.length) {
|
|
1997
1998
|
const join = joins.length;
|
|
1998
1999
|
joins.push({ box: b, parts: [], trailDots: false });
|
|
@@ -2001,7 +2002,7 @@ var OcrEngine = class _OcrEngine {
|
|
|
2001
2002
|
const bare = { x: b.x + x0, y: b.y, w: a - x0, h: b.h };
|
|
2002
2003
|
const end = c > a ? Math.min(c, a + Math.round(b.h * LEADER_CONTEXT)) : a;
|
|
2003
2004
|
x0 = c;
|
|
2004
|
-
if (bare.w >= DET_MIN_SIZE &&
|
|
2005
|
+
if (bare.w >= DET_MIN_SIZE && _chunkB4ZNG3G7cjs.inkStats.call(void 0, _chunkB4ZNG3G7cjs.grayCrop.call(void 0, rgba, width, bare)).contrast >= Math.max(1, tuning.minInkContrast)) {
|
|
2005
2006
|
jobs.push({ box: { ...bare, w: end - (bare.x - b.x) }, rot: 0, group: group++, join, dotsBefore: dots, trimDots: end > a });
|
|
2006
2007
|
dots = false;
|
|
2007
2008
|
}
|
|
@@ -2050,15 +2051,15 @@ var OcrEngine = class _OcrEngine {
|
|
|
2050
2051
|
let text = tuning.postprocess ? restoreSymbols(raw.trim(), note.ringLead) : raw;
|
|
2051
2052
|
if (!text.trim()) continue;
|
|
2052
2053
|
if (tuning.postprocess && job.rot === 0 && text !== "/" && /^[(:;/)]+$/.test(text) && text.includes("/")) {
|
|
2053
|
-
const g =
|
|
2054
|
-
if (
|
|
2054
|
+
const g = _chunkB4ZNG3G7cjs.grayCrop.call(void 0, rgba, width, job.box);
|
|
2055
|
+
if (_chunkB4ZNG3G7cjs.tallInkCount.call(void 0, g, job.box.w, job.box.h, _chunkB4ZNG3G7cjs.inkStats.call(void 0, g)) === 1) text = "/";
|
|
2055
2056
|
}
|
|
2056
2057
|
let ringByShape = false;
|
|
2057
2058
|
if (tuning.postprocess && job.rot === 0 && !/^[◎●▪□■▣❐❏○ㅇ◆◇◈]/.test(text)) {
|
|
2058
2059
|
const chars = [...read], k = chars.findIndex((c) => c.trim());
|
|
2059
2060
|
if (k >= 0 && steps.length === chars.length) {
|
|
2060
|
-
const g =
|
|
2061
|
-
const b =
|
|
2061
|
+
const g = _chunkB4ZNG3G7cjs.grayCrop.call(void 0, rgba, width, job.box);
|
|
2062
|
+
const b = _chunkB4ZNG3G7cjs.leadingBullet.call(void 0, g, job.box.w, job.box.h, _chunkB4ZNG3G7cjs.inkStats.call(void 0, g), (steps[k] + 0.5) * stepPx);
|
|
2062
2063
|
const body = (_nullishCoalesce(text.match(/[가-힣]/g), () => ( []))).length >= 4;
|
|
2063
2064
|
const miss = /^[Oo0•·ㆍ∙‧○]/.test(text);
|
|
2064
2065
|
if (_optionalChain([b, 'optionalAccess', _39 => _39.mark]) === "\u25CE" && b.covers && /^[Oo0○©]/.test(text)) {
|
|
@@ -2073,17 +2074,17 @@ var OcrEngine = class _OcrEngine {
|
|
|
2073
2074
|
} else if (_optionalChain([b, 'optionalAccess', _46 => _46.mark]) === "\u2750" || _optionalChain([b, 'optionalAccess', _47 => _47.mark]) === "\u274F") {
|
|
2074
2075
|
if (b.covers ? /^[ㅁ口]/.test(text) : body) text = b.covers ? b.mark + text.slice(1) : b.mark + " " + text;
|
|
2075
2076
|
} else if (b && b.mark !== "\u25CE" && body) text = b.covers ? miss ? b.mark + " " + text.slice(1).trimStart() : text : b.mark + " " + text;
|
|
2076
|
-
else if (!b && body && /^[가-힣]/.test(chars[k]) &&
|
|
2077
|
+
else if (!b && body && /^[가-힣]/.test(chars[k]) && _chunkB4ZNG3G7cjs.leadingRing.call(void 0, g, job.box.w, job.box.h, _chunkB4ZNG3G7cjs.inkStats.call(void 0, g), (steps[k] + 0.5) * stepPx)) text = "\u25CB " + text;
|
|
2077
2078
|
}
|
|
2078
2079
|
}
|
|
2079
2080
|
if (tuning.postprocess && /^\d/.test(text) && job.rot === 0) {
|
|
2080
|
-
const g =
|
|
2081
|
-
const tri =
|
|
2081
|
+
const g = _chunkB4ZNG3G7cjs.grayCrop.call(void 0, rgba, width, job.box);
|
|
2082
|
+
const tri = _chunkB4ZNG3G7cjs.leadingTriangle.call(void 0, g, job.box.w, job.box.h, _chunkB4ZNG3G7cjs.inkStats.call(void 0, g));
|
|
2082
2083
|
if (tri) text = tri + text;
|
|
2083
2084
|
}
|
|
2084
2085
|
if (tuning.postprocess && text === "\u2192" && job.rot === 0 && job.join === void 0) {
|
|
2085
|
-
const g =
|
|
2086
|
-
text = _nullishCoalesce(
|
|
2086
|
+
const g = _chunkB4ZNG3G7cjs.grayCrop.call(void 0, rgba, width, job.box);
|
|
2087
|
+
text = _nullishCoalesce(_chunkB4ZNG3G7cjs.arrowGlyph.call(void 0, g, job.box.w, job.box.h, _chunkB4ZNG3G7cjs.inkStats.call(void 0, g)), () => ( text));
|
|
2087
2088
|
}
|
|
2088
2089
|
if (job.footer) {
|
|
2089
2090
|
if (!/^[-\u2013\u2014]?\s*(?:\d{1,4}|[ivxIVXⅰ-ⅹⅠ-Ⅹ]{1,4})\s*[-\u2013\u2014]?$/.test(text.trim())) continue;
|
|
@@ -2107,7 +2108,7 @@ var OcrEngine = class _OcrEngine {
|
|
|
2107
2108
|
continue;
|
|
2108
2109
|
}
|
|
2109
2110
|
const item = { text, ...this.itemBox(rgba, width, job.box, tuning), confidence };
|
|
2110
|
-
if (job.rot === 0)
|
|
2111
|
+
if (job.rot === 0) _chunkB4ZNG3G7cjs.rememberOcrTextGaps.call(void 0, item, _chunkB4ZNG3G7cjs.findOcrTextGaps.call(void 0, rgba, width, job.box, read, text, steps, stepPx));
|
|
2111
2112
|
if (job.rot === 0 && job.keep === void 0) boxOf.set(item, job.box);
|
|
2112
2113
|
items.push(item);
|
|
2113
2114
|
}
|
|
@@ -2121,7 +2122,7 @@ var OcrEngine = class _OcrEngine {
|
|
|
2121
2122
|
const merged = rereadNumberText(it.text, r.text);
|
|
2122
2123
|
if (merged === null) return;
|
|
2123
2124
|
it.text = merged;
|
|
2124
|
-
|
|
2125
|
+
_chunkB4ZNG3G7cjs.rememberOcrTextGaps.call(void 0, it, _chunkB4ZNG3G7cjs.findOcrTextGaps.call(void 0, rgba, width, boxOf.get(it), r.text, it.text, r.steps, r.stepPx));
|
|
2125
2126
|
});
|
|
2126
2127
|
}
|
|
2127
2128
|
const pairs = tuning.postprocess ? items.filter((it) => boxOf.has(it) && NUMBER_PAIR.test(it.text.trim())) : [];
|
|
@@ -2149,8 +2150,8 @@ var OcrEngine = class _OcrEngine {
|
|
|
2149
2150
|
const halves = [];
|
|
2150
2151
|
for (const it of tall) {
|
|
2151
2152
|
const b = boxOf.get(it);
|
|
2152
|
-
const gray =
|
|
2153
|
-
const cut = _nullishCoalesce(midBlankRow(gray, b.w, b.h,
|
|
2153
|
+
const gray = _chunkB4ZNG3G7cjs.grayCrop.call(void 0, rgba, width, b);
|
|
2154
|
+
const cut = _nullishCoalesce(midBlankRow(gray, b.w, b.h, _chunkB4ZNG3G7cjs.inkStats.call(void 0, gray)), () => ( valleyRow(gray, b.w, b.h, _chunkB4ZNG3G7cjs.inkStats.call(void 0, gray))));
|
|
2154
2155
|
if (cut) halves.push({ it, top: { ...b, h: cut[0] }, bottom: { ...b, y: b.y + cut[1], h: b.h - cut[1] } });
|
|
2155
2156
|
}
|
|
2156
2157
|
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) : [];
|
|
@@ -2171,14 +2172,14 @@ var OcrEngine = class _OcrEngine {
|
|
|
2171
2172
|
const subs = [];
|
|
2172
2173
|
const stacks = [];
|
|
2173
2174
|
for (const b of [...retry, ...blank2]) {
|
|
2174
|
-
const gray =
|
|
2175
|
-
const ink =
|
|
2175
|
+
const gray = _chunkB4ZNG3G7cjs.grayCrop.call(void 0, rgba, width, b);
|
|
2176
|
+
const ink = _chunkB4ZNG3G7cjs.inkStats.call(void 0, gray);
|
|
2176
2177
|
const cut = retry.includes(b) ? midBlankRow(gray, b.w, b.h, ink) : null;
|
|
2177
2178
|
if (cut && b.w >= 3 * Math.max(cut[0], b.h - cut[1])) {
|
|
2178
2179
|
subs.push({ ...b, h: cut[0] }, { ...b, y: b.y + cut[1], h: b.h - cut[1] });
|
|
2179
2180
|
continue;
|
|
2180
2181
|
}
|
|
2181
|
-
const bands =
|
|
2182
|
+
const bands = _chunkB4ZNG3G7cjs.stackedGlyphBands.call(void 0, gray, b.w, b.h, ink);
|
|
2182
2183
|
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)) });
|
|
2183
2184
|
}
|
|
2184
2185
|
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));
|
|
@@ -2257,8 +2258,8 @@ var OcrEngine = class _OcrEngine {
|
|
|
2257
2258
|
/** 결과 좌표 — det 박스 그대로 또는 박스 안 잉크 외곽 (tightBoxes) */
|
|
2258
2259
|
itemBox(rgba, width, b, tuning) {
|
|
2259
2260
|
if (!tuning.tightBoxes) return b;
|
|
2260
|
-
const gray =
|
|
2261
|
-
const t =
|
|
2261
|
+
const gray = _chunkB4ZNG3G7cjs.grayCrop.call(void 0, rgba, width, b);
|
|
2262
|
+
const t = _chunkB4ZNG3G7cjs.inkBounds.call(void 0, gray, b.w, b.h, _chunkB4ZNG3G7cjs.inkStats.call(void 0, gray));
|
|
2262
2263
|
return { x: b.x + t.x0, y: b.y + t.y0, w: t.x1 - t.x0, h: t.y1 - t.y0 };
|
|
2263
2264
|
}
|
|
2264
2265
|
// ─── det ─────────────────────────────────────────────
|
|
@@ -2329,7 +2330,7 @@ var OcrEngine = class _OcrEngine {
|
|
|
2329
2330
|
const out = await this.rec.run({ [this.rec.inputNames[0]]: tensor });
|
|
2330
2331
|
const logits = out[this.rec.outputNames[0]];
|
|
2331
2332
|
const [, T, C] = logits.dims;
|
|
2332
|
-
if (C !== this.dict.length + 2) throw new (0,
|
|
2333
|
+
if (C !== this.dict.length + 2) throw new (0, _chunk4T4Y2WRRcjs.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`);
|
|
2333
2334
|
const data = logits.data;
|
|
2334
2335
|
idx.forEach((ci, k) => {
|
|
2335
2336
|
const r = ctcDecode(data.subarray(k * T * C, (k + 1) * T * C), T, C, this.dict);
|
|
@@ -2339,9 +2340,9 @@ var OcrEngine = class _OcrEngine {
|
|
|
2339
2340
|
const chars = r ? [...r.text] : [];
|
|
2340
2341
|
if (r && job.rot === 0 && chars.length === r.steps.length && r.steps.some((t) => t > last) && !r.text.includes("(cid:")) {
|
|
2341
2342
|
const tallCh = (c) => !/[\s.,:;\u00b7\u2026'"\u2018-\u201d`\-_~]/.test(c);
|
|
2342
|
-
const g =
|
|
2343
|
+
const g = _chunkB4ZNG3G7cjs.grayCrop.call(void 0, rgba, pageW, job.box);
|
|
2343
2344
|
const inside = chars.filter((c, i) => r.steps[i] <= last && tallCh(c)).length;
|
|
2344
|
-
let budget = inside <= 2 ?
|
|
2345
|
+
let budget = inside <= 2 ? _chunkB4ZNG3G7cjs.tallInkCount.call(void 0, g, job.box.w, job.box.h, _chunkB4ZNG3G7cjs.inkStats.call(void 0, g)) - inside : Infinity;
|
|
2345
2346
|
const keep = chars.map((c, i) => r.steps[i] <= last || !tallCh(c) || budget-- > 0);
|
|
2346
2347
|
if (!keep.every(Boolean)) kept = { ...r, text: chars.filter((_, i) => keep[i]).join(""), steps: r.steps.filter((_, i) => keep[i]) };
|
|
2347
2348
|
}
|
|
@@ -2452,13 +2453,13 @@ async function tryImport(name, loader) {
|
|
|
2452
2453
|
return await loader();
|
|
2453
2454
|
} catch (e) {
|
|
2454
2455
|
throw new Error(
|
|
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.${
|
|
2456
|
+
`\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.${_chunk4T4Y2WRRcjs.OPTIONAL_DEP_INSTALL_HINT} \uC6D0\uC778: ${e.message}`
|
|
2456
2457
|
);
|
|
2457
2458
|
}
|
|
2458
2459
|
}
|
|
2459
2460
|
async function verifiedBytes(s) {
|
|
2460
2461
|
const name = _path.basename.call(void 0, s.file.path);
|
|
2461
|
-
const fail = (why2) => new (0,
|
|
2462
|
+
const fail = (why2) => new (0, _chunk4T4Y2WRRcjs.KordocError)(`OCR \uBAA8\uB378 \uD30C\uC77C\uC744 \uC77D\uC9C0 \uBABB\uD588\uC2B5\uB2C8\uB2E4: ${name} (${why2})`);
|
|
2462
2463
|
const why = (e) => {
|
|
2463
2464
|
const code = e.code;
|
|
2464
2465
|
return code === "ENOENT" ? "\uD30C\uC77C\uC774 \uC5C6\uC74C" : code === "EACCES" || code === "EPERM" ? "\uAD8C\uD55C \uC5C6\uC74C" : "\uC77D\uAE30 \uC2E4\uD328";
|
|
@@ -2479,13 +2480,13 @@ async function verifiedBytes(s) {
|
|
|
2479
2480
|
}
|
|
2480
2481
|
const actual = _crypto.createHash.call(void 0, "sha256").update(bytes).digest("hex");
|
|
2481
2482
|
if (actual !== s.file.sha256) {
|
|
2482
|
-
throw new (0,
|
|
2483
|
+
throw new (0, _chunk4T4Y2WRRcjs.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)`);
|
|
2483
2484
|
}
|
|
2484
2485
|
return bytes;
|
|
2485
2486
|
}
|
|
2486
2487
|
var engines = /* @__PURE__ */ new Map();
|
|
2487
|
-
function getOcrEngine(models =
|
|
2488
|
-
const key =
|
|
2488
|
+
function getOcrEngine(models = _chunkB4ZNG3G7cjs.DEFAULT_OCR_MODELS) {
|
|
2489
|
+
const key = _chunkB4ZNG3G7cjs.ocrSelectionKey.call(void 0, models);
|
|
2489
2490
|
let p = engines.get(key);
|
|
2490
2491
|
if (!p) {
|
|
2491
2492
|
p = OcrEngine.create(models).catch((err) => {
|
|
@@ -2682,22 +2683,66 @@ function categoryRow(items, v) {
|
|
|
2682
2683
|
const words = line.reduce((n, it) => n + it.text.trim().split(/\s+/).length, 0);
|
|
2683
2684
|
return words >= 2 && Math.max(...line.map((it) => it.x + it.w)) > v.x2 + 6 * v.h ? line : [];
|
|
2684
2685
|
}
|
|
2686
|
+
function forestPlotItems(items, horizontals, drop) {
|
|
2687
|
+
const cy = (it) => it.y + it.h / 2;
|
|
2688
|
+
for (const hz of [...horizontals, ...linearAxes(items)]) {
|
|
2689
|
+
const h = hz.h;
|
|
2690
|
+
const label = items.some((it) => cy(it) > hz.y1 - 3 * h && cy(it) < hz.y2 + 3 * h && /favou?rs?|better|우세/i.test(it.text));
|
|
2691
|
+
if (!label) continue;
|
|
2692
|
+
const rows = [...new Set(items.map(cy))].sort((a, b) => a - b);
|
|
2693
|
+
const at = rows.findIndex((y) => y >= hz.y1);
|
|
2694
|
+
let top = hz.y1, bottom = hz.y2;
|
|
2695
|
+
for (let i = at - 1; i >= 0 && rows[i + 1] - rows[i] <= 2.5 * h; i--) top = rows[i];
|
|
2696
|
+
const caption = (y) => items.some((it) => Math.abs(cy(it) - y) < h * 0.5 && /^(그림|Figure|Fig\.|표)\s*\d/.test(it.text.trim()));
|
|
2697
|
+
for (let i = at; i + 1 < rows.length && rows[i + 1] - rows[i] <= 2.5 * h && !caption(rows[i + 1]); i++) bottom = rows[i + 1];
|
|
2698
|
+
items.forEach((it, i) => {
|
|
2699
|
+
if (cy(it) >= top - h * 0.5 && cy(it) <= bottom + h * 0.5) drop.add(i);
|
|
2700
|
+
});
|
|
2701
|
+
}
|
|
2702
|
+
}
|
|
2703
|
+
function linearAxes(items) {
|
|
2704
|
+
const nums = items.filter((it) => number(it.text) !== null);
|
|
2705
|
+
const out = [];
|
|
2706
|
+
const used = /* @__PURE__ */ new Set();
|
|
2707
|
+
for (const seed of nums) {
|
|
2708
|
+
if (used.has(seed)) continue;
|
|
2709
|
+
const row = nums.filter((it) => Math.abs(it.y + it.h / 2 - seed.y - seed.h / 2) <= Math.min(it.h, seed.h) * 0.6).sort((a, b) => a.x - b.x);
|
|
2710
|
+
if (row.length < 3) continue;
|
|
2711
|
+
const pts = row.map((it) => ({ pos: it.x + it.w / 2, value: number(it.text) }));
|
|
2712
|
+
const slopes = pts.slice(1).map((p, i) => (p.pos - pts[i].pos) / (p.value - pts[i].value));
|
|
2713
|
+
if (slopes.some((k) => !(k > 0)) || Math.max(...slopes) > Math.min(...slopes) * 1.25) continue;
|
|
2714
|
+
for (const it of row) used.add(it);
|
|
2715
|
+
out.push({ x1: row[0].x, x2: row[row.length - 1].x + row[row.length - 1].w, y1: Math.min(...row.map((it) => it.y)), y2: Math.max(...row.map((it) => it.y + it.h)), h: seed.h });
|
|
2716
|
+
}
|
|
2717
|
+
return out;
|
|
2718
|
+
}
|
|
2685
2719
|
function chartPlotItems(items) {
|
|
2686
2720
|
const drop = /* @__PURE__ */ new Set();
|
|
2687
2721
|
const verticals = valueAxes(items);
|
|
2688
|
-
if (!verticals.length) return drop;
|
|
2689
2722
|
const horizontals = timeAxes(items);
|
|
2723
|
+
forestPlotItems(items, horizontals, drop);
|
|
2724
|
+
if (!verticals.length) return drop;
|
|
2690
2725
|
for (const v of verticals) {
|
|
2691
2726
|
const hz = horizontals.find((a) => a.y1 >= v.y2 - v.h && a.y1 <= v.y2 + 5 * v.h && a.x1 >= v.x1 - v.h && a.x1 <= v.x2 + 4 * v.h && a.x2 > v.x2 + 8 * v.h);
|
|
2692
2727
|
const cats = hz ? [] : categoryRow(items, v);
|
|
2693
2728
|
if (!hz && cats.length === 0) continue;
|
|
2694
2729
|
const bottom = hz ? hz.y2 + 2.5 * v.h : Math.max(...cats.map((c) => c.y + c.h)) + 0.5 * v.h;
|
|
2695
2730
|
const right = hz ? hz.x2 + 2 * v.h : Math.max(...cats.map((c) => c.x + c.w)) + v.h;
|
|
2696
|
-
const x1 = v.x1 - 5 * v.h, x2 = right, y1 = v.y1 -
|
|
2731
|
+
const x1 = v.x1 - 5 * v.h, x2 = right, y1 = v.y1 - Math.max(1.5 * v.h, _nullishCoalesce(v.gap, () => ( 0))), y2 = bottom;
|
|
2697
2732
|
items.forEach((it, i) => {
|
|
2698
2733
|
const cx = it.x + it.w / 2, cy = it.y + it.h / 2;
|
|
2699
2734
|
if (cx >= x1 && cx <= x2 && cy >= y1 && cy <= y2 && it.x >= x1 - v.h && it.x + it.w <= x2 + v.h) drop.add(i);
|
|
2700
2735
|
});
|
|
2736
|
+
const cyOf = (it) => it.y + it.h / 2;
|
|
2737
|
+
const risk = items.find((it) => cyOf(it) > y2 - v.h && cyOf(it) < y2 + 4 * v.h && /at\s*risk|위험\s*(대상|인원)/i.test(it.text));
|
|
2738
|
+
if (risk) {
|
|
2739
|
+
const rows = [...new Set(items.map(cyOf))].sort((a, b) => a - b);
|
|
2740
|
+
let end = cyOf(risk);
|
|
2741
|
+
for (let k = rows.indexOf(end); k + 1 < rows.length && rows[k + 1] - rows[k] <= 2.5 * v.h && !items.some((it) => Math.abs(cyOf(it) - rows[k + 1]) < v.h * 0.5 && /^(그림|Figure|Fig\.|표)\s*\d/.test(it.text.trim())); k++) end = rows[k + 1];
|
|
2742
|
+
items.forEach((it, i) => {
|
|
2743
|
+
if (cyOf(it) >= cyOf(risk) - v.h * 0.5 && cyOf(it) <= end + v.h * 0.5) drop.add(i);
|
|
2744
|
+
});
|
|
2745
|
+
}
|
|
2701
2746
|
}
|
|
2702
2747
|
return drop;
|
|
2703
2748
|
}
|
|
@@ -2917,20 +2962,20 @@ var REDETECT = { minDropped: 15, minShare: 0.15, scale: 5 / 3 };
|
|
|
2917
2962
|
var AUTO_REC = { pageConf: 0.9, gain: 0.06 };
|
|
2918
2963
|
var DEFAULT_AUTO_REC = { pageConf: 0.9, gain: 0.08, altConf: 0.95, sureGain: 0.1, minDiff: 0.08, minChars: 80, lazy: true };
|
|
2919
2964
|
var DEFAULT_BUILTIN_OCR = Object.freeze({
|
|
2920
|
-
models:
|
|
2965
|
+
models: _chunkB4ZNG3G7cjs.DEFAULT_OCR_MODELS,
|
|
2921
2966
|
tuning: DEFAULT_OCR_TUNING,
|
|
2922
|
-
handwriting:
|
|
2967
|
+
handwriting: _chunkB4ZNG3G7cjs.handwritingFallbackModels.call(void 0, _chunkB4ZNG3G7cjs.DEFAULT_OCR_MODELS),
|
|
2923
2968
|
autoRec: DEFAULT_AUTO_REC
|
|
2924
2969
|
});
|
|
2925
2970
|
var DEFAULT_BUILTIN_OCR_FETCH = Object.freeze({ ...DEFAULT_BUILTIN_OCR, autoRec: { ...DEFAULT_AUTO_REC, fetch: true } });
|
|
2926
2971
|
function builtinOcrConfig(o) {
|
|
2927
2972
|
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;
|
|
2928
2973
|
const bad = _chunkMMK32GPDcjs.validateOcrOptions.call(void 0, o);
|
|
2929
|
-
if (bad) throw new (0,
|
|
2930
|
-
const models =
|
|
2974
|
+
if (bad) throw new (0, _chunk4T4Y2WRRcjs.KordocError)(bad);
|
|
2975
|
+
const models = _chunkB4ZNG3G7cjs.resolveOcrModels.call(void 0, o);
|
|
2931
2976
|
return {
|
|
2932
2977
|
models,
|
|
2933
|
-
...o.ocrRec === "auto" ? { handwriting:
|
|
2978
|
+
...o.ocrRec === "auto" ? { handwriting: _chunkB4ZNG3G7cjs.handwritingFallbackModels.call(void 0, models), autoRec: AUTO_REC } : o.ocrRec === void 0 ? { handwriting: _chunkB4ZNG3G7cjs.handwritingFallbackModels.call(void 0, models), autoRec: o.ocr ? { ...DEFAULT_AUTO_REC, fetch: true } : DEFAULT_AUTO_REC } : {},
|
|
2934
2979
|
tuning: o.ocrDetLongSide === void 0 ? DEFAULT_OCR_TUNING : { ...DEFAULT_OCR_TUNING, detLongSide: o.ocrDetLongSide },
|
|
2935
2980
|
lines: o.ocrLines === "all" ? "all" : o.ocrLines ? "kept" : void 0
|
|
2936
2981
|
};
|
|
@@ -2956,8 +3001,8 @@ async function withHandwritingRec(items, config, tuning, rgba, width, height, st
|
|
|
2956
3001
|
const altStats = { droppedLowConf: 0, ...stats.dropped ? { dropped: [] } : {} };
|
|
2957
3002
|
let alt;
|
|
2958
3003
|
try {
|
|
2959
|
-
if (auto.lazy && !auto.fetch && !await
|
|
2960
|
-
if (auto.lazy) await
|
|
3004
|
+
if (auto.lazy && !auto.fetch && !await _chunkB4ZNG3G7cjs.ocrModelsCached.call(void 0, config.handwriting)) return items;
|
|
3005
|
+
if (auto.lazy) await _chunkB4ZNG3G7cjs.ensureOcrModelsFor.call(void 0, config.handwriting, reportModelDownload);
|
|
2961
3006
|
alt = await (await getOcrEngine(config.handwriting)).recognizePage(rgba, width, height, altStats, tuning, cellRules, rowRules);
|
|
2962
3007
|
} catch (e) {
|
|
2963
3008
|
if (!auto.lazy) throw e;
|
|
@@ -3003,8 +3048,8 @@ async function runPdfOcr(buffer, targets, mode, warnings, onProgress, detectTabl
|
|
|
3003
3048
|
"@hyzyla/pdfium",
|
|
3004
3049
|
() => Promise.resolve().then(() => _interopRequireWildcard(require("@hyzyla/pdfium")))
|
|
3005
3050
|
);
|
|
3006
|
-
if (mode === "builtin") await
|
|
3007
|
-
if (mode === "builtin" && config.handwriting && !_optionalChain([config, 'access', _79 => _79.autoRec, 'optionalAccess', _80 => _80.lazy])) await
|
|
3051
|
+
if (mode === "builtin") await _chunkB4ZNG3G7cjs.ensureOcrModelsFor.call(void 0, config.models, reportModelDownload);
|
|
3052
|
+
if (mode === "builtin" && config.handwriting && !_optionalChain([config, 'access', _79 => _79.autoRec, 'optionalAccess', _80 => _80.lazy])) await _chunkB4ZNG3G7cjs.ensureOcrModelsFor.call(void 0, config.handwriting, reportModelDownload);
|
|
3008
3053
|
const engine = mode === "builtin" ? await getOcrEngine(config.models) : null;
|
|
3009
3054
|
const pdfium = await pdfiumMod.PDFiumLibrary.init();
|
|
3010
3055
|
const doc = await pdfium.loadDocument(new Uint8Array(buffer));
|
|
@@ -3116,7 +3161,7 @@ async function ocrOnePage(page, pageNo, mode, engine, warnings, detectTables, ve
|
|
|
3116
3161
|
const x1 = r.x1 * scale - 2, x2 = r.x2 * scale + 2, y1 = (pdfH - r.y2) * scale - 2, y2 = (pdfH - r.y1) * scale + 2;
|
|
3117
3162
|
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));
|
|
3118
3163
|
if (columnRules < 2) {
|
|
3119
|
-
for (const b of blocks) if (b.type === "table")
|
|
3164
|
+
for (const b of blocks) if (b.type === "table") _chunkB4ZNG3G7cjs.UNRULED_REGION_TABLES.add(b);
|
|
3120
3165
|
}
|
|
3121
3166
|
return blocks;
|
|
3122
3167
|
});
|
|
@@ -3188,7 +3233,7 @@ async function closerReads(rgba, rw, rh, pdfH, hi, regions, engine, tuning = REG
|
|
|
3188
3233
|
const items = await engine.recognizePage(crop, cw, ch, void 0, tuning);
|
|
3189
3234
|
out.push(items.map((it) => {
|
|
3190
3235
|
const placed = { ...it, x: (it.x + x0) / 2, y: (it.y + y0) / 2, w: it.w / 2, h: it.h / 2 };
|
|
3191
|
-
|
|
3236
|
+
_chunkB4ZNG3G7cjs.copyOcrTextGaps.call(void 0, it, placed, 0.5, x0 / 2);
|
|
3192
3237
|
return placed;
|
|
3193
3238
|
}));
|
|
3194
3239
|
}
|
|
@@ -3280,7 +3325,7 @@ function ocrItemsToBlocks(items, pageNumber, pdfW, pdfH, scale, extraLines, dete
|
|
|
3280
3325
|
isHidden: false,
|
|
3281
3326
|
...xs[i].space ? { hasSpaceBefore: true } : {}
|
|
3282
3327
|
};
|
|
3283
|
-
|
|
3328
|
+
_chunkB4ZNG3G7cjs.copyOcrTextGaps.call(void 0, it, normalized, 1 / scale);
|
|
3284
3329
|
return normalized;
|
|
3285
3330
|
}).filter((it) => it.text);
|
|
3286
3331
|
if (_optionalChain([extraLines, 'optionalAccess', _96 => _96.verticals, 'access', _97 => _97.length]) && items.length) {
|
|
@@ -3296,7 +3341,7 @@ function ocrItemsToBlocks(items, pageNumber, pdfW, pdfH, scale, extraLines, dete
|
|
|
3296
3341
|
})
|
|
3297
3342
|
};
|
|
3298
3343
|
}
|
|
3299
|
-
const laid = unframeOcrLayoutTables(splitOcrJoinedHeaders(splitOcrContactColumns(splitOcrNameValueColumns(splitStackedOcrRows(
|
|
3344
|
+
const laid = unframeOcrLayoutTables(splitOcrJoinedHeaders(splitOcrContactColumns(splitOcrNameValueColumns(splitStackedOcrRows(_chunkB4ZNG3G7cjs.extractPageBlocksWithLines.call(void 0, norm, pageNumber, opList, pdfW, pdfH, extraLines, detectTables))))), pdfH);
|
|
3300
3345
|
const blocks = figureRegion ? laid : splitOcrProseRows(laid);
|
|
3301
3346
|
if (!figureRegion) markOcrHeadings(blocks);
|
|
3302
3347
|
return blocks;
|
|
@@ -3357,7 +3402,7 @@ async function tryImport2(name, loader) {
|
|
|
3357
3402
|
return await loader();
|
|
3358
3403
|
} catch (e) {
|
|
3359
3404
|
throw new Error(
|
|
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.${
|
|
3405
|
+
`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.${_chunk4T4Y2WRRcjs.OPTIONAL_DEP_INSTALL_HINT} \uC6D0\uC778: ${e.message}`
|
|
3361
3406
|
);
|
|
3362
3407
|
}
|
|
3363
3408
|
}
|
|
@@ -3410,4 +3455,4 @@ function bgraToRgba(bgra) {
|
|
|
3410
3455
|
|
|
3411
3456
|
|
|
3412
3457
|
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;
|
|
3413
|
-
//# sourceMappingURL=chunk-
|
|
3458
|
+
//# sourceMappingURL=chunk-B4AKPVWA.cjs.map
|