kordoc 4.24.46 → 4.24.48
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/NOTICE +21 -0
- package/README.md +5 -5
- package/dist/{-N45T7D3V.js → -3EMVBTE7.js} +22 -22
- package/dist/{chunk-FQP6MKZY.js → chunk-3UY7ARXP.js} +2 -2
- package/dist/{chunk-NJEMXMHP.js → chunk-4N2ESXR2.js} +2 -2
- package/dist/{chunk-YV6BBJXJ.js → chunk-6YUMHSBG.js} +3 -3
- package/dist/{chunk-7L7VO2L2.js → chunk-7EL6BCO5.js} +2 -2
- package/dist/{chunk-B2VBXPXH.js → chunk-7F5SKDUG.js} +2 -2
- package/dist/{chunk-MYLKNYSY.cjs → chunk-A6EOKPKG.cjs} +85 -50
- package/dist/chunk-A6EOKPKG.cjs.map +1 -0
- package/dist/{chunk-QF7UXLA2.js → chunk-AC7FZDVP.js} +2 -2
- package/dist/{chunk-VL7UACGR.js → chunk-D4TKVZKB.js} +3 -3
- package/dist/{chunk-FRVE5JWE.js → chunk-D7SOY3VR.js} +40 -5
- package/dist/chunk-D7SOY3VR.js.map +1 -0
- package/dist/{chunk-5WR335MB.js → chunk-E47LO7XG.js} +11 -11
- package/dist/{chunk-GKD7J45E.js → chunk-E5RJLP2S.js} +5 -5
- package/dist/{chunk-NJBY4HME.js → chunk-FQMPHPHE.js} +2 -2
- package/dist/{chunk-ZWOUNYCK.js → chunk-GFWCBYAI.js} +2 -2
- package/dist/chunk-GOYAJVR6.js +120 -0
- package/dist/chunk-GOYAJVR6.js.map +1 -0
- package/dist/{chunk-NWABYDS5.js → chunk-HW3DZ7TY.js} +7 -7
- package/dist/{chunk-SHYDVLFD.js → chunk-JC2TMUU5.js} +6 -6
- package/dist/{chunk-WBBTXX7T.js → chunk-KTGOULMH.js} +192 -17
- package/dist/chunk-KTGOULMH.js.map +1 -0
- package/dist/{chunk-X7RBVVDC.cjs → chunk-LBH4KAQM.cjs} +3 -2
- package/dist/chunk-LBH4KAQM.cjs.map +1 -0
- package/dist/{chunk-X2UNKZT4.cjs → chunk-LHZL52HO.cjs} +3 -3
- package/dist/{chunk-X2UNKZT4.cjs.map → chunk-LHZL52HO.cjs.map} +1 -1
- package/dist/{chunk-CUYBCAYZ.cjs → chunk-MHAPDR6T.cjs} +60 -60
- package/dist/{chunk-CUYBCAYZ.cjs.map → chunk-MHAPDR6T.cjs.map} +1 -1
- package/dist/{chunk-QIRUP2IN.js → chunk-MHLTZ3VI.js} +8 -5
- package/dist/chunk-MHLTZ3VI.js.map +1 -0
- package/dist/{chunk-JISE24L4.js → chunk-MYIRYP6D.js} +10 -10
- package/dist/{chunk-4IIMCEUZ.js → chunk-N6B5BINC.js} +6 -6
- package/dist/{chunk-HEH5WH2Q.js → chunk-NLPIXQOV.js} +2 -2
- package/dist/{chunk-JRYQERD5.js → chunk-OBNOOHAW.js} +2 -2
- package/dist/chunk-OBNOOHAW.js.map +1 -0
- package/dist/{chunk-BOQQO7X7.js → chunk-OO4DHHTG.js} +8 -5
- package/dist/chunk-OO4DHHTG.js.map +1 -0
- package/dist/{chunk-MIJ7EO56.js → chunk-OQPIN2OY.js} +2 -2
- package/dist/{chunk-RNWOGZWU.js → chunk-OUUI7I5V.js} +193 -18
- package/dist/chunk-OUUI7I5V.js.map +1 -0
- package/dist/chunk-PHU4VSNF.js +119 -0
- package/dist/chunk-PHU4VSNF.js.map +1 -0
- package/dist/{chunk-BY25KD5A.js → chunk-QJBVP2BS.js} +2 -2
- package/dist/{chunk-TXEWEFWH.js → chunk-QM65ELZE.js} +39 -4
- package/dist/chunk-QM65ELZE.js.map +1 -0
- package/dist/{chunk-XEMHC53A.cjs → chunk-QOBWIFJA.cjs} +282 -107
- package/dist/chunk-QOBWIFJA.cjs.map +1 -0
- package/dist/{chunk-BVLUNWRF.js → chunk-REERG473.js} +6 -6
- package/dist/{chunk-QDBOIQQI.js → chunk-SHYNOLL6.js} +2 -2
- package/dist/{chunk-MZX36SAT.js → chunk-SI3GXM7Z.js} +2 -2
- package/dist/chunk-SJXTCW7I.cjs +122 -0
- package/dist/chunk-SJXTCW7I.cjs.map +1 -0
- package/dist/{chunk-V5EDKEW3.js → chunk-SUOJQHIN.js} +6 -6
- package/dist/{chunk-D46JZLFC.cjs → chunk-TOOOWCKQ.cjs} +98 -98
- package/dist/{chunk-D46JZLFC.cjs.map → chunk-TOOOWCKQ.cjs.map} +1 -1
- package/dist/{chunk-VKVDMH7X.js → chunk-TQ4QOCKT.js} +2 -1
- package/dist/chunk-TQ4QOCKT.js.map +1 -0
- package/dist/{chunk-5O5BKPET.js → chunk-UJ3TZF4Y.js} +2 -2
- package/dist/{chunk-U556XJW6.js → chunk-UN2F6EKQ.js} +2 -1
- package/dist/chunk-UN2F6EKQ.js.map +1 -0
- package/dist/{chunk-7GM5ZLTC.cjs → chunk-VXHZPUMS.cjs} +2 -2
- package/dist/{chunk-7GM5ZLTC.cjs.map → chunk-VXHZPUMS.cjs.map} +1 -1
- package/dist/{chunk-X5APVAKP.js → chunk-WICMTKWR.js} +3 -3
- package/dist/{chunk-MVFUAMCR.js → chunk-WO6PZMMB.js} +2 -2
- package/dist/{chunk-KVRW3522.js → chunk-WVUR3HYW.js} +115 -43
- package/dist/chunk-WVUR3HYW.js.map +1 -0
- package/dist/{chunk-6A36TKBX.cjs → chunk-YFTD6WOP.cjs} +11 -8
- package/dist/chunk-YFTD6WOP.cjs.map +1 -0
- package/dist/chunks-QTVEFJOS.js +11 -0
- package/dist/cli.js +46 -45
- package/dist/cli.js.map +1 -1
- package/dist/{formula-C6ODQNSO.cjs → formula-7RJOEJHX.cjs} +9 -9
- package/dist/{formula-C6ODQNSO.cjs.map → formula-7RJOEJHX.cjs.map} +1 -1
- package/dist/{formula-K6TX7MPD.js → formula-DUHNPES2.js} +4 -4
- package/dist/{formula-NSUMSGTH.js → formula-XNCKOV6K.js} +3 -3
- package/dist/generator-6BFIABTF.js +10 -0
- package/dist/generator-XJLIBYDJ.js +17 -0
- package/dist/generator-XXVCF6TG.cjs +11 -0
- package/dist/{generator-QQ43CWBH.cjs.map → generator-XXVCF6TG.cjs.map} +1 -1
- package/dist/{hancom-MFD3WGNU.cjs → hancom-7F53R77A.cjs} +5 -5
- package/dist/{hancom-MFD3WGNU.cjs.map → hancom-7F53R77A.cjs.map} +1 -1
- package/dist/{hancom-HXONTKAF.js → hancom-D4E3WBPI.js} +2 -2
- package/dist/{hancom-24ZZS7G6.js → hancom-IPF6HM5F.js} +2 -2
- package/dist/{image-ocr-C4PANEFS.js → image-ocr-NFCTNIL5.js} +7 -7
- package/dist/{image-ocr-UWM2JO4F.js → image-ocr-PYOXD5K4.js} +10 -10
- package/dist/{image-ocr-44UBGI4O.cjs → image-ocr-ZLAPJMES.cjs} +27 -27
- package/dist/{image-ocr-44UBGI4O.cjs.map → image-ocr-ZLAPJMES.cjs.map} +1 -1
- package/dist/index.cjs +1601 -1529
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -3
- package/dist/index.d.ts +9 -3
- package/dist/index.js +109 -37
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +37 -37
- package/dist/memo-CNW6ZJFE.js +17 -0
- package/dist/{model-bundle-WAPNK77M.js → model-bundle-TIHWFIN5.js} +5 -5
- package/dist/{models-RVSU27QC.js → models-YBHBEM6J.js} +5 -5
- package/dist/{parse-worker-v2-SV4YBNJU.js → parse-worker-v2-Q7ST3SDO.js} +24 -23
- package/dist/parse-worker-v2-Q7ST3SDO.js.map +1 -0
- package/dist/{parser-N7XYSGJF.js → parser-7JSQYNLS.js} +377 -36
- package/dist/parser-7JSQYNLS.js.map +1 -0
- package/dist/{parser-QOBNISNN.cjs → parser-A76QS3VJ.cjs} +668 -327
- package/dist/parser-A76QS3VJ.cjs.map +1 -0
- package/dist/{parser-YYGB5XWO.js → parser-V25GYLBJ.js} +374 -33
- package/dist/parser-V25GYLBJ.js.map +1 -0
- package/dist/pdf-ocr-5YCDSSLG.cjs +42 -0
- package/dist/{pdf-ocr-EEMKTX5R.cjs.map → pdf-ocr-5YCDSSLG.cjs.map} +1 -1
- package/dist/{pdf-ocr-WXNQMLU2.js → pdf-ocr-GEAW23FB.js} +9 -9
- package/dist/{pdf-ocr-GFQNIMQG.js → pdf-ocr-IJXT6ZJR.js} +6 -6
- package/dist/{profile-io-EKLAEN7W.js → profile-io-Y7SMMS2R.js} +3 -3
- package/dist/{rasterize-IXUL6Y5W.js → rasterize-MLEHT6PU.js} +3 -3
- package/dist/{redact-doc-JUTJ3SOJ.js → redact-doc-GPO2UTTJ.js} +22 -22
- package/dist/{render-YPFJPUNC.js → render-TNWY53S4.js} +13 -13
- package/dist/{rewrite-fallback-H6ORRXXB.js → rewrite-fallback-AHGTN757.js} +14 -14
- package/dist/seal-7HBR3HBQ.js +16 -0
- package/dist/{setup-R2HZNN6F.js → setup-TJ57DQ6I.js} +3 -3
- package/dist/to-hwpx-6JF6Q2TZ.js +21 -0
- package/dist/{to-hwpx-LRYNPYMS.js → to-hwpx-DLVARUND.js} +5 -5
- package/dist/to-hwpx-XLQUY2L2.cjs +16 -0
- package/dist/{to-hwpx-WHCXM2SA.cjs.map → to-hwpx-XLQUY2L2.cjs.map} +1 -1
- package/dist/visual-VBDQUUKP.js +37 -0
- package/dist/{watch-ETBDIPSJ.js → watch-6CHDQ355.js} +23 -23
- package/package.json +3 -2
- package/dist/chunk-6A36TKBX.cjs.map +0 -1
- package/dist/chunk-BOQQO7X7.js.map +0 -1
- package/dist/chunk-FRVE5JWE.js.map +0 -1
- package/dist/chunk-G2T6PBYW.js +0 -31
- package/dist/chunk-G2T6PBYW.js.map +0 -1
- package/dist/chunk-JRYQERD5.js.map +0 -1
- package/dist/chunk-KVRW3522.js.map +0 -1
- package/dist/chunk-MYLKNYSY.cjs.map +0 -1
- package/dist/chunk-QIRUP2IN.js.map +0 -1
- package/dist/chunk-RNWOGZWU.js.map +0 -1
- package/dist/chunk-TXEWEFWH.js.map +0 -1
- package/dist/chunk-U556XJW6.js.map +0 -1
- package/dist/chunk-UHCEBHIY.js +0 -32
- package/dist/chunk-UHCEBHIY.js.map +0 -1
- package/dist/chunk-VKVDMH7X.js.map +0 -1
- package/dist/chunk-WBBTXX7T.js.map +0 -1
- package/dist/chunk-X7RBVVDC.cjs.map +0 -1
- package/dist/chunk-XEMHC53A.cjs.map +0 -1
- package/dist/chunk-ZRKB6EVS.cjs +0 -31
- package/dist/chunk-ZRKB6EVS.cjs.map +0 -1
- package/dist/chunks-4ERKEYKW.js +0 -11
- package/dist/generator-OHDWVKTZ.js +0 -10
- package/dist/generator-QQ43CWBH.cjs +0 -11
- package/dist/generator-SEH6W2LS.js +0 -17
- package/dist/memo-WOHINE33.js +0 -17
- package/dist/parse-worker-v2-SV4YBNJU.js.map +0 -1
- package/dist/parser-N7XYSGJF.js.map +0 -1
- package/dist/parser-QOBNISNN.cjs.map +0 -1
- package/dist/parser-YYGB5XWO.js.map +0 -1
- package/dist/pdf-ocr-EEMKTX5R.cjs +0 -42
- package/dist/seal-J3JWCKI6.js +0 -16
- package/dist/to-hwpx-WHCXM2SA.cjs +0 -16
- package/dist/to-hwpx-WWWZ7USZ.js +0 -21
- package/dist/visual-3XBGXVFX.js +0 -37
- /package/dist/{-N45T7D3V.js.map → -3EMVBTE7.js.map} +0 -0
- /package/dist/{chunk-FQP6MKZY.js.map → chunk-3UY7ARXP.js.map} +0 -0
- /package/dist/{chunk-NJEMXMHP.js.map → chunk-4N2ESXR2.js.map} +0 -0
- /package/dist/{chunk-YV6BBJXJ.js.map → chunk-6YUMHSBG.js.map} +0 -0
- /package/dist/{chunk-7L7VO2L2.js.map → chunk-7EL6BCO5.js.map} +0 -0
- /package/dist/{chunk-B2VBXPXH.js.map → chunk-7F5SKDUG.js.map} +0 -0
- /package/dist/{chunk-QF7UXLA2.js.map → chunk-AC7FZDVP.js.map} +0 -0
- /package/dist/{chunk-VL7UACGR.js.map → chunk-D4TKVZKB.js.map} +0 -0
- /package/dist/{chunk-5WR335MB.js.map → chunk-E47LO7XG.js.map} +0 -0
- /package/dist/{chunk-GKD7J45E.js.map → chunk-E5RJLP2S.js.map} +0 -0
- /package/dist/{chunk-NJBY4HME.js.map → chunk-FQMPHPHE.js.map} +0 -0
- /package/dist/{chunk-ZWOUNYCK.js.map → chunk-GFWCBYAI.js.map} +0 -0
- /package/dist/{chunk-NWABYDS5.js.map → chunk-HW3DZ7TY.js.map} +0 -0
- /package/dist/{chunk-SHYDVLFD.js.map → chunk-JC2TMUU5.js.map} +0 -0
- /package/dist/{chunk-JISE24L4.js.map → chunk-MYIRYP6D.js.map} +0 -0
- /package/dist/{chunk-4IIMCEUZ.js.map → chunk-N6B5BINC.js.map} +0 -0
- /package/dist/{chunk-HEH5WH2Q.js.map → chunk-NLPIXQOV.js.map} +0 -0
- /package/dist/{chunk-MIJ7EO56.js.map → chunk-OQPIN2OY.js.map} +0 -0
- /package/dist/{chunk-BY25KD5A.js.map → chunk-QJBVP2BS.js.map} +0 -0
- /package/dist/{chunk-BVLUNWRF.js.map → chunk-REERG473.js.map} +0 -0
- /package/dist/{chunk-QDBOIQQI.js.map → chunk-SHYNOLL6.js.map} +0 -0
- /package/dist/{chunk-MZX36SAT.js.map → chunk-SI3GXM7Z.js.map} +0 -0
- /package/dist/{chunk-V5EDKEW3.js.map → chunk-SUOJQHIN.js.map} +0 -0
- /package/dist/{chunk-5O5BKPET.js.map → chunk-UJ3TZF4Y.js.map} +0 -0
- /package/dist/{chunk-X5APVAKP.js.map → chunk-WICMTKWR.js.map} +0 -0
- /package/dist/{chunk-MVFUAMCR.js.map → chunk-WO6PZMMB.js.map} +0 -0
- /package/dist/{chunks-4ERKEYKW.js.map → chunks-QTVEFJOS.js.map} +0 -0
- /package/dist/{formula-K6TX7MPD.js.map → formula-DUHNPES2.js.map} +0 -0
- /package/dist/{formula-NSUMSGTH.js.map → formula-XNCKOV6K.js.map} +0 -0
- /package/dist/{generator-OHDWVKTZ.js.map → generator-6BFIABTF.js.map} +0 -0
- /package/dist/{generator-SEH6W2LS.js.map → generator-XJLIBYDJ.js.map} +0 -0
- /package/dist/{hancom-HXONTKAF.js.map → hancom-D4E3WBPI.js.map} +0 -0
- /package/dist/{hancom-24ZZS7G6.js.map → hancom-IPF6HM5F.js.map} +0 -0
- /package/dist/{image-ocr-C4PANEFS.js.map → image-ocr-NFCTNIL5.js.map} +0 -0
- /package/dist/{image-ocr-UWM2JO4F.js.map → image-ocr-PYOXD5K4.js.map} +0 -0
- /package/dist/{memo-WOHINE33.js.map → memo-CNW6ZJFE.js.map} +0 -0
- /package/dist/{model-bundle-WAPNK77M.js.map → model-bundle-TIHWFIN5.js.map} +0 -0
- /package/dist/{models-RVSU27QC.js.map → models-YBHBEM6J.js.map} +0 -0
- /package/dist/{pdf-ocr-GFQNIMQG.js.map → pdf-ocr-GEAW23FB.js.map} +0 -0
- /package/dist/{pdf-ocr-WXNQMLU2.js.map → pdf-ocr-IJXT6ZJR.js.map} +0 -0
- /package/dist/{profile-io-EKLAEN7W.js.map → profile-io-Y7SMMS2R.js.map} +0 -0
- /package/dist/{rasterize-IXUL6Y5W.js.map → rasterize-MLEHT6PU.js.map} +0 -0
- /package/dist/{redact-doc-JUTJ3SOJ.js.map → redact-doc-GPO2UTTJ.js.map} +0 -0
- /package/dist/{render-YPFJPUNC.js.map → render-TNWY53S4.js.map} +0 -0
- /package/dist/{rewrite-fallback-H6ORRXXB.js.map → rewrite-fallback-AHGTN757.js.map} +0 -0
- /package/dist/{seal-J3JWCKI6.js.map → seal-7HBR3HBQ.js.map} +0 -0
- /package/dist/{setup-R2HZNN6F.js.map → setup-TJ57DQ6I.js.map} +0 -0
- /package/dist/{to-hwpx-LRYNPYMS.js.map → to-hwpx-6JF6Q2TZ.js.map} +0 -0
- /package/dist/{to-hwpx-WWWZ7USZ.js.map → to-hwpx-DLVARUND.js.map} +0 -0
- /package/dist/{visual-3XBGXVFX.js.map → visual-VBDQUUKP.js.map} +0 -0
- /package/dist/{watch-ETBDIPSJ.js.map → watch-6CHDQ355.js.map} +0 -0
|
@@ -34,9 +34,10 @@ import {
|
|
|
34
34
|
serifOne,
|
|
35
35
|
slantedPair,
|
|
36
36
|
splitRowBands,
|
|
37
|
+
stackedGlyphBands,
|
|
37
38
|
starRun,
|
|
38
39
|
tallInkCount
|
|
39
|
-
} from "./chunk-
|
|
40
|
+
} from "./chunk-D7SOY3VR.js";
|
|
40
41
|
import {
|
|
41
42
|
validateOcrOptions
|
|
42
43
|
} from "./chunk-TBGGAR7W.js";
|
|
@@ -46,7 +47,7 @@ import {
|
|
|
46
47
|
import {
|
|
47
48
|
KordocError,
|
|
48
49
|
OPTIONAL_DEP_INSTALL_HINT
|
|
49
|
-
} from "./chunk-
|
|
50
|
+
} from "./chunk-3UY7ARXP.js";
|
|
50
51
|
|
|
51
52
|
// src/ocr/ocr-stacked-rows.ts
|
|
52
53
|
var NUMERIC = /^[-+−△▲▽▼]?[\d.,]+[%p]?$|^[-–—·∼~]$|^\([-+−△▲▽▼]?[\d.,]+%?\)$/;
|
|
@@ -388,7 +389,8 @@ function detectRulingLines(rgba, width, height, scale) {
|
|
|
388
389
|
for (const f of frames) {
|
|
389
390
|
const innerH = hs.filter((h) => h.y1 > f.y1 + tol && h.y1 < f.y2 - tol && Math.abs(h.x1 - f.x1) <= tol && Math.abs(h.x2 - f.x2) <= tol);
|
|
390
391
|
const innerV = vs.filter((v) => v.x1 > f.x1 + tol && v.x1 < f.x2 - tol && Math.abs(v.y1 - f.y1) <= tol && Math.abs(v.y2 - f.y2) <= tol);
|
|
391
|
-
|
|
392
|
+
const darkV = inkV.some((v) => v.x1 > f.x1 + tol && v.x1 < f.x2 - tol && v.y1 <= f.y1 + tol && v.y2 >= f.y2 - tol);
|
|
393
|
+
if (innerH.length < 3 || innerV.length < 1 && !darkV) continue;
|
|
392
394
|
for (const h of innerH) if (!horizontals.some((p) => Math.abs(p.y1 - h.y1) <= tol && p.x1 <= h.x1 + tol && p.x2 >= h.x2 - tol)) horizontals.push(h);
|
|
393
395
|
for (const v of innerV) if (!verticals.some((p) => Math.abs(p.x1 - v.x1) <= tol && p.y1 <= v.y1 + tol && p.y2 >= v.y2 - tol)) {
|
|
394
396
|
verticals.push(v);
|
|
@@ -1241,6 +1243,20 @@ function badThousands(text) {
|
|
|
1241
1243
|
}
|
|
1242
1244
|
return false;
|
|
1243
1245
|
}
|
|
1246
|
+
function singleNumberText(text) {
|
|
1247
|
+
return /^[-−(△▲]?\d[\d,]*(?:\.\d+)?\)?\s?(?:[가-힣]{1,2}|%)?$/.test(text.trim());
|
|
1248
|
+
}
|
|
1249
|
+
function rereadNumberText(original, reread) {
|
|
1250
|
+
const skeleton = (t) => t.replace(/[\d,\s]/g, "");
|
|
1251
|
+
if (skeleton(reread) === skeleton(original)) return restoreSymbols(reread.trim());
|
|
1252
|
+
const num = (t) => t.match(/\d[\d,]*\d|\d/g) ?? [];
|
|
1253
|
+
const before = num(original), after = num(reread);
|
|
1254
|
+
if (before.length !== 1 || after.length !== 1) return null;
|
|
1255
|
+
const a = before[0].replace(/,/g, ""), b = after[0].replace(/,/g, "");
|
|
1256
|
+
let i = 0;
|
|
1257
|
+
for (const ch of b) if (ch === a[i]) i++;
|
|
1258
|
+
return b.length > a.length && i === a.length ? original.replace(before[0], after[0]) : null;
|
|
1259
|
+
}
|
|
1244
1260
|
var DET_MAX_BOXES = 3e3;
|
|
1245
1261
|
var REC_MIN_WIDTH = 320;
|
|
1246
1262
|
var REC_BATCH_MAX_PIXELS = 48 * 16e3;
|
|
@@ -1253,6 +1269,7 @@ var ORIENT_MIN_CONF = 0.7;
|
|
|
1253
1269
|
var ORIENT_GAIN = 0.1;
|
|
1254
1270
|
var KEEP_MARGIN = 0.06;
|
|
1255
1271
|
var RETRY_SCORE = 0.9;
|
|
1272
|
+
var STACK_WORD_GAP = 0.3;
|
|
1256
1273
|
var LEADER_MIN_DOTS = 4;
|
|
1257
1274
|
var LEADER_CONTEXT = 0.5;
|
|
1258
1275
|
var DET_MIN_SHORT_SIDE = 80;
|
|
@@ -1870,33 +1887,52 @@ var OcrEngine = class _OcrEngine {
|
|
|
1870
1887
|
items.push(item);
|
|
1871
1888
|
}
|
|
1872
1889
|
for (const stretch of tuning.postprocess ? NUMBER_STRETCH : []) {
|
|
1873
|
-
const fix = items.filter((it) => boxOf.has(it) &&
|
|
1890
|
+
const fix = items.filter((it) => boxOf.has(it) && singleNumberText(it.text) && badThousands(it.text));
|
|
1874
1891
|
if (!fix.length) break;
|
|
1875
1892
|
const res = await this.recognizeJobs(rgba, width, fix.map((it, k) => ({ box: boxOf.get(it), rot: 0, group: k, stretch })), tuning.recBatch);
|
|
1876
|
-
const skeleton = (t) => t.replace(/[\d,\s]/g, "");
|
|
1877
1893
|
fix.forEach((it, k) => {
|
|
1878
1894
|
const r = res[k];
|
|
1879
|
-
if (!r || /\s/.test(r.text.trim()) || badThousands(r.text) || r.confidence < it.confidence - 0.05
|
|
1880
|
-
it.text
|
|
1895
|
+
if (!r || /\s/.test(r.text.trim()) || badThousands(r.text) || r.confidence < it.confidence - 0.05) return;
|
|
1896
|
+
const merged = rereadNumberText(it.text, r.text);
|
|
1897
|
+
if (merged === null) return;
|
|
1898
|
+
it.text = merged;
|
|
1881
1899
|
rememberOcrTextGaps(it, findOcrTextGaps(rgba, width, boxOf.get(it), r.text, it.text, r.steps, r.stepPx));
|
|
1882
1900
|
});
|
|
1883
1901
|
}
|
|
1884
|
-
|
|
1902
|
+
const blank2 = tuning.postprocess ? jobs.filter((j) => j.rot === 0 && j.join === void 0 && !j.footer && !j.keep && !best.has(j.group)).map((j) => j.box) : [];
|
|
1903
|
+
if (retry.length || blank2.length) {
|
|
1885
1904
|
const subs = [];
|
|
1886
|
-
|
|
1905
|
+
const stacks = [];
|
|
1906
|
+
for (const b of [...retry, ...blank2]) {
|
|
1887
1907
|
const gray = grayCrop(rgba, width, b);
|
|
1888
|
-
const
|
|
1889
|
-
|
|
1908
|
+
const ink = inkStats(gray);
|
|
1909
|
+
const cut = retry.includes(b) ? midBlankRow(gray, b.w, b.h, ink) : null;
|
|
1910
|
+
if (cut && b.w >= 3 * Math.max(cut[0], b.h - cut[1])) {
|
|
1911
|
+
subs.push({ ...b, h: cut[0] }, { ...b, y: b.y + cut[1], h: b.h - cut[1] });
|
|
1912
|
+
continue;
|
|
1913
|
+
}
|
|
1914
|
+
const bands = stackedGlyphBands(gray, b.w, b.h, ink);
|
|
1915
|
+
if (bands) stacks.push({ box: b, parts: bandBoxes(b, bands, height), word: bands.every((x, i) => i === 0 || x.y0 - bands[i - 1].y1 <= STACK_WORD_GAP * Math.max(x.y1 - x.y0, bands[i - 1].y1 - bands[i - 1].y0)) });
|
|
1890
1916
|
}
|
|
1891
1917
|
const overlap = (a, o) => Math.max(0, Math.min(a.x + a.w, o.x + o.w) - Math.max(a.x, o.x)) * Math.max(0, Math.min(a.y + a.h, o.y + o.h) - Math.max(a.y, o.y));
|
|
1892
|
-
for (let
|
|
1893
|
-
const res = subs.length ? await this.recognizeJobs(rgba, width, subs.map((box,
|
|
1894
|
-
subs.forEach((box,
|
|
1895
|
-
const r = res[
|
|
1918
|
+
for (let k2 = subs.length - 1; k2 >= 0; k2--) if (subs[k2].h < 8 || items.some((o) => overlap(subs[k2], o) * 2 > subs[k2].w * subs[k2].h)) subs.splice(k2, 1);
|
|
1919
|
+
const res = subs.length ? await this.recognizeJobs(rgba, width, subs.map((box, k2) => ({ box, rot: 0, group: k2 })), tuning.recBatch) : [];
|
|
1920
|
+
subs.forEach((box, k2) => {
|
|
1921
|
+
const r = res[k2];
|
|
1896
1922
|
if (!r || r.confidence < RETRY_SCORE) return;
|
|
1897
1923
|
const text = restoreSymbols(restoreGlyphs(rgba, width, box, r.text, r.steps, r.stepPx).trim());
|
|
1898
1924
|
if ((text.match(/[\p{L}\p{N}]/gu) ?? []).length >= 2) items.push({ text, ...this.itemBox(rgba, width, box, tuning), confidence: r.confidence });
|
|
1899
1925
|
});
|
|
1926
|
+
const free = stacks.filter((st) => !items.some((o) => overlap(st.box, o) * 2 > st.box.w * st.box.h));
|
|
1927
|
+
const parts = free.flatMap((st) => st.parts);
|
|
1928
|
+
const partRes = parts.length ? await this.recognizeJobs(rgba, width, parts.map((box, k2) => ({ box, rot: 0, group: k2 })), tuning.recBatch) : [];
|
|
1929
|
+
let k = 0;
|
|
1930
|
+
for (const st of free) {
|
|
1931
|
+
const rs = partRes.slice(k, k += st.parts.length);
|
|
1932
|
+
if (rs.length !== st.parts.length || rs.some((r) => !r || r.confidence < RETRY_SCORE || !/^[가-힣]$/.test(r.text.trim()))) continue;
|
|
1933
|
+
if (st.word) items.push({ text: rs.map((r) => r.text.trim()).join(""), ...this.itemBox(rgba, width, st.box, tuning), confidence: Math.min(...rs.map((r) => r.confidence)) });
|
|
1934
|
+
else st.parts.forEach((box, i) => items.push({ text: rs[i].text.trim(), ...this.itemBox(rgba, width, box, tuning), confidence: rs[i].confidence }));
|
|
1935
|
+
}
|
|
1900
1936
|
}
|
|
1901
1937
|
const leaderEnds = /* @__PURE__ */ new Map();
|
|
1902
1938
|
for (const j of joins) {
|
|
@@ -2289,6 +2325,141 @@ function rotateRgba(rgba, width, height, deg) {
|
|
|
2289
2325
|
return out;
|
|
2290
2326
|
}
|
|
2291
2327
|
|
|
2328
|
+
// src/ocr/ocr-chart-axes.ts
|
|
2329
|
+
var NUMBER = /^-?\d+(?:\.\d+)?%?$/;
|
|
2330
|
+
var value = (t) => Number(t.replace(/%$/, ""));
|
|
2331
|
+
function evenRun(ticks) {
|
|
2332
|
+
let best = [];
|
|
2333
|
+
for (let s = 0; s + 1 < ticks.length; s++) {
|
|
2334
|
+
const step = ticks[s + 1].value - ticks[s].value, gap = ticks[s + 1].pos - ticks[s].pos;
|
|
2335
|
+
if (step === 0 || gap <= 0) continue;
|
|
2336
|
+
let e = s + 1;
|
|
2337
|
+
while (e + 1 < ticks.length) {
|
|
2338
|
+
const d = ticks[e + 1].pos - ticks[e].pos, v = ticks[e + 1].value - ticks[e].value;
|
|
2339
|
+
if (Math.abs(d - gap) > gap * 0.35 || Math.abs(v - step) > Math.abs(step) * 0.25) break;
|
|
2340
|
+
e++;
|
|
2341
|
+
}
|
|
2342
|
+
if (e - s + 1 > best.length) best = ticks.slice(s, e + 1);
|
|
2343
|
+
}
|
|
2344
|
+
return best;
|
|
2345
|
+
}
|
|
2346
|
+
var number = (t) => NUMBER.test(t.replace(/-$/, "").trim()) ? value(t.replace(/-$/, "").trim()) : null;
|
|
2347
|
+
function valueAxes(items) {
|
|
2348
|
+
const nums = items.filter((it) => number(it.text) !== null);
|
|
2349
|
+
const out = [];
|
|
2350
|
+
const used = /* @__PURE__ */ new Set();
|
|
2351
|
+
for (const seed of nums) {
|
|
2352
|
+
if (used.has(seed)) continue;
|
|
2353
|
+
const col = nums.filter((it) => Math.abs(it.x + it.w - seed.x - seed.w) <= seed.h * 0.8).sort((a, b) => a.y - b.y);
|
|
2354
|
+
const run = evenRun(col.map((it) => ({ pos: it.y + it.h / 2, value: number(it.text), it })));
|
|
2355
|
+
if (run.length < 4 || run[1].value > run[0].value) continue;
|
|
2356
|
+
const ticks = run.map((r) => r.it);
|
|
2357
|
+
for (const it of ticks) used.add(it);
|
|
2358
|
+
const h = ticks.reduce((a, it) => a + it.h, 0) / ticks.length;
|
|
2359
|
+
out.push({ x1: Math.min(...ticks.map((it) => it.x)), x2: Math.max(...ticks.map((it) => it.x + it.w)), y1: ticks[0].y, y2: ticks[ticks.length - 1].y + ticks[ticks.length - 1].h, h });
|
|
2360
|
+
}
|
|
2361
|
+
return out;
|
|
2362
|
+
}
|
|
2363
|
+
function timeAxes(items) {
|
|
2364
|
+
const numeric = items.filter((it) => {
|
|
2365
|
+
const t = it.text.trim().split(/\s+/);
|
|
2366
|
+
return t.length > 0 && t.every((x) => NUMBER.test(x));
|
|
2367
|
+
});
|
|
2368
|
+
const out = [];
|
|
2369
|
+
const used = /* @__PURE__ */ new Set();
|
|
2370
|
+
for (const seed of numeric) {
|
|
2371
|
+
if (used.has(seed)) continue;
|
|
2372
|
+
const row = numeric.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);
|
|
2373
|
+
const ticks = row.flatMap((it) => {
|
|
2374
|
+
const text = it.text.trim(), per = it.w / Math.max(1, text.length);
|
|
2375
|
+
return [...text.matchAll(/\S+/g)].map((m) => ({ pos: it.x + (m.index + m[0].length / 2) * per, value: value(m[0]), it }));
|
|
2376
|
+
});
|
|
2377
|
+
const run = evenRun(ticks);
|
|
2378
|
+
if (run.length < 4 || run[1].value < run[0].value) continue;
|
|
2379
|
+
const boxes = [...new Set(run.map((r) => r.it))];
|
|
2380
|
+
for (const it of boxes) used.add(it);
|
|
2381
|
+
out.push({ x1: Math.min(...boxes.map((it) => it.x)), x2: Math.max(...boxes.map((it) => it.x + it.w)), y1: Math.min(...boxes.map((it) => it.y)), y2: Math.max(...boxes.map((it) => it.y + it.h)), h: seed.h });
|
|
2382
|
+
}
|
|
2383
|
+
return out;
|
|
2384
|
+
}
|
|
2385
|
+
function chartPlotItems(items) {
|
|
2386
|
+
const drop = /* @__PURE__ */ new Set();
|
|
2387
|
+
const verticals = valueAxes(items);
|
|
2388
|
+
if (!verticals.length) return drop;
|
|
2389
|
+
const horizontals = timeAxes(items);
|
|
2390
|
+
for (const v of verticals) {
|
|
2391
|
+
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);
|
|
2392
|
+
if (!hz) continue;
|
|
2393
|
+
const x1 = v.x1 - 5 * v.h, x2 = hz.x2 + 2 * v.h, y1 = v.y1 - 1.5 * v.h, y2 = hz.y2 + 2.5 * v.h;
|
|
2394
|
+
items.forEach((it, i) => {
|
|
2395
|
+
const cx = it.x + it.w / 2, cy = it.y + it.h / 2;
|
|
2396
|
+
if (cx >= x1 && cx <= x2 && cy >= y1 && cy <= y2 && it.x >= x1 - v.h && it.x + it.w <= x2 + v.h) drop.add(i);
|
|
2397
|
+
});
|
|
2398
|
+
}
|
|
2399
|
+
return drop;
|
|
2400
|
+
}
|
|
2401
|
+
|
|
2402
|
+
// src/ocr/ocr-contact-columns.ts
|
|
2403
|
+
var CONTACT = /^([가-힣](?:\s*[가-힣]){0,4})\s+([가-힣]{2,4})\s*([^가-힣\s][^가-힣]{5,48})$/;
|
|
2404
|
+
var PHONE = /^\(?0\d{1,3}\)?[-\s]?\d{3,4}-\d{4}\)?$/;
|
|
2405
|
+
var MAIL = /^\(?[\w.+-]+@[\w-]+(?:\.[\w-]+)+\)?$/;
|
|
2406
|
+
function contactParts(text) {
|
|
2407
|
+
const m = CONTACT.exec(text.trim());
|
|
2408
|
+
if (!m) return null;
|
|
2409
|
+
const contact = m[3].includes("@") ? m[3].replace(/\s+/g, "") : m[3].trim();
|
|
2410
|
+
return PHONE.test(contact) || MAIL.test(contact) ? [m[1], m[2], contact] : null;
|
|
2411
|
+
}
|
|
2412
|
+
function owners2(t) {
|
|
2413
|
+
const own = Array.from({ length: t.rows }, () => Array(t.cols));
|
|
2414
|
+
for (let r = 0; r < t.rows; r++) for (let c = 0; c < t.cols; c++) {
|
|
2415
|
+
if (own[r][c]) continue;
|
|
2416
|
+
const cell = t.cells[r][c];
|
|
2417
|
+
for (let i = r; i < Math.min(t.rows, r + Math.max(1, cell.rowSpan ?? 1)); i++)
|
|
2418
|
+
for (let j = c; j < Math.min(t.cols, c + Math.max(1, cell.colSpan ?? 1)); j++) own[i][j] ??= cell;
|
|
2419
|
+
}
|
|
2420
|
+
return own;
|
|
2421
|
+
}
|
|
2422
|
+
function splitTable3(t) {
|
|
2423
|
+
if (t.cells.length !== t.rows || t.cells.some((row) => row.length !== t.cols)) return;
|
|
2424
|
+
const own = owners2(t);
|
|
2425
|
+
const anchor = (r, c) => own[r][c] === t.cells[r][c] ? t.cells[r][c] : null;
|
|
2426
|
+
const targets = [];
|
|
2427
|
+
for (let c = 0; c < t.cols; c++) {
|
|
2428
|
+
let filled = 0, hits = 0;
|
|
2429
|
+
for (let r = 0; r < t.rows; r++) {
|
|
2430
|
+
const cell = anchor(r, c);
|
|
2431
|
+
if (!cell || (cell.colSpan ?? 1) !== 1 || cell.blocks?.length || !cell.text.trim()) continue;
|
|
2432
|
+
if (contactParts(cell.text)) hits++;
|
|
2433
|
+
if (hits) filled++;
|
|
2434
|
+
}
|
|
2435
|
+
if (hits >= 2 && hits >= filled * 0.8) targets.push(c);
|
|
2436
|
+
}
|
|
2437
|
+
for (const c of targets.reverse()) {
|
|
2438
|
+
const grown = /* @__PURE__ */ new Set();
|
|
2439
|
+
for (let r = 0; r < t.rows; r++) {
|
|
2440
|
+
const cell = anchor(r, c);
|
|
2441
|
+
let added = [{ text: "", colSpan: 1, rowSpan: 1 }, { text: "", colSpan: 1, rowSpan: 1 }];
|
|
2442
|
+
if (cell && (cell.colSpan ?? 1) === 1 && !cell.blocks?.length) {
|
|
2443
|
+
const parts = contactParts(cell.text);
|
|
2444
|
+
if (parts) {
|
|
2445
|
+
cell.text = parts[0];
|
|
2446
|
+
added = [{ ...cell, text: parts[1] }, { ...cell, text: parts[2] }];
|
|
2447
|
+
} else cell.colSpan = 3;
|
|
2448
|
+
grown.add(cell);
|
|
2449
|
+
} else if (!grown.has(own[r][c])) {
|
|
2450
|
+
own[r][c].colSpan = Math.max(1, own[r][c].colSpan ?? 1) + 2;
|
|
2451
|
+
grown.add(own[r][c]);
|
|
2452
|
+
}
|
|
2453
|
+
t.cells[r].splice(c + 1, 0, ...added);
|
|
2454
|
+
}
|
|
2455
|
+
t.cols += 2;
|
|
2456
|
+
}
|
|
2457
|
+
}
|
|
2458
|
+
function splitOcrContactColumns(blocks) {
|
|
2459
|
+
for (const b of blocks) if (b.type === "table" && b.table) splitTable3(b.table);
|
|
2460
|
+
return blocks;
|
|
2461
|
+
}
|
|
2462
|
+
|
|
2292
2463
|
// src/ocr/pdf-ocr.ts
|
|
2293
2464
|
var OCR_RENDER_SCALE = 3;
|
|
2294
2465
|
var MAX_OCR_PIXELS = 24e6;
|
|
@@ -2596,6 +2767,10 @@ function groupOcrLines(items, figureRegion = false) {
|
|
|
2596
2767
|
return lines.filter((l) => l.length > 0);
|
|
2597
2768
|
}
|
|
2598
2769
|
function ocrItemsToBlocks(items, pageNumber, pdfW, pdfH, scale, extraLines, detectTables = true, opList = { fnArray: [], argsArray: [] }, figureRegion = false) {
|
|
2770
|
+
if (!figureRegion) {
|
|
2771
|
+
const chart = chartPlotItems(items);
|
|
2772
|
+
if (chart.size) items = items.filter((_, i) => !chart.has(i));
|
|
2773
|
+
}
|
|
2599
2774
|
const bottoms = items.map((it) => it.y + it.h);
|
|
2600
2775
|
const xs = items.map((it) => ({ x: it.x, r: it.x + it.w, space: false }));
|
|
2601
2776
|
const texts = items.map((it) => it.text);
|
|
@@ -2638,7 +2813,7 @@ function ocrItemsToBlocks(items, pageNumber, pdfW, pdfH, scale, extraLines, dete
|
|
|
2638
2813
|
copyOcrTextGaps(it, normalized, 1 / scale);
|
|
2639
2814
|
return normalized;
|
|
2640
2815
|
}).filter((it) => it.text);
|
|
2641
|
-
const blocks = unframeOcrLayoutTables(splitOcrNameValueColumns(splitStackedOcrRows(extractPageBlocksWithLines(norm, pageNumber, opList, pdfW, pdfH, extraLines, detectTables))), pdfH);
|
|
2816
|
+
const blocks = unframeOcrLayoutTables(splitOcrContactColumns(splitOcrNameValueColumns(splitStackedOcrRows(extractPageBlocksWithLines(norm, pageNumber, opList, pdfW, pdfH, extraLines, detectTables)))), pdfH);
|
|
2642
2817
|
if (!figureRegion) markOcrHeadings(blocks);
|
|
2643
2818
|
return blocks;
|
|
2644
2819
|
}
|
|
@@ -2749,4 +2924,4 @@ export {
|
|
|
2749
2924
|
ocrItemsToBlocks,
|
|
2750
2925
|
markOcrHeadings
|
|
2751
2926
|
};
|
|
2752
|
-
//# sourceMappingURL=chunk-
|
|
2927
|
+
//# sourceMappingURL=chunk-KTGOULMH.js.map
|