kordoc 4.25.22 → 4.25.24
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-2T27SM3Q.js → chunk-37HQ5S2F.js} +2 -2
- package/dist/{chunk-5B2IKEEY.js → chunk-3IWIEZVL.js} +4 -4
- package/dist/{chunk-VTFMNEQA.js → chunk-3Q2SUJDV.js} +276 -4
- package/dist/chunk-3Q2SUJDV.js.map +1 -0
- package/dist/{chunk-U4IIEEPU.js → chunk-4KVMSM4M.js} +2 -2
- package/dist/{chunk-SBXUMTMQ.js → chunk-BHPVQPNN.js} +130 -7
- package/dist/chunk-BHPVQPNN.js.map +7 -0
- package/dist/{chunk-JY2OBKK2.js → chunk-CIHS4CEL.js} +2 -2
- package/dist/{chunk-OQX5GAZU.js → chunk-CLO7BUJQ.js} +2 -2
- package/dist/{chunk-LNJUYPFX.js → chunk-CNDF2YB6.js} +2 -2
- package/dist/{chunk-F64JL4SC.js → chunk-EAWIG76N.js} +2 -2
- package/dist/{chunk-LY235W6K.js → chunk-FILDST6S.js} +2 -2
- package/dist/{chunk-MNHHSFDQ.js → chunk-FWQESIOO.js} +6 -6
- package/dist/{chunk-RPMBH66S.js → chunk-JCYMJZ3O.js} +5 -5
- package/dist/{chunk-GEQU7GFI.js → chunk-KLHZ3NO5.js} +18 -18
- package/dist/{chunk-PTYOQBAD.js → chunk-KNWJ32ZD.js} +2 -2
- package/dist/{chunk-D57I7HNQ.js → chunk-LJZJYQBF.js} +2 -2
- package/dist/{chunk-IKU7LVKA.js → chunk-LKM3Q4PN.js} +2 -2
- package/dist/{chunk-3ABE7X6L.js → chunk-OD47OPYO.js} +3 -3
- package/dist/{chunk-X4LW6P67.js → chunk-QQAPWGEI.js} +2 -2
- package/dist/{chunk-M4V6DG5V.js → chunk-T76QL6GL.js} +8 -8
- package/dist/{chunk-FU2VJEA7.js → chunk-TIAII5S4.js} +6 -6
- package/dist/{chunk-VE4T5RNY.js → chunk-VX46EMOW.js} +2 -2
- package/dist/{chunk-GG2M23FC.js → chunk-WUZ4NQHI.js} +3 -3
- package/dist/{chunk-SZHSPADM.js → chunk-XPPBR7OB.js} +2 -2
- package/dist/{chunk-2BC6IRWI.js → chunk-YD5O4FD4.js} +14 -13
- package/dist/chunk-YD5O4FD4.js.map +7 -0
- package/dist/{chunk-XJWOBLDL.js → chunk-ZPDMIZ5Y.js} +10 -10
- package/dist/{chunk-IWPT63UP.js → chunk-ZTML7NPB.js} +6 -6
- package/dist/chunks-M2PN7VGE.js +10 -0
- package/dist/cli.js +37 -37
- package/dist/{formula-62KCIJTD.js → formula-3PN3KZC3.js} +4 -4
- package/dist/{generator-OGG7G6RV.js → generator-XK6NFJC2.js} +7 -7
- package/dist/{hancom-SGF24IFE.js → hancom-QXZ7ARFM.js} +2 -2
- package/dist/{image-ocr-ZGRESXDU.js → image-ocr-Y354DC6V.js} +11 -11
- package/dist/index.cjs +410 -18
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +21 -21
- package/dist/mcp.js +33 -33
- package/dist/memo-Y6LTIS2E.js +15 -0
- package/dist/{model-bundle-ZB3IUIDI.js → model-bundle-K6ABN65H.js} +5 -5
- package/dist/{models-JW4G7TAS.js → models-VGMWR3V2.js} +5 -5
- package/dist/{page-images-MW7EJGDY.js → page-images-FQWZHAS4.js} +2 -2
- package/dist/{parse-worker-v2-24QWDLDW.js → parse-worker-v2-XKXQOFTS.js} +23 -23
- package/dist/{parser-X74GRUEK.js → parser-JLHRN7ER.js} +14 -14
- package/dist/{pdf-ocr-5N4CHVYH.js → pdf-ocr-LK7YOVMO.js} +9 -9
- package/dist/{profile-io-EDOARKYW.js → profile-io-EJK2SQGT.js} +3 -3
- package/dist/{rasterize-YHFV2XB4.js → rasterize-Y3WTTUZ6.js} +3 -3
- package/dist/{redact-doc-YAQFZNBP.js → redact-doc-7OG6B6KY.js} +22 -22
- package/dist/{render-YKPIJ5XF.js → render-WVEIBFOG.js} +10 -10
- package/dist/{rewrite-fallback-W4SQTEKX.js → rewrite-fallback-2HLAIX63.js} +12 -12
- package/dist/seal-LAVHUYGU.js +14 -0
- package/dist/{setup-GVWJ2UM5.js → setup-K5AO7GDX.js} +3 -3
- package/dist/{to-hwpx-LC7SM2NG.js → to-hwpx-2SFOLVTM.js} +7 -7
- package/dist/visual-C23UG67K.js +42 -0
- package/dist/{watch-EHCJUHRO.js → watch-QX36YW5B.js} +22 -22
- package/package.json +1 -1
- package/dist/chunk-2BC6IRWI.js.map +0 -7
- package/dist/chunk-SBXUMTMQ.js.map +0 -7
- package/dist/chunk-VTFMNEQA.js.map +0 -1
- package/dist/chunks-S5RQ5IVJ.js +0 -10
- package/dist/memo-C6TAWLJY.js +0 -15
- package/dist/seal-IZ77VWF2.js +0 -14
- package/dist/visual-FRQN5F77.js +0 -42
- /package/dist/{chunk-2T27SM3Q.js.map → chunk-37HQ5S2F.js.map} +0 -0
- /package/dist/{chunk-5B2IKEEY.js.map → chunk-3IWIEZVL.js.map} +0 -0
- /package/dist/{chunk-U4IIEEPU.js.map → chunk-4KVMSM4M.js.map} +0 -0
- /package/dist/{chunk-JY2OBKK2.js.map → chunk-CIHS4CEL.js.map} +0 -0
- /package/dist/{chunk-OQX5GAZU.js.map → chunk-CLO7BUJQ.js.map} +0 -0
- /package/dist/{chunk-LNJUYPFX.js.map → chunk-CNDF2YB6.js.map} +0 -0
- /package/dist/{chunk-F64JL4SC.js.map → chunk-EAWIG76N.js.map} +0 -0
- /package/dist/{chunk-LY235W6K.js.map → chunk-FILDST6S.js.map} +0 -0
- /package/dist/{chunk-MNHHSFDQ.js.map → chunk-FWQESIOO.js.map} +0 -0
- /package/dist/{chunk-RPMBH66S.js.map → chunk-JCYMJZ3O.js.map} +0 -0
- /package/dist/{chunk-GEQU7GFI.js.map → chunk-KLHZ3NO5.js.map} +0 -0
- /package/dist/{chunk-PTYOQBAD.js.map → chunk-KNWJ32ZD.js.map} +0 -0
- /package/dist/{chunk-D57I7HNQ.js.map → chunk-LJZJYQBF.js.map} +0 -0
- /package/dist/{chunk-IKU7LVKA.js.map → chunk-LKM3Q4PN.js.map} +0 -0
- /package/dist/{chunk-3ABE7X6L.js.map → chunk-OD47OPYO.js.map} +0 -0
- /package/dist/{chunk-X4LW6P67.js.map → chunk-QQAPWGEI.js.map} +0 -0
- /package/dist/{chunk-M4V6DG5V.js.map → chunk-T76QL6GL.js.map} +0 -0
- /package/dist/{chunk-FU2VJEA7.js.map → chunk-TIAII5S4.js.map} +0 -0
- /package/dist/{chunk-VE4T5RNY.js.map → chunk-VX46EMOW.js.map} +0 -0
- /package/dist/{chunk-GG2M23FC.js.map → chunk-WUZ4NQHI.js.map} +0 -0
- /package/dist/{chunk-SZHSPADM.js.map → chunk-XPPBR7OB.js.map} +0 -0
- /package/dist/{chunk-XJWOBLDL.js.map → chunk-ZPDMIZ5Y.js.map} +0 -0
- /package/dist/{chunk-IWPT63UP.js.map → chunk-ZTML7NPB.js.map} +0 -0
- /package/dist/{chunks-S5RQ5IVJ.js.map → chunks-M2PN7VGE.js.map} +0 -0
- /package/dist/{formula-62KCIJTD.js.map → formula-3PN3KZC3.js.map} +0 -0
- /package/dist/{generator-OGG7G6RV.js.map → generator-XK6NFJC2.js.map} +0 -0
- /package/dist/{hancom-SGF24IFE.js.map → hancom-QXZ7ARFM.js.map} +0 -0
- /package/dist/{image-ocr-ZGRESXDU.js.map → image-ocr-Y354DC6V.js.map} +0 -0
- /package/dist/{memo-C6TAWLJY.js.map → memo-Y6LTIS2E.js.map} +0 -0
- /package/dist/{model-bundle-ZB3IUIDI.js.map → model-bundle-K6ABN65H.js.map} +0 -0
- /package/dist/{models-JW4G7TAS.js.map → models-VGMWR3V2.js.map} +0 -0
- /package/dist/{page-images-MW7EJGDY.js.map → page-images-FQWZHAS4.js.map} +0 -0
- /package/dist/{parse-worker-v2-24QWDLDW.js.map → parse-worker-v2-XKXQOFTS.js.map} +0 -0
- /package/dist/{parser-X74GRUEK.js.map → parser-JLHRN7ER.js.map} +0 -0
- /package/dist/{pdf-ocr-5N4CHVYH.js.map → pdf-ocr-LK7YOVMO.js.map} +0 -0
- /package/dist/{profile-io-EDOARKYW.js.map → profile-io-EJK2SQGT.js.map} +0 -0
- /package/dist/{rasterize-YHFV2XB4.js.map → rasterize-Y3WTTUZ6.js.map} +0 -0
- /package/dist/{redact-doc-YAQFZNBP.js.map → redact-doc-7OG6B6KY.js.map} +0 -0
- /package/dist/{render-YKPIJ5XF.js.map → render-WVEIBFOG.js.map} +0 -0
- /package/dist/{rewrite-fallback-W4SQTEKX.js.map → rewrite-fallback-2HLAIX63.js.map} +0 -0
- /package/dist/{seal-IZ77VWF2.js.map → seal-LAVHUYGU.js.map} +0 -0
- /package/dist/{setup-GVWJ2UM5.js.map → setup-K5AO7GDX.js.map} +0 -0
- /package/dist/{to-hwpx-LC7SM2NG.js.map → to-hwpx-2SFOLVTM.js.map} +0 -0
- /package/dist/{visual-FRQN5F77.js.map → visual-C23UG67K.js.map} +0 -0
- /package/dist/{watch-EHCJUHRO.js.map → watch-QX36YW5B.js.map} +0 -0
package/README.md
CHANGED
|
@@ -130,15 +130,15 @@ await writeFile("보고서.hwpx", Buffer.from(hwpx))
|
|
|
130
130
|
|
|
131
131
|
## 최근 업데이트
|
|
132
132
|
|
|
133
|
-
최신 배포: **[4.25.
|
|
133
|
+
최신 배포: **[4.25.24](https://github.com/chrisryugj/kordoc/releases/tag/v4.25.24)** · 2026-11-27
|
|
134
134
|
|
|
135
135
|
| 버전 | 바뀐 점 | 실측 변화 |
|
|
136
136
|
| --- | --- | --- |
|
|
137
|
+
| 4.25.24 | OCR 이 촘촘한 표 칸에서 맞닿은 여러 줄을 한 줄로 읽어 버리던 것을 줄마다 나눠 읽습니다. 표 칸 머리 "#" 를 이스케이프하지 않습니다 | KoOCR 877쪽 오름 4·OCR 오름 1(빈칸이던 머리 "전문경력관")·열화 견고성 오름 1 · ODL 표 TEDS 1문서 0.993 → **1** · 하락 0 |
|
|
138
|
+
| 4.25.23 | 스캔·사진 서식의 체크 칸 □·[ ] 를 찾아 체크 여부를 ☑·□ 로 냅니다(#243, @VerifiedIdiot). 쪽 테두리와 이어진 표가 본문까지 삼키던 OCR 쪽, "각 과 및 안전센터" 를 붙이던 균등배분 접기를 고쳤습니다. Upstage DP-Bench 기준선 벤치를 더했습니다(#245, @LimePencil) | KoOCR 877쪽 0.907 → **0.908**(표 0.918 → 0.919, 관보 행정예고 쪽 CER 0.877 → 0.388)·내림 0 · OCR 56문서 오름 3 · PDF 글 오름 5·표 오름 1 · 하락 0 · DP-Bench NID 96.12·TEDS 99.11 |
|
|
137
139
|
| 4.25.22 | 각주 글도 patch 로 고칩니다(HWPX·HWP 5.x, #241, @serithemage). 고친 각주의 문단만 바꾸고 각주 번호·개체는 그대로 둡니다. HWP 5.x 에서 본문을 고쳐도 손대지 않은 제목 줄 판정이 바뀌지 않습니다(#242) | 각주 글 수정: 건너뜀 → **적용** · 기안문 HWP 본문 수정 뒤 검증 modified 1 → **0** · score 5,465문서·roundtrip 75문서 하락 0 · 시험 5,367개 실패 0 |
|
|
138
140
|
| 4.25.21 | 각주가 달린 문단·표 칸의 본문도 patch 로 고칩니다(HWP 5.x·HWPX, #240). 각주는 그대로 두고, 각주 글만 고친 편집은 그 이유로 알립니다. OCR 의 천분율 ‰ 를 바로 읽습니다 | 각주 달린 HWP 문단·HWP/HWPX 칸 본문 수정: 건너뜀 → **적용** · KoOCR 877쪽 2쪽 오름·내림 0 · roundtrip·formats·OCR·견고성 하락 0 · 시험 실패 0 |
|
|
139
141
|
| 4.25.20 | PDF 그림 PNG 압축을 비동기로 바꿔 그림 많은 PDF가 빨라졌습니다(#239, @LimePencil). 머리 행이 합친 칸인 관보 자금 표가 글 상자로 강등되던 것과, OCR 표 아래 출처 줄이 끝 행 칸에 들어가던 것을 고쳤습니다 | PDF 400개 처리 560초 → **431초**(출력 바이트 동일) · KoOCR 877쪽 11쪽 오름·내림 0, 표 0.916 → **0.918** · 관보 자금 표 CER 0.148 → 0.003 · 표·별표·ODL·글·OCR·견고성 하락 0 · 시험 실패 0 |
|
|
140
|
-
| 4.25.19 | 휴대폰으로 비스듬히 찍어 글줄 기울기가 위아래로 다른 쪽을 OCR 전에 행마다 폅니다(#237, @VerifiedIdiot). 가로 용지 HWP 를 HWPX 로 바꾸면 한글에서 세로로 열리던 문제를 고쳤습니다(#238) | 원근 변형 54쪽 CER persp8 **8.46%** · persp8+2 14.1% · 기존 OCR 경로 쪽별 결과 그대로(KoOCR 877쪽·OCR·견고성·odlocr) · 인쇄 설정이 한글 저장본과 같은 짝 109 → **263/264** · 시험 실패 0 |
|
|
141
|
-
| 4.25.18 | HWP 5.x 표 칸을 빈칸으로 패치한 파일을 한글 뷰어가 손상으로 판정하던 문제를 고쳤습니다(#236). 빈 문단은 한글처럼 글 레코드 없이 씁니다 | 한글 저장 HWP 3건 칸 비우기 패치: 끝 문자만 든 글 레코드 1·1·0 → **0·0·0** · 재파싱 정상 · 시험 5,336개 실패 0 |
|
|
142
142
|
|
|
143
143
|
이전 버전과 상세 내용은 [변경 이력](CHANGELOG.md)에 있습니다.
|
|
144
144
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
assertNetworkAllowed
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-VX46EMOW.js";
|
|
4
4
|
|
|
5
5
|
// src/pdf/formula/models.ts
|
|
6
6
|
import { createHash as createHash2 } from "crypto";
|
|
@@ -299,4 +299,4 @@ export {
|
|
|
299
299
|
ensureFormulaModels,
|
|
300
300
|
ensureSingleModel
|
|
301
301
|
};
|
|
302
|
-
//# sourceMappingURL=chunk-
|
|
302
|
+
//# sourceMappingURL=chunk-37HQ5S2F.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
patchZipEntries
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-LJZJYQBF.js";
|
|
4
4
|
import {
|
|
5
5
|
applySplices,
|
|
6
6
|
scanSectionXml
|
|
@@ -8,11 +8,11 @@ import {
|
|
|
8
8
|
import {
|
|
9
9
|
parseRenderStyles,
|
|
10
10
|
readZipEntry
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-FILDST6S.js";
|
|
12
12
|
import {
|
|
13
13
|
KordocError,
|
|
14
14
|
precheckZipSize
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-CNDF2YB6.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-3IWIEZVL.js.map
|
|
@@ -9,11 +9,11 @@ import {
|
|
|
9
9
|
HEADING_RATIO_H3,
|
|
10
10
|
tidyScriptTags,
|
|
11
11
|
toTex
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-KNWJ32ZD.js";
|
|
13
13
|
import {
|
|
14
14
|
safeMax,
|
|
15
15
|
safeMin
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-CNDF2YB6.js";
|
|
17
17
|
|
|
18
18
|
// src/ocr/line-split.ts
|
|
19
19
|
function grayCrop(rgba, pageW, box) {
|
|
@@ -143,6 +143,44 @@ function splitRowBands(gray, w, h, ink, minBandRatio) {
|
|
|
143
143
|
return { y0, y1, x0, x1 };
|
|
144
144
|
});
|
|
145
145
|
}
|
|
146
|
+
var VALLEY_MAX = 0.35;
|
|
147
|
+
function valleyBands(gray, w, h, ink, k) {
|
|
148
|
+
if (k < 2) return null;
|
|
149
|
+
const isInk = (v) => ink.darkInk ? v <= ink.threshold : v > ink.threshold;
|
|
150
|
+
const colInk = new Uint32Array(w);
|
|
151
|
+
for (let y = 0; y < h; y++) for (let x = 0; x < w; x++) if (isInk(gray[y * w + x])) colInk[x]++;
|
|
152
|
+
const live = (x) => colInk[x] < h * 0.85;
|
|
153
|
+
const row = new Float64Array(h);
|
|
154
|
+
for (let y = 0; y < h; y++) for (let x = 0; x < w; x++) if (live(x) && isInk(gray[y * w + x])) row[y]++;
|
|
155
|
+
const sm = (y) => (row[Math.max(0, y - 1)] + row[y] + row[Math.min(h - 1, y + 1)]) / 3;
|
|
156
|
+
const inked = [...row].filter((v) => v > 0).sort((a, b) => a - b);
|
|
157
|
+
const med = inked[inked.length >> 1];
|
|
158
|
+
if (!med) return null;
|
|
159
|
+
const cuts = [];
|
|
160
|
+
for (let j = 1; j < k; j++) {
|
|
161
|
+
const c = h * j / k, r = h / k * 0.3;
|
|
162
|
+
let best = -1, bestV = Infinity;
|
|
163
|
+
for (let y = Math.max(1, Math.round(c - r)); y <= Math.min(h - 2, Math.round(c + r)); y++) {
|
|
164
|
+
const v = sm(y);
|
|
165
|
+
if (v < bestV) {
|
|
166
|
+
bestV = v;
|
|
167
|
+
best = y;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
if (best < 0 || bestV > med * VALLEY_MAX || cuts.length && best <= cuts[cuts.length - 1]) return null;
|
|
171
|
+
cuts.push(best);
|
|
172
|
+
}
|
|
173
|
+
const edges = [0, ...cuts, h];
|
|
174
|
+
return edges.slice(1).map((y1, i) => {
|
|
175
|
+
const y0 = edges[i];
|
|
176
|
+
let x0 = w, x1 = -1;
|
|
177
|
+
for (let y = y0; y < y1; y++) for (let x = 0; x < w; x++) if (live(x) && isInk(gray[y * w + x])) {
|
|
178
|
+
if (x < x0) x0 = x;
|
|
179
|
+
if (x > x1) x1 = x;
|
|
180
|
+
}
|
|
181
|
+
return { y0, y1, x0: x1 >= x0 ? x0 : 0, x1: x1 >= x0 ? x1 + 1 : w };
|
|
182
|
+
});
|
|
183
|
+
}
|
|
146
184
|
function components(gray, w, h, ink) {
|
|
147
185
|
const isInk = (v) => ink.darkInk ? v <= ink.threshold : v > ink.threshold;
|
|
148
186
|
const comps = [];
|
|
@@ -1080,6 +1118,220 @@ function stackedGlyphBands(gray, w, h, ink) {
|
|
|
1080
1118
|
const bands = splitRowBands(gray, w, h, ink, 0.45);
|
|
1081
1119
|
return bands.length >= 2 && bands.length <= 4 ? bands : null;
|
|
1082
1120
|
}
|
|
1121
|
+
function checkboxFrames(gray, w, h, ink) {
|
|
1122
|
+
if (!ink.darkInk || h < 12 || w < h) return [];
|
|
1123
|
+
const sorted = Uint8Array.from(gray).sort(), bg = sorted[sorted.length >> 1];
|
|
1124
|
+
let n = 0, sum = 0;
|
|
1125
|
+
for (let i = 0; i < gray.length; i++) if (gray[i] <= ink.threshold) {
|
|
1126
|
+
n++;
|
|
1127
|
+
sum += gray[i];
|
|
1128
|
+
}
|
|
1129
|
+
const dk = n ? sum / n : bg;
|
|
1130
|
+
if (bg - dk < 40) return [];
|
|
1131
|
+
const k = Math.max(2, Math.round(h * 0.05)), delta = Math.max(10, (bg - dk) * 0.12), mark = bg - (bg - dk) * 0.5;
|
|
1132
|
+
const at = (x, y) => gray[Math.min(h - 1, Math.max(0, y)) * w + Math.min(w - 1, Math.max(0, x))];
|
|
1133
|
+
const V = new Uint8Array(w * h), H = new Uint8Array(w * h);
|
|
1134
|
+
for (let y = 0; y < h; y++) for (let x = 0; x < w; x++) {
|
|
1135
|
+
const v = gray[y * w + x];
|
|
1136
|
+
if (v < Math.min(at(x - k, y), at(x + k, y)) - delta) V[y * w + x] = 1;
|
|
1137
|
+
if (v < Math.min(at(x, y - k), at(x, y + k)) - delta) H[y * w + x] = 1;
|
|
1138
|
+
}
|
|
1139
|
+
const inside = (x, y) => x >= 0 && x < w && y >= 0 && y < h;
|
|
1140
|
+
const vr = (x, y) => inside(x, y) && V[y * w + x] === 1;
|
|
1141
|
+
const hr = (x, y) => inside(x, y) && H[y * w + x] === 1;
|
|
1142
|
+
const dark = (x, y) => inside(x, y) && gray[y * w + x] < mark;
|
|
1143
|
+
const sMin = Math.max(8, h * 0.15), sMax = h;
|
|
1144
|
+
const gap = Math.max(1, Math.round(h * 0.04));
|
|
1145
|
+
const vmap = (any) => {
|
|
1146
|
+
const src = any ? VD : V, m = new Uint8Array(w * h);
|
|
1147
|
+
for (let i = 0; i < w * h; i++) {
|
|
1148
|
+
const x = i % w;
|
|
1149
|
+
m[i] = src[i] | (x > 0 ? src[i - 1] : 0) | (x + 1 < w ? src[i + 1] : 0);
|
|
1150
|
+
}
|
|
1151
|
+
const p = new Int32Array(w * (h + 1));
|
|
1152
|
+
for (let x = 0; x < w; x++) for (let y = 0; y < h; y++) {
|
|
1153
|
+
let on = 0;
|
|
1154
|
+
for (let d = -gap; d <= gap && !on; d++) {
|
|
1155
|
+
const yy = y + d;
|
|
1156
|
+
if (yy >= 0 && yy < h && m[yy * w + x]) on = 1;
|
|
1157
|
+
}
|
|
1158
|
+
p[(y + 1) * w + x] = p[y * w + x] + on;
|
|
1159
|
+
}
|
|
1160
|
+
return p;
|
|
1161
|
+
};
|
|
1162
|
+
const hmap = (any) => {
|
|
1163
|
+
const src = any ? HD : H, m = new Uint8Array(w * h);
|
|
1164
|
+
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);
|
|
1165
|
+
const p = new Int32Array((w + 1) * h);
|
|
1166
|
+
for (let y = 0; y < h; y++) for (let x = 0; x < w; x++) {
|
|
1167
|
+
let on = 0;
|
|
1168
|
+
for (let d = -gap; d <= gap && !on; d++) {
|
|
1169
|
+
const xx = x + d;
|
|
1170
|
+
if (xx >= 0 && xx < w && m[y * w + xx]) on = 1;
|
|
1171
|
+
}
|
|
1172
|
+
p[y * (w + 1) + x + 1] = p[y * (w + 1) + x] + on;
|
|
1173
|
+
}
|
|
1174
|
+
return p;
|
|
1175
|
+
};
|
|
1176
|
+
const VD = new Uint8Array(w * h), HD = new Uint8Array(w * h);
|
|
1177
|
+
for (let i = 0; i < w * h; i++) {
|
|
1178
|
+
const dk2 = gray[i] < mark ? 1 : 0;
|
|
1179
|
+
VD[i] = V[i] | dk2;
|
|
1180
|
+
HD[i] = H[i] | dk2;
|
|
1181
|
+
}
|
|
1182
|
+
const VA = vmap(true), VR = vmap(false), HA = hmap(true), HR = hmap(false);
|
|
1183
|
+
const vside = (x, ya, yb, any) => {
|
|
1184
|
+
const p = any ? VA : VR;
|
|
1185
|
+
return (p[(yb + 1) * w + x] - p[ya * w + x]) / (yb - ya + 1);
|
|
1186
|
+
};
|
|
1187
|
+
const hside = (xa, xb, y, any) => {
|
|
1188
|
+
if (y < 0 || y >= h) return 0;
|
|
1189
|
+
const p = any ? HA : HR;
|
|
1190
|
+
return (p[y * (w + 1) + xb + 1] - p[y * (w + 1) + xa]) / (xb - xa + 1);
|
|
1191
|
+
};
|
|
1192
|
+
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));
|
|
1193
|
+
const strokes = [];
|
|
1194
|
+
for (let x = 0; x < w; x++) {
|
|
1195
|
+
let best = 0, bestTop = 0, start = -1, miss = 0;
|
|
1196
|
+
for (let y = 0; y <= h; y++) {
|
|
1197
|
+
if (y < h && (vr(x - 1, y) || vr(x, y) || vr(x + 1, y))) {
|
|
1198
|
+
if (start < 0) start = y;
|
|
1199
|
+
miss = 0;
|
|
1200
|
+
} else if (start >= 0 && (y === h || ++miss > gap)) {
|
|
1201
|
+
const l = (y === h ? h - 1 - miss : y - miss) - start + 1;
|
|
1202
|
+
if (l > best) {
|
|
1203
|
+
best = l;
|
|
1204
|
+
bestTop = start;
|
|
1205
|
+
}
|
|
1206
|
+
start = -1;
|
|
1207
|
+
miss = 0;
|
|
1208
|
+
}
|
|
1209
|
+
}
|
|
1210
|
+
if (best < sMin * 0.8) continue;
|
|
1211
|
+
const p = strokes[strokes.length - 1];
|
|
1212
|
+
if (p && x - p.x1 <= 1) {
|
|
1213
|
+
p.x1 = x;
|
|
1214
|
+
if (best > p.y1 - p.y0) {
|
|
1215
|
+
p.x = x;
|
|
1216
|
+
p.y0 = bestTop;
|
|
1217
|
+
p.y1 = bestTop + best;
|
|
1218
|
+
}
|
|
1219
|
+
} else strokes.push({ x0: x, x1: x, x, y0: bestTop, y1: bestTop + best });
|
|
1220
|
+
}
|
|
1221
|
+
const corner = (x, y) => {
|
|
1222
|
+
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;
|
|
1223
|
+
return false;
|
|
1224
|
+
};
|
|
1225
|
+
const found = [], seen2 = /* @__PURE__ */ new Set();
|
|
1226
|
+
const lineStraight = (xc, y0, y1, outward, size) => {
|
|
1227
|
+
const ends = [];
|
|
1228
|
+
for (let y = y0 + 1; y <= y1 - 1; y++) for (let t = 3; t >= -3; t--) if (vr(xc + outward * t, y)) {
|
|
1229
|
+
ends.push(xc + outward * t);
|
|
1230
|
+
break;
|
|
1231
|
+
}
|
|
1232
|
+
if (ends.length < 3) return true;
|
|
1233
|
+
ends.sort((p, q) => p - q);
|
|
1234
|
+
return ends[Math.floor(ends.length * 0.9)] - ends[Math.floor(ends.length * 0.1)] <= Math.max(2, size * 0.06);
|
|
1235
|
+
};
|
|
1236
|
+
const tryBox = (lx, rx, ya, lw, rw) => {
|
|
1237
|
+
const d = rx - lx;
|
|
1238
|
+
const y0 = Math.max(0, ya), y1 = Math.min(h - 1, ya + d);
|
|
1239
|
+
if (d < sMin || d > sMax || lx < 0 || rx >= w || y1 - y0 < d * 0.8) return;
|
|
1240
|
+
const hook = Math.max(2, Math.round(d * 0.25));
|
|
1241
|
+
const lc = vside(lx, y0, y1, true), rc = vside(rx, y0, y1, true);
|
|
1242
|
+
if (lc < 0.75 || rc < 0.75) return;
|
|
1243
|
+
const tc = hbest(lx, rx, y0, true), bc = hbest(lx, rx, y1, true);
|
|
1244
|
+
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));
|
|
1245
|
+
const square = corner(lx, y0) && corner(rx, y0) && corner(lx, y1) && corner(rx, y1);
|
|
1246
|
+
const straight = (xc, outward) => lineStraight(xc, y0, y1, outward, d);
|
|
1247
|
+
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;
|
|
1248
|
+
if (ix1 <= ix0 || iy1 <= iy0) return;
|
|
1249
|
+
let c = 0, a = 0, mx0 = w, mx1 = -1;
|
|
1250
|
+
for (let y = iy0; y <= iy1; y++) for (let x = ix0; x <= ix1; x++) {
|
|
1251
|
+
a++;
|
|
1252
|
+
if (gray[y * w + x] < mark) {
|
|
1253
|
+
c++;
|
|
1254
|
+
if (x < mx0) mx0 = x;
|
|
1255
|
+
if (x > mx1) mx1 = x;
|
|
1256
|
+
}
|
|
1257
|
+
}
|
|
1258
|
+
const fill = c / a;
|
|
1259
|
+
if (fill >= 0.6) return;
|
|
1260
|
+
const checked = fill >= 0.06 && mx1 - mx0 + 1 >= (ix1 - ix0 + 1) * 0.35;
|
|
1261
|
+
const ink2 = (x, y) => vr(x, y) || hr(x, y);
|
|
1262
|
+
const any = (x, y) => ink2(x, y) || dark(x, y);
|
|
1263
|
+
const outer = (from, to, step, at2, ua, ub) => {
|
|
1264
|
+
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;
|
|
1265
|
+
return NaN;
|
|
1266
|
+
};
|
|
1267
|
+
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);
|
|
1268
|
+
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);
|
|
1269
|
+
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);
|
|
1270
|
+
const cw = Math.max(1, Math.round(d * 0.1));
|
|
1271
|
+
const filled = (cx, cy, sx, sy) => {
|
|
1272
|
+
for (let i = 0; i < cw; i++) for (let j = 0; j < cw; j++) if (any(cx + sx * i, cy + sy * j)) return true;
|
|
1273
|
+
return false;
|
|
1274
|
+
};
|
|
1275
|
+
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;
|
|
1276
|
+
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;
|
|
1277
|
+
if (!kind) return;
|
|
1278
|
+
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))];
|
|
1279
|
+
const clear = [vside(lx, y0, y1, false), vside(rx, y0, y1, false), ...ridge].filter((v) => v >= 0.5).length >= 3;
|
|
1280
|
+
if (!clear) return;
|
|
1281
|
+
const key = `${lx - lw},${rx + rw},${y0}`;
|
|
1282
|
+
if (seen2.has(key)) return;
|
|
1283
|
+
seen2.add(key);
|
|
1284
|
+
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) });
|
|
1285
|
+
};
|
|
1286
|
+
const tryBracket = (lx, rx, y0, y1, lw, rw) => {
|
|
1287
|
+
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));
|
|
1288
|
+
if (vside(lx, y0, y1, false) < 0.75 || vside(rx, y0, y1, false) < 0.75) return;
|
|
1289
|
+
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));
|
|
1290
|
+
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;
|
|
1291
|
+
const corners = [corner(lx, y0), corner(rx, y0), corner(lx, y1), corner(rx, y1)].every(Boolean);
|
|
1292
|
+
if (!corners || !lineStraight(lx, y0, y1, -1, len) || !lineStraight(rx, y0, y1, 1, len)) return;
|
|
1293
|
+
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;
|
|
1294
|
+
if (ix1 <= ix0 || iy1 <= iy0) return;
|
|
1295
|
+
let c = 0, a = 0, my0 = h, my1 = -1;
|
|
1296
|
+
for (let y = iy0; y <= iy1; y++) for (let x = ix0; x <= ix1; x++) {
|
|
1297
|
+
a++;
|
|
1298
|
+
if (gray[y * w + x] < mark) {
|
|
1299
|
+
c++;
|
|
1300
|
+
if (y < my0) my0 = y;
|
|
1301
|
+
if (y > my1) my1 = y;
|
|
1302
|
+
}
|
|
1303
|
+
}
|
|
1304
|
+
if (c / a >= 0.6) return;
|
|
1305
|
+
const checked = c / a >= 0.03 && my1 - my0 + 1 >= (iy1 - iy0 + 1) * 0.35;
|
|
1306
|
+
const key = `[${lx - lw},${rx + rw},${y0}`;
|
|
1307
|
+
if (seen2.has(key)) return;
|
|
1308
|
+
seen2.add(key);
|
|
1309
|
+
found.push({ x0: Math.max(0, lx - lw), x1: Math.min(w - 1, rx + rw), y0, y1, kind: "[]", checked, score: 2 + hooks * 2 });
|
|
1310
|
+
};
|
|
1311
|
+
for (let i = 0; i < strokes.length; i++) {
|
|
1312
|
+
const L = strokes[i], len = L.y1 - L.y0;
|
|
1313
|
+
for (let j = i + 1; j < strokes.length; j++) {
|
|
1314
|
+
const R = strokes[j], d = R.x - L.x;
|
|
1315
|
+
if (d < sMin) continue;
|
|
1316
|
+
if (d > sMax) break;
|
|
1317
|
+
if (L.x1 - L.x0 > d * 0.3 || R.x1 - R.x0 > d * 0.3) continue;
|
|
1318
|
+
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);
|
|
1319
|
+
}
|
|
1320
|
+
if (L.x1 - L.x0 <= len * 0.3) for (const d of [len - 1, len, len + 1]) {
|
|
1321
|
+
tryBox(L.x - d, L.x, L.y0, L.x1 - L.x0, L.x1 - L.x0);
|
|
1322
|
+
tryBox(L.x, L.x + d, L.y0, L.x1 - L.x0, L.x1 - L.x0);
|
|
1323
|
+
}
|
|
1324
|
+
for (let j = i + 1; j < strokes.length; j++) {
|
|
1325
|
+
const R = strokes[j], d = R.x - L.x, rlen = R.y1 - R.y0;
|
|
1326
|
+
if (d > len * 2.5) break;
|
|
1327
|
+
if (d < len * 0.6 || d < sMin || Math.abs(rlen - len) > len * 0.25) continue;
|
|
1328
|
+
const y0 = Math.max(L.y0, R.y0), y1 = Math.min(L.y1, R.y1) - 1;
|
|
1329
|
+
if (y1 - y0 < len * 0.8) continue;
|
|
1330
|
+
tryBracket(L.x, R.x, y0, y1, L.x1 - L.x0, R.x1 - R.x0);
|
|
1331
|
+
}
|
|
1332
|
+
}
|
|
1333
|
+
return found.sort((p, q) => q.score - p.score).map(({ score: _, ...f }) => f);
|
|
1334
|
+
}
|
|
1083
1335
|
|
|
1084
1336
|
// src/ocr/text-gaps.ts
|
|
1085
1337
|
var evidence = /* @__PURE__ */ new WeakMap();
|
|
@@ -4528,7 +4780,8 @@ function collapseEvenSpacing(text, whole = true) {
|
|
|
4528
4780
|
const tokens = text.split(" ");
|
|
4529
4781
|
const visible = tokens.map((t) => t.replace(/<\/?u>|~~/g, ""));
|
|
4530
4782
|
const singleCharCount = visible.filter((t) => t.length === 1).length;
|
|
4531
|
-
|
|
4783
|
+
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));
|
|
4784
|
+
if (tokens.length >= 3 && singleCharCount / tokens.length >= 0.7 && !wordy && !isDateUnitBlank(visible)) return tokens.join("");
|
|
4532
4785
|
}
|
|
4533
4786
|
return text.replace(
|
|
4534
4787
|
/(?<![^\s>])[가-힣](?: [가-힣\d]){2,}(?![^\s<])/g,
|
|
@@ -4537,6 +4790,12 @@ function collapseEvenSpacing(text, whole = true) {
|
|
|
4537
4790
|
const after = text.slice(offset + match.length).replace(/^(?:<\/?u>|~~)+/, "");
|
|
4538
4791
|
if (/\S$/.test(before) || /^\S/.test(after)) return match;
|
|
4539
4792
|
if (isDateUnitBlank(match.split(" "))) return match;
|
|
4793
|
+
const edge = /^및 | 및$/.exec(match);
|
|
4794
|
+
if (edge) {
|
|
4795
|
+
const rest = match.replace(/^및 | 및$/, "");
|
|
4796
|
+
if (rest.split(" ").length < 3) return match;
|
|
4797
|
+
return match.startsWith("및 ") ? "및 " + rest.replace(/ /g, "") : rest.replace(/ /g, "") + " 및";
|
|
4798
|
+
}
|
|
4540
4799
|
const parts = match.split(/ 및 (?=[가-힣\d])/);
|
|
4541
4800
|
return parts.length > 1 ? parts.map((p) => p.replace(/ /g, "")).join(" 및 ") : match.replace(/ /g, "");
|
|
4542
4801
|
}
|
|
@@ -10368,6 +10627,17 @@ function extractPageBlocksWithLines(items, pageNum, opList, pageWidth, pageHeigh
|
|
|
10368
10627
|
}
|
|
10369
10628
|
}
|
|
10370
10629
|
}
|
|
10630
|
+
if (ocrItems && ocrSpan >= pageHeight * 0.5) {
|
|
10631
|
+
for (let i = grids.length - 1; i >= 0; i--) {
|
|
10632
|
+
const g = grids[i];
|
|
10633
|
+
const area = (b) => (b.x2 - b.x1) * (b.y2 - b.y1);
|
|
10634
|
+
if (g.cells || area(g.bbox) < pageWidth * pageHeight * 0.5) continue;
|
|
10635
|
+
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);
|
|
10636
|
+
if (inner.length === 0 || inner.reduce((s, o) => s + area(o.bbox), 0) > area(g.bbox) * 0.75) continue;
|
|
10637
|
+
const own = (vs, pick) => vs.slice(1, -1).every((v) => inner.some((o) => pick(o).some((w) => Math.abs(w - v) <= 4)));
|
|
10638
|
+
if (own(g.colXs, (o) => o.colXs) && own(g.rowYs, (o) => o.rowYs)) grids.splice(i, 1);
|
|
10639
|
+
}
|
|
10640
|
+
}
|
|
10371
10641
|
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
10642
|
return ruledColumnBlocks(items, horizontals, verticals, pageWidth, pageHeight, pageNum, detectTables, lex) ?? extractPageBlocksFallback(items, pageNum, true, detectTables, lex, figures());
|
|
10373
10643
|
}
|
|
@@ -11503,6 +11773,7 @@ export {
|
|
|
11503
11773
|
grayCrop,
|
|
11504
11774
|
inkStats,
|
|
11505
11775
|
splitRowBands,
|
|
11776
|
+
valleyBands,
|
|
11506
11777
|
leadingTriangle,
|
|
11507
11778
|
arrowGlyph,
|
|
11508
11779
|
leaderRuns,
|
|
@@ -11525,6 +11796,7 @@ export {
|
|
|
11525
11796
|
bracketShape,
|
|
11526
11797
|
leadingBullet,
|
|
11527
11798
|
stackedGlyphBands,
|
|
11799
|
+
checkboxFrames,
|
|
11528
11800
|
rememberOcrTextGaps,
|
|
11529
11801
|
copyOcrTextGaps,
|
|
11530
11802
|
findOcrTextGaps,
|
|
@@ -11582,4 +11854,4 @@ export {
|
|
|
11582
11854
|
UNRULED_REGION_TABLES,
|
|
11583
11855
|
mergeOcrImageRegions
|
|
11584
11856
|
};
|
|
11585
|
-
//# sourceMappingURL=chunk-
|
|
11857
|
+
//# sourceMappingURL=chunk-3Q2SUJDV.js.map
|