kordoc 4.24.64 → 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 +3 -3
- package/dist/{-QAZ44KKA.js → -3Q26OZHW.js} +21 -21
- package/dist/{chunk-36EJXOCF.js → chunk-27ZUZMQY.js} +5 -5
- package/dist/{chunk-34OGRWYW.js → chunk-3JHKWOVZ.js} +49 -5
- package/dist/{chunk-34OGRWYW.js.map → chunk-3JHKWOVZ.js.map} +1 -1
- package/dist/{chunk-OJKFBZPW.js → chunk-3Z7WJCP2.js} +2 -2
- package/dist/{chunk-T3JCWBOI.cjs → chunk-4T4Y2WRR.cjs} +2 -2
- package/dist/{chunk-T3JCWBOI.cjs.map → chunk-4T4Y2WRR.cjs.map} +1 -1
- package/dist/{chunk-MMZO2B5N.cjs → chunk-6J5RTSBG.cjs} +3 -3
- package/dist/{chunk-MMZO2B5N.cjs.map → chunk-6J5RTSBG.cjs.map} +1 -1
- package/dist/{chunk-COARY4DW.js → chunk-6R4M2LVY.js} +2 -2
- package/dist/{chunk-MEHJKEUZ.js → chunk-7DQI7BU6.js} +2 -2
- package/dist/{chunk-R7GE5HUE.js → chunk-7PTPUYYJ.js} +3 -3
- package/dist/{chunk-PZOKLEDR.js → chunk-ABA2Z4LT.js} +2 -2
- package/dist/{chunk-GOXFAAHN.js → chunk-AKYUE4JE.js} +2 -2
- package/dist/{chunk-EUNUDJXO.js → chunk-AX34AL6K.js} +2 -2
- package/dist/{chunk-72H52U6F.cjs → chunk-B4AKPVWA.cjs} +134 -90
- package/dist/{chunk-72H52U6F.cjs.map → chunk-B4AKPVWA.cjs.map} +1 -1
- package/dist/{chunk-FEFKONND.cjs → chunk-B4ZNG3G7.cjs} +25 -25
- package/dist/{chunk-FEFKONND.cjs.map → chunk-B4ZNG3G7.cjs.map} +1 -1
- package/dist/{chunk-ACDKOGKO.js → chunk-BPNJBWKQ.js} +15 -15
- package/dist/{chunk-PO2TQW2B.js → chunk-BRDRZHVC.js} +2 -2
- package/dist/{chunk-DFZIE6NM.js → chunk-BYTIJ226.js} +2 -2
- package/dist/{chunk-AZZKSDLD.js → chunk-CLI5IIY3.js} +2 -2
- package/dist/{chunk-XCPST2YL.js → chunk-DKSSS4ED.js} +2 -2
- package/dist/{chunk-CKA2X7FC.js → chunk-DQQ6C7WA.js} +2 -2
- package/dist/{chunk-IEOC3SKK.js → chunk-EG47QXJE.js} +5 -5
- package/dist/{chunk-X2XUGRV3.js → chunk-FTMDZ4Y5.js} +3 -3
- package/dist/{chunk-KVLIFFDJ.cjs → chunk-GITPHKYL.cjs} +8 -8
- package/dist/{chunk-KVLIFFDJ.cjs.map → chunk-GITPHKYL.cjs.map} +1 -1
- package/dist/{chunk-LJUESQWH.js → chunk-GZC4XIKW.js} +5 -5
- package/dist/{chunk-LNAOHM6K.js → chunk-I2HHHJF5.js} +2 -2
- package/dist/{chunk-4R6LAJCT.js → chunk-JW6PNIXI.js} +7 -7
- package/dist/{chunk-PTJDTKU3.js → chunk-KUAPGGQE.js} +6 -6
- package/dist/{chunk-HQSGKBH4.js → chunk-LXRBEPYC.js} +2 -2
- package/dist/{chunk-I4ON2NHU.js → chunk-MTUGM4ZK.js} +6 -6
- package/dist/{chunk-Q4AQE7TN.js → chunk-NBBT2EYG.js} +2 -2
- package/dist/{chunk-GDRQGXPC.js → chunk-NTMN5UKQ.js} +3 -3
- package/dist/{chunk-R5PEYGFS.js → chunk-PWSUGKMS.js} +2 -2
- package/dist/{chunk-PNEMJTPG.js → chunk-RH6E2YVG.js} +2 -2
- package/dist/{chunk-35WLNE3R.cjs → chunk-S5XPBZQ6.cjs} +3 -3
- package/dist/{chunk-35WLNE3R.cjs.map → chunk-S5XPBZQ6.cjs.map} +1 -1
- package/dist/{chunk-NVHBKHTR.js → chunk-TN2C7M6Q.js} +11 -11
- package/dist/{chunk-LKCLRP4E.js → chunk-TYJFA5S7.js} +2 -2
- package/dist/{chunk-YFEV3NNV.js → chunk-U2TSYPPM.js} +2 -2
- package/dist/{chunk-3XZR5JQY.cjs → chunk-UJI2ZP6M.cjs} +104 -104
- package/dist/{chunk-3XZR5JQY.cjs.map → chunk-UJI2ZP6M.cjs.map} +1 -1
- package/dist/{chunk-S6WRR43D.js → chunk-UYEZER77.js} +2 -2
- package/dist/{chunk-DAP3G7G3.js → chunk-VMR3QMB5.js} +50 -6
- package/dist/{chunk-DAP3G7G3.js.map → chunk-VMR3QMB5.js.map} +1 -1
- package/dist/{chunk-FPC3GEAD.js → chunk-VQZIP2UW.js} +10 -10
- package/dist/{chunk-ZRHMLFJB.js → chunk-XS254L5R.js} +3 -3
- package/dist/{chunk-FNRCQGZN.js → chunk-Y6UT3AYV.js} +4 -4
- package/dist/{chunk-LKH3LG3N.cjs → chunk-ZMJVWAH2.cjs} +58 -58
- package/dist/{chunk-LKH3LG3N.cjs.map → chunk-ZMJVWAH2.cjs.map} +1 -1
- package/dist/chunks-LAMEBTHT.js +11 -0
- package/dist/cli.js +45 -45
- package/dist/{formula-IWBM3D27.cjs → formula-HNVGC323.cjs} +9 -9
- package/dist/{formula-IWBM3D27.cjs.map → formula-HNVGC323.cjs.map} +1 -1
- package/dist/{formula-AKSUUGPE.js → formula-N6HZBMYV.js} +4 -4
- package/dist/{formula-TGSWQZXE.js → formula-WDYM2TBT.js} +3 -3
- package/dist/generator-GJID5Q4V.cjs +12 -0
- package/dist/{generator-AUHRYGI3.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-HQBZBCSR.js → hancom-TJ2T5WD7.js} +2 -2
- package/dist/{hancom-PV626GYI.js → hancom-XNW5F3S5.js} +2 -2
- package/dist/{hancom-QSZ33R47.cjs → hancom-Y4QJMNTG.cjs} +5 -5
- package/dist/{hancom-QSZ33R47.cjs.map → hancom-Y4QJMNTG.cjs.map} +1 -1
- package/dist/{image-ocr-EL2WFECB.cjs → image-ocr-2P6OUO7R.cjs} +28 -28
- package/dist/{image-ocr-EL2WFECB.cjs.map → image-ocr-2P6OUO7R.cjs.map} +1 -1
- package/dist/{image-ocr-2EYCNJJU.js → image-ocr-EEI3UA36.js} +10 -10
- package/dist/{image-ocr-P5XZGIPX.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-5ZAV3WPL.js → model-bundle-QMXOK6ML.js} +5 -5
- package/dist/{models-KOHBYNOH.js → models-VRTWSRWY.js} +5 -5
- package/dist/{parse-worker-v2-SSXAWHMP.js → parse-worker-v2-4YEQVFDN.js} +22 -22
- package/dist/{parser-Q2LYKLLS.js → parser-4FZWTV4P.js} +12 -12
- package/dist/{parser-JAXFIY4Z.cjs → parser-5X3O5FMI.cjs} +166 -166
- package/dist/{parser-JAXFIY4Z.cjs.map → parser-5X3O5FMI.cjs.map} +1 -1
- package/dist/{parser-GAT6U7NK.js → parser-6ZIQHTU7.js} +9 -9
- package/dist/pdf-ocr-47CN4L3H.cjs +43 -0
- package/dist/{pdf-ocr-S6LZ5SDT.cjs.map → pdf-ocr-47CN4L3H.cjs.map} +1 -1
- package/dist/{pdf-ocr-ZK6W2KRC.js → pdf-ocr-HHWYGVYA.js} +9 -9
- package/dist/{pdf-ocr-5EHHYF3C.js → pdf-ocr-TIYXB6UN.js} +6 -6
- package/dist/{profile-io-6LSVAJGK.js → profile-io-6FHN5UEA.js} +3 -3
- package/dist/{rasterize-JRBWIABQ.js → rasterize-JFBYSQSV.js} +3 -3
- package/dist/{redact-doc-K6Q3J4QN.js → redact-doc-PYL7KZBW.js} +21 -21
- package/dist/{render-QXCUXJBD.js → render-6V2YIVO3.js} +12 -12
- package/dist/{rewrite-fallback-LKK3CK7E.js → rewrite-fallback-53SOLUTC.js} +13 -13
- package/dist/seal-KRIMAC4M.js +16 -0
- package/dist/{setup-NA3L7AP4.js → setup-LFIDDDUO.js} +3 -3
- package/dist/{to-hwpx-YNCXFNZV.js → to-hwpx-PVXV4MP3.js} +7 -7
- package/dist/to-hwpx-SNIR5XQE.cjs +16 -0
- package/dist/{to-hwpx-ICWG2YYM.cjs.map → to-hwpx-SNIR5XQE.cjs.map} +1 -1
- package/dist/{to-hwpx-QVGHZIYD.js → to-hwpx-VPIDINZP.js} +4 -4
- package/dist/visual-HKD7SS2K.js +38 -0
- package/dist/{watch-C276YW4I.js → watch-RDE5VTIX.js} +22 -22
- package/package.json +1 -1
- package/dist/chunks-OWWHWU6T.js +0 -11
- package/dist/generator-AUHRYGI3.cjs +0 -12
- package/dist/generator-TGYD6N7S.js +0 -11
- package/dist/generator-UB2TEEE6.js +0 -18
- package/dist/memo-I5S4HZBP.js +0 -17
- package/dist/pdf-ocr-S6LZ5SDT.cjs +0 -43
- package/dist/seal-GMZGRQE7.js +0 -16
- package/dist/to-hwpx-ICWG2YYM.cjs +0 -16
- package/dist/visual-5BXQ3MAX.js +0 -38
- /package/dist/{-QAZ44KKA.js.map → -3Q26OZHW.js.map} +0 -0
- /package/dist/{chunk-36EJXOCF.js.map → chunk-27ZUZMQY.js.map} +0 -0
- /package/dist/{chunk-OJKFBZPW.js.map → chunk-3Z7WJCP2.js.map} +0 -0
- /package/dist/{chunk-COARY4DW.js.map → chunk-6R4M2LVY.js.map} +0 -0
- /package/dist/{chunk-MEHJKEUZ.js.map → chunk-7DQI7BU6.js.map} +0 -0
- /package/dist/{chunk-R7GE5HUE.js.map → chunk-7PTPUYYJ.js.map} +0 -0
- /package/dist/{chunk-PZOKLEDR.js.map → chunk-ABA2Z4LT.js.map} +0 -0
- /package/dist/{chunk-GOXFAAHN.js.map → chunk-AKYUE4JE.js.map} +0 -0
- /package/dist/{chunk-EUNUDJXO.js.map → chunk-AX34AL6K.js.map} +0 -0
- /package/dist/{chunk-ACDKOGKO.js.map → chunk-BPNJBWKQ.js.map} +0 -0
- /package/dist/{chunk-PO2TQW2B.js.map → chunk-BRDRZHVC.js.map} +0 -0
- /package/dist/{chunk-DFZIE6NM.js.map → chunk-BYTIJ226.js.map} +0 -0
- /package/dist/{chunk-AZZKSDLD.js.map → chunk-CLI5IIY3.js.map} +0 -0
- /package/dist/{chunk-XCPST2YL.js.map → chunk-DKSSS4ED.js.map} +0 -0
- /package/dist/{chunk-CKA2X7FC.js.map → chunk-DQQ6C7WA.js.map} +0 -0
- /package/dist/{chunk-IEOC3SKK.js.map → chunk-EG47QXJE.js.map} +0 -0
- /package/dist/{chunk-X2XUGRV3.js.map → chunk-FTMDZ4Y5.js.map} +0 -0
- /package/dist/{chunk-LJUESQWH.js.map → chunk-GZC4XIKW.js.map} +0 -0
- /package/dist/{chunk-LNAOHM6K.js.map → chunk-I2HHHJF5.js.map} +0 -0
- /package/dist/{chunk-4R6LAJCT.js.map → chunk-JW6PNIXI.js.map} +0 -0
- /package/dist/{chunk-PTJDTKU3.js.map → chunk-KUAPGGQE.js.map} +0 -0
- /package/dist/{chunk-HQSGKBH4.js.map → chunk-LXRBEPYC.js.map} +0 -0
- /package/dist/{chunk-I4ON2NHU.js.map → chunk-MTUGM4ZK.js.map} +0 -0
- /package/dist/{chunk-Q4AQE7TN.js.map → chunk-NBBT2EYG.js.map} +0 -0
- /package/dist/{chunk-GDRQGXPC.js.map → chunk-NTMN5UKQ.js.map} +0 -0
- /package/dist/{chunk-R5PEYGFS.js.map → chunk-PWSUGKMS.js.map} +0 -0
- /package/dist/{chunk-PNEMJTPG.js.map → chunk-RH6E2YVG.js.map} +0 -0
- /package/dist/{chunk-NVHBKHTR.js.map → chunk-TN2C7M6Q.js.map} +0 -0
- /package/dist/{chunk-LKCLRP4E.js.map → chunk-TYJFA5S7.js.map} +0 -0
- /package/dist/{chunk-YFEV3NNV.js.map → chunk-U2TSYPPM.js.map} +0 -0
- /package/dist/{chunk-S6WRR43D.js.map → chunk-UYEZER77.js.map} +0 -0
- /package/dist/{chunk-FPC3GEAD.js.map → chunk-VQZIP2UW.js.map} +0 -0
- /package/dist/{chunk-ZRHMLFJB.js.map → chunk-XS254L5R.js.map} +0 -0
- /package/dist/{chunk-FNRCQGZN.js.map → chunk-Y6UT3AYV.js.map} +0 -0
- /package/dist/{chunks-OWWHWU6T.js.map → chunks-LAMEBTHT.js.map} +0 -0
- /package/dist/{formula-AKSUUGPE.js.map → formula-N6HZBMYV.js.map} +0 -0
- /package/dist/{formula-TGSWQZXE.js.map → formula-WDYM2TBT.js.map} +0 -0
- /package/dist/{generator-TGYD6N7S.js.map → generator-LGSVRPVO.js.map} +0 -0
- /package/dist/{generator-UB2TEEE6.js.map → generator-QQTCTEMZ.js.map} +0 -0
- /package/dist/{hancom-HQBZBCSR.js.map → hancom-TJ2T5WD7.js.map} +0 -0
- /package/dist/{hancom-PV626GYI.js.map → hancom-XNW5F3S5.js.map} +0 -0
- /package/dist/{image-ocr-2EYCNJJU.js.map → image-ocr-EEI3UA36.js.map} +0 -0
- /package/dist/{image-ocr-P5XZGIPX.js.map → image-ocr-HXQV325C.js.map} +0 -0
- /package/dist/{memo-I5S4HZBP.js.map → memo-JYBL4KYT.js.map} +0 -0
- /package/dist/{model-bundle-5ZAV3WPL.js.map → model-bundle-QMXOK6ML.js.map} +0 -0
- /package/dist/{models-KOHBYNOH.js.map → models-VRTWSRWY.js.map} +0 -0
- /package/dist/{parse-worker-v2-SSXAWHMP.js.map → parse-worker-v2-4YEQVFDN.js.map} +0 -0
- /package/dist/{parser-Q2LYKLLS.js.map → parser-4FZWTV4P.js.map} +0 -0
- /package/dist/{parser-GAT6U7NK.js.map → parser-6ZIQHTU7.js.map} +0 -0
- /package/dist/{pdf-ocr-5EHHYF3C.js.map → pdf-ocr-HHWYGVYA.js.map} +0 -0
- /package/dist/{pdf-ocr-ZK6W2KRC.js.map → pdf-ocr-TIYXB6UN.js.map} +0 -0
- /package/dist/{profile-io-6LSVAJGK.js.map → profile-io-6FHN5UEA.js.map} +0 -0
- /package/dist/{rasterize-JRBWIABQ.js.map → rasterize-JFBYSQSV.js.map} +0 -0
- /package/dist/{redact-doc-K6Q3J4QN.js.map → redact-doc-PYL7KZBW.js.map} +0 -0
- /package/dist/{render-QXCUXJBD.js.map → render-6V2YIVO3.js.map} +0 -0
- /package/dist/{rewrite-fallback-LKK3CK7E.js.map → rewrite-fallback-53SOLUTC.js.map} +0 -0
- /package/dist/{seal-GMZGRQE7.js.map → seal-KRIMAC4M.js.map} +0 -0
- /package/dist/{setup-NA3L7AP4.js.map → setup-LFIDDDUO.js.map} +0 -0
- /package/dist/{to-hwpx-QVGHZIYD.js.map → to-hwpx-PVXV4MP3.js.map} +0 -0
- /package/dist/{to-hwpx-YNCXFNZV.js.map → to-hwpx-VPIDINZP.js.map} +0 -0
- /package/dist/{visual-5BXQ3MAX.js.map → visual-HKD7SS2K.js.map} +0 -0
- /package/dist/{watch-C276YW4I.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.,]+%?\)$/;
|
|
@@ -805,8 +805,8 @@ var INKLESS_DELTA = 32;
|
|
|
805
805
|
function ringAsks(rgba, pageW, box, text, steps, stepPx) {
|
|
806
806
|
const chars = [...text];
|
|
807
807
|
if (chars.length !== steps.length || !/[가-힣]/.test(text)) return [];
|
|
808
|
-
const gray =
|
|
809
|
-
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));
|
|
810
810
|
const owner = ringOwners(chars, (i) => (steps[i] + 0.5) * stepPx, rings);
|
|
811
811
|
return rings.flatMap((r, k) => {
|
|
812
812
|
const at = owner.indexOf(k);
|
|
@@ -846,8 +846,8 @@ function ringGlyph(read, jamo = null, confidence = 1) {
|
|
|
846
846
|
function restoreGlyphs(rgba, pageW, box, text, steps, stepPx, note = {}, rings = []) {
|
|
847
847
|
const chars = [...text];
|
|
848
848
|
if (chars.length !== steps.length) return text;
|
|
849
|
-
const gray =
|
|
850
|
-
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) };
|
|
851
851
|
if (/[[\]]/.test(text)) brackets(c);
|
|
852
852
|
if (text.includes("'")) cornerQuotes(c);
|
|
853
853
|
if (/['"]/.test(text)) quotes(c);
|
|
@@ -877,7 +877,7 @@ function restoreGlyphs(rgba, pageW, box, text, steps, stepPx, note = {}, rings =
|
|
|
877
877
|
function trimInklessEnds(rgba, pageW, box, text, steps, stepPx) {
|
|
878
878
|
const chars = [...text], { w, h } = box;
|
|
879
879
|
if (chars.length !== steps.length || steps.some((s) => (s + 0.5) * stepPx > w + stepPx)) return { text, steps };
|
|
880
|
-
const gray =
|
|
880
|
+
const gray = _chunkB4ZNG3G7cjs.grayCrop.call(void 0, rgba, pageW, box);
|
|
881
881
|
const hist = new Uint32Array(256);
|
|
882
882
|
for (const v of gray) hist[v]++;
|
|
883
883
|
let bg = 0;
|
|
@@ -908,8 +908,8 @@ function cornerCommas({ chars, cx, gray, w, h, ink }) {
|
|
|
908
908
|
continue;
|
|
909
909
|
}
|
|
910
910
|
if (open > 0) {
|
|
911
|
-
const f =
|
|
912
|
-
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") {
|
|
913
913
|
chars[i] = "\u300D";
|
|
914
914
|
open--;
|
|
915
915
|
}
|
|
@@ -919,12 +919,12 @@ function cornerCommas({ chars, cx, gray, w, h, ink }) {
|
|
|
919
919
|
function cornerQuotes({ chars, cx, gray, w, h, ink }) {
|
|
920
920
|
for (let i = 0; i < chars.length; i++) {
|
|
921
921
|
if (chars[i] !== "'" || !/^[가-힣]/.test(_nullishCoalesce(chars[i + 1], () => ( "")))) continue;
|
|
922
|
-
const f =
|
|
923
|
-
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;
|
|
924
924
|
const rest = chars.slice(i + 1), end = rest.findIndex((c) => c === "'" || c === "\u300D" || c === ",");
|
|
925
925
|
const pair = end >= 0 && rest[end] !== "'" && (rest[end] === "\u300D" || (() => {
|
|
926
|
-
const g =
|
|
927
|
-
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";
|
|
928
928
|
})());
|
|
929
929
|
if (pair) chars[i] = "\u300C";
|
|
930
930
|
}
|
|
@@ -932,8 +932,8 @@ function cornerQuotes({ chars, cx, gray, w, h, ink }) {
|
|
|
932
932
|
function brackets({ chars, cx, gray, w, h, ink }) {
|
|
933
933
|
const shape = chars.map((c, i) => {
|
|
934
934
|
if (c !== "[" && c !== "]") return null;
|
|
935
|
-
const f =
|
|
936
|
-
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 === "]");
|
|
937
937
|
});
|
|
938
938
|
for (let i = 0; i < chars.length; i++) {
|
|
939
939
|
if (chars[i] !== "[") continue;
|
|
@@ -965,7 +965,7 @@ function quotes({ chars, cx, gray, w, h, ink }) {
|
|
|
965
965
|
continue;
|
|
966
966
|
}
|
|
967
967
|
if (!year(i) && !single[kind]) continue;
|
|
968
|
-
const r =
|
|
968
|
+
const r = _chunkB4ZNG3G7cjs.quoteHead.call(void 0, gray, w, h, ink, cx(i));
|
|
969
969
|
if (r !== null && r >= 0.47) {
|
|
970
970
|
chars[i] = kind === "'" ? "\u2018" : "\u201C";
|
|
971
971
|
open[kind] = true;
|
|
@@ -976,7 +976,7 @@ function dashes({ chars, cx, gray, w, h, ink }) {
|
|
|
976
976
|
const head = chars.findIndex((c) => c.trim()), letters = chars.some((c) => /[가-힣A-Za-z]/.test(c));
|
|
977
977
|
for (let i = 0; i < chars.length; i++) {
|
|
978
978
|
if (!/^[-\u2013\u2014]$/.test(chars[i])) continue;
|
|
979
|
-
const r =
|
|
979
|
+
const r = _chunkB4ZNG3G7cjs.dashRatio.call(void 0, gray, w, h, ink, cx(i));
|
|
980
980
|
if (r === null) continue;
|
|
981
981
|
if (r < 0.65) chars[i] = "-";
|
|
982
982
|
else if (r > 0.75 && i === head && letters) chars[i] = "\u2014";
|
|
@@ -986,7 +986,7 @@ function circled({ chars, cx, gray, w, h, ink }) {
|
|
|
986
986
|
const alone = (re, i) => re.test(chars[i]) && !re.test(_nullishCoalesce(chars[i - 1], () => ( ""))) && !re.test(_nullishCoalesce(chars[i + 1], () => ( "")));
|
|
987
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] : []);
|
|
988
988
|
if (!at.length) return;
|
|
989
|
-
const hit =
|
|
989
|
+
const hit = _chunkB4ZNG3G7cjs.circledAt.call(void 0, gray, w, h, ink, at.map(cx));
|
|
990
990
|
const JAMO = "\u3131\u3134\u3137\u3139\u3141\u3142\u3145\u3147\u3148\u314A\u314B\u314C\u314D\u314E";
|
|
991
991
|
at.forEach((i, k) => {
|
|
992
992
|
if (!hit[k]) return;
|
|
@@ -999,16 +999,16 @@ function stars({ chars, cx, gray, w, h, ink }) {
|
|
|
999
999
|
if (chars[i] !== "*" || chars[i - 1] === "*") continue;
|
|
1000
1000
|
let e = i;
|
|
1001
1001
|
while (chars[e + 1] === "*") e++;
|
|
1002
|
-
const n =
|
|
1002
|
+
const n = _chunkB4ZNG3G7cjs.starRun.call(void 0, gray, w, h, ink, cx(i));
|
|
1003
1003
|
if (n > e - i + 1 && n <= 4) chars[e] += "*".repeat(n - (e - i + 1));
|
|
1004
1004
|
i = e;
|
|
1005
1005
|
}
|
|
1006
1006
|
}
|
|
1007
1007
|
function discs({ chars, cx, gray, w, h, ink }) {
|
|
1008
|
-
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";
|
|
1009
1009
|
}
|
|
1010
1010
|
function gaps({ chars, cx, gray, w, h, ink }) {
|
|
1011
|
-
const { glyphs, bandH } =
|
|
1011
|
+
const { glyphs, bandH } = _chunkB4ZNG3G7cjs.gapGlyphs.call(void 0, gray, w, h, ink);
|
|
1012
1012
|
if (!glyphs.length) return;
|
|
1013
1013
|
const live = chars.map((c, i) => i).filter((i) => chars[i].trim());
|
|
1014
1014
|
if (!live.length) return;
|
|
@@ -1079,18 +1079,18 @@ function ring({ chars, cx, gray, w, h, ink }) {
|
|
|
1079
1079
|
const rest = chars.slice(k + 1).join("").trimStart();
|
|
1080
1080
|
const live = chars.map((c, i) => i).filter((i) => chars[i].trim());
|
|
1081
1081
|
if (live.length <= 3 && live.every((i) => /^[Oo]$/.test(chars[i]))) {
|
|
1082
|
-
if (_optionalChain([
|
|
1083
|
-
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;
|
|
1084
1084
|
for (const i of live) chars[i] = "\u25CB";
|
|
1085
1085
|
return true;
|
|
1086
1086
|
}
|
|
1087
1087
|
if (/^[A-Z]{2,}/.test(rest) && /^[Oo0]$/.test(chars[k])) {
|
|
1088
|
-
if (
|
|
1088
|
+
if (_chunkB4ZNG3G7cjs.ringBullet.call(void 0, gray, w, h, ink, cx(k)) !== "\u25CB") return false;
|
|
1089
1089
|
chars[k] = chars[k + 1] === " " ? "\u25CB" : "\u25CB ";
|
|
1090
1090
|
return true;
|
|
1091
1091
|
}
|
|
1092
1092
|
if (!/^[(\[「【<]?\d*[가-힣]/.test(rest)) return false;
|
|
1093
|
-
const r =
|
|
1093
|
+
const r = _chunkB4ZNG3G7cjs.ringBullet.call(void 0, gray, w, h, ink, cx(k));
|
|
1094
1094
|
if (/^[Cc]$/.test(chars[k]) && r !== "\u25CB") return false;
|
|
1095
1095
|
if (r) chars[k] = r;
|
|
1096
1096
|
return r !== null;
|
|
@@ -1107,7 +1107,7 @@ function parallels({ chars, cx, gray, w, h, ink }) {
|
|
|
1107
1107
|
let p = s - 1, q = e + 1;
|
|
1108
1108
|
while (p >= 0 && !chars[p].trim()) p--;
|
|
1109
1109
|
while (q < chars.length && !chars[q].trim()) q++;
|
|
1110
|
-
if (
|
|
1110
|
+
if (_chunkB4ZNG3G7cjs.slantedPair.call(void 0, gray, w, h, ink, p >= 0 ? cx(p) : -Infinity, q < chars.length ? cx(q) : Infinity)) {
|
|
1111
1111
|
chars[s] = "\u2225";
|
|
1112
1112
|
for (let k = s + 1; k <= e; k++) chars[k] = "";
|
|
1113
1113
|
}
|
|
@@ -1119,7 +1119,7 @@ function roman({ chars, cx, gray, w, h, ink }) {
|
|
|
1119
1119
|
const ROMAN = /^[IⅠ-Ⅲ]$/, LATIN = /[A-Za-z]$/;
|
|
1120
1120
|
for (let i = 0; i < chars.length; i++) {
|
|
1121
1121
|
if (chars[i] !== "1" || /[\dA-Za-z]$/.test(_nullishCoalesce(chars[i - 1], () => ( ""))) || /^[\dA-Za-z,]/.test(_nullishCoalesce(chars[i + 1], () => ( "")))) continue;
|
|
1122
|
-
if (
|
|
1122
|
+
if (_chunkB4ZNG3G7cjs.serifOne.call(void 0, gray, w, h, ink, cx(i))) chars[i] = "\u2160";
|
|
1123
1123
|
}
|
|
1124
1124
|
for (let i = 0; i < chars.length; i++) {
|
|
1125
1125
|
const hangul = /^[파피]$/.test(chars[i]);
|
|
@@ -1129,13 +1129,13 @@ function roman({ chars, cx, gray, w, h, ink }) {
|
|
|
1129
1129
|
while (q < chars.length && !chars[q].trim()) q++;
|
|
1130
1130
|
const glued = hangul ? chars[p] === "(" && chars[q] === "-" : /[가-힣]$/.test(_nullishCoalesce(chars[i - 1], () => ( ""))) || (_nullishCoalesce(chars[i + 1], () => ( ""))) === "." || chars[p] === "-" && chars[q] === "-";
|
|
1131
1131
|
if (!glued) continue;
|
|
1132
|
-
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], () => ( ""))));
|
|
1133
1133
|
if (n) chars[i] = String.fromCharCode(8543 + n);
|
|
1134
1134
|
}
|
|
1135
1135
|
const inRoman = (i) => ROMAN.test(chars[i]) || chars[i] === "1" && (ROMAN.test(_nullishCoalesce(chars[i - 1], () => ( ""))) || ROMAN.test(_nullishCoalesce(chars[i + 1], () => ( ""))));
|
|
1136
1136
|
const k = chars.findIndex((c) => c.trim());
|
|
1137
1137
|
if (chars[k] === "." && chars.slice(k + 1).some((c) => /[가-힣A-Za-z0-9]/.test(c))) {
|
|
1138
|
-
const n =
|
|
1138
|
+
const n = _chunkB4ZNG3G7cjs.romanStems.call(void 0, gray, w, h, ink, -Infinity, cx(k));
|
|
1139
1139
|
if (n) chars[k] = String.fromCharCode(8543 + n) + chars[k];
|
|
1140
1140
|
}
|
|
1141
1141
|
for (let s = 0; s < chars.length; ) {
|
|
@@ -1153,7 +1153,7 @@ function roman({ chars, cx, gray, w, h, ink }) {
|
|
|
1153
1153
|
let p = s - 1, q = e;
|
|
1154
1154
|
while (p >= 0 && !chars[p].trim()) p--;
|
|
1155
1155
|
while (q < chars.length && !chars[q].trim()) q++;
|
|
1156
|
-
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], () => ( ""))));
|
|
1157
1157
|
const canon = n ? [["\u2160", "I"], ["\u2161", "II"], ["\u2162", "III"]][n - 1] : null;
|
|
1158
1158
|
if (canon && !canon.includes(tok)) {
|
|
1159
1159
|
chars[s] = canon[0];
|
|
@@ -1582,8 +1582,8 @@ function joinGapLeaders(rgba, width, items) {
|
|
|
1582
1582
|
if (g1 - g0 < h * 3) continue;
|
|
1583
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));
|
|
1584
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 };
|
|
1585
|
-
const gray =
|
|
1586
|
-
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);
|
|
1587
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);
|
|
1588
1588
|
if (cover < (g1 - g0) * 0.6) continue;
|
|
1589
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);
|
|
@@ -1866,7 +1866,7 @@ var OcrEngine = class _OcrEngine {
|
|
|
1866
1866
|
this.ort = parts.ort;
|
|
1867
1867
|
this.sharp = parts.sharp;
|
|
1868
1868
|
}
|
|
1869
|
-
static async create(models =
|
|
1869
|
+
static async create(models = _chunkB4ZNG3G7cjs.DEFAULT_OCR_MODELS) {
|
|
1870
1870
|
_chunkTK3FDAEEcjs.disableOrtTelemetry.call(void 0, );
|
|
1871
1871
|
const [ortMod, sharpModRaw] = await Promise.all([
|
|
1872
1872
|
tryImport("onnxruntime-node", () => Promise.resolve().then(() => _interopRequireWildcard(require("onnxruntime-node")))),
|
|
@@ -1886,16 +1886,16 @@ var OcrEngine = class _OcrEngine {
|
|
|
1886
1886
|
const local = (s) => "spec" in s ? Promise.resolve(null) : verifiedBytes(s);
|
|
1887
1887
|
const [detBytes, recBytes, dictBytes] = await Promise.all([local(models.det), local(models.rec), local(models.dict)]);
|
|
1888
1888
|
const session = (s, bytes) => bytes ? ortMod.InferenceSession.create(bytes, sessionOpts).catch(() => {
|
|
1889
|
-
throw new (0,
|
|
1890
|
-
}) : 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);
|
|
1891
1891
|
const [det, rec, dictYml] = await Promise.all([
|
|
1892
1892
|
session(models.det, detBytes),
|
|
1893
1893
|
session(models.rec, recBytes),
|
|
1894
|
-
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")
|
|
1895
1895
|
]);
|
|
1896
|
-
const dict =
|
|
1896
|
+
const dict = _chunkB4ZNG3G7cjs.parseCharacterDict.call(void 0, dictYml);
|
|
1897
1897
|
if (dict.length === 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,
|
|
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`);
|
|
1899
1899
|
}
|
|
1900
1900
|
return new _OcrEngine({ det, rec, dict, ort: ortMod, sharp: sharpMod });
|
|
1901
1901
|
}
|
|
@@ -1927,10 +1927,10 @@ var OcrEngine = class _OcrEngine {
|
|
|
1927
1927
|
if (it.x - x < it.h * 0.8) return;
|
|
1928
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;
|
|
1929
1929
|
const box = { x, y: it.y, w: it.x + it.w - x, h: it.h };
|
|
1930
|
-
const g =
|
|
1931
|
-
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);
|
|
1932
1932
|
if (_optionalChain([b, 'optionalAccess', _36 => _36.mark]) !== "\u25A1" || b.covers) return;
|
|
1933
|
-
const ink =
|
|
1933
|
+
const ink = _chunkB4ZNG3G7cjs.inkStats.call(void 0, g), on = (v) => ink.darkInk ? v <= ink.threshold : v > ink.threshold;
|
|
1934
1934
|
let left = 0;
|
|
1935
1935
|
while (left < it.x - x && !Array.from({ length: box.h }, (_, y) => g[y * box.w + left]).some(on)) left++;
|
|
1936
1936
|
it.text = "\u25A1 " + it.text;
|
|
@@ -1962,12 +1962,12 @@ var OcrEngine = class _OcrEngine {
|
|
|
1962
1962
|
const joins = [];
|
|
1963
1963
|
let group = 0;
|
|
1964
1964
|
for (const b of boxes) {
|
|
1965
|
-
const gray =
|
|
1966
|
-
const ink =
|
|
1965
|
+
const gray = _chunkB4ZNG3G7cjs.grayCrop.call(void 0, rgba, width, b);
|
|
1966
|
+
const ink = _chunkB4ZNG3G7cjs.inkStats.call(void 0, gray);
|
|
1967
1967
|
if (tuning.minInkContrast > 0 && ink.contrast < tuning.minInkContrast) continue;
|
|
1968
1968
|
if (tuning.minInkContrast > 0 && ink.inkRatio < MIN_INK_RATIO) continue;
|
|
1969
1969
|
if (tuning.splitTall && b.h >= b.w * TALL_RATIO) {
|
|
1970
|
-
const bands =
|
|
1970
|
+
const bands = _chunkB4ZNG3G7cjs.splitRowBands.call(void 0, gray, b.w, b.h, ink, 0.45);
|
|
1971
1971
|
if (bands.length >= 2) {
|
|
1972
1972
|
for (const sub of bandBoxes(b, bands, height)) jobs.push({ box: sub, rot: 0, group: group++ });
|
|
1973
1973
|
continue;
|
|
@@ -1991,9 +1991,9 @@ var OcrEngine = class _OcrEngine {
|
|
|
1991
1991
|
continue;
|
|
1992
1992
|
}
|
|
1993
1993
|
}
|
|
1994
|
-
const trim = tuning.trimEdges ?
|
|
1994
|
+
const trim = tuning.trimEdges ? _chunkB4ZNG3G7cjs.edgeTrim.call(void 0, gray, b.w, b.h, ink) : null;
|
|
1995
1995
|
const keep = trim ? { ...trim, bg: median(gray) } : void 0;
|
|
1996
|
-
const leaders = tuning.splitLeaders ?
|
|
1996
|
+
const leaders = tuning.splitLeaders ? _chunkB4ZNG3G7cjs.leaderRuns.call(void 0, gray, b.w, b.h, ink, LEADER_MIN_DOTS) : [];
|
|
1997
1997
|
if (leaders.length) {
|
|
1998
1998
|
const join = joins.length;
|
|
1999
1999
|
joins.push({ box: b, parts: [], trailDots: false });
|
|
@@ -2002,7 +2002,7 @@ var OcrEngine = class _OcrEngine {
|
|
|
2002
2002
|
const bare = { x: b.x + x0, y: b.y, w: a - x0, h: b.h };
|
|
2003
2003
|
const end = c > a ? Math.min(c, a + Math.round(b.h * LEADER_CONTEXT)) : a;
|
|
2004
2004
|
x0 = c;
|
|
2005
|
-
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)) {
|
|
2006
2006
|
jobs.push({ box: { ...bare, w: end - (bare.x - b.x) }, rot: 0, group: group++, join, dotsBefore: dots, trimDots: end > a });
|
|
2007
2007
|
dots = false;
|
|
2008
2008
|
}
|
|
@@ -2051,15 +2051,15 @@ var OcrEngine = class _OcrEngine {
|
|
|
2051
2051
|
let text = tuning.postprocess ? restoreSymbols(raw.trim(), note.ringLead) : raw;
|
|
2052
2052
|
if (!text.trim()) continue;
|
|
2053
2053
|
if (tuning.postprocess && job.rot === 0 && text !== "/" && /^[(:;/)]+$/.test(text) && text.includes("/")) {
|
|
2054
|
-
const g =
|
|
2055
|
-
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 = "/";
|
|
2056
2056
|
}
|
|
2057
2057
|
let ringByShape = false;
|
|
2058
2058
|
if (tuning.postprocess && job.rot === 0 && !/^[◎●▪□■▣❐❏○ㅇ◆◇◈]/.test(text)) {
|
|
2059
2059
|
const chars = [...read], k = chars.findIndex((c) => c.trim());
|
|
2060
2060
|
if (k >= 0 && steps.length === chars.length) {
|
|
2061
|
-
const g =
|
|
2062
|
-
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);
|
|
2063
2063
|
const body = (_nullishCoalesce(text.match(/[가-힣]/g), () => ( []))).length >= 4;
|
|
2064
2064
|
const miss = /^[Oo0•·ㆍ∙‧○]/.test(text);
|
|
2065
2065
|
if (_optionalChain([b, 'optionalAccess', _39 => _39.mark]) === "\u25CE" && b.covers && /^[Oo0○©]/.test(text)) {
|
|
@@ -2074,17 +2074,17 @@ var OcrEngine = class _OcrEngine {
|
|
|
2074
2074
|
} else if (_optionalChain([b, 'optionalAccess', _46 => _46.mark]) === "\u2750" || _optionalChain([b, 'optionalAccess', _47 => _47.mark]) === "\u274F") {
|
|
2075
2075
|
if (b.covers ? /^[ㅁ口]/.test(text) : body) text = b.covers ? b.mark + text.slice(1) : b.mark + " " + text;
|
|
2076
2076
|
} else if (b && b.mark !== "\u25CE" && body) text = b.covers ? miss ? b.mark + " " + text.slice(1).trimStart() : text : b.mark + " " + text;
|
|
2077
|
-
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;
|
|
2078
2078
|
}
|
|
2079
2079
|
}
|
|
2080
2080
|
if (tuning.postprocess && /^\d/.test(text) && job.rot === 0) {
|
|
2081
|
-
const g =
|
|
2082
|
-
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));
|
|
2083
2083
|
if (tri) text = tri + text;
|
|
2084
2084
|
}
|
|
2085
2085
|
if (tuning.postprocess && text === "\u2192" && job.rot === 0 && job.join === void 0) {
|
|
2086
|
-
const g =
|
|
2087
|
-
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));
|
|
2088
2088
|
}
|
|
2089
2089
|
if (job.footer) {
|
|
2090
2090
|
if (!/^[-\u2013\u2014]?\s*(?:\d{1,4}|[ivxIVXⅰ-ⅹⅠ-Ⅹ]{1,4})\s*[-\u2013\u2014]?$/.test(text.trim())) continue;
|
|
@@ -2108,7 +2108,7 @@ var OcrEngine = class _OcrEngine {
|
|
|
2108
2108
|
continue;
|
|
2109
2109
|
}
|
|
2110
2110
|
const item = { text, ...this.itemBox(rgba, width, job.box, tuning), confidence };
|
|
2111
|
-
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));
|
|
2112
2112
|
if (job.rot === 0 && job.keep === void 0) boxOf.set(item, job.box);
|
|
2113
2113
|
items.push(item);
|
|
2114
2114
|
}
|
|
@@ -2122,7 +2122,7 @@ var OcrEngine = class _OcrEngine {
|
|
|
2122
2122
|
const merged = rereadNumberText(it.text, r.text);
|
|
2123
2123
|
if (merged === null) return;
|
|
2124
2124
|
it.text = merged;
|
|
2125
|
-
|
|
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));
|
|
2126
2126
|
});
|
|
2127
2127
|
}
|
|
2128
2128
|
const pairs = tuning.postprocess ? items.filter((it) => boxOf.has(it) && NUMBER_PAIR.test(it.text.trim())) : [];
|
|
@@ -2150,8 +2150,8 @@ var OcrEngine = class _OcrEngine {
|
|
|
2150
2150
|
const halves = [];
|
|
2151
2151
|
for (const it of tall) {
|
|
2152
2152
|
const b = boxOf.get(it);
|
|
2153
|
-
const gray =
|
|
2154
|
-
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))));
|
|
2155
2155
|
if (cut) halves.push({ it, top: { ...b, h: cut[0] }, bottom: { ...b, y: b.y + cut[1], h: b.h - cut[1] } });
|
|
2156
2156
|
}
|
|
2157
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) : [];
|
|
@@ -2172,14 +2172,14 @@ var OcrEngine = class _OcrEngine {
|
|
|
2172
2172
|
const subs = [];
|
|
2173
2173
|
const stacks = [];
|
|
2174
2174
|
for (const b of [...retry, ...blank2]) {
|
|
2175
|
-
const gray =
|
|
2176
|
-
const ink =
|
|
2175
|
+
const gray = _chunkB4ZNG3G7cjs.grayCrop.call(void 0, rgba, width, b);
|
|
2176
|
+
const ink = _chunkB4ZNG3G7cjs.inkStats.call(void 0, gray);
|
|
2177
2177
|
const cut = retry.includes(b) ? midBlankRow(gray, b.w, b.h, ink) : null;
|
|
2178
2178
|
if (cut && b.w >= 3 * Math.max(cut[0], b.h - cut[1])) {
|
|
2179
2179
|
subs.push({ ...b, h: cut[0] }, { ...b, y: b.y + cut[1], h: b.h - cut[1] });
|
|
2180
2180
|
continue;
|
|
2181
2181
|
}
|
|
2182
|
-
const bands =
|
|
2182
|
+
const bands = _chunkB4ZNG3G7cjs.stackedGlyphBands.call(void 0, gray, b.w, b.h, ink);
|
|
2183
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)) });
|
|
2184
2184
|
}
|
|
2185
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));
|
|
@@ -2258,8 +2258,8 @@ var OcrEngine = class _OcrEngine {
|
|
|
2258
2258
|
/** 결과 좌표 — det 박스 그대로 또는 박스 안 잉크 외곽 (tightBoxes) */
|
|
2259
2259
|
itemBox(rgba, width, b, tuning) {
|
|
2260
2260
|
if (!tuning.tightBoxes) return b;
|
|
2261
|
-
const gray =
|
|
2262
|
-
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));
|
|
2263
2263
|
return { x: b.x + t.x0, y: b.y + t.y0, w: t.x1 - t.x0, h: t.y1 - t.y0 };
|
|
2264
2264
|
}
|
|
2265
2265
|
// ─── det ─────────────────────────────────────────────
|
|
@@ -2330,7 +2330,7 @@ var OcrEngine = class _OcrEngine {
|
|
|
2330
2330
|
const out = await this.rec.run({ [this.rec.inputNames[0]]: tensor });
|
|
2331
2331
|
const logits = out[this.rec.outputNames[0]];
|
|
2332
2332
|
const [, T, C] = logits.dims;
|
|
2333
|
-
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`);
|
|
2334
2334
|
const data = logits.data;
|
|
2335
2335
|
idx.forEach((ci, k) => {
|
|
2336
2336
|
const r = ctcDecode(data.subarray(k * T * C, (k + 1) * T * C), T, C, this.dict);
|
|
@@ -2340,9 +2340,9 @@ var OcrEngine = class _OcrEngine {
|
|
|
2340
2340
|
const chars = r ? [...r.text] : [];
|
|
2341
2341
|
if (r && job.rot === 0 && chars.length === r.steps.length && r.steps.some((t) => t > last) && !r.text.includes("(cid:")) {
|
|
2342
2342
|
const tallCh = (c) => !/[\s.,:;\u00b7\u2026'"\u2018-\u201d`\-_~]/.test(c);
|
|
2343
|
-
const g =
|
|
2343
|
+
const g = _chunkB4ZNG3G7cjs.grayCrop.call(void 0, rgba, pageW, job.box);
|
|
2344
2344
|
const inside = chars.filter((c, i) => r.steps[i] <= last && tallCh(c)).length;
|
|
2345
|
-
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;
|
|
2346
2346
|
const keep = chars.map((c, i) => r.steps[i] <= last || !tallCh(c) || budget-- > 0);
|
|
2347
2347
|
if (!keep.every(Boolean)) kept = { ...r, text: chars.filter((_, i) => keep[i]).join(""), steps: r.steps.filter((_, i) => keep[i]) };
|
|
2348
2348
|
}
|
|
@@ -2453,13 +2453,13 @@ async function tryImport(name, loader) {
|
|
|
2453
2453
|
return await loader();
|
|
2454
2454
|
} catch (e) {
|
|
2455
2455
|
throw new Error(
|
|
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.${
|
|
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}`
|
|
2457
2457
|
);
|
|
2458
2458
|
}
|
|
2459
2459
|
}
|
|
2460
2460
|
async function verifiedBytes(s) {
|
|
2461
2461
|
const name = _path.basename.call(void 0, s.file.path);
|
|
2462
|
-
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})`);
|
|
2463
2463
|
const why = (e) => {
|
|
2464
2464
|
const code = e.code;
|
|
2465
2465
|
return code === "ENOENT" ? "\uD30C\uC77C\uC774 \uC5C6\uC74C" : code === "EACCES" || code === "EPERM" ? "\uAD8C\uD55C \uC5C6\uC74C" : "\uC77D\uAE30 \uC2E4\uD328";
|
|
@@ -2480,13 +2480,13 @@ async function verifiedBytes(s) {
|
|
|
2480
2480
|
}
|
|
2481
2481
|
const actual = _crypto.createHash.call(void 0, "sha256").update(bytes).digest("hex");
|
|
2482
2482
|
if (actual !== s.file.sha256) {
|
|
2483
|
-
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)`);
|
|
2484
2484
|
}
|
|
2485
2485
|
return bytes;
|
|
2486
2486
|
}
|
|
2487
2487
|
var engines = /* @__PURE__ */ new Map();
|
|
2488
|
-
function getOcrEngine(models =
|
|
2489
|
-
const key =
|
|
2488
|
+
function getOcrEngine(models = _chunkB4ZNG3G7cjs.DEFAULT_OCR_MODELS) {
|
|
2489
|
+
const key = _chunkB4ZNG3G7cjs.ocrSelectionKey.call(void 0, models);
|
|
2490
2490
|
let p = engines.get(key);
|
|
2491
2491
|
if (!p) {
|
|
2492
2492
|
p = OcrEngine.create(models).catch((err) => {
|
|
@@ -2683,22 +2683,66 @@ function categoryRow(items, v) {
|
|
|
2683
2683
|
const words = line.reduce((n, it) => n + it.text.trim().split(/\s+/).length, 0);
|
|
2684
2684
|
return words >= 2 && Math.max(...line.map((it) => it.x + it.w)) > v.x2 + 6 * v.h ? line : [];
|
|
2685
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
|
+
}
|
|
2686
2719
|
function chartPlotItems(items) {
|
|
2687
2720
|
const drop = /* @__PURE__ */ new Set();
|
|
2688
2721
|
const verticals = valueAxes(items);
|
|
2689
|
-
if (!verticals.length) return drop;
|
|
2690
2722
|
const horizontals = timeAxes(items);
|
|
2723
|
+
forestPlotItems(items, horizontals, drop);
|
|
2724
|
+
if (!verticals.length) return drop;
|
|
2691
2725
|
for (const v of verticals) {
|
|
2692
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);
|
|
2693
2727
|
const cats = hz ? [] : categoryRow(items, v);
|
|
2694
2728
|
if (!hz && cats.length === 0) continue;
|
|
2695
2729
|
const bottom = hz ? hz.y2 + 2.5 * v.h : Math.max(...cats.map((c) => c.y + c.h)) + 0.5 * v.h;
|
|
2696
2730
|
const right = hz ? hz.x2 + 2 * v.h : Math.max(...cats.map((c) => c.x + c.w)) + v.h;
|
|
2697
|
-
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;
|
|
2698
2732
|
items.forEach((it, i) => {
|
|
2699
2733
|
const cx = it.x + it.w / 2, cy = it.y + it.h / 2;
|
|
2700
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);
|
|
2701
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
|
+
}
|
|
2702
2746
|
}
|
|
2703
2747
|
return drop;
|
|
2704
2748
|
}
|
|
@@ -2918,20 +2962,20 @@ var REDETECT = { minDropped: 15, minShare: 0.15, scale: 5 / 3 };
|
|
|
2918
2962
|
var AUTO_REC = { pageConf: 0.9, gain: 0.06 };
|
|
2919
2963
|
var DEFAULT_AUTO_REC = { pageConf: 0.9, gain: 0.08, altConf: 0.95, sureGain: 0.1, minDiff: 0.08, minChars: 80, lazy: true };
|
|
2920
2964
|
var DEFAULT_BUILTIN_OCR = Object.freeze({
|
|
2921
|
-
models:
|
|
2965
|
+
models: _chunkB4ZNG3G7cjs.DEFAULT_OCR_MODELS,
|
|
2922
2966
|
tuning: DEFAULT_OCR_TUNING,
|
|
2923
|
-
handwriting:
|
|
2967
|
+
handwriting: _chunkB4ZNG3G7cjs.handwritingFallbackModels.call(void 0, _chunkB4ZNG3G7cjs.DEFAULT_OCR_MODELS),
|
|
2924
2968
|
autoRec: DEFAULT_AUTO_REC
|
|
2925
2969
|
});
|
|
2926
2970
|
var DEFAULT_BUILTIN_OCR_FETCH = Object.freeze({ ...DEFAULT_BUILTIN_OCR, autoRec: { ...DEFAULT_AUTO_REC, fetch: true } });
|
|
2927
2971
|
function builtinOcrConfig(o) {
|
|
2928
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;
|
|
2929
2973
|
const bad = _chunkMMK32GPDcjs.validateOcrOptions.call(void 0, o);
|
|
2930
|
-
if (bad) throw new (0,
|
|
2931
|
-
const models =
|
|
2974
|
+
if (bad) throw new (0, _chunk4T4Y2WRRcjs.KordocError)(bad);
|
|
2975
|
+
const models = _chunkB4ZNG3G7cjs.resolveOcrModels.call(void 0, o);
|
|
2932
2976
|
return {
|
|
2933
2977
|
models,
|
|
2934
|
-
...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 } : {},
|
|
2935
2979
|
tuning: o.ocrDetLongSide === void 0 ? DEFAULT_OCR_TUNING : { ...DEFAULT_OCR_TUNING, detLongSide: o.ocrDetLongSide },
|
|
2936
2980
|
lines: o.ocrLines === "all" ? "all" : o.ocrLines ? "kept" : void 0
|
|
2937
2981
|
};
|
|
@@ -2957,8 +3001,8 @@ async function withHandwritingRec(items, config, tuning, rgba, width, height, st
|
|
|
2957
3001
|
const altStats = { droppedLowConf: 0, ...stats.dropped ? { dropped: [] } : {} };
|
|
2958
3002
|
let alt;
|
|
2959
3003
|
try {
|
|
2960
|
-
if (auto.lazy && !auto.fetch && !await
|
|
2961
|
-
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);
|
|
2962
3006
|
alt = await (await getOcrEngine(config.handwriting)).recognizePage(rgba, width, height, altStats, tuning, cellRules, rowRules);
|
|
2963
3007
|
} catch (e) {
|
|
2964
3008
|
if (!auto.lazy) throw e;
|
|
@@ -3004,8 +3048,8 @@ async function runPdfOcr(buffer, targets, mode, warnings, onProgress, detectTabl
|
|
|
3004
3048
|
"@hyzyla/pdfium",
|
|
3005
3049
|
() => Promise.resolve().then(() => _interopRequireWildcard(require("@hyzyla/pdfium")))
|
|
3006
3050
|
);
|
|
3007
|
-
if (mode === "builtin") await
|
|
3008
|
-
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);
|
|
3009
3053
|
const engine = mode === "builtin" ? await getOcrEngine(config.models) : null;
|
|
3010
3054
|
const pdfium = await pdfiumMod.PDFiumLibrary.init();
|
|
3011
3055
|
const doc = await pdfium.loadDocument(new Uint8Array(buffer));
|
|
@@ -3117,7 +3161,7 @@ async function ocrOnePage(page, pageNo, mode, engine, warnings, detectTables, ve
|
|
|
3117
3161
|
const x1 = r.x1 * scale - 2, x2 = r.x2 * scale + 2, y1 = (pdfH - r.y2) * scale - 2, y2 = (pdfH - r.y1) * scale + 2;
|
|
3118
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));
|
|
3119
3163
|
if (columnRules < 2) {
|
|
3120
|
-
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);
|
|
3121
3165
|
}
|
|
3122
3166
|
return blocks;
|
|
3123
3167
|
});
|
|
@@ -3189,7 +3233,7 @@ async function closerReads(rgba, rw, rh, pdfH, hi, regions, engine, tuning = REG
|
|
|
3189
3233
|
const items = await engine.recognizePage(crop, cw, ch, void 0, tuning);
|
|
3190
3234
|
out.push(items.map((it) => {
|
|
3191
3235
|
const placed = { ...it, x: (it.x + x0) / 2, y: (it.y + y0) / 2, w: it.w / 2, h: it.h / 2 };
|
|
3192
|
-
|
|
3236
|
+
_chunkB4ZNG3G7cjs.copyOcrTextGaps.call(void 0, it, placed, 0.5, x0 / 2);
|
|
3193
3237
|
return placed;
|
|
3194
3238
|
}));
|
|
3195
3239
|
}
|
|
@@ -3281,7 +3325,7 @@ function ocrItemsToBlocks(items, pageNumber, pdfW, pdfH, scale, extraLines, dete
|
|
|
3281
3325
|
isHidden: false,
|
|
3282
3326
|
...xs[i].space ? { hasSpaceBefore: true } : {}
|
|
3283
3327
|
};
|
|
3284
|
-
|
|
3328
|
+
_chunkB4ZNG3G7cjs.copyOcrTextGaps.call(void 0, it, normalized, 1 / scale);
|
|
3285
3329
|
return normalized;
|
|
3286
3330
|
}).filter((it) => it.text);
|
|
3287
3331
|
if (_optionalChain([extraLines, 'optionalAccess', _96 => _96.verticals, 'access', _97 => _97.length]) && items.length) {
|
|
@@ -3297,7 +3341,7 @@ function ocrItemsToBlocks(items, pageNumber, pdfW, pdfH, scale, extraLines, dete
|
|
|
3297
3341
|
})
|
|
3298
3342
|
};
|
|
3299
3343
|
}
|
|
3300
|
-
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);
|
|
3301
3345
|
const blocks = figureRegion ? laid : splitOcrProseRows(laid);
|
|
3302
3346
|
if (!figureRegion) markOcrHeadings(blocks);
|
|
3303
3347
|
return blocks;
|
|
@@ -3358,7 +3402,7 @@ async function tryImport2(name, loader) {
|
|
|
3358
3402
|
return await loader();
|
|
3359
3403
|
} catch (e) {
|
|
3360
3404
|
throw new Error(
|
|
3361
|
-
`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}`
|
|
3362
3406
|
);
|
|
3363
3407
|
}
|
|
3364
3408
|
}
|
|
@@ -3411,4 +3455,4 @@ function bgraToRgba(bgra) {
|
|
|
3411
3455
|
|
|
3412
3456
|
|
|
3413
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;
|
|
3414
|
-
//# sourceMappingURL=chunk-
|
|
3458
|
+
//# sourceMappingURL=chunk-B4AKPVWA.cjs.map
|