kordoc 4.24.64 → 4.24.66
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 +5 -5
- package/dist/{-QAZ44KKA.js → -F525UPLU.js} +21 -21
- package/dist/{chunk-FPC3GEAD.js → chunk-2XL56JBH.js} +10 -10
- package/dist/{chunk-MEHJKEUZ.js → chunk-3UBJILCL.js} +2 -2
- package/dist/{chunk-Q4AQE7TN.js → chunk-4AQEYIQ3.js} +2 -2
- package/dist/{chunk-FNRCQGZN.js → chunk-4UU2SHSY.js} +35 -8
- package/dist/chunk-4UU2SHSY.js.map +1 -0
- package/dist/{chunk-35WLNE3R.cjs → chunk-64EE67KV.cjs} +3 -3
- package/dist/{chunk-35WLNE3R.cjs.map → chunk-64EE67KV.cjs.map} +1 -1
- package/dist/{chunk-OJKFBZPW.js → chunk-6I5IGEH5.js} +2 -2
- package/dist/{chunk-S6WRR43D.js → chunk-727NQOEV.js} +2 -2
- package/dist/{chunk-R5PEYGFS.js → chunk-7VOBRIAX.js} +2 -2
- package/dist/{chunk-X2XUGRV3.js → chunk-ADVM2BSC.js} +3 -3
- package/dist/{chunk-4R6LAJCT.js → chunk-AKHGU46M.js} +7 -7
- package/dist/{chunk-DAP3G7G3.js → chunk-AQ2MNHLW.js} +104 -15
- package/dist/chunk-AQ2MNHLW.js.map +1 -0
- package/dist/{chunk-PNEMJTPG.js → chunk-CFQG5H5S.js} +2 -2
- package/dist/{chunk-COARY4DW.js → chunk-CNM5LSE2.js} +2 -2
- package/dist/{chunk-DFZIE6NM.js → chunk-DQAHD7AV.js} +2 -2
- package/dist/{chunk-EUNUDJXO.js → chunk-E3MKUDIV.js} +2 -2
- package/dist/{chunk-HQSGKBH4.js → chunk-EKLKGFW3.js} +2 -2
- package/dist/{chunk-GOXFAAHN.js → chunk-JDLRNVPW.js} +2 -2
- package/dist/{chunk-72H52U6F.cjs → chunk-JMCNY622.cjs} +188 -99
- package/dist/chunk-JMCNY622.cjs.map +1 -0
- package/dist/{chunk-GDRQGXPC.js → chunk-JTBGDI7W.js} +34 -7
- package/dist/chunk-JTBGDI7W.js.map +1 -0
- package/dist/{chunk-KVLIFFDJ.cjs → chunk-JWPSOXBE.cjs} +8 -8
- package/dist/{chunk-KVLIFFDJ.cjs.map → chunk-JWPSOXBE.cjs.map} +1 -1
- package/dist/{chunk-3XZR5JQY.cjs → chunk-MJBGYWZE.cjs} +104 -104
- package/dist/{chunk-3XZR5JQY.cjs.map → chunk-MJBGYWZE.cjs.map} +1 -1
- package/dist/{chunk-NVHBKHTR.js → chunk-NHTQRDJ6.js} +11 -11
- package/dist/{chunk-IEOC3SKK.js → chunk-O62APXCV.js} +5 -5
- package/dist/{chunk-34OGRWYW.js → chunk-PHWKC6UC.js} +103 -14
- package/dist/chunk-PHWKC6UC.js.map +1 -0
- package/dist/{chunk-LKH3LG3N.cjs → chunk-QN6WSJVU.cjs} +58 -58
- package/dist/{chunk-LKH3LG3N.cjs.map → chunk-QN6WSJVU.cjs.map} +1 -1
- package/dist/{chunk-PO2TQW2B.js → chunk-QPEOOQV5.js} +2 -2
- package/dist/{chunk-YFEV3NNV.js → chunk-R4JIQ5TC.js} +2 -2
- package/dist/{chunk-36EJXOCF.js → chunk-RDNYND2I.js} +5 -5
- package/dist/{chunk-I4ON2NHU.js → chunk-RN46L3AU.js} +6 -6
- package/dist/{chunk-PZOKLEDR.js → chunk-RXE7BWTU.js} +2 -2
- package/dist/{chunk-CKA2X7FC.js → chunk-S2KMYEFM.js} +2 -2
- package/dist/{chunk-XCPST2YL.js → chunk-S532VXZW.js} +2 -2
- package/dist/{chunk-LKCLRP4E.js → chunk-SMPW433I.js} +2 -2
- package/dist/{chunk-AZZKSDLD.js → chunk-THKLA33K.js} +2 -2
- package/dist/{chunk-LJUESQWH.js → chunk-TLN3QVS3.js} +5 -5
- package/dist/{chunk-LNAOHM6K.js → chunk-TW7LJ4CT.js} +2 -2
- package/dist/{chunk-ZRHMLFJB.js → chunk-U5BSGXWG.js} +3 -3
- package/dist/{chunk-ACDKOGKO.js → chunk-V5AGFLMV.js} +15 -15
- package/dist/{chunk-R7GE5HUE.js → chunk-VUVENRQF.js} +3 -3
- package/dist/{chunk-FEFKONND.cjs → chunk-WD5KO2FI.cjs} +203 -176
- package/dist/chunk-WD5KO2FI.cjs.map +1 -0
- package/dist/{chunk-T3JCWBOI.cjs → chunk-WL6FHOXS.cjs} +2 -2
- package/dist/{chunk-T3JCWBOI.cjs.map → chunk-WL6FHOXS.cjs.map} +1 -1
- package/dist/{chunk-PTJDTKU3.js → chunk-X2JWEVBD.js} +6 -6
- package/dist/{chunk-MMZO2B5N.cjs → chunk-ZLZ3XYNR.cjs} +3 -3
- package/dist/{chunk-MMZO2B5N.cjs.map → chunk-ZLZ3XYNR.cjs.map} +1 -1
- package/dist/chunks-4IEOCUKM.js +11 -0
- package/dist/cli.js +45 -45
- package/dist/{formula-TGSWQZXE.js → formula-DNEIS4K3.js} +3 -3
- package/dist/{formula-IWBM3D27.cjs → formula-HKMKULZI.cjs} +9 -9
- package/dist/{formula-IWBM3D27.cjs.map → formula-HKMKULZI.cjs.map} +1 -1
- package/dist/{formula-AKSUUGPE.js → formula-Z6MQKJK4.js} +4 -4
- package/dist/generator-54YDTC4H.js +11 -0
- package/dist/generator-LGPN5WJF.cjs +12 -0
- package/dist/{generator-AUHRYGI3.cjs.map → generator-LGPN5WJF.cjs.map} +1 -1
- package/dist/generator-ZECPB7JM.js +18 -0
- package/dist/{hancom-QSZ33R47.cjs → hancom-DYJIMXYD.cjs} +5 -5
- package/dist/{hancom-QSZ33R47.cjs.map → hancom-DYJIMXYD.cjs.map} +1 -1
- package/dist/{hancom-HQBZBCSR.js → hancom-EKGYO3DR.js} +2 -2
- package/dist/{hancom-PV626GYI.js → hancom-UA3FAKPN.js} +2 -2
- package/dist/{image-ocr-P5XZGIPX.js → image-ocr-AEJC2HYX.js} +7 -7
- package/dist/{image-ocr-EL2WFECB.cjs → image-ocr-PZ2U43B5.cjs} +28 -28
- package/dist/{image-ocr-EL2WFECB.cjs.map → image-ocr-PZ2U43B5.cjs.map} +1 -1
- package/dist/{image-ocr-2EYCNJJU.js → image-ocr-V5ULS7PL.js} +10 -10
- package/dist/index.cjs +1115 -1115
- package/dist/index.js +9 -9
- package/dist/mcp.js +36 -36
- package/dist/memo-WGP7QJ7M.js +17 -0
- package/dist/{model-bundle-5ZAV3WPL.js → model-bundle-OYH3ZTJK.js} +5 -5
- package/dist/{models-KOHBYNOH.js → models-52726NXY.js} +5 -5
- package/dist/{parse-worker-v2-SSXAWHMP.js → parse-worker-v2-5C3VXRFT.js} +22 -22
- package/dist/{parser-Q2LYKLLS.js → parser-4EIBYZUS.js} +12 -12
- package/dist/{parser-GAT6U7NK.js → parser-L55CW5GW.js} +9 -9
- package/dist/{parser-JAXFIY4Z.cjs → parser-Y3F7ULSO.cjs} +166 -166
- package/dist/{parser-JAXFIY4Z.cjs.map → parser-Y3F7ULSO.cjs.map} +1 -1
- package/dist/{pdf-ocr-ZK6W2KRC.js → pdf-ocr-4XG2GDWK.js} +9 -9
- package/dist/pdf-ocr-6DDEOYWS.cjs +43 -0
- package/dist/{pdf-ocr-S6LZ5SDT.cjs.map → pdf-ocr-6DDEOYWS.cjs.map} +1 -1
- package/dist/{pdf-ocr-5EHHYF3C.js → pdf-ocr-DO3GQSVO.js} +6 -6
- package/dist/{profile-io-6LSVAJGK.js → profile-io-J4BGPXD6.js} +3 -3
- package/dist/{rasterize-JRBWIABQ.js → rasterize-2BD3ST5L.js} +3 -3
- package/dist/{redact-doc-K6Q3J4QN.js → redact-doc-T5ZO5BUF.js} +21 -21
- package/dist/{render-QXCUXJBD.js → render-XHAEGFDS.js} +12 -12
- package/dist/{rewrite-fallback-LKK3CK7E.js → rewrite-fallback-GDC6ISST.js} +13 -13
- package/dist/seal-DDP5FWKY.js +16 -0
- package/dist/{setup-NA3L7AP4.js → setup-JAH3DJMB.js} +3 -3
- package/dist/to-hwpx-CBFKBA26.cjs +16 -0
- package/dist/{to-hwpx-ICWG2YYM.cjs.map → to-hwpx-CBFKBA26.cjs.map} +1 -1
- package/dist/{to-hwpx-YNCXFNZV.js → to-hwpx-FU5MRESY.js} +7 -7
- package/dist/{to-hwpx-QVGHZIYD.js → to-hwpx-HQLTHIOW.js} +4 -4
- package/dist/visual-TYA7MDHZ.js +38 -0
- package/dist/{watch-C276YW4I.js → watch-52TBPFGB.js} +22 -22
- package/package.json +1 -1
- package/dist/chunk-34OGRWYW.js.map +0 -1
- package/dist/chunk-72H52U6F.cjs.map +0 -1
- package/dist/chunk-DAP3G7G3.js.map +0 -1
- package/dist/chunk-FEFKONND.cjs.map +0 -1
- package/dist/chunk-FNRCQGZN.js.map +0 -1
- package/dist/chunk-GDRQGXPC.js.map +0 -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 → -F525UPLU.js.map} +0 -0
- /package/dist/{chunk-FPC3GEAD.js.map → chunk-2XL56JBH.js.map} +0 -0
- /package/dist/{chunk-MEHJKEUZ.js.map → chunk-3UBJILCL.js.map} +0 -0
- /package/dist/{chunk-Q4AQE7TN.js.map → chunk-4AQEYIQ3.js.map} +0 -0
- /package/dist/{chunk-OJKFBZPW.js.map → chunk-6I5IGEH5.js.map} +0 -0
- /package/dist/{chunk-S6WRR43D.js.map → chunk-727NQOEV.js.map} +0 -0
- /package/dist/{chunk-R5PEYGFS.js.map → chunk-7VOBRIAX.js.map} +0 -0
- /package/dist/{chunk-X2XUGRV3.js.map → chunk-ADVM2BSC.js.map} +0 -0
- /package/dist/{chunk-4R6LAJCT.js.map → chunk-AKHGU46M.js.map} +0 -0
- /package/dist/{chunk-PNEMJTPG.js.map → chunk-CFQG5H5S.js.map} +0 -0
- /package/dist/{chunk-COARY4DW.js.map → chunk-CNM5LSE2.js.map} +0 -0
- /package/dist/{chunk-DFZIE6NM.js.map → chunk-DQAHD7AV.js.map} +0 -0
- /package/dist/{chunk-EUNUDJXO.js.map → chunk-E3MKUDIV.js.map} +0 -0
- /package/dist/{chunk-HQSGKBH4.js.map → chunk-EKLKGFW3.js.map} +0 -0
- /package/dist/{chunk-GOXFAAHN.js.map → chunk-JDLRNVPW.js.map} +0 -0
- /package/dist/{chunk-NVHBKHTR.js.map → chunk-NHTQRDJ6.js.map} +0 -0
- /package/dist/{chunk-IEOC3SKK.js.map → chunk-O62APXCV.js.map} +0 -0
- /package/dist/{chunk-PO2TQW2B.js.map → chunk-QPEOOQV5.js.map} +0 -0
- /package/dist/{chunk-YFEV3NNV.js.map → chunk-R4JIQ5TC.js.map} +0 -0
- /package/dist/{chunk-36EJXOCF.js.map → chunk-RDNYND2I.js.map} +0 -0
- /package/dist/{chunk-I4ON2NHU.js.map → chunk-RN46L3AU.js.map} +0 -0
- /package/dist/{chunk-PZOKLEDR.js.map → chunk-RXE7BWTU.js.map} +0 -0
- /package/dist/{chunk-CKA2X7FC.js.map → chunk-S2KMYEFM.js.map} +0 -0
- /package/dist/{chunk-XCPST2YL.js.map → chunk-S532VXZW.js.map} +0 -0
- /package/dist/{chunk-LKCLRP4E.js.map → chunk-SMPW433I.js.map} +0 -0
- /package/dist/{chunk-AZZKSDLD.js.map → chunk-THKLA33K.js.map} +0 -0
- /package/dist/{chunk-LJUESQWH.js.map → chunk-TLN3QVS3.js.map} +0 -0
- /package/dist/{chunk-LNAOHM6K.js.map → chunk-TW7LJ4CT.js.map} +0 -0
- /package/dist/{chunk-ZRHMLFJB.js.map → chunk-U5BSGXWG.js.map} +0 -0
- /package/dist/{chunk-ACDKOGKO.js.map → chunk-V5AGFLMV.js.map} +0 -0
- /package/dist/{chunk-R7GE5HUE.js.map → chunk-VUVENRQF.js.map} +0 -0
- /package/dist/{chunk-PTJDTKU3.js.map → chunk-X2JWEVBD.js.map} +0 -0
- /package/dist/{chunks-OWWHWU6T.js.map → chunks-4IEOCUKM.js.map} +0 -0
- /package/dist/{formula-TGSWQZXE.js.map → formula-DNEIS4K3.js.map} +0 -0
- /package/dist/{formula-AKSUUGPE.js.map → formula-Z6MQKJK4.js.map} +0 -0
- /package/dist/{generator-TGYD6N7S.js.map → generator-54YDTC4H.js.map} +0 -0
- /package/dist/{generator-UB2TEEE6.js.map → generator-ZECPB7JM.js.map} +0 -0
- /package/dist/{hancom-HQBZBCSR.js.map → hancom-EKGYO3DR.js.map} +0 -0
- /package/dist/{hancom-PV626GYI.js.map → hancom-UA3FAKPN.js.map} +0 -0
- /package/dist/{image-ocr-P5XZGIPX.js.map → image-ocr-AEJC2HYX.js.map} +0 -0
- /package/dist/{image-ocr-2EYCNJJU.js.map → image-ocr-V5ULS7PL.js.map} +0 -0
- /package/dist/{memo-I5S4HZBP.js.map → memo-WGP7QJ7M.js.map} +0 -0
- /package/dist/{model-bundle-5ZAV3WPL.js.map → model-bundle-OYH3ZTJK.js.map} +0 -0
- /package/dist/{models-KOHBYNOH.js.map → models-52726NXY.js.map} +0 -0
- /package/dist/{parse-worker-v2-SSXAWHMP.js.map → parse-worker-v2-5C3VXRFT.js.map} +0 -0
- /package/dist/{parser-Q2LYKLLS.js.map → parser-4EIBYZUS.js.map} +0 -0
- /package/dist/{parser-GAT6U7NK.js.map → parser-L55CW5GW.js.map} +0 -0
- /package/dist/{pdf-ocr-5EHHYF3C.js.map → pdf-ocr-4XG2GDWK.js.map} +0 -0
- /package/dist/{pdf-ocr-ZK6W2KRC.js.map → pdf-ocr-DO3GQSVO.js.map} +0 -0
- /package/dist/{profile-io-6LSVAJGK.js.map → profile-io-J4BGPXD6.js.map} +0 -0
- /package/dist/{rasterize-JRBWIABQ.js.map → rasterize-2BD3ST5L.js.map} +0 -0
- /package/dist/{redact-doc-K6Q3J4QN.js.map → redact-doc-T5ZO5BUF.js.map} +0 -0
- /package/dist/{render-QXCUXJBD.js.map → render-XHAEGFDS.js.map} +0 -0
- /package/dist/{rewrite-fallback-LKK3CK7E.js.map → rewrite-fallback-GDC6ISST.js.map} +0 -0
- /package/dist/{seal-GMZGRQE7.js.map → seal-DDP5FWKY.js.map} +0 -0
- /package/dist/{setup-NA3L7AP4.js.map → setup-JAH3DJMB.js.map} +0 -0
- /package/dist/{to-hwpx-QVGHZIYD.js.map → to-hwpx-FU5MRESY.js.map} +0 -0
- /package/dist/{to-hwpx-YNCXFNZV.js.map → to-hwpx-HQLTHIOW.js.map} +0 -0
- /package/dist/{visual-5BXQ3MAX.js.map → visual-TYA7MDHZ.js.map} +0 -0
- /package/dist/{watch-C276YW4I.js.map → watch-52TBPFGB.js.map} +0 -0
|
@@ -30,7 +30,7 @@ import {
|
|
|
30
30
|
stackedGlyphBands,
|
|
31
31
|
starRun,
|
|
32
32
|
tallInkCount
|
|
33
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-JTBGDI7W.js";
|
|
34
34
|
import {
|
|
35
35
|
validateOcrOptions
|
|
36
36
|
} from "./chunk-IIOBUTXH.js";
|
|
@@ -46,14 +46,14 @@ import {
|
|
|
46
46
|
ocrSourcePath,
|
|
47
47
|
parseCharacterDict,
|
|
48
48
|
resolveOcrModels
|
|
49
|
-
} from "./chunk-
|
|
49
|
+
} from "./chunk-S532VXZW.js";
|
|
50
50
|
import {
|
|
51
51
|
disableOrtTelemetry
|
|
52
52
|
} from "./chunk-6H25SXDI.js";
|
|
53
53
|
import {
|
|
54
54
|
KordocError,
|
|
55
55
|
OPTIONAL_DEP_INSTALL_HINT
|
|
56
|
-
} from "./chunk-
|
|
56
|
+
} from "./chunk-SMPW433I.js";
|
|
57
57
|
|
|
58
58
|
// src/ocr/ocr-stacked-rows.ts
|
|
59
59
|
var NUMERIC = /^[-+−△▲▽▼]?[\d.,]+[%p원]?$|^[-–—·∼~]원?$|^\([-+−△▲▽▼]?[\d.,]+%?\)$/;
|
|
@@ -431,7 +431,46 @@ function detectRulingLines(rgba, width, height, scale) {
|
|
|
431
431
|
};
|
|
432
432
|
const dotted = (m, base, step, span) => dottedRuns(m, base, step, span, minLenPx, dot.maxGap, dot.maxDash, dot.maxPeriod);
|
|
433
433
|
const horizontals = detectBands(ink, width, height, maxThickPx, false, solid);
|
|
434
|
+
const filledAt = (x, h) => {
|
|
435
|
+
const yt = Math.round(h.y1 - h.thicknessPx / 2) - 2, yb = Math.round(h.y1 + h.thicknessPx / 2) + 2;
|
|
436
|
+
return yt >= 0 && yb < height && ink[yt * width + x] === 1 && ink[yb * width + x] === 1;
|
|
437
|
+
};
|
|
438
|
+
const trimFilled = (h) => {
|
|
439
|
+
let x1 = Math.round(h.x1), x2 = Math.round(h.x2);
|
|
440
|
+
while (x1 < x2 && filledAt(x1, h)) x1++;
|
|
441
|
+
while (x2 > x1 && filledAt(x2, h)) x2--;
|
|
442
|
+
return x2 - x1 + 1 >= minLenPx ? { ...h, x1, x2, isolated: true } : null;
|
|
443
|
+
};
|
|
444
|
+
const hAdd = detectBands(ink, width, height, maxThickPx, false, solid, true).map(trimFilled).filter((h) => h !== null).filter((h) => !horizontals.some((p) => Math.abs(p.y1 - h.y1) <= maxThickPx && Math.min(p.x2, h.x2) - Math.max(p.x1, h.x1) > (h.x2 - h.x1) * 0.5));
|
|
445
|
+
const baseH = horizontals.length;
|
|
446
|
+
horizontals.push(...hAdd);
|
|
434
447
|
const verticals = detectBands(ink, width, height, maxThickPx, true, solid);
|
|
448
|
+
const faint = (x, y) => {
|
|
449
|
+
const l = luma[y * width + x];
|
|
450
|
+
return l > INK_LUMA_MAX && l <= 230 && x >= 3 && x + 3 < width && l + 20 <= Math.min(luma[y * width + x - 3], luma[y * width + x + 3]);
|
|
451
|
+
};
|
|
452
|
+
for (const v of verticals) {
|
|
453
|
+
const xs = [Math.round(v.x1) - 1, Math.round(v.x1), Math.round(v.x1) + 1];
|
|
454
|
+
const cross = (y) => xs.some((x) => x >= 3 && x + 3 < width && luma[y * width + x] <= INK_LUMA_MAX && luma[y * width + x - 3] <= INK_LUMA_MAX && luma[y * width + x + 3] <= INK_LUMA_MAX);
|
|
455
|
+
const at = (y) => xs.some((x) => faint(x, y));
|
|
456
|
+
for (const dir of [1, -1]) {
|
|
457
|
+
let y = dir > 0 ? Math.round(v.y2) + 1 : Math.round(v.y1) - 1, end = y - dir, gap2 = 0;
|
|
458
|
+
while (y >= 0 && y < height && gap2 <= GAP_TOL_PX) {
|
|
459
|
+
if (at(y)) {
|
|
460
|
+
end = y;
|
|
461
|
+
gap2 = 0;
|
|
462
|
+
} else if (!cross(y)) gap2++;
|
|
463
|
+
y += dir;
|
|
464
|
+
}
|
|
465
|
+
if (Math.abs(end - (dir > 0 ? v.y2 : v.y1)) < minLenPx) continue;
|
|
466
|
+
if (!horizontals.some((h) => Math.abs(h.y1 - end) <= maxThickPx * 2 && h.x1 <= v.x1 + maxThickPx && h.x2 >= v.x1 - maxThickPx)) continue;
|
|
467
|
+
if (!verticals.some((o) => o !== v && Math.abs((dir > 0 ? o.y2 : o.y1) - end) <= maxThickPx * 2)) continue;
|
|
468
|
+
if (dir > 0) v.y2 = end;
|
|
469
|
+
else v.y1 = end;
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
const meets = (h) => new Set(verticals.filter((v) => v.x1 >= h.x1 - maxThickPx && v.x1 <= h.x2 + maxThickPx && h.y1 >= v.y1 - maxThickPx && h.y1 <= v.y2 + maxThickPx).map((v) => Math.round(v.x1 / 4))).size >= 2;
|
|
473
|
+
horizontals.splice(baseH, hAdd.length, ...hAdd.filter((h) => h.thicknessPx <= 3 && meets(h)));
|
|
435
474
|
const dotH = detectBands(ink, width, height, maxThickPx, false, dotted);
|
|
436
475
|
const dotV = detectBands(ink, width, height, maxThickPx, true, dotted);
|
|
437
476
|
const tol = Math.max(2, Math.round(DOT_TOUCH_PT * scale));
|
|
@@ -562,10 +601,10 @@ function detectRulingLines(rgba, width, height, scale) {
|
|
|
562
601
|
}
|
|
563
602
|
}
|
|
564
603
|
if (frames.length) {
|
|
565
|
-
const
|
|
566
|
-
for (let p = 0; p <
|
|
567
|
-
const hs = detectBands(
|
|
568
|
-
const vs = detectBands(
|
|
604
|
+
const faint2 = new Uint8Array(ink.length);
|
|
605
|
+
for (let p = 0; p < faint2.length; p++) if (luma[p] <= 240 && rgba[p * 4 + 3] >= 128) faint2[p] = 1;
|
|
606
|
+
const hs = detectBands(faint2, width, height, maxThickPx, false, solid);
|
|
607
|
+
const vs = detectBands(faint2, width, height, maxThickPx, true, solid);
|
|
569
608
|
for (const f of frames) {
|
|
570
609
|
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);
|
|
571
610
|
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);
|
|
@@ -717,7 +756,7 @@ function dottedRuns(mask, base, step, span, minLenPx, maxGap, maxDash, maxPeriod
|
|
|
717
756
|
flush();
|
|
718
757
|
return runs;
|
|
719
758
|
}
|
|
720
|
-
function detectBands(ink, width, height, maxThickPx, transpose, readRuns) {
|
|
759
|
+
function detectBands(ink, width, height, maxThickPx, transpose, readRuns, prevRun = false) {
|
|
721
760
|
const lines = transpose ? width : height;
|
|
722
761
|
const span = transpose ? height : width;
|
|
723
762
|
const step = transpose ? width : 1;
|
|
@@ -737,6 +776,7 @@ function detectBands(ink, width, height, maxThickPx, transpose, readRuns) {
|
|
|
737
776
|
const emit = (b) => {
|
|
738
777
|
const thick = b.last - b.first + 1;
|
|
739
778
|
if (thick > maxThickPx) return;
|
|
779
|
+
if (prevRun && (surroundInkRatio(b, b.first - 2) >= SURROUND_INK_RATIO || surroundInkRatio(b, b.last + 2) >= SURROUND_INK_RATIO)) return;
|
|
740
780
|
if (surroundInkRatio(b, b.first - 2) >= SURROUND_INK_RATIO && surroundInkRatio(b, b.last + 2) >= SURROUND_INK_RATIO) return;
|
|
741
781
|
const center = (b.first + b.last) / 2;
|
|
742
782
|
out.push(
|
|
@@ -756,11 +796,15 @@ function detectBands(ink, width, height, maxThickPx, transpose, readRuns) {
|
|
|
756
796
|
for (let r = 0; r < runs.length; r++) {
|
|
757
797
|
if (used.has(r)) continue;
|
|
758
798
|
const run = runs[r];
|
|
759
|
-
const
|
|
760
|
-
const
|
|
761
|
-
|
|
799
|
+
const lo = prevRun ? band.plo : band.lo, hi = prevRun ? band.phi : band.hi;
|
|
800
|
+
const overlap = Math.min(hi, run.hi) - Math.max(lo, run.lo) + 1;
|
|
801
|
+
const prevLen = hi - lo + 1, runLen = run.hi - run.lo + 1;
|
|
802
|
+
const shorter = Math.min(prevLen, runLen);
|
|
803
|
+
if (overlap >= shorter * BAND_OVERLAP_RATIO && (!prevRun || shorter * 2 >= Math.max(prevLen, runLen))) {
|
|
762
804
|
band.lo = Math.min(band.lo, run.lo);
|
|
763
805
|
band.hi = Math.max(band.hi, run.hi);
|
|
806
|
+
band.plo = run.lo;
|
|
807
|
+
band.phi = run.hi;
|
|
764
808
|
band.last = line;
|
|
765
809
|
next.push(band);
|
|
766
810
|
used.add(r);
|
|
@@ -771,7 +815,7 @@ function detectBands(ink, width, height, maxThickPx, transpose, readRuns) {
|
|
|
771
815
|
if (!merged) emit(band);
|
|
772
816
|
}
|
|
773
817
|
for (let r = 0; r < runs.length; r++) {
|
|
774
|
-
if (!used.has(r)) next.push({ lo: runs[r].lo, hi: runs[r].hi, first: line, last: line });
|
|
818
|
+
if (!used.has(r)) next.push({ lo: runs[r].lo, hi: runs[r].hi, first: line, last: line, plo: runs[r].lo, phi: runs[r].hi });
|
|
775
819
|
}
|
|
776
820
|
open = next;
|
|
777
821
|
}
|
|
@@ -2686,22 +2730,66 @@ function categoryRow(items, v) {
|
|
|
2686
2730
|
const words = line.reduce((n, it) => n + it.text.trim().split(/\s+/).length, 0);
|
|
2687
2731
|
return words >= 2 && Math.max(...line.map((it) => it.x + it.w)) > v.x2 + 6 * v.h ? line : [];
|
|
2688
2732
|
}
|
|
2733
|
+
function forestPlotItems(items, horizontals, drop) {
|
|
2734
|
+
const cy = (it) => it.y + it.h / 2;
|
|
2735
|
+
for (const hz of [...horizontals, ...linearAxes(items)]) {
|
|
2736
|
+
const h = hz.h;
|
|
2737
|
+
const label = items.some((it) => cy(it) > hz.y1 - 3 * h && cy(it) < hz.y2 + 3 * h && /favou?rs?|better|우세/i.test(it.text));
|
|
2738
|
+
if (!label) continue;
|
|
2739
|
+
const rows = [...new Set(items.map(cy))].sort((a, b) => a - b);
|
|
2740
|
+
const at = rows.findIndex((y) => y >= hz.y1);
|
|
2741
|
+
let top = hz.y1, bottom = hz.y2;
|
|
2742
|
+
for (let i = at - 1; i >= 0 && rows[i + 1] - rows[i] <= 2.5 * h; i--) top = rows[i];
|
|
2743
|
+
const caption = (y) => items.some((it) => Math.abs(cy(it) - y) < h * 0.5 && /^(그림|Figure|Fig\.|표)\s*\d/.test(it.text.trim()));
|
|
2744
|
+
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];
|
|
2745
|
+
items.forEach((it, i) => {
|
|
2746
|
+
if (cy(it) >= top - h * 0.5 && cy(it) <= bottom + h * 0.5) drop.add(i);
|
|
2747
|
+
});
|
|
2748
|
+
}
|
|
2749
|
+
}
|
|
2750
|
+
function linearAxes(items) {
|
|
2751
|
+
const nums = items.filter((it) => number(it.text) !== null);
|
|
2752
|
+
const out = [];
|
|
2753
|
+
const used = /* @__PURE__ */ new Set();
|
|
2754
|
+
for (const seed of nums) {
|
|
2755
|
+
if (used.has(seed)) continue;
|
|
2756
|
+
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);
|
|
2757
|
+
if (row.length < 3) continue;
|
|
2758
|
+
const pts = row.map((it) => ({ pos: it.x + it.w / 2, value: number(it.text) }));
|
|
2759
|
+
const slopes = pts.slice(1).map((p, i) => (p.pos - pts[i].pos) / (p.value - pts[i].value));
|
|
2760
|
+
if (slopes.some((k) => !(k > 0)) || Math.max(...slopes) > Math.min(...slopes) * 1.25) continue;
|
|
2761
|
+
for (const it of row) used.add(it);
|
|
2762
|
+
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 });
|
|
2763
|
+
}
|
|
2764
|
+
return out;
|
|
2765
|
+
}
|
|
2689
2766
|
function chartPlotItems(items) {
|
|
2690
2767
|
const drop = /* @__PURE__ */ new Set();
|
|
2691
2768
|
const verticals = valueAxes(items);
|
|
2692
|
-
if (!verticals.length) return drop;
|
|
2693
2769
|
const horizontals = timeAxes(items);
|
|
2770
|
+
forestPlotItems(items, horizontals, drop);
|
|
2771
|
+
if (!verticals.length) return drop;
|
|
2694
2772
|
for (const v of verticals) {
|
|
2695
2773
|
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);
|
|
2696
2774
|
const cats = hz ? [] : categoryRow(items, v);
|
|
2697
2775
|
if (!hz && cats.length === 0) continue;
|
|
2698
2776
|
const bottom = hz ? hz.y2 + 2.5 * v.h : Math.max(...cats.map((c) => c.y + c.h)) + 0.5 * v.h;
|
|
2699
2777
|
const right = hz ? hz.x2 + 2 * v.h : Math.max(...cats.map((c) => c.x + c.w)) + v.h;
|
|
2700
|
-
const x1 = v.x1 - 5 * v.h, x2 = right, y1 = v.y1 -
|
|
2778
|
+
const x1 = v.x1 - 5 * v.h, x2 = right, y1 = v.y1 - Math.max(1.5 * v.h, v.gap ?? 0), y2 = bottom;
|
|
2701
2779
|
items.forEach((it, i) => {
|
|
2702
2780
|
const cx = it.x + it.w / 2, cy = it.y + it.h / 2;
|
|
2703
2781
|
if (cx >= x1 && cx <= x2 && cy >= y1 && cy <= y2 && it.x >= x1 - v.h && it.x + it.w <= x2 + v.h) drop.add(i);
|
|
2704
2782
|
});
|
|
2783
|
+
const cyOf = (it) => it.y + it.h / 2;
|
|
2784
|
+
const risk = items.find((it) => cyOf(it) > y2 - v.h && cyOf(it) < y2 + 4 * v.h && /at\s*risk|위험\s*(대상|인원)/i.test(it.text));
|
|
2785
|
+
if (risk) {
|
|
2786
|
+
const rows = [...new Set(items.map(cyOf))].sort((a, b) => a - b);
|
|
2787
|
+
let end = cyOf(risk);
|
|
2788
|
+
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];
|
|
2789
|
+
items.forEach((it, i) => {
|
|
2790
|
+
if (cyOf(it) >= cyOf(risk) - v.h * 0.5 && cyOf(it) <= end + v.h * 0.5) drop.add(i);
|
|
2791
|
+
});
|
|
2792
|
+
}
|
|
2705
2793
|
}
|
|
2706
2794
|
return drop;
|
|
2707
2795
|
}
|
|
@@ -3057,6 +3145,7 @@ async function ocrOnePage(page, pageNo, mode, engine, warnings, detectTables, ve
|
|
|
3057
3145
|
let { rgba: upright, angle } = vectorOps || regions ? { rgba, angle: 0 } : deskewPage(rgba, rw, rh);
|
|
3058
3146
|
const stats = { droppedLowConf: 0, ...config.lines === "all" ? { dropped: [] } : {} };
|
|
3059
3147
|
let ruling = vectorOps ? void 0 : detectRulingLines(upright, rw, rh, rh / pdfH);
|
|
3148
|
+
if (ruling && regions) ruling = { ...ruling, horizontals: ruling.horizontals.filter((h) => !h.isolated) };
|
|
3060
3149
|
const tuning = regions ? regionTuning(config.tuning) : vectorOps ? { ...config.tuning, orientPage: false } : config.tuning;
|
|
3061
3150
|
let items = await recognizeOcrPage(
|
|
3062
3151
|
engine,
|
|
@@ -3414,4 +3503,4 @@ export {
|
|
|
3414
3503
|
ocrItemsToBlocks,
|
|
3415
3504
|
markOcrHeadings
|
|
3416
3505
|
};
|
|
3417
|
-
//# sourceMappingURL=chunk-
|
|
3506
|
+
//# sourceMappingURL=chunk-AQ2MNHLW.js.map
|