kordoc 4.25.21 → 4.25.23
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/{chunk-PVOLFVXE.js → chunk-2PQMHHX4.js} +2 -2
- package/dist/{chunk-6I3X54AQ.js → chunk-377GAL46.js} +2 -2
- package/dist/{chunk-ZCMMU34Z.js → chunk-3IVEGZI3.js} +2 -2
- package/dist/{chunk-5ULHNZ3P.js → chunk-7LW2HG7F.js} +3 -3
- package/dist/{chunk-LSUTK3DH.js → chunk-7S4KRBXC.js} +2 -2
- package/dist/{chunk-COJYQKGH.js → chunk-B3LK5RVY.js} +83 -4
- package/dist/chunk-B3LK5RVY.js.map +7 -0
- package/dist/{chunk-QNJ2LMUO.js → chunk-BXHO5BB5.js} +8 -8
- package/dist/{chunk-HQILGS2O.js → chunk-GMYXTUSJ.js} +2 -2
- package/dist/{chunk-6MCJHRSM.js → chunk-GZX5UQ4P.js} +2 -2
- package/dist/{chunk-3AYNFK6J.js → chunk-IRR32NHL.js} +2 -2
- package/dist/{chunk-FDSFXE2L.js → chunk-J4OTJFSW.js} +2 -2
- package/dist/{chunk-TI6S3KZF.js → chunk-K5ZUKPU3.js} +2 -2
- package/dist/{chunk-W5AHXAUP.js → chunk-LTXF66N6.js} +7 -7
- package/dist/{chunk-B2SRYWEY.js → chunk-MJ2B3EXE.js} +19 -1
- package/dist/{chunk-B2SRYWEY.js.map → chunk-MJ2B3EXE.js.map} +2 -2
- package/dist/{chunk-TYJSNW4Z.js → chunk-MMJIFTWZ.js} +131 -32
- package/dist/chunk-MMJIFTWZ.js.map +7 -0
- package/dist/{chunk-MWCJYIJC.js → chunk-MPEWMDM2.js} +19 -19
- package/dist/{chunk-DHXKCDAU.js → chunk-NFMC6FLB.js} +66 -9
- package/dist/chunk-NFMC6FLB.js.map +7 -0
- package/dist/{chunk-ZO4P735U.js → chunk-PGBRNQAF.js} +2 -2
- package/dist/{chunk-PFNZQ3XI.js → chunk-PQIIJRV2.js} +2 -2
- package/dist/{chunk-S553BW45.js → chunk-QAQDSBAC.js} +6 -6
- package/dist/{chunk-XUBBFY3H.js → chunk-QI7LT4AX.js} +6 -6
- package/dist/{chunk-XUBBFY3H.js.map → chunk-QI7LT4AX.js.map} +2 -2
- package/dist/{chunk-QOCUFTT4.js → chunk-SE5HAJNL.js} +5 -5
- package/dist/{chunk-5MDRUEHP.js → chunk-SKZ2LLN5.js} +237 -4
- package/dist/chunk-SKZ2LLN5.js.map +1 -0
- package/dist/{chunk-KW4JO5CV.js → chunk-TYANRH6O.js} +3 -3
- package/dist/{chunk-DZOA5N5W.js → chunk-WLHQL53U.js} +2 -2
- package/dist/{chunk-24LB25LZ.js → chunk-YDOIXWSF.js} +2 -2
- package/dist/{chunk-GJORKM42.js → chunk-YWRAHQTV.js} +2 -2
- package/dist/chunks-A2NELZR2.js +10 -0
- package/dist/cli.js +38 -38
- package/dist/{formula-HMKT4BZL.js → formula-LUPB363D.js} +4 -4
- package/dist/generator-MK3VLXV2.js +18 -0
- package/dist/{hancom-QWJBWOOE.js → hancom-24SHJFWF.js} +2 -2
- package/dist/{image-ocr-P5AIZNT3.js → image-ocr-CSV7OLPX.js} +11 -11
- package/dist/index.cjs +517 -30
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +22 -22
- package/dist/mcp.js +34 -34
- package/dist/memo-5G32P322.js +15 -0
- package/dist/{model-bundle-5CXCIZHZ.js → model-bundle-U6ONSDTJ.js} +5 -5
- package/dist/{models-PS4L7NLP.js → models-X4FVLSSQ.js} +5 -5
- package/dist/{page-images-QW7IUTUB.js → page-images-E67SJN3S.js} +2 -2
- package/dist/{parse-worker-v2-PRH6KVKP.js → parse-worker-v2-3VY5X7SF.js} +24 -24
- package/dist/{parser-OQIR5ZMI.js → parser-6GFE6B42.js} +14 -14
- package/dist/{pdf-ocr-ZH4JAUTR.js → pdf-ocr-MKQURNXT.js} +9 -9
- package/dist/{profile-io-JFRAM2VE.js → profile-io-DAZZHP7S.js} +3 -3
- package/dist/{rasterize-JJOMUTYX.js → rasterize-BJTBPSDM.js} +3 -3
- package/dist/{redact-doc-A7TW4MNF.js → redact-doc-W6H7SXGB.js} +23 -23
- package/dist/{render-VAOMAQV2.js → render-HJDMKGMV.js} +10 -10
- package/dist/{rewrite-fallback-7PR7V3AZ.js → rewrite-fallback-VKA6BLLT.js} +13 -13
- package/dist/seal-5KR6SUIU.js +14 -0
- package/dist/{setup-6DXZJQCT.js → setup-UGWQLJ5Z.js} +3 -3
- package/dist/{to-hwpx-A56R6H27.js → to-hwpx-WI5CGWDZ.js} +7 -7
- package/dist/visual-YDMDCB7Q.js +42 -0
- package/dist/{watch-7W6CKGX7.js → watch-CIO5522I.js} +23 -23
- package/package.json +1 -1
- package/dist/chunk-5MDRUEHP.js.map +0 -1
- package/dist/chunk-COJYQKGH.js.map +0 -7
- package/dist/chunk-DHXKCDAU.js.map +0 -7
- package/dist/chunk-TYJSNW4Z.js.map +0 -7
- package/dist/chunks-XX7RHVQF.js +0 -10
- package/dist/generator-HOY4SZ26.js +0 -18
- package/dist/memo-Q7772VJD.js +0 -15
- package/dist/seal-RZZNRJFL.js +0 -14
- package/dist/visual-25RY7EFI.js +0 -42
- /package/dist/{chunk-PVOLFVXE.js.map → chunk-2PQMHHX4.js.map} +0 -0
- /package/dist/{chunk-6I3X54AQ.js.map → chunk-377GAL46.js.map} +0 -0
- /package/dist/{chunk-ZCMMU34Z.js.map → chunk-3IVEGZI3.js.map} +0 -0
- /package/dist/{chunk-5ULHNZ3P.js.map → chunk-7LW2HG7F.js.map} +0 -0
- /package/dist/{chunk-LSUTK3DH.js.map → chunk-7S4KRBXC.js.map} +0 -0
- /package/dist/{chunk-QNJ2LMUO.js.map → chunk-BXHO5BB5.js.map} +0 -0
- /package/dist/{chunk-HQILGS2O.js.map → chunk-GMYXTUSJ.js.map} +0 -0
- /package/dist/{chunk-6MCJHRSM.js.map → chunk-GZX5UQ4P.js.map} +0 -0
- /package/dist/{chunk-3AYNFK6J.js.map → chunk-IRR32NHL.js.map} +0 -0
- /package/dist/{chunk-FDSFXE2L.js.map → chunk-J4OTJFSW.js.map} +0 -0
- /package/dist/{chunk-TI6S3KZF.js.map → chunk-K5ZUKPU3.js.map} +0 -0
- /package/dist/{chunk-W5AHXAUP.js.map → chunk-LTXF66N6.js.map} +0 -0
- /package/dist/{chunk-MWCJYIJC.js.map → chunk-MPEWMDM2.js.map} +0 -0
- /package/dist/{chunk-ZO4P735U.js.map → chunk-PGBRNQAF.js.map} +0 -0
- /package/dist/{chunk-PFNZQ3XI.js.map → chunk-PQIIJRV2.js.map} +0 -0
- /package/dist/{chunk-S553BW45.js.map → chunk-QAQDSBAC.js.map} +0 -0
- /package/dist/{chunk-QOCUFTT4.js.map → chunk-SE5HAJNL.js.map} +0 -0
- /package/dist/{chunk-KW4JO5CV.js.map → chunk-TYANRH6O.js.map} +0 -0
- /package/dist/{chunk-DZOA5N5W.js.map → chunk-WLHQL53U.js.map} +0 -0
- /package/dist/{chunk-24LB25LZ.js.map → chunk-YDOIXWSF.js.map} +0 -0
- /package/dist/{chunk-GJORKM42.js.map → chunk-YWRAHQTV.js.map} +0 -0
- /package/dist/{chunks-XX7RHVQF.js.map → chunks-A2NELZR2.js.map} +0 -0
- /package/dist/{formula-HMKT4BZL.js.map → formula-LUPB363D.js.map} +0 -0
- /package/dist/{generator-HOY4SZ26.js.map → generator-MK3VLXV2.js.map} +0 -0
- /package/dist/{hancom-QWJBWOOE.js.map → hancom-24SHJFWF.js.map} +0 -0
- /package/dist/{image-ocr-P5AIZNT3.js.map → image-ocr-CSV7OLPX.js.map} +0 -0
- /package/dist/{memo-Q7772VJD.js.map → memo-5G32P322.js.map} +0 -0
- /package/dist/{model-bundle-5CXCIZHZ.js.map → model-bundle-U6ONSDTJ.js.map} +0 -0
- /package/dist/{models-PS4L7NLP.js.map → models-X4FVLSSQ.js.map} +0 -0
- /package/dist/{page-images-QW7IUTUB.js.map → page-images-E67SJN3S.js.map} +0 -0
- /package/dist/{parse-worker-v2-PRH6KVKP.js.map → parse-worker-v2-3VY5X7SF.js.map} +0 -0
- /package/dist/{parser-OQIR5ZMI.js.map → parser-6GFE6B42.js.map} +0 -0
- /package/dist/{pdf-ocr-ZH4JAUTR.js.map → pdf-ocr-MKQURNXT.js.map} +0 -0
- /package/dist/{profile-io-JFRAM2VE.js.map → profile-io-DAZZHP7S.js.map} +0 -0
- /package/dist/{rasterize-JJOMUTYX.js.map → rasterize-BJTBPSDM.js.map} +0 -0
- /package/dist/{redact-doc-A7TW4MNF.js.map → redact-doc-W6H7SXGB.js.map} +0 -0
- /package/dist/{render-VAOMAQV2.js.map → render-HJDMKGMV.js.map} +0 -0
- /package/dist/{rewrite-fallback-7PR7V3AZ.js.map → rewrite-fallback-VKA6BLLT.js.map} +0 -0
- /package/dist/{seal-RZZNRJFL.js.map → seal-5KR6SUIU.js.map} +0 -0
- /package/dist/{setup-6DXZJQCT.js.map → setup-UGWQLJ5Z.js.map} +0 -0
- /package/dist/{to-hwpx-A56R6H27.js.map → to-hwpx-WI5CGWDZ.js.map} +0 -0
- /package/dist/{visual-25RY7EFI.js.map → visual-YDMDCB7Q.js.map} +0 -0
- /package/dist/{watch-7W6CKGX7.js.map → watch-CIO5522I.js.map} +0 -0
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import {
|
|
2
2
|
patchZipEntries
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-GZX5UQ4P.js";
|
|
4
4
|
import {
|
|
5
5
|
applySplices,
|
|
6
6
|
scanSectionXml
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-MJ2B3EXE.js";
|
|
8
8
|
import {
|
|
9
9
|
parseRenderStyles,
|
|
10
10
|
readZipEntry
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-377GAL46.js";
|
|
12
12
|
import {
|
|
13
13
|
KordocError,
|
|
14
14
|
precheckZipSize
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-YDOIXWSF.js";
|
|
16
16
|
|
|
17
17
|
// src/form/seal.ts
|
|
18
18
|
import JSZip from "jszip";
|
|
@@ -318,4 +318,4 @@ export {
|
|
|
318
318
|
collectSites,
|
|
319
319
|
placeSealHwpx
|
|
320
320
|
};
|
|
321
|
-
//# sourceMappingURL=chunk-
|
|
321
|
+
//# sourceMappingURL=chunk-SE5HAJNL.js.map
|
|
@@ -9,11 +9,11 @@ import {
|
|
|
9
9
|
HEADING_RATIO_H3,
|
|
10
10
|
tidyScriptTags,
|
|
11
11
|
toTex
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-YWRAHQTV.js";
|
|
13
13
|
import {
|
|
14
14
|
safeMax,
|
|
15
15
|
safeMin
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-YDOIXWSF.js";
|
|
17
17
|
|
|
18
18
|
// src/ocr/line-split.ts
|
|
19
19
|
function grayCrop(rgba, pageW, box) {
|
|
@@ -1080,6 +1080,220 @@ function stackedGlyphBands(gray, w, h, ink) {
|
|
|
1080
1080
|
const bands = splitRowBands(gray, w, h, ink, 0.45);
|
|
1081
1081
|
return bands.length >= 2 && bands.length <= 4 ? bands : null;
|
|
1082
1082
|
}
|
|
1083
|
+
function checkboxFrames(gray, w, h, ink) {
|
|
1084
|
+
if (!ink.darkInk || h < 12 || w < h) return [];
|
|
1085
|
+
const sorted = Uint8Array.from(gray).sort(), bg = sorted[sorted.length >> 1];
|
|
1086
|
+
let n = 0, sum = 0;
|
|
1087
|
+
for (let i = 0; i < gray.length; i++) if (gray[i] <= ink.threshold) {
|
|
1088
|
+
n++;
|
|
1089
|
+
sum += gray[i];
|
|
1090
|
+
}
|
|
1091
|
+
const dk = n ? sum / n : bg;
|
|
1092
|
+
if (bg - dk < 40) return [];
|
|
1093
|
+
const k = Math.max(2, Math.round(h * 0.05)), delta = Math.max(10, (bg - dk) * 0.12), mark = bg - (bg - dk) * 0.5;
|
|
1094
|
+
const at = (x, y) => gray[Math.min(h - 1, Math.max(0, y)) * w + Math.min(w - 1, Math.max(0, x))];
|
|
1095
|
+
const V = new Uint8Array(w * h), H = new Uint8Array(w * h);
|
|
1096
|
+
for (let y = 0; y < h; y++) for (let x = 0; x < w; x++) {
|
|
1097
|
+
const v = gray[y * w + x];
|
|
1098
|
+
if (v < Math.min(at(x - k, y), at(x + k, y)) - delta) V[y * w + x] = 1;
|
|
1099
|
+
if (v < Math.min(at(x, y - k), at(x, y + k)) - delta) H[y * w + x] = 1;
|
|
1100
|
+
}
|
|
1101
|
+
const inside = (x, y) => x >= 0 && x < w && y >= 0 && y < h;
|
|
1102
|
+
const vr = (x, y) => inside(x, y) && V[y * w + x] === 1;
|
|
1103
|
+
const hr = (x, y) => inside(x, y) && H[y * w + x] === 1;
|
|
1104
|
+
const dark = (x, y) => inside(x, y) && gray[y * w + x] < mark;
|
|
1105
|
+
const sMin = Math.max(8, h * 0.15), sMax = h;
|
|
1106
|
+
const gap = Math.max(1, Math.round(h * 0.04));
|
|
1107
|
+
const vmap = (any) => {
|
|
1108
|
+
const src = any ? VD : V, m = new Uint8Array(w * h);
|
|
1109
|
+
for (let i = 0; i < w * h; i++) {
|
|
1110
|
+
const x = i % w;
|
|
1111
|
+
m[i] = src[i] | (x > 0 ? src[i - 1] : 0) | (x + 1 < w ? src[i + 1] : 0);
|
|
1112
|
+
}
|
|
1113
|
+
const p = new Int32Array(w * (h + 1));
|
|
1114
|
+
for (let x = 0; x < w; x++) for (let y = 0; y < h; y++) {
|
|
1115
|
+
let on = 0;
|
|
1116
|
+
for (let d = -gap; d <= gap && !on; d++) {
|
|
1117
|
+
const yy = y + d;
|
|
1118
|
+
if (yy >= 0 && yy < h && m[yy * w + x]) on = 1;
|
|
1119
|
+
}
|
|
1120
|
+
p[(y + 1) * w + x] = p[y * w + x] + on;
|
|
1121
|
+
}
|
|
1122
|
+
return p;
|
|
1123
|
+
};
|
|
1124
|
+
const hmap = (any) => {
|
|
1125
|
+
const src = any ? HD : H, m = new Uint8Array(w * h);
|
|
1126
|
+
for (let i = 0; i < w * h; i++) m[i] = src[i] | (i >= w ? src[i - w] : 0) | (i + w < w * h ? src[i + w] : 0);
|
|
1127
|
+
const p = new Int32Array((w + 1) * h);
|
|
1128
|
+
for (let y = 0; y < h; y++) for (let x = 0; x < w; x++) {
|
|
1129
|
+
let on = 0;
|
|
1130
|
+
for (let d = -gap; d <= gap && !on; d++) {
|
|
1131
|
+
const xx = x + d;
|
|
1132
|
+
if (xx >= 0 && xx < w && m[y * w + xx]) on = 1;
|
|
1133
|
+
}
|
|
1134
|
+
p[y * (w + 1) + x + 1] = p[y * (w + 1) + x] + on;
|
|
1135
|
+
}
|
|
1136
|
+
return p;
|
|
1137
|
+
};
|
|
1138
|
+
const VD = new Uint8Array(w * h), HD = new Uint8Array(w * h);
|
|
1139
|
+
for (let i = 0; i < w * h; i++) {
|
|
1140
|
+
const dk2 = gray[i] < mark ? 1 : 0;
|
|
1141
|
+
VD[i] = V[i] | dk2;
|
|
1142
|
+
HD[i] = H[i] | dk2;
|
|
1143
|
+
}
|
|
1144
|
+
const VA = vmap(true), VR = vmap(false), HA = hmap(true), HR = hmap(false);
|
|
1145
|
+
const vside = (x, ya, yb, any) => {
|
|
1146
|
+
const p = any ? VA : VR;
|
|
1147
|
+
return (p[(yb + 1) * w + x] - p[ya * w + x]) / (yb - ya + 1);
|
|
1148
|
+
};
|
|
1149
|
+
const hside = (xa, xb, y, any) => {
|
|
1150
|
+
if (y < 0 || y >= h) return 0;
|
|
1151
|
+
const p = any ? HA : HR;
|
|
1152
|
+
return (p[y * (w + 1) + xb + 1] - p[y * (w + 1) + xa]) / (xb - xa + 1);
|
|
1153
|
+
};
|
|
1154
|
+
const hbest = (xa, xb, y, any) => Math.max(hside(xa, xb, y - 2, any), hside(xa, xb, y - 1, any), hside(xa, xb, y, any), hside(xa, xb, y + 1, any), hside(xa, xb, y + 2, any));
|
|
1155
|
+
const strokes = [];
|
|
1156
|
+
for (let x = 0; x < w; x++) {
|
|
1157
|
+
let best = 0, bestTop = 0, start = -1, miss = 0;
|
|
1158
|
+
for (let y = 0; y <= h; y++) {
|
|
1159
|
+
if (y < h && (vr(x - 1, y) || vr(x, y) || vr(x + 1, y))) {
|
|
1160
|
+
if (start < 0) start = y;
|
|
1161
|
+
miss = 0;
|
|
1162
|
+
} else if (start >= 0 && (y === h || ++miss > gap)) {
|
|
1163
|
+
const l = (y === h ? h - 1 - miss : y - miss) - start + 1;
|
|
1164
|
+
if (l > best) {
|
|
1165
|
+
best = l;
|
|
1166
|
+
bestTop = start;
|
|
1167
|
+
}
|
|
1168
|
+
start = -1;
|
|
1169
|
+
miss = 0;
|
|
1170
|
+
}
|
|
1171
|
+
}
|
|
1172
|
+
if (best < sMin * 0.8) continue;
|
|
1173
|
+
const p = strokes[strokes.length - 1];
|
|
1174
|
+
if (p && x - p.x1 <= 1) {
|
|
1175
|
+
p.x1 = x;
|
|
1176
|
+
if (best > p.y1 - p.y0) {
|
|
1177
|
+
p.x = x;
|
|
1178
|
+
p.y0 = bestTop;
|
|
1179
|
+
p.y1 = bestTop + best;
|
|
1180
|
+
}
|
|
1181
|
+
} else strokes.push({ x0: x, x1: x, x, y0: bestTop, y1: bestTop + best });
|
|
1182
|
+
}
|
|
1183
|
+
const corner = (x, y) => {
|
|
1184
|
+
for (let dy = -1; dy <= 1; dy++) for (let dx = -1; dx <= 1; dx++) if (vr(x + dx, y + dy) || hr(x + dx, y + dy) || dark(x + dx, y + dy)) return true;
|
|
1185
|
+
return false;
|
|
1186
|
+
};
|
|
1187
|
+
const found = [], seen2 = /* @__PURE__ */ new Set();
|
|
1188
|
+
const lineStraight = (xc, y0, y1, outward, size) => {
|
|
1189
|
+
const ends = [];
|
|
1190
|
+
for (let y = y0 + 1; y <= y1 - 1; y++) for (let t = 3; t >= -3; t--) if (vr(xc + outward * t, y)) {
|
|
1191
|
+
ends.push(xc + outward * t);
|
|
1192
|
+
break;
|
|
1193
|
+
}
|
|
1194
|
+
if (ends.length < 3) return true;
|
|
1195
|
+
ends.sort((p, q) => p - q);
|
|
1196
|
+
return ends[Math.floor(ends.length * 0.9)] - ends[Math.floor(ends.length * 0.1)] <= Math.max(2, size * 0.06);
|
|
1197
|
+
};
|
|
1198
|
+
const tryBox = (lx, rx, ya, lw, rw) => {
|
|
1199
|
+
const d = rx - lx;
|
|
1200
|
+
const y0 = Math.max(0, ya), y1 = Math.min(h - 1, ya + d);
|
|
1201
|
+
if (d < sMin || d > sMax || lx < 0 || rx >= w || y1 - y0 < d * 0.8) return;
|
|
1202
|
+
const hook = Math.max(2, Math.round(d * 0.25));
|
|
1203
|
+
const lc = vside(lx, y0, y1, true), rc = vside(rx, y0, y1, true);
|
|
1204
|
+
if (lc < 0.75 || rc < 0.75) return;
|
|
1205
|
+
const tc = hbest(lx, rx, y0, true), bc = hbest(lx, rx, y1, true);
|
|
1206
|
+
const hooks = Math.min(hbest(lx, lx + hook, y0, true), hbest(rx - hook, rx, y0, true), hbest(lx, lx + hook, y1, true), hbest(rx - hook, rx, y1, true));
|
|
1207
|
+
const square = corner(lx, y0) && corner(rx, y0) && corner(lx, y1) && corner(rx, y1);
|
|
1208
|
+
const straight = (xc, outward) => lineStraight(xc, y0, y1, outward, d);
|
|
1209
|
+
const m = Math.max(2, Math.round(d * 0.2), lw + 2, rw + 2), ix0 = lx + m, ix1 = rx - m, iy0 = y0 + m, iy1 = y1 - m;
|
|
1210
|
+
if (ix1 <= ix0 || iy1 <= iy0) return;
|
|
1211
|
+
let c = 0, a = 0, mx0 = w, mx1 = -1;
|
|
1212
|
+
for (let y = iy0; y <= iy1; y++) for (let x = ix0; x <= ix1; x++) {
|
|
1213
|
+
a++;
|
|
1214
|
+
if (gray[y * w + x] < mark) {
|
|
1215
|
+
c++;
|
|
1216
|
+
if (x < mx0) mx0 = x;
|
|
1217
|
+
if (x > mx1) mx1 = x;
|
|
1218
|
+
}
|
|
1219
|
+
}
|
|
1220
|
+
const fill = c / a;
|
|
1221
|
+
if (fill >= 0.6) return;
|
|
1222
|
+
const checked = fill >= 0.06 && mx1 - mx0 + 1 >= (ix1 - ix0 + 1) * 0.35;
|
|
1223
|
+
const ink2 = (x, y) => vr(x, y) || hr(x, y);
|
|
1224
|
+
const any = (x, y) => ink2(x, y) || dark(x, y);
|
|
1225
|
+
const outer = (from, to, step, at2, ua, ub) => {
|
|
1226
|
+
for (let t = from; step > 0 ? t <= to : t >= to; t += step) for (let u = ua; u <= ub; u++) if (at2(t, u)) return t;
|
|
1227
|
+
return NaN;
|
|
1228
|
+
};
|
|
1229
|
+
const ex0 = Math.round(lx + d * 0.2), ex1 = Math.round(rx - d * 0.2), ey0 = Math.round(y0 + d * 0.2), ey1 = Math.round(y1 - d * 0.2);
|
|
1230
|
+
const top = outer(y0 - 3, y0 + 3, 1, (y, x) => ink2(x, y), ex0, ex1), bot = outer(y1 + 3, y1 - 3, -1, (y, x) => ink2(x, y), ex0, ex1);
|
|
1231
|
+
const lft = outer(lx - 3, lx + 3, 1, (x, y) => ink2(x, y), ey0, ey1), rgt = outer(rx + 3, rx - 3, -1, (x, y) => ink2(x, y), ey0, ey1);
|
|
1232
|
+
const cw = Math.max(1, Math.round(d * 0.1));
|
|
1233
|
+
const filled = (cx, cy, sx, sy) => {
|
|
1234
|
+
for (let i = 0; i < cw; i++) for (let j = 0; j < cw; j++) if (any(cx + sx * i, cy + sy * j)) return true;
|
|
1235
|
+
return false;
|
|
1236
|
+
};
|
|
1237
|
+
const corners = [top, bot, lft, rgt].some(isNaN) ? 0 : [filled(lft, top, 1, 1), filled(rgt, top, -1, 1), filled(lft, bot, 1, -1), filled(rgt, bot, -1, -1)].filter(Boolean).length;
|
|
1238
|
+
const kind = tc >= 0.75 && bc >= 0.75 ? corners >= (checked ? 2 : 3) ? "□" : null : square && hooks >= 0.6 && tc < 0.75 && bc < 0.75 && straight(lx, -1) && straight(rx, 1) ? "[]" : null;
|
|
1239
|
+
if (!kind) return;
|
|
1240
|
+
const ridge = kind === "□" ? [hbest(lx, rx, y0, false), hbest(lx, rx, y1, false)] : [Math.min(hbest(lx, lx + hook, y0, false), hbest(rx - hook, rx, y0, false)), Math.min(hbest(lx, lx + hook, y1, false), hbest(rx - hook, rx, y1, false))];
|
|
1241
|
+
const clear = [vside(lx, y0, y1, false), vside(rx, y0, y1, false), ...ridge].filter((v) => v >= 0.5).length >= 3;
|
|
1242
|
+
if (!clear) return;
|
|
1243
|
+
const key = `${lx - lw},${rx + rw},${y0}`;
|
|
1244
|
+
if (seen2.has(key)) return;
|
|
1245
|
+
seen2.add(key);
|
|
1246
|
+
found.push({ x0: Math.max(0, lx - lw), x1: Math.min(w - 1, rx + rw), y0, y1, kind, checked, score: lc + rc + Math.max(tc + bc, 2 * hooks) });
|
|
1247
|
+
};
|
|
1248
|
+
const tryBracket = (lx, rx, y0, y1, lw, rw) => {
|
|
1249
|
+
const len = y1 - y0, d = rx - lx, hook = Math.max(2, Math.round(len * 0.25)), gap2 = Math.max(1, Math.round(len * 0.08));
|
|
1250
|
+
if (vside(lx, y0, y1, false) < 0.75 || vside(rx, y0, y1, false) < 0.75) return;
|
|
1251
|
+
const hooks = Math.min(hbest(lx, lx + hook, y0, true), hbest(rx - hook, rx, y0, true), hbest(lx, lx + hook, y1, true), hbest(rx - hook, rx, y1, true));
|
|
1252
|
+
if (hooks < 0.6 || hbest(lx + hook + gap2, rx - hook - gap2, y0, true) >= 0.75 || hbest(lx + hook + gap2, rx - hook - gap2, y1, true) >= 0.75) return;
|
|
1253
|
+
const corners = [corner(lx, y0), corner(rx, y0), corner(lx, y1), corner(rx, y1)].every(Boolean);
|
|
1254
|
+
if (!corners || !lineStraight(lx, y0, y1, -1, len) || !lineStraight(rx, y0, y1, 1, len)) return;
|
|
1255
|
+
const m = Math.max(2, Math.round(len * 0.2), lw + 2, rw + 2), ix0 = lx + m, ix1 = rx - m, iy0 = y0 + m, iy1 = y1 - m;
|
|
1256
|
+
if (ix1 <= ix0 || iy1 <= iy0) return;
|
|
1257
|
+
let c = 0, a = 0, my0 = h, my1 = -1;
|
|
1258
|
+
for (let y = iy0; y <= iy1; y++) for (let x = ix0; x <= ix1; x++) {
|
|
1259
|
+
a++;
|
|
1260
|
+
if (gray[y * w + x] < mark) {
|
|
1261
|
+
c++;
|
|
1262
|
+
if (y < my0) my0 = y;
|
|
1263
|
+
if (y > my1) my1 = y;
|
|
1264
|
+
}
|
|
1265
|
+
}
|
|
1266
|
+
if (c / a >= 0.6) return;
|
|
1267
|
+
const checked = c / a >= 0.03 && my1 - my0 + 1 >= (iy1 - iy0 + 1) * 0.35;
|
|
1268
|
+
const key = `[${lx - lw},${rx + rw},${y0}`;
|
|
1269
|
+
if (seen2.has(key)) return;
|
|
1270
|
+
seen2.add(key);
|
|
1271
|
+
found.push({ x0: Math.max(0, lx - lw), x1: Math.min(w - 1, rx + rw), y0, y1, kind: "[]", checked, score: 2 + hooks * 2 });
|
|
1272
|
+
};
|
|
1273
|
+
for (let i = 0; i < strokes.length; i++) {
|
|
1274
|
+
const L = strokes[i], len = L.y1 - L.y0;
|
|
1275
|
+
for (let j = i + 1; j < strokes.length; j++) {
|
|
1276
|
+
const R = strokes[j], d = R.x - L.x;
|
|
1277
|
+
if (d < sMin) continue;
|
|
1278
|
+
if (d > sMax) break;
|
|
1279
|
+
if (L.x1 - L.x0 > d * 0.3 || R.x1 - R.x0 > d * 0.3) continue;
|
|
1280
|
+
for (const ya of /* @__PURE__ */ new Set([L.y0, R.y0, L.y1 - d, R.y1 - d])) tryBox(L.x, R.x, ya, L.x1 - L.x0, R.x1 - R.x0);
|
|
1281
|
+
}
|
|
1282
|
+
if (L.x1 - L.x0 <= len * 0.3) for (const d of [len - 1, len, len + 1]) {
|
|
1283
|
+
tryBox(L.x - d, L.x, L.y0, L.x1 - L.x0, L.x1 - L.x0);
|
|
1284
|
+
tryBox(L.x, L.x + d, L.y0, L.x1 - L.x0, L.x1 - L.x0);
|
|
1285
|
+
}
|
|
1286
|
+
for (let j = i + 1; j < strokes.length; j++) {
|
|
1287
|
+
const R = strokes[j], d = R.x - L.x, rlen = R.y1 - R.y0;
|
|
1288
|
+
if (d > len * 2.5) break;
|
|
1289
|
+
if (d < len * 0.6 || d < sMin || Math.abs(rlen - len) > len * 0.25) continue;
|
|
1290
|
+
const y0 = Math.max(L.y0, R.y0), y1 = Math.min(L.y1, R.y1) - 1;
|
|
1291
|
+
if (y1 - y0 < len * 0.8) continue;
|
|
1292
|
+
tryBracket(L.x, R.x, y0, y1, L.x1 - L.x0, R.x1 - R.x0);
|
|
1293
|
+
}
|
|
1294
|
+
}
|
|
1295
|
+
return found.sort((p, q) => q.score - p.score).map(({ score: _, ...f }) => f);
|
|
1296
|
+
}
|
|
1083
1297
|
|
|
1084
1298
|
// src/ocr/text-gaps.ts
|
|
1085
1299
|
var evidence = /* @__PURE__ */ new WeakMap();
|
|
@@ -4528,7 +4742,8 @@ function collapseEvenSpacing(text, whole = true) {
|
|
|
4528
4742
|
const tokens = text.split(" ");
|
|
4529
4743
|
const visible = tokens.map((t) => t.replace(/<\/?u>|~~/g, ""));
|
|
4530
4744
|
const singleCharCount = visible.filter((t) => t.length === 1).length;
|
|
4531
|
-
|
|
4745
|
+
const wordy = visible.reduce((n, t) => n + (t.match(/[가-힣]{3,}/g) ?? []).reduce((m, w) => m + w.length, 0), 0) >= singleCharCount && visible.every((t) => t.length !== 1 || /[가-힣]/.test(t));
|
|
4746
|
+
if (tokens.length >= 3 && singleCharCount / tokens.length >= 0.7 && !wordy && !isDateUnitBlank(visible)) return tokens.join("");
|
|
4532
4747
|
}
|
|
4533
4748
|
return text.replace(
|
|
4534
4749
|
/(?<![^\s>])[가-힣](?: [가-힣\d]){2,}(?![^\s<])/g,
|
|
@@ -4537,6 +4752,12 @@ function collapseEvenSpacing(text, whole = true) {
|
|
|
4537
4752
|
const after = text.slice(offset + match.length).replace(/^(?:<\/?u>|~~)+/, "");
|
|
4538
4753
|
if (/\S$/.test(before) || /^\S/.test(after)) return match;
|
|
4539
4754
|
if (isDateUnitBlank(match.split(" "))) return match;
|
|
4755
|
+
const edge = /^및 | 및$/.exec(match);
|
|
4756
|
+
if (edge) {
|
|
4757
|
+
const rest = match.replace(/^및 | 및$/, "");
|
|
4758
|
+
if (rest.split(" ").length < 3) return match;
|
|
4759
|
+
return match.startsWith("및 ") ? "및 " + rest.replace(/ /g, "") : rest.replace(/ /g, "") + " 및";
|
|
4760
|
+
}
|
|
4540
4761
|
const parts = match.split(/ 및 (?=[가-힣\d])/);
|
|
4541
4762
|
return parts.length > 1 ? parts.map((p) => p.replace(/ /g, "")).join(" 및 ") : match.replace(/ /g, "");
|
|
4542
4763
|
}
|
|
@@ -10368,6 +10589,17 @@ function extractPageBlocksWithLines(items, pageNum, opList, pageWidth, pageHeigh
|
|
|
10368
10589
|
}
|
|
10369
10590
|
}
|
|
10370
10591
|
}
|
|
10592
|
+
if (ocrItems && ocrSpan >= pageHeight * 0.5) {
|
|
10593
|
+
for (let i = grids.length - 1; i >= 0; i--) {
|
|
10594
|
+
const g = grids[i];
|
|
10595
|
+
const area = (b) => (b.x2 - b.x1) * (b.y2 - b.y1);
|
|
10596
|
+
if (g.cells || area(g.bbox) < pageWidth * pageHeight * 0.5) continue;
|
|
10597
|
+
const inner = grids.filter((o) => o !== g && !o.cells && o.bbox.x1 >= g.bbox.x1 - 2 && o.bbox.x2 <= g.bbox.x2 + 2 && o.bbox.y1 >= g.bbox.y1 - 2 && o.bbox.y2 <= g.bbox.y2 + 2);
|
|
10598
|
+
if (inner.length === 0 || inner.reduce((s, o) => s + area(o.bbox), 0) > area(g.bbox) * 0.75) continue;
|
|
10599
|
+
const own = (vs, pick) => vs.slice(1, -1).every((v) => inner.some((o) => pick(o).some((w) => Math.abs(w - v) <= 4)));
|
|
10600
|
+
if (own(g.colXs, (o) => o.colXs) && own(g.rowYs, (o) => o.rowYs)) grids.splice(i, 1);
|
|
10601
|
+
}
|
|
10602
|
+
}
|
|
10371
10603
|
if (ocrItems && ocrSpan >= pageHeight * 0.5 && grids.length > 0 && grids.every((g) => g.rowYs.length === 2 && g.colXs.length === 2 && !g.cells && ((g.bbox.x2 - g.bbox.x1) * (g.bbox.y2 - g.bbox.y1) < pageWidth * pageHeight * 0.02 || g.bbox.x2 - g.bbox.x1 < pageWidth * 0.55))) {
|
|
10372
10604
|
return ruledColumnBlocks(items, horizontals, verticals, pageWidth, pageHeight, pageNum, detectTables, lex) ?? extractPageBlocksFallback(items, pageNum, true, detectTables, lex, figures());
|
|
10373
10605
|
}
|
|
@@ -11525,6 +11757,7 @@ export {
|
|
|
11525
11757
|
bracketShape,
|
|
11526
11758
|
leadingBullet,
|
|
11527
11759
|
stackedGlyphBands,
|
|
11760
|
+
checkboxFrames,
|
|
11528
11761
|
rememberOcrTextGaps,
|
|
11529
11762
|
copyOcrTextGaps,
|
|
11530
11763
|
findOcrTextGaps,
|
|
@@ -11582,4 +11815,4 @@ export {
|
|
|
11582
11815
|
UNRULED_REGION_TABLES,
|
|
11583
11816
|
mergeOcrImageRegions
|
|
11584
11817
|
};
|
|
11585
|
-
//# sourceMappingURL=chunk-
|
|
11818
|
+
//# sourceMappingURL=chunk-SKZ2LLN5.js.map
|