kordoc 4.24.55 → 4.24.56
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/{-GHMJ3363.js → -WGAKP3KZ.js} +21 -21
- package/dist/{chunk-7AZYXT4H.js → chunk-3N3AKCVA.js} +2 -2
- package/dist/{chunk-LXU73SJI.cjs → chunk-4GKCBRSS.cjs} +112 -94
- package/dist/chunk-4GKCBRSS.cjs.map +1 -0
- package/dist/{chunk-WNZ5LCYB.js → chunk-56FUD7JF.js} +2 -2
- package/dist/{chunk-ULSUZHLO.js → chunk-6F4HMJEJ.js} +3 -3
- package/dist/{chunk-GQ6GQ422.js → chunk-A7X6JM2E.js} +5 -5
- package/dist/{chunk-SUE5SQKX.js → chunk-AN23MDXT.js} +2 -2
- package/dist/{chunk-LFJPH5RB.js → chunk-ATLW4BFE.js} +5 -5
- package/dist/{chunk-EFDCMT4P.cjs → chunk-B5GR3467.cjs} +98 -98
- package/dist/{chunk-EFDCMT4P.cjs.map → chunk-B5GR3467.cjs.map} +1 -1
- package/dist/{chunk-TSESEQTD.js → chunk-COJXBMHS.js} +2 -2
- package/dist/{chunk-AHOQZRSH.cjs → chunk-CZRYLGRV.cjs} +6 -6
- package/dist/{chunk-AHOQZRSH.cjs.map → chunk-CZRYLGRV.cjs.map} +1 -1
- package/dist/{chunk-6BQZPLYD.js → chunk-EJDMD2PH.js} +2 -2
- package/dist/{chunk-GGMDXPYZ.js → chunk-EO4E4N6J.js} +3 -3
- package/dist/{chunk-WHSQZ52O.js → chunk-FAGRTJ5V.js} +2 -2
- package/dist/{chunk-6YNVSOBE.js → chunk-I3HC5JFQ.js} +7 -7
- package/dist/{chunk-YW3YB6VM.js → chunk-JCCFUUVQ.js} +2 -2
- package/dist/{chunk-2IB777JN.cjs → chunk-K4EVJ5DX.cjs} +3 -3
- package/dist/{chunk-2IB777JN.cjs.map → chunk-K4EVJ5DX.cjs.map} +1 -1
- package/dist/{chunk-YDOKUVIT.js → chunk-K4GFDSZD.js} +6 -6
- package/dist/{chunk-4WR6VPNW.js → chunk-KTEVCQ3F.js} +29 -11
- package/dist/chunk-KTEVCQ3F.js.map +1 -0
- package/dist/{chunk-KJGRWA5R.js → chunk-KZCOCJTD.js} +2 -2
- package/dist/{chunk-3Q5AKSLH.js → chunk-M2XX26WJ.js} +15 -15
- package/dist/{chunk-6NKTJ6XK.js → chunk-N26SI5VH.js} +2 -2
- package/dist/{chunk-UNWPVP42.js → chunk-NKPFF3LE.js} +2 -2
- package/dist/{chunk-5FQCWHOV.js → chunk-ORC43RFM.js} +4 -4
- package/dist/{chunk-P4XP5SQV.js → chunk-OSIAH3YY.js} +11 -11
- package/dist/{chunk-YMBU2QML.cjs → chunk-OX2YMAOG.cjs} +2 -2
- package/dist/{chunk-YMBU2QML.cjs.map → chunk-OX2YMAOG.cjs.map} +1 -1
- package/dist/{chunk-HSZEKMV3.js → chunk-PD6J4662.js} +2 -2
- package/dist/{chunk-EWUUDKHJ.js → chunk-PDK5TYG4.js} +3 -3
- package/dist/{chunk-2PU62D4B.js → chunk-POIGFLWY.js} +2 -2
- package/dist/{chunk-PP25G757.js → chunk-POQM5OTB.js} +30 -12
- package/dist/chunk-POQM5OTB.js.map +1 -0
- package/dist/{chunk-JK7Z3KXV.js → chunk-Q6EK3HUU.js} +2 -2
- package/dist/{chunk-JZKMOJOQ.js → chunk-R2B2FWR3.js} +2 -2
- package/dist/{chunk-E4736BVE.js → chunk-RILJ3EAS.js} +2 -2
- package/dist/{chunk-LCHXF4NQ.js → chunk-RWMZO6IM.js} +5 -5
- package/dist/{chunk-FSPYS5HZ.js → chunk-UL5DHSKV.js} +6 -6
- package/dist/{chunk-4MJC522W.js → chunk-UTDOLU4J.js} +3 -3
- package/dist/{chunk-X3R5Y6UJ.js → chunk-UYE7IX7E.js} +2 -2
- package/dist/{chunk-C2VFYHFB.js → chunk-VP5C7J5N.js} +2 -2
- package/dist/{chunk-CYQDSRA6.js → chunk-VWI76LON.js} +2 -2
- package/dist/{chunk-LZFTIWWT.cjs → chunk-W3KLU3DI.cjs} +25 -25
- package/dist/{chunk-LZFTIWWT.cjs.map → chunk-W3KLU3DI.cjs.map} +1 -1
- package/dist/{chunk-HJZ6RTL2.js → chunk-X2YWO3ZQ.js} +2 -2
- package/dist/{chunk-XMWQKPNB.cjs → chunk-XLAW7YT3.cjs} +3 -3
- package/dist/{chunk-XMWQKPNB.cjs.map → chunk-XLAW7YT3.cjs.map} +1 -1
- package/dist/{chunk-ENAVUPND.js → chunk-YFX6OPOT.js} +10 -10
- package/dist/{chunk-P3JQFGEC.cjs → chunk-YULXABPV.cjs} +58 -58
- package/dist/{chunk-P3JQFGEC.cjs.map → chunk-YULXABPV.cjs.map} +1 -1
- package/dist/chunks-EM6Q7BGP.js +11 -0
- package/dist/cli.js +45 -45
- package/dist/{formula-TU52HNNZ.js → formula-EEL33Q6V.js} +4 -4
- package/dist/{formula-EC3RANLB.cjs → formula-IAVQCYWH.cjs} +9 -9
- package/dist/{formula-EC3RANLB.cjs.map → formula-IAVQCYWH.cjs.map} +1 -1
- package/dist/{formula-O4A5XPLV.js → formula-OKIJQUJO.js} +3 -3
- package/dist/generator-3YX2SMBO.js +18 -0
- package/dist/generator-5OEZXKDV.cjs +12 -0
- package/dist/{generator-G2V4TTAE.cjs.map → generator-5OEZXKDV.cjs.map} +1 -1
- package/dist/generator-U7NTN55X.js +11 -0
- package/dist/{hancom-TCEBLCLO.js → hancom-2A4C7XGR.js} +2 -2
- package/dist/{hancom-E4CLLAZR.cjs → hancom-KN4AM3GL.cjs} +5 -5
- package/dist/{hancom-E4CLLAZR.cjs.map → hancom-KN4AM3GL.cjs.map} +1 -1
- package/dist/{hancom-7ECGMQBN.js → hancom-Z3BZW77B.js} +2 -2
- package/dist/{image-ocr-VZJP44CK.cjs → image-ocr-A2RV46VI.cjs} +28 -28
- package/dist/{image-ocr-VZJP44CK.cjs.map → image-ocr-A2RV46VI.cjs.map} +1 -1
- package/dist/{image-ocr-NQ5B6AWV.js → image-ocr-GFH36WZS.js} +7 -7
- package/dist/{image-ocr-MVFHAHCY.js → image-ocr-QDKSBFKO.js} +10 -10
- package/dist/index.cjs +1105 -1105
- package/dist/index.js +9 -9
- package/dist/mcp.js +36 -36
- package/dist/memo-MRCSSOEZ.js +17 -0
- package/dist/{model-bundle-QUQYDHA6.js → model-bundle-PWFXTV4A.js} +5 -5
- package/dist/{models-ZNLVYYWP.js → models-6KDYIHEN.js} +5 -5
- package/dist/{parse-worker-v2-KBQJQP5S.js → parse-worker-v2-K2FCAJS4.js} +22 -22
- package/dist/{parser-O4G2AY5Q.cjs → parser-6DEZJ5ZL.cjs} +166 -166
- package/dist/{parser-O4G2AY5Q.cjs.map → parser-6DEZJ5ZL.cjs.map} +1 -1
- package/dist/{parser-T7Y3FGN2.js → parser-BWUX2HTE.js} +12 -12
- package/dist/{parser-OGO3NK5N.js → parser-IM7EIBEA.js} +9 -9
- package/dist/{pdf-ocr-436VYY5B.js → pdf-ocr-CI2Q6F5P.js} +6 -6
- package/dist/pdf-ocr-UB32YXNZ.cjs +43 -0
- package/dist/{pdf-ocr-GNRW2VB6.cjs.map → pdf-ocr-UB32YXNZ.cjs.map} +1 -1
- package/dist/{pdf-ocr-E3YSDWU7.js → pdf-ocr-XJGFERSR.js} +9 -9
- package/dist/{profile-io-7OAJEZI7.js → profile-io-R7G6W7D3.js} +3 -3
- package/dist/{rasterize-GXDINI6Q.js → rasterize-WKT2EIIQ.js} +3 -3
- package/dist/{redact-doc-DIJHSDJ3.js → redact-doc-V6V3HNIW.js} +21 -21
- package/dist/{render-HO3P7BRB.js → render-NHQYZ3YR.js} +12 -12
- package/dist/{rewrite-fallback-ST7YOFXJ.js → rewrite-fallback-PXFNBPG3.js} +13 -13
- package/dist/seal-3VZWGL7F.js +16 -0
- package/dist/{setup-F3BD5JSA.js → setup-WTNCJOAA.js} +3 -3
- package/dist/{to-hwpx-KUNRSYSS.js → to-hwpx-3UZR67PR.js} +4 -4
- package/dist/{to-hwpx-DDPZ26BD.js → to-hwpx-77VNCLDE.js} +7 -7
- package/dist/to-hwpx-JZ2MKAUY.cjs +16 -0
- package/dist/{to-hwpx-OWEROQLW.cjs.map → to-hwpx-JZ2MKAUY.cjs.map} +1 -1
- package/dist/visual-Z24G6HFY.js +38 -0
- package/dist/{watch-5NL6MWIS.js → watch-CZ2PILD4.js} +22 -22
- package/package.json +1 -1
- package/dist/chunk-4WR6VPNW.js.map +0 -1
- package/dist/chunk-LXU73SJI.cjs.map +0 -1
- package/dist/chunk-PP25G757.js.map +0 -1
- package/dist/chunks-7CLCUC6E.js +0 -11
- package/dist/generator-G2V4TTAE.cjs +0 -12
- package/dist/generator-NYL5CUF7.js +0 -18
- package/dist/generator-T2WQKKKB.js +0 -11
- package/dist/memo-4GVGF23W.js +0 -17
- package/dist/pdf-ocr-GNRW2VB6.cjs +0 -43
- package/dist/seal-FVM2AXVF.js +0 -16
- package/dist/to-hwpx-OWEROQLW.cjs +0 -16
- package/dist/visual-I42IEF3V.js +0 -38
- /package/dist/{-GHMJ3363.js.map → -WGAKP3KZ.js.map} +0 -0
- /package/dist/{chunk-7AZYXT4H.js.map → chunk-3N3AKCVA.js.map} +0 -0
- /package/dist/{chunk-WNZ5LCYB.js.map → chunk-56FUD7JF.js.map} +0 -0
- /package/dist/{chunk-ULSUZHLO.js.map → chunk-6F4HMJEJ.js.map} +0 -0
- /package/dist/{chunk-GQ6GQ422.js.map → chunk-A7X6JM2E.js.map} +0 -0
- /package/dist/{chunk-SUE5SQKX.js.map → chunk-AN23MDXT.js.map} +0 -0
- /package/dist/{chunk-LFJPH5RB.js.map → chunk-ATLW4BFE.js.map} +0 -0
- /package/dist/{chunk-TSESEQTD.js.map → chunk-COJXBMHS.js.map} +0 -0
- /package/dist/{chunk-6BQZPLYD.js.map → chunk-EJDMD2PH.js.map} +0 -0
- /package/dist/{chunk-GGMDXPYZ.js.map → chunk-EO4E4N6J.js.map} +0 -0
- /package/dist/{chunk-WHSQZ52O.js.map → chunk-FAGRTJ5V.js.map} +0 -0
- /package/dist/{chunk-6YNVSOBE.js.map → chunk-I3HC5JFQ.js.map} +0 -0
- /package/dist/{chunk-YW3YB6VM.js.map → chunk-JCCFUUVQ.js.map} +0 -0
- /package/dist/{chunk-YDOKUVIT.js.map → chunk-K4GFDSZD.js.map} +0 -0
- /package/dist/{chunk-KJGRWA5R.js.map → chunk-KZCOCJTD.js.map} +0 -0
- /package/dist/{chunk-3Q5AKSLH.js.map → chunk-M2XX26WJ.js.map} +0 -0
- /package/dist/{chunk-6NKTJ6XK.js.map → chunk-N26SI5VH.js.map} +0 -0
- /package/dist/{chunk-UNWPVP42.js.map → chunk-NKPFF3LE.js.map} +0 -0
- /package/dist/{chunk-5FQCWHOV.js.map → chunk-ORC43RFM.js.map} +0 -0
- /package/dist/{chunk-P4XP5SQV.js.map → chunk-OSIAH3YY.js.map} +0 -0
- /package/dist/{chunk-HSZEKMV3.js.map → chunk-PD6J4662.js.map} +0 -0
- /package/dist/{chunk-EWUUDKHJ.js.map → chunk-PDK5TYG4.js.map} +0 -0
- /package/dist/{chunk-2PU62D4B.js.map → chunk-POIGFLWY.js.map} +0 -0
- /package/dist/{chunk-JK7Z3KXV.js.map → chunk-Q6EK3HUU.js.map} +0 -0
- /package/dist/{chunk-JZKMOJOQ.js.map → chunk-R2B2FWR3.js.map} +0 -0
- /package/dist/{chunk-E4736BVE.js.map → chunk-RILJ3EAS.js.map} +0 -0
- /package/dist/{chunk-LCHXF4NQ.js.map → chunk-RWMZO6IM.js.map} +0 -0
- /package/dist/{chunk-FSPYS5HZ.js.map → chunk-UL5DHSKV.js.map} +0 -0
- /package/dist/{chunk-4MJC522W.js.map → chunk-UTDOLU4J.js.map} +0 -0
- /package/dist/{chunk-X3R5Y6UJ.js.map → chunk-UYE7IX7E.js.map} +0 -0
- /package/dist/{chunk-C2VFYHFB.js.map → chunk-VP5C7J5N.js.map} +0 -0
- /package/dist/{chunk-CYQDSRA6.js.map → chunk-VWI76LON.js.map} +0 -0
- /package/dist/{chunk-HJZ6RTL2.js.map → chunk-X2YWO3ZQ.js.map} +0 -0
- /package/dist/{chunk-ENAVUPND.js.map → chunk-YFX6OPOT.js.map} +0 -0
- /package/dist/{chunks-7CLCUC6E.js.map → chunks-EM6Q7BGP.js.map} +0 -0
- /package/dist/{formula-TU52HNNZ.js.map → formula-EEL33Q6V.js.map} +0 -0
- /package/dist/{formula-O4A5XPLV.js.map → formula-OKIJQUJO.js.map} +0 -0
- /package/dist/{generator-NYL5CUF7.js.map → generator-3YX2SMBO.js.map} +0 -0
- /package/dist/{generator-T2WQKKKB.js.map → generator-U7NTN55X.js.map} +0 -0
- /package/dist/{hancom-TCEBLCLO.js.map → hancom-2A4C7XGR.js.map} +0 -0
- /package/dist/{hancom-7ECGMQBN.js.map → hancom-Z3BZW77B.js.map} +0 -0
- /package/dist/{image-ocr-NQ5B6AWV.js.map → image-ocr-GFH36WZS.js.map} +0 -0
- /package/dist/{image-ocr-MVFHAHCY.js.map → image-ocr-QDKSBFKO.js.map} +0 -0
- /package/dist/{memo-4GVGF23W.js.map → memo-MRCSSOEZ.js.map} +0 -0
- /package/dist/{model-bundle-QUQYDHA6.js.map → model-bundle-PWFXTV4A.js.map} +0 -0
- /package/dist/{models-ZNLVYYWP.js.map → models-6KDYIHEN.js.map} +0 -0
- /package/dist/{parse-worker-v2-KBQJQP5S.js.map → parse-worker-v2-K2FCAJS4.js.map} +0 -0
- /package/dist/{parser-T7Y3FGN2.js.map → parser-BWUX2HTE.js.map} +0 -0
- /package/dist/{parser-OGO3NK5N.js.map → parser-IM7EIBEA.js.map} +0 -0
- /package/dist/{pdf-ocr-436VYY5B.js.map → pdf-ocr-CI2Q6F5P.js.map} +0 -0
- /package/dist/{pdf-ocr-E3YSDWU7.js.map → pdf-ocr-XJGFERSR.js.map} +0 -0
- /package/dist/{profile-io-7OAJEZI7.js.map → profile-io-R7G6W7D3.js.map} +0 -0
- /package/dist/{rasterize-GXDINI6Q.js.map → rasterize-WKT2EIIQ.js.map} +0 -0
- /package/dist/{redact-doc-DIJHSDJ3.js.map → redact-doc-V6V3HNIW.js.map} +0 -0
- /package/dist/{render-HO3P7BRB.js.map → render-NHQYZ3YR.js.map} +0 -0
- /package/dist/{rewrite-fallback-ST7YOFXJ.js.map → rewrite-fallback-PXFNBPG3.js.map} +0 -0
- /package/dist/{seal-FVM2AXVF.js.map → seal-3VZWGL7F.js.map} +0 -0
- /package/dist/{setup-F3BD5JSA.js.map → setup-WTNCJOAA.js.map} +0 -0
- /package/dist/{to-hwpx-DDPZ26BD.js.map → to-hwpx-3UZR67PR.js.map} +0 -0
- /package/dist/{to-hwpx-KUNRSYSS.js.map → to-hwpx-77VNCLDE.js.map} +0 -0
- /package/dist/{visual-I42IEF3V.js.map → visual-Z24G6HFY.js.map} +0 -0
- /package/dist/{watch-5NL6MWIS.js.map → watch-CZ2PILD4.js.map} +0 -0
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
|
|
38
38
|
|
|
39
39
|
|
|
40
|
-
var
|
|
40
|
+
var _chunkW3KLU3DIcjs = require('./chunk-W3KLU3DI.cjs');
|
|
41
41
|
|
|
42
42
|
|
|
43
43
|
var _chunkMMK32GPDcjs = require('./chunk-MMK32GPD.cjs');
|
|
@@ -50,10 +50,10 @@ var _chunk64H2FCYFcjs = require('./chunk-64H2FCYF.cjs');
|
|
|
50
50
|
|
|
51
51
|
|
|
52
52
|
|
|
53
|
-
var
|
|
53
|
+
var _chunkOX2YMAOGcjs = require('./chunk-OX2YMAOG.cjs');
|
|
54
54
|
|
|
55
55
|
// src/ocr/ocr-stacked-rows.ts
|
|
56
|
-
var NUMERIC = /^[-+−△▲▽▼]?[\d.,]+[%p]?$|^[-–—·∼~]
|
|
56
|
+
var NUMERIC = /^[-+−△▲▽▼]?[\d.,]+[%p원]?$|^[-–—·∼~]원?$|^\([-+−△▲▽▼]?[\d.,]+%?\)$/;
|
|
57
57
|
var blank = () => ({ text: "", colSpan: 1, rowSpan: 1 });
|
|
58
58
|
function rowAnchors(t, r, coveredFromAbove) {
|
|
59
59
|
const out = [];
|
|
@@ -87,7 +87,7 @@ function splitTable(t) {
|
|
|
87
87
|
});
|
|
88
88
|
const counts = /* @__PURE__ */ new Map();
|
|
89
89
|
for (const ls of lines) if (ls.length >= 2) counts.set(ls.length, (_nullishCoalesce(counts.get(ls.length), () => ( 0))) + 1);
|
|
90
|
-
const [k, n] = _nullishCoalesce([...counts].sort((a, b) => b[1] - a[1])[0], () => ( [0, 0]));
|
|
90
|
+
const [k, n] = _nullishCoalesce([...counts].sort((a, b) => b[1] - a[1] || b[0] - a[0])[0], () => ( [0, 0]));
|
|
91
91
|
lines.forEach((ls, i) => {
|
|
92
92
|
if (ls.length > 1 && ls.length < k && ls.every((l) => /^[가-힣A-Za-z]$/.test(l))) lines[i] = [ls.join("")];
|
|
93
93
|
});
|
|
@@ -98,7 +98,11 @@ function splitTable(t) {
|
|
|
98
98
|
const numericShare = flat.length ? flat.filter((s) => NUMERIC.test(s.replace(/\s+/g, ""))).length / flat.length : 0;
|
|
99
99
|
const spanOk = anchors.every((a, i) => (_nullishCoalesce(a.cell.rowSpan, () => ( 1))) === 1 || lines[i].length <= 1);
|
|
100
100
|
const shares = k === 2 && stacked.length >= 2 && stacked.every((ls) => NUMERIC.test(ls[0].replace(/\s+/g, "")) && /^\(.*\)$/.test(ls[1]));
|
|
101
|
-
const
|
|
101
|
+
const isNum = (s) => NUMERIC.test(s.replace(/\s+/g, ""));
|
|
102
|
+
const kind = (ls) => ls.filter(isNum).length >= ls.length * 0.8 ? "num" : ls.some((l) => /^[○◦]/.test(l)) && ls.every((l) => !isNum(l) && l.replace(/\s+/g, "").length <= 12) ? "label" : "other";
|
|
103
|
+
const kinds = stacked.map(kind);
|
|
104
|
+
const valueRows = numericShare >= 0.6 || kinds.includes("num") && kinds.includes("label") && !kinds.includes("other");
|
|
105
|
+
const ok = spanOk && k >= 2 && n >= 2 && (stacked.length * 2 >= nonEmpty || shares) && lines.every((ls) => ls.length <= 1 || near(ls)) && valueRows;
|
|
102
106
|
if (!ok) {
|
|
103
107
|
newRows.push(row);
|
|
104
108
|
continue;
|
|
@@ -778,8 +782,8 @@ var INKLESS_DELTA = 32;
|
|
|
778
782
|
function ringAsks(rgba, pageW, box, text, steps, stepPx) {
|
|
779
783
|
const chars = [...text];
|
|
780
784
|
if (chars.length !== steps.length || !/[가-힣]/.test(text)) return [];
|
|
781
|
-
const gray =
|
|
782
|
-
const rings =
|
|
785
|
+
const gray = _chunkW3KLU3DIcjs.grayCrop.call(void 0, rgba, pageW, box);
|
|
786
|
+
const rings = _chunkW3KLU3DIcjs.ringBoxes.call(void 0, gray, box.w, box.h, _chunkW3KLU3DIcjs.inkStats.call(void 0, gray));
|
|
783
787
|
const owner = ringOwners(chars, (i) => (steps[i] + 0.5) * stepPx, rings);
|
|
784
788
|
return rings.flatMap((r, k) => {
|
|
785
789
|
const at = owner.indexOf(k);
|
|
@@ -819,8 +823,8 @@ function ringGlyph(read, jamo = null, confidence = 1) {
|
|
|
819
823
|
function restoreGlyphs(rgba, pageW, box, text, steps, stepPx, note = {}, rings = []) {
|
|
820
824
|
const chars = [...text];
|
|
821
825
|
if (chars.length !== steps.length) return text;
|
|
822
|
-
const gray =
|
|
823
|
-
const c = { chars, cx: (i) => (steps[i] + 0.5) * stepPx, gray, w: box.w, h: box.h, ink:
|
|
826
|
+
const gray = _chunkW3KLU3DIcjs.grayCrop.call(void 0, rgba, pageW, box);
|
|
827
|
+
const c = { chars, cx: (i) => (steps[i] + 0.5) * stepPx, gray, w: box.w, h: box.h, ink: _chunkW3KLU3DIcjs.inkStats.call(void 0, gray) };
|
|
824
828
|
if (/[[\]]/.test(text)) brackets(c);
|
|
825
829
|
if (text.includes("'")) cornerQuotes(c);
|
|
826
830
|
if (/['"]/.test(text)) quotes(c);
|
|
@@ -850,7 +854,7 @@ function restoreGlyphs(rgba, pageW, box, text, steps, stepPx, note = {}, rings =
|
|
|
850
854
|
function trimInklessEnds(rgba, pageW, box, text, steps, stepPx) {
|
|
851
855
|
const chars = [...text], { w, h } = box;
|
|
852
856
|
if (chars.length !== steps.length || steps.some((s) => (s + 0.5) * stepPx > w + stepPx)) return { text, steps };
|
|
853
|
-
const gray =
|
|
857
|
+
const gray = _chunkW3KLU3DIcjs.grayCrop.call(void 0, rgba, pageW, box);
|
|
854
858
|
const hist = new Uint32Array(256);
|
|
855
859
|
for (const v of gray) hist[v]++;
|
|
856
860
|
let bg = 0;
|
|
@@ -881,8 +885,8 @@ function cornerCommas({ chars, cx, gray, w, h, ink }) {
|
|
|
881
885
|
continue;
|
|
882
886
|
}
|
|
883
887
|
if (open > 0) {
|
|
884
|
-
const f =
|
|
885
|
-
if (f &&
|
|
888
|
+
const f = _chunkW3KLU3DIcjs.bracketFeatures.call(void 0, gray, w, h, ink, cx(i));
|
|
889
|
+
if (f && _chunkW3KLU3DIcjs.bracketShape.call(void 0, f, true) === "\u300D") {
|
|
886
890
|
chars[i] = "\u300D";
|
|
887
891
|
open--;
|
|
888
892
|
}
|
|
@@ -892,12 +896,12 @@ function cornerCommas({ chars, cx, gray, w, h, ink }) {
|
|
|
892
896
|
function cornerQuotes({ chars, cx, gray, w, h, ink }) {
|
|
893
897
|
for (let i = 0; i < chars.length; i++) {
|
|
894
898
|
if (chars[i] !== "'" || !/^[가-힣]/.test(_nullishCoalesce(chars[i + 1], () => ( "")))) continue;
|
|
895
|
-
const f =
|
|
896
|
-
if (!f || f.ch < f.charH * 0.45 ||
|
|
899
|
+
const f = _chunkW3KLU3DIcjs.bracketFeatures.call(void 0, gray, w, h, ink, cx(i));
|
|
900
|
+
if (!f || f.ch < f.charH * 0.45 || _chunkW3KLU3DIcjs.bracketShape.call(void 0, f, false) !== "\u300C") continue;
|
|
897
901
|
const rest = chars.slice(i + 1), end = rest.findIndex((c) => c === "'" || c === "\u300D" || c === ",");
|
|
898
902
|
const pair = end >= 0 && rest[end] !== "'" && (rest[end] === "\u300D" || (() => {
|
|
899
|
-
const g =
|
|
900
|
-
return !!g &&
|
|
903
|
+
const g = _chunkW3KLU3DIcjs.bracketFeatures.call(void 0, gray, w, h, ink, cx(i + 1 + end));
|
|
904
|
+
return !!g && _chunkW3KLU3DIcjs.bracketShape.call(void 0, g, true) === "\u300D";
|
|
901
905
|
})());
|
|
902
906
|
if (pair) chars[i] = "\u300C";
|
|
903
907
|
}
|
|
@@ -905,8 +909,8 @@ function cornerQuotes({ chars, cx, gray, w, h, ink }) {
|
|
|
905
909
|
function brackets({ chars, cx, gray, w, h, ink }) {
|
|
906
910
|
const shape = chars.map((c, i) => {
|
|
907
911
|
if (c !== "[" && c !== "]") return null;
|
|
908
|
-
const f =
|
|
909
|
-
return f &&
|
|
912
|
+
const f = _chunkW3KLU3DIcjs.bracketFeatures.call(void 0, gray, w, h, ink, cx(i));
|
|
913
|
+
return f && _chunkW3KLU3DIcjs.bracketShape.call(void 0, f, c === "]");
|
|
910
914
|
});
|
|
911
915
|
for (let i = 0; i < chars.length; i++) {
|
|
912
916
|
if (chars[i] !== "[") continue;
|
|
@@ -938,7 +942,7 @@ function quotes({ chars, cx, gray, w, h, ink }) {
|
|
|
938
942
|
continue;
|
|
939
943
|
}
|
|
940
944
|
if (!year(i) && !single[kind]) continue;
|
|
941
|
-
const r =
|
|
945
|
+
const r = _chunkW3KLU3DIcjs.quoteHead.call(void 0, gray, w, h, ink, cx(i));
|
|
942
946
|
if (r !== null && r >= 0.47) {
|
|
943
947
|
chars[i] = kind === "'" ? "\u2018" : "\u201C";
|
|
944
948
|
open[kind] = true;
|
|
@@ -949,7 +953,7 @@ function dashes({ chars, cx, gray, w, h, ink }) {
|
|
|
949
953
|
const head = chars.findIndex((c) => c.trim()), letters = chars.some((c) => /[가-힣A-Za-z]/.test(c));
|
|
950
954
|
for (let i = 0; i < chars.length; i++) {
|
|
951
955
|
if (!/^[-\u2013\u2014]$/.test(chars[i])) continue;
|
|
952
|
-
const r =
|
|
956
|
+
const r = _chunkW3KLU3DIcjs.dashRatio.call(void 0, gray, w, h, ink, cx(i));
|
|
953
957
|
if (r === null) continue;
|
|
954
958
|
if (r < 0.65) chars[i] = "-";
|
|
955
959
|
else if (r > 0.75 && i === head && letters) chars[i] = "\u2014";
|
|
@@ -959,7 +963,7 @@ function circled({ chars, cx, gray, w, h, ink }) {
|
|
|
959
963
|
const alone = (re, i) => re.test(chars[i]) && !re.test(_nullishCoalesce(chars[i - 1], () => ( ""))) && !re.test(_nullishCoalesce(chars[i + 1], () => ( "")));
|
|
960
964
|
const at = chars.flatMap((_, i) => alone(/^\d$/, i) && chars[i] !== "0" || alone(/^[ㄱ-ㅎ]$/, i) || alone(/^[A-Za-z]$/, i) && /[a-zCSUVWXZ]/.test(chars[i]) ? [i] : []);
|
|
961
965
|
if (!at.length) return;
|
|
962
|
-
const hit =
|
|
966
|
+
const hit = _chunkW3KLU3DIcjs.circledAt.call(void 0, gray, w, h, ink, at.map(cx));
|
|
963
967
|
const JAMO = "\u3131\u3134\u3137\u3139\u3141\u3142\u3145\u3147\u3148\u314A\u314B\u314C\u314D\u314E";
|
|
964
968
|
at.forEach((i, k) => {
|
|
965
969
|
if (!hit[k]) return;
|
|
@@ -972,16 +976,16 @@ function stars({ chars, cx, gray, w, h, ink }) {
|
|
|
972
976
|
if (chars[i] !== "*" || chars[i - 1] === "*") continue;
|
|
973
977
|
let e = i;
|
|
974
978
|
while (chars[e + 1] === "*") e++;
|
|
975
|
-
const n =
|
|
979
|
+
const n = _chunkW3KLU3DIcjs.starRun.call(void 0, gray, w, h, ink, cx(i));
|
|
976
980
|
if (n > e - i + 1 && n <= 4) chars[e] += "*".repeat(n - (e - i + 1));
|
|
977
981
|
i = e;
|
|
978
982
|
}
|
|
979
983
|
}
|
|
980
984
|
function discs({ chars, cx, gray, w, h, ink }) {
|
|
981
|
-
for (let i = 0; i < chars.length; i++) if (/^[\u00b7\u2022]$/.test(chars[i]) &&
|
|
985
|
+
for (let i = 0; i < chars.length; i++) if (/^[\u00b7\u2022]$/.test(chars[i]) && _chunkW3KLU3DIcjs.discAt.call(void 0, gray, w, h, ink, cx(i))) chars[i] = "\u25CF";
|
|
982
986
|
}
|
|
983
987
|
function gaps({ chars, cx, gray, w, h, ink }) {
|
|
984
|
-
const { glyphs, bandH } =
|
|
988
|
+
const { glyphs, bandH } = _chunkW3KLU3DIcjs.gapGlyphs.call(void 0, gray, w, h, ink);
|
|
985
989
|
if (!glyphs.length) return;
|
|
986
990
|
const live = chars.map((c, i) => i).filter((i) => chars[i].trim());
|
|
987
991
|
if (!live.length) return;
|
|
@@ -1052,18 +1056,18 @@ function ring({ chars, cx, gray, w, h, ink }) {
|
|
|
1052
1056
|
const rest = chars.slice(k + 1).join("").trimStart();
|
|
1053
1057
|
const live = chars.map((c, i) => i).filter((i) => chars[i].trim());
|
|
1054
1058
|
if (live.length <= 3 && live.every((i) => /^[Oo]$/.test(chars[i]))) {
|
|
1055
|
-
if (_optionalChain([
|
|
1056
|
-
if (!live.every((i) =>
|
|
1059
|
+
if (_optionalChain([_chunkW3KLU3DIcjs.leadingBullet.call(void 0, gray, w, h, ink, cx(live[0])), 'optionalAccess', _11 => _11.mark]) === "\u25CE") return false;
|
|
1060
|
+
if (!live.every((i) => _chunkW3KLU3DIcjs.ringBullet.call(void 0, gray, w, h, ink, cx(i)) === "\u25CB")) return false;
|
|
1057
1061
|
for (const i of live) chars[i] = "\u25CB";
|
|
1058
1062
|
return true;
|
|
1059
1063
|
}
|
|
1060
1064
|
if (/^[A-Z]{2,}/.test(rest) && /^[Oo0]$/.test(chars[k])) {
|
|
1061
|
-
if (
|
|
1065
|
+
if (_chunkW3KLU3DIcjs.ringBullet.call(void 0, gray, w, h, ink, cx(k)) !== "\u25CB") return false;
|
|
1062
1066
|
chars[k] = chars[k + 1] === " " ? "\u25CB" : "\u25CB ";
|
|
1063
1067
|
return true;
|
|
1064
1068
|
}
|
|
1065
1069
|
if (!/^[(\[「【<]?\d*[가-힣]/.test(rest)) return false;
|
|
1066
|
-
const r =
|
|
1070
|
+
const r = _chunkW3KLU3DIcjs.ringBullet.call(void 0, gray, w, h, ink, cx(k));
|
|
1067
1071
|
if (/^[Cc]$/.test(chars[k]) && r !== "\u25CB") return false;
|
|
1068
1072
|
if (r) chars[k] = r;
|
|
1069
1073
|
return r !== null;
|
|
@@ -1080,7 +1084,7 @@ function parallels({ chars, cx, gray, w, h, ink }) {
|
|
|
1080
1084
|
let p = s - 1, q = e + 1;
|
|
1081
1085
|
while (p >= 0 && !chars[p].trim()) p--;
|
|
1082
1086
|
while (q < chars.length && !chars[q].trim()) q++;
|
|
1083
|
-
if (
|
|
1087
|
+
if (_chunkW3KLU3DIcjs.slantedPair.call(void 0, gray, w, h, ink, p >= 0 ? cx(p) : -Infinity, q < chars.length ? cx(q) : Infinity)) {
|
|
1084
1088
|
chars[s] = "\u2225";
|
|
1085
1089
|
for (let k = s + 1; k <= e; k++) chars[k] = "";
|
|
1086
1090
|
}
|
|
@@ -1092,7 +1096,7 @@ function roman({ chars, cx, gray, w, h, ink }) {
|
|
|
1092
1096
|
const ROMAN = /^[IⅠ-Ⅲ]$/, LATIN = /[A-Za-z]$/;
|
|
1093
1097
|
for (let i = 0; i < chars.length; i++) {
|
|
1094
1098
|
if (chars[i] !== "1" || /[\dA-Za-z]$/.test(_nullishCoalesce(chars[i - 1], () => ( ""))) || /^[\dA-Za-z,]/.test(_nullishCoalesce(chars[i + 1], () => ( "")))) continue;
|
|
1095
|
-
if (
|
|
1099
|
+
if (_chunkW3KLU3DIcjs.serifOne.call(void 0, gray, w, h, ink, cx(i))) chars[i] = "\u2160";
|
|
1096
1100
|
}
|
|
1097
1101
|
for (let i = 0; i < chars.length; i++) {
|
|
1098
1102
|
const hangul = /^[파피]$/.test(chars[i]);
|
|
@@ -1102,13 +1106,13 @@ function roman({ chars, cx, gray, w, h, ink }) {
|
|
|
1102
1106
|
while (q < chars.length && !chars[q].trim()) q++;
|
|
1103
1107
|
const glued = hangul ? chars[p] === "(" && chars[q] === "-" : /[가-힣]$/.test(_nullishCoalesce(chars[i - 1], () => ( ""))) || (_nullishCoalesce(chars[i + 1], () => ( ""))) === "." || chars[p] === "-" && chars[q] === "-";
|
|
1104
1108
|
if (!glued) continue;
|
|
1105
|
-
const n =
|
|
1109
|
+
const n = _chunkW3KLU3DIcjs.romanStems.call(void 0, gray, w, h, ink, p >= 0 ? cx(p) : -Infinity, q < chars.length ? cx(q) : Infinity, /[가-힣]$/.test(_nullishCoalesce(chars[p], () => ( ""))));
|
|
1106
1110
|
if (n) chars[i] = String.fromCharCode(8543 + n);
|
|
1107
1111
|
}
|
|
1108
1112
|
const inRoman = (i) => ROMAN.test(chars[i]) || chars[i] === "1" && (ROMAN.test(_nullishCoalesce(chars[i - 1], () => ( ""))) || ROMAN.test(_nullishCoalesce(chars[i + 1], () => ( ""))));
|
|
1109
1113
|
const k = chars.findIndex((c) => c.trim());
|
|
1110
1114
|
if (chars[k] === "." && chars.slice(k + 1).some((c) => /[가-힣A-Za-z0-9]/.test(c))) {
|
|
1111
|
-
const n =
|
|
1115
|
+
const n = _chunkW3KLU3DIcjs.romanStems.call(void 0, gray, w, h, ink, -Infinity, cx(k));
|
|
1112
1116
|
if (n) chars[k] = String.fromCharCode(8543 + n) + chars[k];
|
|
1113
1117
|
}
|
|
1114
1118
|
for (let s = 0; s < chars.length; ) {
|
|
@@ -1126,7 +1130,7 @@ function roman({ chars, cx, gray, w, h, ink }) {
|
|
|
1126
1130
|
let p = s - 1, q = e;
|
|
1127
1131
|
while (p >= 0 && !chars[p].trim()) p--;
|
|
1128
1132
|
while (q < chars.length && !chars[q].trim()) q++;
|
|
1129
|
-
const n =
|
|
1133
|
+
const n = _chunkW3KLU3DIcjs.romanStems.call(void 0, gray, w, h, ink, p >= 0 ? cx(p) : -Infinity, q < chars.length ? cx(q) : Infinity, /[가-힣]$/.test(_nullishCoalesce(chars[p], () => ( ""))));
|
|
1130
1134
|
const canon = n ? [["\u2160", "I"], ["\u2161", "II"], ["\u2162", "III"]][n - 1] : null;
|
|
1131
1135
|
if (canon && !canon.includes(tok)) {
|
|
1132
1136
|
chars[s] = canon[0];
|
|
@@ -1382,7 +1386,8 @@ var DEFAULT_OCR_TUNING = Object.freeze({
|
|
|
1382
1386
|
postprocess: true,
|
|
1383
1387
|
tightBoxes: true,
|
|
1384
1388
|
splitLeaders: true,
|
|
1385
|
-
orientPage: true
|
|
1389
|
+
orientPage: true,
|
|
1390
|
+
redetect: true
|
|
1386
1391
|
});
|
|
1387
1392
|
var DET_MIN_SIZE = 3;
|
|
1388
1393
|
var NUMBER_STRETCH = [1.6, 2.2];
|
|
@@ -1549,8 +1554,8 @@ function joinGapLeaders(rgba, width, items) {
|
|
|
1549
1554
|
if (g1 - g0 < h * 3) continue;
|
|
1550
1555
|
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));
|
|
1551
1556
|
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 };
|
|
1552
|
-
const gray =
|
|
1553
|
-
const runs =
|
|
1557
|
+
const gray = _chunkW3KLU3DIcjs.grayCrop.call(void 0, rgba, width, box);
|
|
1558
|
+
const runs = _chunkW3KLU3DIcjs.leaderRuns.call(void 0, gray, box.w, box.h, _chunkW3KLU3DIcjs.inkStats.call(void 0, gray), LEADER_MIN_DOTS);
|
|
1554
1559
|
const cover = runs.reduce((k, [a, b]) => k + Math.max(0, Math.min(b, g1 - box.x) - Math.max(a, g0 - box.x)), 0);
|
|
1555
1560
|
if (cover < (g1 - g0) * 0.6) continue;
|
|
1556
1561
|
for (const o of items) if (junk(o) && sameLine(o, num) && o.x >= g0 - 2 && o.x + o.w <= g1 + 2) gone.add(o);
|
|
@@ -1817,7 +1822,7 @@ var OcrEngine = class _OcrEngine {
|
|
|
1817
1822
|
this.ort = parts.ort;
|
|
1818
1823
|
this.sharp = parts.sharp;
|
|
1819
1824
|
}
|
|
1820
|
-
static async create(models =
|
|
1825
|
+
static async create(models = _chunkW3KLU3DIcjs.DEFAULT_OCR_MODELS) {
|
|
1821
1826
|
_chunkTK3FDAEEcjs.disableOrtTelemetry.call(void 0, );
|
|
1822
1827
|
const [ortMod, sharpModRaw] = await Promise.all([
|
|
1823
1828
|
tryImport("onnxruntime-node", () => Promise.resolve().then(() => _interopRequireWildcard(require("onnxruntime-node")))),
|
|
@@ -1837,16 +1842,16 @@ var OcrEngine = class _OcrEngine {
|
|
|
1837
1842
|
const local = (s) => "spec" in s ? Promise.resolve(null) : verifiedBytes(s);
|
|
1838
1843
|
const [detBytes, recBytes, dictBytes] = await Promise.all([local(models.det), local(models.rec), local(models.dict)]);
|
|
1839
1844
|
const session = (s, bytes) => bytes ? ortMod.InferenceSession.create(bytes, sessionOpts).catch(() => {
|
|
1840
|
-
throw new (0,
|
|
1841
|
-
}) : ortMod.InferenceSession.create(
|
|
1845
|
+
throw new (0, _chunkOX2YMAOGcjs.KordocError)(`OCR \uBAA8\uB378\uC744 \uC5F4\uC9C0 \uBABB\uD588\uC2B5\uB2C8\uB2E4: ${_path.basename.call(void 0, _chunkW3KLU3DIcjs.ocrSourcePath.call(void 0, s))} \u2014 ONNX \uBAA8\uB378\uC774 \uC544\uB2C8\uAC70\uB098 \uC190\uC0C1\uB410\uC2B5\uB2C8\uB2E4`);
|
|
1846
|
+
}) : ortMod.InferenceSession.create(_chunkW3KLU3DIcjs.ocrSourcePath.call(void 0, s), sessionOpts);
|
|
1842
1847
|
const [det, rec, dictYml] = await Promise.all([
|
|
1843
1848
|
session(models.det, detBytes),
|
|
1844
1849
|
session(models.rec, recBytes),
|
|
1845
|
-
dictBytes ? new TextDecoder().decode(dictBytes) : _promises.readFile.call(void 0,
|
|
1850
|
+
dictBytes ? new TextDecoder().decode(dictBytes) : _promises.readFile.call(void 0, _chunkW3KLU3DIcjs.ocrSourcePath.call(void 0, models.dict), "utf-8")
|
|
1846
1851
|
]);
|
|
1847
|
-
const dict =
|
|
1852
|
+
const dict = _chunkW3KLU3DIcjs.parseCharacterDict.call(void 0, dictYml);
|
|
1848
1853
|
if (dict.length === 0) {
|
|
1849
|
-
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,
|
|
1854
|
+
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, _chunkOX2YMAOGcjs.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`);
|
|
1850
1855
|
}
|
|
1851
1856
|
return new _OcrEngine({ det, rec, dict, ort: ortMod, sharp: sharpMod });
|
|
1852
1857
|
}
|
|
@@ -1878,10 +1883,10 @@ var OcrEngine = class _OcrEngine {
|
|
|
1878
1883
|
if (it.x - x < it.h * 0.8) return;
|
|
1879
1884
|
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;
|
|
1880
1885
|
const box = { x, y: it.y, w: it.x + it.w - x, h: it.h };
|
|
1881
|
-
const g =
|
|
1882
|
-
const b =
|
|
1886
|
+
const g = _chunkW3KLU3DIcjs.grayCrop.call(void 0, rgba, width, box);
|
|
1887
|
+
const b = _chunkW3KLU3DIcjs.leadingBullet.call(void 0, g, box.w, box.h, _chunkW3KLU3DIcjs.inkStats.call(void 0, g), it.x - x, 1.05);
|
|
1883
1888
|
if (_optionalChain([b, 'optionalAccess', _36 => _36.mark]) !== "\u25A1" || b.covers) return;
|
|
1884
|
-
const ink =
|
|
1889
|
+
const ink = _chunkW3KLU3DIcjs.inkStats.call(void 0, g), on = (v) => ink.darkInk ? v <= ink.threshold : v > ink.threshold;
|
|
1885
1890
|
let left = 0;
|
|
1886
1891
|
while (left < it.x - x && !Array.from({ length: box.h }, (_, y) => g[y * box.w + left]).some(on)) left++;
|
|
1887
1892
|
it.text = "\u25A1 " + it.text;
|
|
@@ -1913,12 +1918,12 @@ var OcrEngine = class _OcrEngine {
|
|
|
1913
1918
|
const joins = [];
|
|
1914
1919
|
let group = 0;
|
|
1915
1920
|
for (const b of boxes) {
|
|
1916
|
-
const gray =
|
|
1917
|
-
const ink =
|
|
1921
|
+
const gray = _chunkW3KLU3DIcjs.grayCrop.call(void 0, rgba, width, b);
|
|
1922
|
+
const ink = _chunkW3KLU3DIcjs.inkStats.call(void 0, gray);
|
|
1918
1923
|
if (tuning.minInkContrast > 0 && ink.contrast < tuning.minInkContrast) continue;
|
|
1919
1924
|
if (tuning.minInkContrast > 0 && ink.inkRatio < MIN_INK_RATIO) continue;
|
|
1920
1925
|
if (tuning.splitTall && b.h >= b.w * TALL_RATIO) {
|
|
1921
|
-
const bands =
|
|
1926
|
+
const bands = _chunkW3KLU3DIcjs.splitRowBands.call(void 0, gray, b.w, b.h, ink, 0.45);
|
|
1922
1927
|
if (bands.length >= 2) {
|
|
1923
1928
|
for (const sub of bandBoxes(b, bands, height)) jobs.push({ box: sub, rot: 0, group: group++ });
|
|
1924
1929
|
continue;
|
|
@@ -1929,9 +1934,9 @@ var OcrEngine = class _OcrEngine {
|
|
|
1929
1934
|
continue;
|
|
1930
1935
|
}
|
|
1931
1936
|
}
|
|
1932
|
-
const trim = tuning.trimEdges ?
|
|
1937
|
+
const trim = tuning.trimEdges ? _chunkW3KLU3DIcjs.edgeTrim.call(void 0, gray, b.w, b.h, ink) : null;
|
|
1933
1938
|
const keep = trim ? { ...trim, bg: median(gray) } : void 0;
|
|
1934
|
-
const leaders = tuning.splitLeaders ?
|
|
1939
|
+
const leaders = tuning.splitLeaders ? _chunkW3KLU3DIcjs.leaderRuns.call(void 0, gray, b.w, b.h, ink, LEADER_MIN_DOTS) : [];
|
|
1935
1940
|
if (leaders.length) {
|
|
1936
1941
|
const join = joins.length;
|
|
1937
1942
|
joins.push({ box: b, parts: [], trailDots: false });
|
|
@@ -1940,7 +1945,7 @@ var OcrEngine = class _OcrEngine {
|
|
|
1940
1945
|
const bare = { x: b.x + x0, y: b.y, w: a - x0, h: b.h };
|
|
1941
1946
|
const end = c > a ? Math.min(c, a + Math.round(b.h * LEADER_CONTEXT)) : a;
|
|
1942
1947
|
x0 = c;
|
|
1943
|
-
if (bare.w >= DET_MIN_SIZE &&
|
|
1948
|
+
if (bare.w >= DET_MIN_SIZE && _chunkW3KLU3DIcjs.inkStats.call(void 0, _chunkW3KLU3DIcjs.grayCrop.call(void 0, rgba, width, bare)).contrast >= Math.max(1, tuning.minInkContrast)) {
|
|
1944
1949
|
jobs.push({ box: { ...bare, w: end - (bare.x - b.x) }, rot: 0, group: group++, join, dotsBefore: dots, trimDots: end > a });
|
|
1945
1950
|
dots = false;
|
|
1946
1951
|
}
|
|
@@ -1988,15 +1993,15 @@ var OcrEngine = class _OcrEngine {
|
|
|
1988
1993
|
let text = tuning.postprocess ? restoreSymbols(raw.trim(), note.ringLead) : raw;
|
|
1989
1994
|
if (!text.trim()) continue;
|
|
1990
1995
|
if (tuning.postprocess && job.rot === 0 && text !== "/" && /^[(:;/)]+$/.test(text) && text.includes("/")) {
|
|
1991
|
-
const g =
|
|
1992
|
-
if (
|
|
1996
|
+
const g = _chunkW3KLU3DIcjs.grayCrop.call(void 0, rgba, width, job.box);
|
|
1997
|
+
if (_chunkW3KLU3DIcjs.tallInkCount.call(void 0, g, job.box.w, job.box.h, _chunkW3KLU3DIcjs.inkStats.call(void 0, g)) === 1) text = "/";
|
|
1993
1998
|
}
|
|
1994
1999
|
let ringByShape = false;
|
|
1995
2000
|
if (tuning.postprocess && job.rot === 0 && !/^[◎●▪□■▣❐❏○ㅇ◆◇◈]/.test(text)) {
|
|
1996
2001
|
const chars = [...read], k = chars.findIndex((c) => c.trim());
|
|
1997
2002
|
if (k >= 0 && steps.length === chars.length) {
|
|
1998
|
-
const g =
|
|
1999
|
-
const b =
|
|
2003
|
+
const g = _chunkW3KLU3DIcjs.grayCrop.call(void 0, rgba, width, job.box);
|
|
2004
|
+
const b = _chunkW3KLU3DIcjs.leadingBullet.call(void 0, g, job.box.w, job.box.h, _chunkW3KLU3DIcjs.inkStats.call(void 0, g), (steps[k] + 0.5) * stepPx);
|
|
2000
2005
|
const body = (_nullishCoalesce(text.match(/[가-힣]/g), () => ( []))).length >= 4;
|
|
2001
2006
|
const miss = /^[Oo0•·ㆍ∙‧○]/.test(text);
|
|
2002
2007
|
if (_optionalChain([b, 'optionalAccess', _39 => _39.mark]) === "\u25CE" && b.covers && /^[Oo0○©]/.test(text)) {
|
|
@@ -2011,17 +2016,17 @@ var OcrEngine = class _OcrEngine {
|
|
|
2011
2016
|
} else if (_optionalChain([b, 'optionalAccess', _46 => _46.mark]) === "\u2750" || _optionalChain([b, 'optionalAccess', _47 => _47.mark]) === "\u274F") {
|
|
2012
2017
|
if (b.covers ? /^[ㅁ口]/.test(text) : body) text = b.covers ? b.mark + text.slice(1) : b.mark + " " + text;
|
|
2013
2018
|
} else if (b && b.mark !== "\u25CE" && body) text = b.covers ? miss ? b.mark + " " + text.slice(1).trimStart() : text : b.mark + " " + text;
|
|
2014
|
-
else if (!b && body && /^[가-힣]/.test(chars[k]) &&
|
|
2019
|
+
else if (!b && body && /^[가-힣]/.test(chars[k]) && _chunkW3KLU3DIcjs.leadingRing.call(void 0, g, job.box.w, job.box.h, _chunkW3KLU3DIcjs.inkStats.call(void 0, g), (steps[k] + 0.5) * stepPx)) text = "\u25CB " + text;
|
|
2015
2020
|
}
|
|
2016
2021
|
}
|
|
2017
2022
|
if (tuning.postprocess && /^\d/.test(text) && job.rot === 0) {
|
|
2018
|
-
const g =
|
|
2019
|
-
const tri =
|
|
2023
|
+
const g = _chunkW3KLU3DIcjs.grayCrop.call(void 0, rgba, width, job.box);
|
|
2024
|
+
const tri = _chunkW3KLU3DIcjs.leadingTriangle.call(void 0, g, job.box.w, job.box.h, _chunkW3KLU3DIcjs.inkStats.call(void 0, g));
|
|
2020
2025
|
if (tri) text = tri + text;
|
|
2021
2026
|
}
|
|
2022
2027
|
if (tuning.postprocess && text === "\u2192" && job.rot === 0 && job.join === void 0) {
|
|
2023
|
-
const g =
|
|
2024
|
-
text = _nullishCoalesce(
|
|
2028
|
+
const g = _chunkW3KLU3DIcjs.grayCrop.call(void 0, rgba, width, job.box);
|
|
2029
|
+
text = _nullishCoalesce(_chunkW3KLU3DIcjs.arrowGlyph.call(void 0, g, job.box.w, job.box.h, _chunkW3KLU3DIcjs.inkStats.call(void 0, g)), () => ( text));
|
|
2025
2030
|
}
|
|
2026
2031
|
if (job.footer) {
|
|
2027
2032
|
if (!/^[-\u2013\u2014]?\s*(?:\d{1,4}|[ivxIVXⅰ-ⅹⅠ-Ⅹ]{1,4})\s*[-\u2013\u2014]?$/.test(text.trim())) continue;
|
|
@@ -2042,7 +2047,7 @@ var OcrEngine = class _OcrEngine {
|
|
|
2042
2047
|
continue;
|
|
2043
2048
|
}
|
|
2044
2049
|
const item = { text, ...this.itemBox(rgba, width, job.box, tuning), confidence };
|
|
2045
|
-
if (job.rot === 0)
|
|
2050
|
+
if (job.rot === 0) _chunkW3KLU3DIcjs.rememberOcrTextGaps.call(void 0, item, _chunkW3KLU3DIcjs.findOcrTextGaps.call(void 0, rgba, width, job.box, read, text, steps, stepPx));
|
|
2046
2051
|
if (job.rot === 0 && job.keep === void 0) boxOf.set(item, job.box);
|
|
2047
2052
|
items.push(item);
|
|
2048
2053
|
}
|
|
@@ -2056,7 +2061,7 @@ var OcrEngine = class _OcrEngine {
|
|
|
2056
2061
|
const merged = rereadNumberText(it.text, r.text);
|
|
2057
2062
|
if (merged === null) return;
|
|
2058
2063
|
it.text = merged;
|
|
2059
|
-
|
|
2064
|
+
_chunkW3KLU3DIcjs.rememberOcrTextGaps.call(void 0, it, _chunkW3KLU3DIcjs.findOcrTextGaps.call(void 0, rgba, width, boxOf.get(it), r.text, it.text, r.steps, r.stepPx));
|
|
2060
2065
|
});
|
|
2061
2066
|
}
|
|
2062
2067
|
const pairs = tuning.postprocess ? items.filter((it) => boxOf.has(it) && NUMBER_PAIR.test(it.text.trim())) : [];
|
|
@@ -2079,14 +2084,14 @@ var OcrEngine = class _OcrEngine {
|
|
|
2079
2084
|
const subs = [];
|
|
2080
2085
|
const stacks = [];
|
|
2081
2086
|
for (const b of [...retry, ...blank2]) {
|
|
2082
|
-
const gray =
|
|
2083
|
-
const ink =
|
|
2087
|
+
const gray = _chunkW3KLU3DIcjs.grayCrop.call(void 0, rgba, width, b);
|
|
2088
|
+
const ink = _chunkW3KLU3DIcjs.inkStats.call(void 0, gray);
|
|
2084
2089
|
const cut = retry.includes(b) ? midBlankRow(gray, b.w, b.h, ink) : null;
|
|
2085
2090
|
if (cut && b.w >= 3 * Math.max(cut[0], b.h - cut[1])) {
|
|
2086
2091
|
subs.push({ ...b, h: cut[0] }, { ...b, y: b.y + cut[1], h: b.h - cut[1] });
|
|
2087
2092
|
continue;
|
|
2088
2093
|
}
|
|
2089
|
-
const bands =
|
|
2094
|
+
const bands = _chunkW3KLU3DIcjs.stackedGlyphBands.call(void 0, gray, b.w, b.h, ink);
|
|
2090
2095
|
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)) });
|
|
2091
2096
|
}
|
|
2092
2097
|
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));
|
|
@@ -2159,8 +2164,8 @@ var OcrEngine = class _OcrEngine {
|
|
|
2159
2164
|
/** 결과 좌표 — det 박스 그대로 또는 박스 안 잉크 외곽 (tightBoxes) */
|
|
2160
2165
|
itemBox(rgba, width, b, tuning) {
|
|
2161
2166
|
if (!tuning.tightBoxes) return b;
|
|
2162
|
-
const gray =
|
|
2163
|
-
const t =
|
|
2167
|
+
const gray = _chunkW3KLU3DIcjs.grayCrop.call(void 0, rgba, width, b);
|
|
2168
|
+
const t = _chunkW3KLU3DIcjs.inkBounds.call(void 0, gray, b.w, b.h, _chunkW3KLU3DIcjs.inkStats.call(void 0, gray));
|
|
2164
2169
|
return { x: b.x + t.x0, y: b.y + t.y0, w: t.x1 - t.x0, h: t.y1 - t.y0 };
|
|
2165
2170
|
}
|
|
2166
2171
|
// ─── det ─────────────────────────────────────────────
|
|
@@ -2231,7 +2236,7 @@ var OcrEngine = class _OcrEngine {
|
|
|
2231
2236
|
const out = await this.rec.run({ [this.rec.inputNames[0]]: tensor });
|
|
2232
2237
|
const logits = out[this.rec.outputNames[0]];
|
|
2233
2238
|
const [, T, C] = logits.dims;
|
|
2234
|
-
if (C !== this.dict.length + 2) throw new (0,
|
|
2239
|
+
if (C !== this.dict.length + 2) throw new (0, _chunkOX2YMAOGcjs.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`);
|
|
2235
2240
|
const data = logits.data;
|
|
2236
2241
|
idx.forEach((ci, k) => {
|
|
2237
2242
|
const r = ctcDecode(data.subarray(k * T * C, (k + 1) * T * C), T, C, this.dict);
|
|
@@ -2241,9 +2246,9 @@ var OcrEngine = class _OcrEngine {
|
|
|
2241
2246
|
const chars = r ? [...r.text] : [];
|
|
2242
2247
|
if (r && job.rot === 0 && chars.length === r.steps.length && r.steps.some((t) => t > last) && !r.text.includes("(cid:")) {
|
|
2243
2248
|
const tallCh = (c) => !/[\s.,:;\u00b7\u2026'"\u2018-\u201d`\-_~]/.test(c);
|
|
2244
|
-
const g =
|
|
2249
|
+
const g = _chunkW3KLU3DIcjs.grayCrop.call(void 0, rgba, pageW, job.box);
|
|
2245
2250
|
const inside = chars.filter((c, i) => r.steps[i] <= last && tallCh(c)).length;
|
|
2246
|
-
let budget = inside <= 2 ?
|
|
2251
|
+
let budget = inside <= 2 ? _chunkW3KLU3DIcjs.tallInkCount.call(void 0, g, job.box.w, job.box.h, _chunkW3KLU3DIcjs.inkStats.call(void 0, g)) - inside : Infinity;
|
|
2247
2252
|
const keep = chars.map((c, i) => r.steps[i] <= last || !tallCh(c) || budget-- > 0);
|
|
2248
2253
|
if (!keep.every(Boolean)) kept = { ...r, text: chars.filter((_, i) => keep[i]).join(""), steps: r.steps.filter((_, i) => keep[i]) };
|
|
2249
2254
|
}
|
|
@@ -2354,13 +2359,13 @@ async function tryImport(name, loader) {
|
|
|
2354
2359
|
return await loader();
|
|
2355
2360
|
} catch (e) {
|
|
2356
2361
|
throw new Error(
|
|
2357
|
-
`\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.${
|
|
2362
|
+
`\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.${_chunkOX2YMAOGcjs.OPTIONAL_DEP_INSTALL_HINT} \uC6D0\uC778: ${e.message}`
|
|
2358
2363
|
);
|
|
2359
2364
|
}
|
|
2360
2365
|
}
|
|
2361
2366
|
async function verifiedBytes(s) {
|
|
2362
2367
|
const name = _path.basename.call(void 0, s.file.path);
|
|
2363
|
-
const fail = (why2) => new (0,
|
|
2368
|
+
const fail = (why2) => new (0, _chunkOX2YMAOGcjs.KordocError)(`OCR \uBAA8\uB378 \uD30C\uC77C\uC744 \uC77D\uC9C0 \uBABB\uD588\uC2B5\uB2C8\uB2E4: ${name} (${why2})`);
|
|
2364
2369
|
const why = (e) => {
|
|
2365
2370
|
const code = e.code;
|
|
2366
2371
|
return code === "ENOENT" ? "\uD30C\uC77C\uC774 \uC5C6\uC74C" : code === "EACCES" || code === "EPERM" ? "\uAD8C\uD55C \uC5C6\uC74C" : "\uC77D\uAE30 \uC2E4\uD328";
|
|
@@ -2381,13 +2386,13 @@ async function verifiedBytes(s) {
|
|
|
2381
2386
|
}
|
|
2382
2387
|
const actual = _crypto.createHash.call(void 0, "sha256").update(bytes).digest("hex");
|
|
2383
2388
|
if (actual !== s.file.sha256) {
|
|
2384
|
-
throw new (0,
|
|
2389
|
+
throw new (0, _chunkOX2YMAOGcjs.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)`);
|
|
2385
2390
|
}
|
|
2386
2391
|
return bytes;
|
|
2387
2392
|
}
|
|
2388
2393
|
var engines = /* @__PURE__ */ new Map();
|
|
2389
|
-
function getOcrEngine(models =
|
|
2390
|
-
const key =
|
|
2394
|
+
function getOcrEngine(models = _chunkW3KLU3DIcjs.DEFAULT_OCR_MODELS) {
|
|
2395
|
+
const key = _chunkW3KLU3DIcjs.ocrSelectionKey.call(void 0, models);
|
|
2391
2396
|
let p = engines.get(key);
|
|
2392
2397
|
if (!p) {
|
|
2393
2398
|
p = OcrEngine.create(models).catch((err) => {
|
|
@@ -2815,38 +2820,51 @@ async function rescueEmptyCells(engine, tuning, rgba, width, height, ruling, ite
|
|
|
2815
2820
|
var OCR_RENDER_SCALE = 3;
|
|
2816
2821
|
var MAX_OCR_PIXELS = 24e6;
|
|
2817
2822
|
var PAGE_TIMEOUT_MS = 12e4;
|
|
2823
|
+
var REDETECT = { minDropped: 15, minShare: 0.15, scale: 5 / 3 };
|
|
2818
2824
|
var AUTO_REC = { pageConf: 0.9, gain: 0.06 };
|
|
2819
2825
|
var DEFAULT_AUTO_REC = { pageConf: 0.9, gain: 0.08, altConf: 0.95, sureGain: 0.1, minDiff: 0.08, minChars: 80, lazy: true };
|
|
2820
2826
|
var DEFAULT_BUILTIN_OCR = Object.freeze({
|
|
2821
|
-
models:
|
|
2827
|
+
models: _chunkW3KLU3DIcjs.DEFAULT_OCR_MODELS,
|
|
2822
2828
|
tuning: DEFAULT_OCR_TUNING,
|
|
2823
|
-
handwriting:
|
|
2829
|
+
handwriting: _chunkW3KLU3DIcjs.handwritingFallbackModels.call(void 0, _chunkW3KLU3DIcjs.DEFAULT_OCR_MODELS),
|
|
2824
2830
|
autoRec: DEFAULT_AUTO_REC
|
|
2825
2831
|
});
|
|
2826
2832
|
var DEFAULT_BUILTIN_OCR_FETCH = Object.freeze({ ...DEFAULT_BUILTIN_OCR, autoRec: { ...DEFAULT_AUTO_REC, fetch: true } });
|
|
2827
2833
|
function builtinOcrConfig(o) {
|
|
2828
2834
|
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;
|
|
2829
2835
|
const bad = _chunkMMK32GPDcjs.validateOcrOptions.call(void 0, o);
|
|
2830
|
-
if (bad) throw new (0,
|
|
2831
|
-
const models =
|
|
2836
|
+
if (bad) throw new (0, _chunkOX2YMAOGcjs.KordocError)(bad);
|
|
2837
|
+
const models = _chunkW3KLU3DIcjs.resolveOcrModels.call(void 0, o);
|
|
2832
2838
|
return {
|
|
2833
2839
|
models,
|
|
2834
|
-
...o.ocrRec === "auto" ? { handwriting:
|
|
2840
|
+
...o.ocrRec === "auto" ? { handwriting: _chunkW3KLU3DIcjs.handwritingFallbackModels.call(void 0, models), autoRec: AUTO_REC } : o.ocrRec === void 0 ? { handwriting: _chunkW3KLU3DIcjs.handwritingFallbackModels.call(void 0, models), autoRec: o.ocr ? { ...DEFAULT_AUTO_REC, fetch: true } : DEFAULT_AUTO_REC } : {},
|
|
2835
2841
|
tuning: o.ocrDetLongSide === void 0 ? DEFAULT_OCR_TUNING : { ...DEFAULT_OCR_TUNING, detLongSide: o.ocrDetLongSide },
|
|
2836
2842
|
lines: o.ocrLines === "all" ? "all" : o.ocrLines ? "kept" : void 0
|
|
2837
2843
|
};
|
|
2838
2844
|
}
|
|
2839
2845
|
async function recognizeOcrPage(engine, config, tuning, rgba, width, height, stats, cellRules, rowRules) {
|
|
2840
|
-
const
|
|
2841
|
-
|
|
2846
|
+
const read = async (t, st) => {
|
|
2847
|
+
const items2 = await engine.recognizePage(rgba, width, height, st, t, cellRules, rowRules);
|
|
2848
|
+
return st.pageRotation ? items2 : withHandwritingRec(items2, config, t, rgba, width, height, st, cellRules, rowRules);
|
|
2849
|
+
};
|
|
2850
|
+
const items = await read(tuning, stats);
|
|
2851
|
+
if (!tuning.redetect || stats.pageRotation || stats.droppedLowConf < REDETECT.minDropped || stats.droppedLowConf < (items.length + stats.droppedLowConf) * REDETECT.minShare) return items;
|
|
2852
|
+
const bigStats = { droppedLowConf: 0, ...stats.dropped ? { dropped: [] } : {} };
|
|
2853
|
+
const big = await read({ ...tuning, detLongSide: Math.round(tuning.detLongSide * REDETECT.scale) }, bigStats);
|
|
2854
|
+
if (bigStats.pageRotation || bigStats.droppedLowConf >= stats.droppedLowConf || meanConfidence(big) <= meanConfidence(items)) return items;
|
|
2855
|
+
Object.assign(stats, bigStats);
|
|
2856
|
+
return big;
|
|
2857
|
+
}
|
|
2858
|
+
async function withHandwritingRec(items, config, tuning, rgba, width, height, stats, cellRules, rowRules) {
|
|
2859
|
+
if (!config.handwriting) return items;
|
|
2842
2860
|
const auto = _nullishCoalesce(config.autoRec, () => ( AUTO_REC));
|
|
2843
2861
|
const base = meanConfidence(items);
|
|
2844
2862
|
if (base >= auto.pageConf) return items;
|
|
2845
2863
|
const altStats = { droppedLowConf: 0, ...stats.dropped ? { dropped: [] } : {} };
|
|
2846
2864
|
let alt;
|
|
2847
2865
|
try {
|
|
2848
|
-
if (auto.lazy && !auto.fetch && !await
|
|
2849
|
-
if (auto.lazy) await
|
|
2866
|
+
if (auto.lazy && !auto.fetch && !await _chunkW3KLU3DIcjs.ocrModelsCached.call(void 0, config.handwriting)) return items;
|
|
2867
|
+
if (auto.lazy) await _chunkW3KLU3DIcjs.ensureOcrModelsFor.call(void 0, config.handwriting, reportModelDownload);
|
|
2850
2868
|
alt = await (await getOcrEngine(config.handwriting)).recognizePage(rgba, width, height, altStats, tuning, cellRules, rowRules);
|
|
2851
2869
|
} catch (e) {
|
|
2852
2870
|
if (!auto.lazy) throw e;
|
|
@@ -2892,8 +2910,8 @@ async function runPdfOcr(buffer, targets, mode, warnings, onProgress, detectTabl
|
|
|
2892
2910
|
"@hyzyla/pdfium",
|
|
2893
2911
|
() => Promise.resolve().then(() => _interopRequireWildcard(require("@hyzyla/pdfium")))
|
|
2894
2912
|
);
|
|
2895
|
-
if (mode === "builtin") await
|
|
2896
|
-
if (mode === "builtin" && config.handwriting && !_optionalChain([config, 'access', _79 => _79.autoRec, 'optionalAccess', _80 => _80.lazy])) await
|
|
2913
|
+
if (mode === "builtin") await _chunkW3KLU3DIcjs.ensureOcrModelsFor.call(void 0, config.models, reportModelDownload);
|
|
2914
|
+
if (mode === "builtin" && config.handwriting && !_optionalChain([config, 'access', _79 => _79.autoRec, 'optionalAccess', _80 => _80.lazy])) await _chunkW3KLU3DIcjs.ensureOcrModelsFor.call(void 0, config.handwriting, reportModelDownload);
|
|
2897
2915
|
const engine = mode === "builtin" ? await getOcrEngine(config.models) : null;
|
|
2898
2916
|
const pdfium = await pdfiumMod.PDFiumLibrary.init();
|
|
2899
2917
|
const doc = await pdfium.loadDocument(new Uint8Array(buffer));
|
|
@@ -3005,7 +3023,7 @@ async function ocrOnePage(page, pageNo, mode, engine, warnings, detectTables, ve
|
|
|
3005
3023
|
const x1 = r.x1 * scale - 2, x2 = r.x2 * scale + 2, y1 = (pdfH - r.y2) * scale - 2, y2 = (pdfH - r.y1) * scale + 2;
|
|
3006
3024
|
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));
|
|
3007
3025
|
if (columnRules < 2) {
|
|
3008
|
-
for (const b of blocks) if (b.type === "table")
|
|
3026
|
+
for (const b of blocks) if (b.type === "table") _chunkW3KLU3DIcjs.UNRULED_REGION_TABLES.add(b);
|
|
3009
3027
|
}
|
|
3010
3028
|
return blocks;
|
|
3011
3029
|
});
|
|
@@ -3039,8 +3057,8 @@ function halve(src, w, h) {
|
|
|
3039
3057
|
}
|
|
3040
3058
|
return { rgba: out, width: W, height: H };
|
|
3041
3059
|
}
|
|
3042
|
-
var REGION_TUNING = Object.freeze({ ...DEFAULT_OCR_TUNING, trimEdges: false, orientPage: false });
|
|
3043
|
-
var regionTuning = (t) => t === DEFAULT_OCR_TUNING ? REGION_TUNING : { ...t, trimEdges: false, orientPage: false };
|
|
3060
|
+
var REGION_TUNING = Object.freeze({ ...DEFAULT_OCR_TUNING, trimEdges: false, orientPage: false, redetect: false });
|
|
3061
|
+
var regionTuning = (t) => t === DEFAULT_OCR_TUNING ? REGION_TUNING : { ...t, trimEdges: false, orientPage: false, redetect: false };
|
|
3044
3062
|
function meanConfidence(items) {
|
|
3045
3063
|
let n = 0, sum = 0;
|
|
3046
3064
|
for (const it of items) {
|
|
@@ -3077,7 +3095,7 @@ async function closerReads(rgba, rw, rh, pdfH, hi, regions, engine, tuning = REG
|
|
|
3077
3095
|
const items = await engine.recognizePage(crop, cw, ch, void 0, tuning);
|
|
3078
3096
|
out.push(items.map((it) => {
|
|
3079
3097
|
const placed = { ...it, x: (it.x + x0) / 2, y: (it.y + y0) / 2, w: it.w / 2, h: it.h / 2 };
|
|
3080
|
-
|
|
3098
|
+
_chunkW3KLU3DIcjs.copyOcrTextGaps.call(void 0, it, placed, 0.5, x0 / 2);
|
|
3081
3099
|
return placed;
|
|
3082
3100
|
}));
|
|
3083
3101
|
}
|
|
@@ -3169,10 +3187,10 @@ function ocrItemsToBlocks(items, pageNumber, pdfW, pdfH, scale, extraLines, dete
|
|
|
3169
3187
|
isHidden: false,
|
|
3170
3188
|
...xs[i].space ? { hasSpaceBefore: true } : {}
|
|
3171
3189
|
};
|
|
3172
|
-
|
|
3190
|
+
_chunkW3KLU3DIcjs.copyOcrTextGaps.call(void 0, it, normalized, 1 / scale);
|
|
3173
3191
|
return normalized;
|
|
3174
3192
|
}).filter((it) => it.text);
|
|
3175
|
-
const laid = unframeOcrLayoutTables(splitOcrJoinedHeaders(splitOcrContactColumns(splitOcrNameValueColumns(splitStackedOcrRows(
|
|
3193
|
+
const laid = unframeOcrLayoutTables(splitOcrJoinedHeaders(splitOcrContactColumns(splitOcrNameValueColumns(splitStackedOcrRows(_chunkW3KLU3DIcjs.extractPageBlocksWithLines.call(void 0, norm, pageNumber, opList, pdfW, pdfH, extraLines, detectTables))))), pdfH);
|
|
3176
3194
|
const blocks = figureRegion ? laid : splitOcrProseRows(laid);
|
|
3177
3195
|
if (!figureRegion) markOcrHeadings(blocks);
|
|
3178
3196
|
return blocks;
|
|
@@ -3232,7 +3250,7 @@ async function tryImport2(name, loader) {
|
|
|
3232
3250
|
return await loader();
|
|
3233
3251
|
} catch (e) {
|
|
3234
3252
|
throw new Error(
|
|
3235
|
-
`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.${
|
|
3253
|
+
`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.${_chunkOX2YMAOGcjs.OPTIONAL_DEP_INSTALL_HINT} \uC6D0\uC778: ${e.message}`
|
|
3236
3254
|
);
|
|
3237
3255
|
}
|
|
3238
3256
|
}
|
|
@@ -3285,4 +3303,4 @@ function bgraToRgba(bgra) {
|
|
|
3285
3303
|
|
|
3286
3304
|
|
|
3287
3305
|
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;
|
|
3288
|
-
//# sourceMappingURL=chunk-
|
|
3306
|
+
//# sourceMappingURL=chunk-4GKCBRSS.cjs.map
|