kordoc 4.24.75 → 4.24.76
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 +2 -2
- package/dist/{-IA5KLKYE.js → -2LCJEMU4.js} +22 -22
- package/dist/{chunk-7JMND4DW.cjs → chunk-2P3SFHOF.cjs} +88 -88
- package/dist/{chunk-7JMND4DW.cjs.map → chunk-2P3SFHOF.cjs.map} +1 -1
- package/dist/{chunk-UXWF3PM7.js → chunk-2P5GYSEI.js} +2 -2
- package/dist/{chunk-RYYDGS4R.js → chunk-2ZQUSUDC.js} +5 -5
- package/dist/{chunk-UNIYOWUQ.js → chunk-3X3ETOLW.js} +7 -7
- package/dist/{chunk-XNHDKTTV.cjs → chunk-43VUUMKV.cjs} +6 -6
- package/dist/{chunk-XNHDKTTV.cjs.map → chunk-43VUUMKV.cjs.map} +1 -1
- package/dist/{chunk-BX6TAXOM.js → chunk-45AT4XJD.js} +2 -2
- package/dist/{chunk-JQ6N26LA.js → chunk-4L3SF7EF.js} +2 -2
- package/dist/{chunk-RJBQXQAM.js → chunk-4RB5OPUZ.js} +2 -2
- package/dist/{chunk-HY3LV5HN.cjs → chunk-A7QRUXCJ.cjs} +3 -3
- package/dist/{chunk-HY3LV5HN.cjs.map → chunk-A7QRUXCJ.cjs.map} +1 -1
- package/dist/{chunk-V5XT2PRB.js → chunk-BUZLNJXB.js} +2 -2
- package/dist/{chunk-SODVNDR5.js → chunk-CWEB4XAH.js} +5 -5
- package/dist/{chunk-6F54BTUN.cjs → chunk-DIUYXWT2.cjs} +3 -3
- package/dist/{chunk-6F54BTUN.cjs.map → chunk-DIUYXWT2.cjs.map} +1 -1
- package/dist/{chunk-SEO3FQLR.cjs → chunk-DKRKNL2X.cjs} +58 -58
- package/dist/{chunk-SEO3FQLR.cjs.map → chunk-DKRKNL2X.cjs.map} +1 -1
- package/dist/{chunk-M33WZZPM.js → chunk-DTKVCSRC.js} +2 -2
- package/dist/{chunk-IITWVZF5.js → chunk-E2RQPNXX.js} +2 -2
- package/dist/{chunk-QQTMRZUG.cjs → chunk-HHRQX733.cjs} +203 -162
- package/dist/chunk-HHRQX733.cjs.map +1 -0
- package/dist/{chunk-RGSVM7RL.js → chunk-HQXVNLH2.js} +6 -6
- package/dist/{chunk-7USEKDFP.js → chunk-IRCO55NY.js} +2 -2
- package/dist/{chunk-TSACZSXD.js → chunk-J6RLB6KE.js} +2 -2
- package/dist/{chunk-WQQVAAPX.js → chunk-JT54JHR3.js} +2 -2
- package/dist/{chunk-GBOVNTH6.js → chunk-JYNG27VR.js} +54 -13
- package/dist/chunk-JYNG27VR.js.map +1 -0
- package/dist/{chunk-H7OEE7UV.js → chunk-LFXIZHPE.js} +16 -16
- package/dist/{chunk-N564V2TH.js → chunk-MHDVZBUV.js} +2 -2
- package/dist/{chunk-XV6A6WHZ.js → chunk-MQ44UJN6.js} +55 -14
- package/dist/chunk-MQ44UJN6.js.map +1 -0
- package/dist/{chunk-NNTUIJLC.js → chunk-MRHLGVK5.js} +2 -2
- package/dist/{chunk-SOW4ES4Y.js → chunk-ODJRLTXE.js} +2 -2
- package/dist/{chunk-DZPF2PWU.js → chunk-ODQJEBCB.js} +2 -2
- package/dist/{chunk-XJID65VS.js → chunk-PATC34WZ.js} +10 -10
- package/dist/{chunk-2RTRPVUB.js → chunk-PE3XRCTM.js} +4 -4
- package/dist/{chunk-XJNRTANY.js → chunk-PJ32UFPA.js} +2 -2
- package/dist/{chunk-QKOORIR2.cjs → chunk-QCH63KBP.cjs} +104 -104
- package/dist/{chunk-QKOORIR2.cjs.map → chunk-QCH63KBP.cjs.map} +1 -1
- package/dist/{chunk-SDQZSUFR.js → chunk-QDETIVPA.js} +6 -6
- package/dist/{chunk-NI3YCMGC.cjs → chunk-QIVOVMEC.cjs} +2 -2
- package/dist/{chunk-NI3YCMGC.cjs.map → chunk-QIVOVMEC.cjs.map} +1 -1
- package/dist/{chunk-YIW4AEC6.js → chunk-RNBBMRKF.js} +2 -2
- package/dist/{chunk-CXQXLQVT.js → chunk-RZXJFM3A.js} +2 -2
- package/dist/{chunk-ZOXPQZ4D.js → chunk-SABDVSQU.js} +11 -11
- package/dist/{chunk-S3RWTPEO.js → chunk-SQ7BI34M.js} +3 -3
- package/dist/{chunk-BIHQG2N7.js → chunk-T7YHAP4A.js} +3 -3
- package/dist/{chunk-SJG57YQQ.js → chunk-TGM5V7UD.js} +2 -2
- package/dist/{chunk-OQAE5NDF.js → chunk-U7EJ6QY7.js} +3 -3
- package/dist/{chunk-FZMAFLAY.js → chunk-V3MVGLWO.js} +5 -5
- package/dist/{chunk-CJYGYR2V.js → chunk-WTKISVEW.js} +2 -2
- package/dist/{chunk-MG2DFKP7.js → chunk-XIUXBJHE.js} +2 -2
- package/dist/{chunk-TOBOXNSE.cjs → chunk-XM4VBVYH.cjs} +8 -8
- package/dist/{chunk-TOBOXNSE.cjs.map → chunk-XM4VBVYH.cjs.map} +1 -1
- package/dist/{chunk-IPR3I6YO.js → chunk-XOC5PVAC.js} +2 -2
- package/dist/{chunk-FV57PXPQ.js → chunk-ZWA3MWAE.js} +3 -3
- package/dist/chunks-INR44FWQ.js +11 -0
- package/dist/cli.js +46 -46
- package/dist/{formula-XSFAUBCL.js → formula-3RUSZL2X.js} +4 -4
- package/dist/{formula-VPH2VTGN.cjs → formula-PNWIA2MN.cjs} +9 -9
- package/dist/{formula-VPH2VTGN.cjs.map → formula-PNWIA2MN.cjs.map} +1 -1
- package/dist/{formula-PMHBDDCI.js → formula-UJKRUT4H.js} +3 -3
- package/dist/generator-335G75L5.js +11 -0
- package/dist/generator-3S2MTXHO.cjs +12 -0
- package/dist/{generator-GFSOVACB.cjs.map → generator-3S2MTXHO.cjs.map} +1 -1
- package/dist/generator-R2CZZ2KU.js +18 -0
- package/dist/{hancom-UZAYAZLU.cjs → hancom-35Z4YAJB.cjs} +5 -5
- package/dist/{hancom-UZAYAZLU.cjs.map → hancom-35Z4YAJB.cjs.map} +1 -1
- package/dist/{hancom-Q2VC3YBY.js → hancom-4LFQU2RS.js} +2 -2
- package/dist/{hancom-MOQ5X7BT.js → hancom-VLS77NRS.js} +2 -2
- package/dist/{image-ocr-4RGMDWKZ.cjs → image-ocr-AGEB22EF.cjs} +36 -36
- package/dist/{image-ocr-4RGMDWKZ.cjs.map → image-ocr-AGEB22EF.cjs.map} +1 -1
- package/dist/{image-ocr-2Q2ZJYAJ.js → image-ocr-B7RRK43I.js} +8 -8
- package/dist/{image-ocr-KVV5JKY6.js → image-ocr-CCLUXSWY.js} +11 -11
- package/dist/index.cjs +1113 -1113
- package/dist/index.js +10 -10
- package/dist/mcp.js +37 -37
- package/dist/memo-SPNLGMIZ.js +17 -0
- package/dist/{model-bundle-SKRKICE4.js → model-bundle-KFPWVEFB.js} +5 -5
- package/dist/{models-QRQ4SU52.js → models-IOX5WK67.js} +5 -5
- package/dist/{parse-worker-v2-4BSQYNJ4.js → parse-worker-v2-IL6U65X3.js} +23 -23
- package/dist/{parser-B6YSYZTH.js → parser-ANWES7Z3.js} +12 -12
- package/dist/{parser-LVDXYJ2F.js → parser-ATU5CQZY.js} +9 -9
- package/dist/{parser-N5CJ252P.cjs → parser-NCSJG5KJ.cjs} +164 -164
- package/dist/{parser-N5CJ252P.cjs.map → parser-NCSJG5KJ.cjs.map} +1 -1
- package/dist/{pdf-ocr-5X2ZFG5O.js → pdf-ocr-7IH7FGKQ.js} +9 -9
- package/dist/pdf-ocr-F3ABLLXD.cjs +43 -0
- package/dist/{pdf-ocr-ZEP6O2UV.cjs.map → pdf-ocr-F3ABLLXD.cjs.map} +1 -1
- package/dist/{pdf-ocr-BJFC7NL3.js → pdf-ocr-ZUGHKM32.js} +6 -6
- package/dist/{profile-io-C55VLUZW.js → profile-io-BGUQJDGK.js} +3 -3
- package/dist/{rasterize-LCD3Q43I.js → rasterize-JOAG2QCQ.js} +3 -3
- package/dist/{redact-doc-BKNJOYE3.js → redact-doc-WL2GWBMN.js} +22 -22
- package/dist/{render-TWO5VQNJ.js → render-672D354C.js} +12 -12
- package/dist/{rewrite-fallback-AH3RNFIL.js → rewrite-fallback-2JAAIU6G.js} +13 -13
- package/dist/seal-XLDIGIIE.js +16 -0
- package/dist/{setup-VPGX6IJS.js → setup-L4PVFG65.js} +3 -3
- package/dist/{to-hwpx-JUWORW4M.js → to-hwpx-FR6GDNMY.js} +7 -7
- package/dist/{to-hwpx-TZFO5KL2.js → to-hwpx-OHZK2KBP.js} +4 -4
- package/dist/to-hwpx-VBVI5H4N.cjs +16 -0
- package/dist/{to-hwpx-LJQWVGOZ.cjs.map → to-hwpx-VBVI5H4N.cjs.map} +1 -1
- package/dist/visual-IXMRTYJK.js +40 -0
- package/dist/{watch-3J3O5GZN.js → watch-OH4BMY2N.js} +23 -23
- package/package.json +1 -1
- package/dist/chunk-GBOVNTH6.js.map +0 -1
- package/dist/chunk-QQTMRZUG.cjs.map +0 -1
- package/dist/chunk-XV6A6WHZ.js.map +0 -1
- package/dist/chunks-SC2MGE4B.js +0 -11
- package/dist/generator-4P5RXII7.js +0 -18
- package/dist/generator-GFSOVACB.cjs +0 -12
- package/dist/generator-NABTD6TU.js +0 -11
- package/dist/memo-K65K6E5J.js +0 -17
- package/dist/pdf-ocr-ZEP6O2UV.cjs +0 -43
- package/dist/seal-OCTCBT5O.js +0 -16
- package/dist/to-hwpx-LJQWVGOZ.cjs +0 -16
- package/dist/visual-SDJQ6EGR.js +0 -40
- /package/dist/{-IA5KLKYE.js.map → -2LCJEMU4.js.map} +0 -0
- /package/dist/{chunk-UXWF3PM7.js.map → chunk-2P5GYSEI.js.map} +0 -0
- /package/dist/{chunk-RYYDGS4R.js.map → chunk-2ZQUSUDC.js.map} +0 -0
- /package/dist/{chunk-UNIYOWUQ.js.map → chunk-3X3ETOLW.js.map} +0 -0
- /package/dist/{chunk-BX6TAXOM.js.map → chunk-45AT4XJD.js.map} +0 -0
- /package/dist/{chunk-JQ6N26LA.js.map → chunk-4L3SF7EF.js.map} +0 -0
- /package/dist/{chunk-RJBQXQAM.js.map → chunk-4RB5OPUZ.js.map} +0 -0
- /package/dist/{chunk-V5XT2PRB.js.map → chunk-BUZLNJXB.js.map} +0 -0
- /package/dist/{chunk-SODVNDR5.js.map → chunk-CWEB4XAH.js.map} +0 -0
- /package/dist/{chunk-M33WZZPM.js.map → chunk-DTKVCSRC.js.map} +0 -0
- /package/dist/{chunk-IITWVZF5.js.map → chunk-E2RQPNXX.js.map} +0 -0
- /package/dist/{chunk-RGSVM7RL.js.map → chunk-HQXVNLH2.js.map} +0 -0
- /package/dist/{chunk-7USEKDFP.js.map → chunk-IRCO55NY.js.map} +0 -0
- /package/dist/{chunk-TSACZSXD.js.map → chunk-J6RLB6KE.js.map} +0 -0
- /package/dist/{chunk-WQQVAAPX.js.map → chunk-JT54JHR3.js.map} +0 -0
- /package/dist/{chunk-H7OEE7UV.js.map → chunk-LFXIZHPE.js.map} +0 -0
- /package/dist/{chunk-N564V2TH.js.map → chunk-MHDVZBUV.js.map} +0 -0
- /package/dist/{chunk-NNTUIJLC.js.map → chunk-MRHLGVK5.js.map} +0 -0
- /package/dist/{chunk-SOW4ES4Y.js.map → chunk-ODJRLTXE.js.map} +0 -0
- /package/dist/{chunk-DZPF2PWU.js.map → chunk-ODQJEBCB.js.map} +0 -0
- /package/dist/{chunk-XJID65VS.js.map → chunk-PATC34WZ.js.map} +0 -0
- /package/dist/{chunk-2RTRPVUB.js.map → chunk-PE3XRCTM.js.map} +0 -0
- /package/dist/{chunk-XJNRTANY.js.map → chunk-PJ32UFPA.js.map} +0 -0
- /package/dist/{chunk-SDQZSUFR.js.map → chunk-QDETIVPA.js.map} +0 -0
- /package/dist/{chunk-YIW4AEC6.js.map → chunk-RNBBMRKF.js.map} +0 -0
- /package/dist/{chunk-CXQXLQVT.js.map → chunk-RZXJFM3A.js.map} +0 -0
- /package/dist/{chunk-ZOXPQZ4D.js.map → chunk-SABDVSQU.js.map} +0 -0
- /package/dist/{chunk-S3RWTPEO.js.map → chunk-SQ7BI34M.js.map} +0 -0
- /package/dist/{chunk-BIHQG2N7.js.map → chunk-T7YHAP4A.js.map} +0 -0
- /package/dist/{chunk-SJG57YQQ.js.map → chunk-TGM5V7UD.js.map} +0 -0
- /package/dist/{chunk-OQAE5NDF.js.map → chunk-U7EJ6QY7.js.map} +0 -0
- /package/dist/{chunk-FZMAFLAY.js.map → chunk-V3MVGLWO.js.map} +0 -0
- /package/dist/{chunk-CJYGYR2V.js.map → chunk-WTKISVEW.js.map} +0 -0
- /package/dist/{chunk-MG2DFKP7.js.map → chunk-XIUXBJHE.js.map} +0 -0
- /package/dist/{chunk-IPR3I6YO.js.map → chunk-XOC5PVAC.js.map} +0 -0
- /package/dist/{chunk-FV57PXPQ.js.map → chunk-ZWA3MWAE.js.map} +0 -0
- /package/dist/{chunks-SC2MGE4B.js.map → chunks-INR44FWQ.js.map} +0 -0
- /package/dist/{formula-XSFAUBCL.js.map → formula-3RUSZL2X.js.map} +0 -0
- /package/dist/{formula-PMHBDDCI.js.map → formula-UJKRUT4H.js.map} +0 -0
- /package/dist/{generator-4P5RXII7.js.map → generator-335G75L5.js.map} +0 -0
- /package/dist/{generator-NABTD6TU.js.map → generator-R2CZZ2KU.js.map} +0 -0
- /package/dist/{hancom-Q2VC3YBY.js.map → hancom-4LFQU2RS.js.map} +0 -0
- /package/dist/{hancom-MOQ5X7BT.js.map → hancom-VLS77NRS.js.map} +0 -0
- /package/dist/{image-ocr-2Q2ZJYAJ.js.map → image-ocr-B7RRK43I.js.map} +0 -0
- /package/dist/{image-ocr-KVV5JKY6.js.map → image-ocr-CCLUXSWY.js.map} +0 -0
- /package/dist/{memo-K65K6E5J.js.map → memo-SPNLGMIZ.js.map} +0 -0
- /package/dist/{model-bundle-SKRKICE4.js.map → model-bundle-KFPWVEFB.js.map} +0 -0
- /package/dist/{models-QRQ4SU52.js.map → models-IOX5WK67.js.map} +0 -0
- /package/dist/{parse-worker-v2-4BSQYNJ4.js.map → parse-worker-v2-IL6U65X3.js.map} +0 -0
- /package/dist/{parser-B6YSYZTH.js.map → parser-ANWES7Z3.js.map} +0 -0
- /package/dist/{parser-LVDXYJ2F.js.map → parser-ATU5CQZY.js.map} +0 -0
- /package/dist/{pdf-ocr-5X2ZFG5O.js.map → pdf-ocr-7IH7FGKQ.js.map} +0 -0
- /package/dist/{pdf-ocr-BJFC7NL3.js.map → pdf-ocr-ZUGHKM32.js.map} +0 -0
- /package/dist/{profile-io-C55VLUZW.js.map → profile-io-BGUQJDGK.js.map} +0 -0
- /package/dist/{rasterize-LCD3Q43I.js.map → rasterize-JOAG2QCQ.js.map} +0 -0
- /package/dist/{redact-doc-BKNJOYE3.js.map → redact-doc-WL2GWBMN.js.map} +0 -0
- /package/dist/{render-TWO5VQNJ.js.map → render-672D354C.js.map} +0 -0
- /package/dist/{rewrite-fallback-AH3RNFIL.js.map → rewrite-fallback-2JAAIU6G.js.map} +0 -0
- /package/dist/{seal-OCTCBT5O.js.map → seal-XLDIGIIE.js.map} +0 -0
- /package/dist/{setup-VPGX6IJS.js.map → setup-L4PVFG65.js.map} +0 -0
- /package/dist/{to-hwpx-JUWORW4M.js.map → to-hwpx-FR6GDNMY.js.map} +0 -0
- /package/dist/{to-hwpx-TZFO5KL2.js.map → to-hwpx-OHZK2KBP.js.map} +0 -0
- /package/dist/{visual-SDJQ6EGR.js.map → visual-IXMRTYJK.js.map} +0 -0
- /package/dist/{watch-3J3O5GZN.js.map → watch-OH4BMY2N.js.map} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class;
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var _chunkDIUYXWT2cjs = require('./chunk-DIUYXWT2.cjs');
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
@@ -9,11 +9,11 @@ var _chunk6F54BTUNcjs = require('./chunk-6F54BTUN.cjs');
|
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _chunkXM4VBVYHcjs = require('./chunk-XM4VBVYH.cjs');
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
|
|
16
|
-
var
|
|
16
|
+
var _chunkQIVOVMECcjs = require('./chunk-QIVOVMEC.cjs');
|
|
17
17
|
|
|
18
18
|
// src/ocr/models.ts
|
|
19
19
|
var _path = require('path');
|
|
@@ -65,7 +65,7 @@ var OCR_REC_DICT = {
|
|
|
65
65
|
sizeMb: 1
|
|
66
66
|
};
|
|
67
67
|
function getOcrModelsDir() {
|
|
68
|
-
return
|
|
68
|
+
return _chunkDIUYXWT2cjs.getModelsDir.call(void 0, "ppocr");
|
|
69
69
|
}
|
|
70
70
|
var DEFAULT_OCR_MODELS = Object.freeze({
|
|
71
71
|
det: { spec: OCR_DET_MODEL },
|
|
@@ -110,7 +110,7 @@ async function ensureOcrModelsFor(sel, onProgress) {
|
|
|
110
110
|
if (!stamp || verifiedInProcess.get(path) !== stamp) todo.push(s.spec);
|
|
111
111
|
}
|
|
112
112
|
if (!todo.length) return;
|
|
113
|
-
await
|
|
113
|
+
await _chunkDIUYXWT2cjs.ensureModelsIn.call(void 0, dir, todo, onProgress);
|
|
114
114
|
for (const spec of todo) {
|
|
115
115
|
const path = _path.join.call(void 0, dir, spec.filename), stamp = await fileStamp(path);
|
|
116
116
|
if (stamp) verifiedInProcess.set(path, stamp);
|
|
@@ -3414,16 +3414,16 @@ function recordOpenEndCellEdges(grid, cells, horizontals) {
|
|
|
3414
3414
|
}
|
|
3415
3415
|
function takeClipCellEdges(from, to) {
|
|
3416
3416
|
const e = CLIP_CELL_EDGES.get(from);
|
|
3417
|
-
if (e)
|
|
3417
|
+
if (e) _chunkXM4VBVYHcjs.CELL_EDGES.set(to, e);
|
|
3418
3418
|
}
|
|
3419
3419
|
function hasOpenCellSeam(a, b) {
|
|
3420
|
-
const u =
|
|
3420
|
+
const u = _chunkXM4VBVYHcjs.CELL_EDGES.get(a), d = _chunkXM4VBVYHcjs.CELL_EDGES.get(b);
|
|
3421
3421
|
return !!u && !!d && u.t && !u.b && !d.t && d.b && u.l && u.r && d.l && d.r;
|
|
3422
3422
|
}
|
|
3423
3423
|
function joinCellEdges(a, b) {
|
|
3424
|
-
const u =
|
|
3424
|
+
const u = _chunkXM4VBVYHcjs.CELL_EDGES.get(a), d = _chunkXM4VBVYHcjs.CELL_EDGES.get(b);
|
|
3425
3425
|
if (!u || !d) return;
|
|
3426
|
-
|
|
3426
|
+
_chunkXM4VBVYHcjs.CELL_EDGES.set(a, { t: u.t, b: d.b, l: u.l || d.l, r: u.r || d.r });
|
|
3427
3427
|
}
|
|
3428
3428
|
|
|
3429
3429
|
// src/pdf/cell-extract.ts
|
|
@@ -3608,7 +3608,7 @@ function tagScripts(text, lines) {
|
|
|
3608
3608
|
const [s, e, kind] = marks[m];
|
|
3609
3609
|
out = out.slice(0, s) + `<${kind}>` + out.slice(s, e) + `</${kind}>` + out.slice(e);
|
|
3610
3610
|
}
|
|
3611
|
-
return
|
|
3611
|
+
return _chunkXM4VBVYHcjs.tidyScriptTags.call(void 0, out);
|
|
3612
3612
|
}
|
|
3613
3613
|
|
|
3614
3614
|
// src/pdf/line-wrap.ts
|
|
@@ -4211,7 +4211,8 @@ function mergeSuperscriptRows(lines) {
|
|
|
4211
4211
|
const overlap2 = Math.min(a.top, b.top) - Math.max(a.bottom, b.bottom);
|
|
4212
4212
|
const prevIsFrag = (isFrag(prev) || isAttachedScripts(prev, curr)) && a.height <= b.height * 0.8 && overlap2 >= a.height * 0.5;
|
|
4213
4213
|
const currIsFrag = (isFrag(curr) || isAttachedScripts(curr, prev)) && b.height <= a.height * 0.8 && overlap2 >= b.height * 0.5;
|
|
4214
|
-
const
|
|
4214
|
+
const sameSize = (a2, b2) => Math.abs(a2.fontSize - b2.fontSize) <= Math.max(a2.fontSize, b2.fontSize) * 0.1;
|
|
4215
|
+
const stacked = prev.some((o) => curr.some((it) => (o.fontName === "ocr" ? it.fontName === "ocr" : it.fontName !== "ocr" && sameSize(o, it)) && Math.min(it.x + it.w, o.x + o.w) - Math.max(it.x, o.x) > Math.min(it.w, o.w) * 0.5));
|
|
4215
4216
|
if ((prevIsFrag || currIsFrag) && !stacked) {
|
|
4216
4217
|
result[result.length - 1] = [...prev, ...curr];
|
|
4217
4218
|
} else {
|
|
@@ -4859,15 +4860,35 @@ function groupByY(items) {
|
|
|
4859
4860
|
return lines;
|
|
4860
4861
|
}
|
|
4861
4862
|
var PREFIX_SCRIPT = /^[^A-Za-z+=×÷<>≤≥∫∑∏√∞^_{}\\/]+$/;
|
|
4863
|
+
function scriptRunFits(run, h) {
|
|
4864
|
+
const sizes = run.map((r) => _nullishCoalesce(r.fontSize, () => ( Infinity)));
|
|
4865
|
+
return !/^[()[\]{}<>]*$/.test(_nullishCoalesce(h.text, () => ( ""))) && Math.max(...sizes) <= h.fontSize * 0.85 && Math.max(...sizes) <= Math.min(...sizes) * 1.15;
|
|
4866
|
+
}
|
|
4862
4867
|
function isAttachedScripts(line, host) {
|
|
4863
|
-
|
|
4864
|
-
|
|
4865
|
-
|
|
4866
|
-
return
|
|
4867
|
-
|
|
4868
|
-
|
|
4869
|
-
|
|
4868
|
+
if (line.length <= 1 || line.length > 16) return false;
|
|
4869
|
+
const short = (i) => {
|
|
4870
|
+
const n = i.text.trim().length;
|
|
4871
|
+
return n > 0 && n <= 8;
|
|
4872
|
+
};
|
|
4873
|
+
const prefixBefore = (i, smaller) => PREFIX_SCRIPT.test(i.text.trim()) && host.some((h) => {
|
|
4874
|
+
const before = h.x - (i.x + i.w);
|
|
4875
|
+
return before <= h.fontSize * 0.6 && before >= -h.fontSize * 0.25 && (!smaller || scriptRunFits(smaller, h));
|
|
4870
4876
|
});
|
|
4877
|
+
const attached = (i) => short(i) && (prefixBefore(i) || host.some((h) => {
|
|
4878
|
+
const after = i.x - (h.x + h.w);
|
|
4879
|
+
return i.text.trim().length <= 3 && after <= h.fontSize * 0.35 && after >= -h.fontSize * 0.25;
|
|
4880
|
+
}));
|
|
4881
|
+
const sorted = [...line].sort((a, b) => a.x - b.x);
|
|
4882
|
+
let ok = 0;
|
|
4883
|
+
for (let k = 0, start = 0; k < sorted.length; k++) {
|
|
4884
|
+
const next = sorted[k + 1];
|
|
4885
|
+
if (next && next.x - (sorted[k].x + sorted[k].w) <= (_nullishCoalesce(_nullishCoalesce(sorted[k].fontSize, () => ( _optionalChain([host, 'access', _160 => _160[0], 'optionalAccess', _161 => _161.fontSize]))), () => ( 10))) * 0.7) continue;
|
|
4886
|
+
const run = sorted.slice(start, k + 1);
|
|
4887
|
+
const runOk = run.length > 1 && run.every((i) => short(i) && PREFIX_SCRIPT.test(i.text.trim())) && prefixBefore(run[run.length - 1], run);
|
|
4888
|
+
for (const i of run) if (runOk || attached(i)) ok++;
|
|
4889
|
+
start = k + 1;
|
|
4890
|
+
}
|
|
4891
|
+
return ok === line.length;
|
|
4871
4892
|
}
|
|
4872
4893
|
function isFragmentLine(line) {
|
|
4873
4894
|
let total = 0;
|
|
@@ -4942,7 +4963,7 @@ function trackedSpaces(sorted, med = trackingShift([sorted])) {
|
|
|
4942
4963
|
});
|
|
4943
4964
|
}
|
|
4944
4965
|
function mergeLineSimple(items) {
|
|
4945
|
-
if (items.length <= 1) return _optionalChain([items, 'access',
|
|
4966
|
+
if (items.length <= 1) return _optionalChain([items, 'access', _162 => _162[0], 'optionalAccess', _163 => _163.text]) || "";
|
|
4946
4967
|
const sorted = sortLineByX([...items]);
|
|
4947
4968
|
const tracked = trackedSpaces(sorted);
|
|
4948
4969
|
const isEvenSpaced = detectEvenSpacedItems(sorted);
|
|
@@ -4977,7 +4998,7 @@ function mergeLineSimple(items) {
|
|
|
4977
4998
|
result += sorted[i].text;
|
|
4978
4999
|
continue;
|
|
4979
5000
|
}
|
|
4980
|
-
if (gap > spaceGapThreshold(avgFs) || _optionalChain([tracked, 'optionalAccess',
|
|
5001
|
+
if (gap > spaceGapThreshold(avgFs) || _optionalChain([tracked, 'optionalAccess', _164 => _164[i]])) result += " ";
|
|
4981
5002
|
result += sorted[i].text;
|
|
4982
5003
|
}
|
|
4983
5004
|
return result;
|
|
@@ -5034,7 +5055,7 @@ function isProseTable(table) {
|
|
|
5034
5055
|
if (!(long > 0 && long >= total * 0.5 && longRows >= rows * 0.4)) return false;
|
|
5035
5056
|
for (let c = 0; c < table.cols; c++) {
|
|
5036
5057
|
const filled = table.cells.map((row) => row[c]).filter((cell) => cell && cell.colSpan < table.cols && cell.text.trim()).map((cell) => cell.text.trim());
|
|
5037
|
-
if (filled.length >= 3 && filled.length >= rows * 0.6 && filled.every((text) => text.length <= 30 && (_nullishCoalesce(_optionalChain([text, 'access',
|
|
5058
|
+
if (filled.length >= 3 && filled.length >= rows * 0.6 && filled.every((text) => text.length <= 30 && (_nullishCoalesce(_optionalChain([text, 'access', _165 => _165.match, 'call', _166 => _166(/\p{L}/gu), 'optionalAccess', _167 => _167.length]), () => ( 0))) >= 2)) return false;
|
|
5038
5059
|
}
|
|
5039
5060
|
return true;
|
|
5040
5061
|
}
|
|
@@ -5063,7 +5084,7 @@ var TICK = /^-?[\d,]+(?:\.\d+)?%?$/;
|
|
|
5063
5084
|
var QUANTITY = /^[-−–]?[\d,]*\.?\d+%?$/;
|
|
5064
5085
|
var quantity = (token) => Number(token.replace(/^[−–]/, "-").replace(/[,%]/g, ""));
|
|
5065
5086
|
function isValueAxisColumn(table, c) {
|
|
5066
|
-
const lines = table.cells.flatMap((row) => (_nullishCoalesce(_optionalChain([row, 'access',
|
|
5087
|
+
const lines = table.cells.flatMap((row) => (_nullishCoalesce(_optionalChain([row, 'access', _168 => _168[c], 'optionalAccess', _169 => _169.text]), () => ( ""))).split("\n").map((line) => line.trim().split(/\s+/)));
|
|
5067
5088
|
const others = table.cells.flatMap((row) => row.filter((_, k) => k !== c).map((cell) => cell.text.trim().split(/\s+/))).filter((tokens) => tokens.every((token) => QUANTITY.test(token))).flat().map(quantity).filter((v) => !(Number.isInteger(v) && v >= 1900 && v <= 2100));
|
|
5068
5089
|
for (const ticks of [lines.flat().filter((t) => TICK.test(t)).map(quantity), lines.map((tokens) => tokens[0]).filter((t) => TICK.test(t)).map(quantity)]) {
|
|
5069
5090
|
const run = fallingRun(ticks);
|
|
@@ -5096,7 +5117,7 @@ function isChartTable(table, ocr = false) {
|
|
|
5096
5117
|
if (numeric < texts.length * 0.5) return false;
|
|
5097
5118
|
if (ocr && table.cols >= 3 && table.cells.slice(0, 3).some((row) => row.filter((cell) => /[가-힣]{2}/.test(cell.text)).length >= 2)) return false;
|
|
5098
5119
|
for (let c = 0; c < table.cols; c++) {
|
|
5099
|
-
if (!ocr ? isValueAxisColumn(table, c) : hasValueAxis(table.cells.flatMap((row) => (_nullishCoalesce(_optionalChain([row, 'access',
|
|
5120
|
+
if (!ocr ? isValueAxisColumn(table, c) : hasValueAxis(table.cells.flatMap((row) => (_nullishCoalesce(_optionalChain([row, 'access', _170 => _170[c], 'optionalAccess', _171 => _171.text]), () => ( ""))).split(/\s+/)).filter((t) => TICK.test(t)).map((t) => Number(t.replace(/[,%]/g, ""))))) return true;
|
|
5100
5121
|
}
|
|
5101
5122
|
const values = texts.filter((text) => text.split(/\s+/).every((token) => QUANTITY.test(token))).length;
|
|
5102
5123
|
const cells = table.rows * table.cols;
|
|
@@ -5105,7 +5126,7 @@ function isChartTable(table, ocr = false) {
|
|
|
5105
5126
|
function isProseFragmentTable(table) {
|
|
5106
5127
|
const texts = table.cells.flat().map((cell) => cell.text.trim()).filter(Boolean);
|
|
5107
5128
|
if (texts.length < 4) return false;
|
|
5108
|
-
const hangul = (text) => _nullishCoalesce(_optionalChain([text, 'access',
|
|
5129
|
+
const hangul = (text) => _nullishCoalesce(_optionalChain([text, 'access', _172 => _172.match, 'call', _173 => _173(/[가-힣]/g), 'optionalAccess', _174 => _174.length]), () => ( 0));
|
|
5109
5130
|
if (texts.filter((text) => hangul(text) >= 2).length < texts.length * 0.7) return false;
|
|
5110
5131
|
if (texts.length >= 12 && texts.filter((text) => hangul(text) >= 15 && !text.includes("\n")).length >= texts.length * 0.4) return true;
|
|
5111
5132
|
return texts.filter((text) => /(?:[다요고서는을를에게지며면어아야니까던]|[.,?!])$/.test(text)).length >= texts.length * 0.3;
|
|
@@ -5158,7 +5179,7 @@ function clusterCellLines(items) {
|
|
|
5158
5179
|
}
|
|
5159
5180
|
var WRAP_INDENT_MAX = 3;
|
|
5160
5181
|
function joinClusterCellLines(lines, box, lex) {
|
|
5161
|
-
let out = _nullishCoalesce(_optionalChain([lines, 'access',
|
|
5182
|
+
let out = _nullishCoalesce(_optionalChain([lines, 'access', _175 => _175[0], 'optionalAccess', _176 => _176.text]), () => ( ""));
|
|
5162
5183
|
for (let i = 1; i < lines.length; i++) {
|
|
5163
5184
|
const a = lines[i - 1], b = lines[i];
|
|
5164
5185
|
const join2 = !a.spaceAfter && cellLineWraps(box, box.x1, a.right, a.fontSize, b.firstCharW) && a.left - box.x1 <= WRAP_INDENT_MAX * a.fontSize && b.left - box.x1 <= WRAP_INDENT_MAX * b.fontSize && /<\/u>$/.test(a.text) === /^<u>/.test(b.text) && !startsNewItem(out, b.text) && wrapJoiner(out, b.text, lex, false) === "";
|
|
@@ -5288,7 +5309,7 @@ function detectClusterTables(items, pageNum, rejected, lex) {
|
|
|
5288
5309
|
}
|
|
5289
5310
|
return results.filter((r) => {
|
|
5290
5311
|
const twoColumns = isTwoColumnProse(r);
|
|
5291
|
-
const prose = twoColumns || isProseTable(r.table) || gaplessCjkLines(r) || [...r.usedItems].every((it) => it.fontName === "ocr") && isProseFragmentTable(r.table);
|
|
5312
|
+
const prose = twoColumns || isProseTable(r.table) || gaplessCjkLines(r) || isFootnoteList(r.table) || [...r.usedItems].every((it) => it.fontName === "ocr") && isProseFragmentTable(r.table);
|
|
5292
5313
|
if (prose && rejected) rejected.prose++;
|
|
5293
5314
|
if (twoColumns && rejected && [...r.usedItems].every((it) => it.fontName === "ocr")) {
|
|
5294
5315
|
const used = [...r.usedItems].sort((a, b) => a.x - b.x);
|
|
@@ -5307,6 +5328,11 @@ function detectClusterTables(items, pageNum, rejected, lex) {
|
|
|
5307
5328
|
return !prose;
|
|
5308
5329
|
});
|
|
5309
5330
|
}
|
|
5331
|
+
function isFootnoteList(table) {
|
|
5332
|
+
const filled = table.cells.map((row) => row.filter((cell) => cell.text.trim())).filter((row) => row.length);
|
|
5333
|
+
const marks = filled.map((row) => /^(\d{1,3})\)$/.exec(row[0].text.trim())).filter((m) => m !== null).map((m) => Number(m[1]));
|
|
5334
|
+
return marks.length >= 3 && marks.length >= filled.length - 1 && marks.every((v, i) => i === 0 || v === marks[i - 1] + 1);
|
|
5335
|
+
}
|
|
5310
5336
|
function gaplessCjkLines(r) {
|
|
5311
5337
|
let lines = 0, gapless = 0;
|
|
5312
5338
|
for (const row of groupByBaseline([...r.usedItems].filter((i) => i.text.trim()))) {
|
|
@@ -5503,7 +5529,7 @@ function detectAlignedTwoColumnTables(rows, pageNum) {
|
|
|
5503
5529
|
continue;
|
|
5504
5530
|
}
|
|
5505
5531
|
const top = rows[i - 1];
|
|
5506
|
-
const title = _optionalChain([top, 'optionalAccess',
|
|
5532
|
+
const title = _optionalChain([top, 'optionalAccess', _177 => _177.items, 'access', _178 => _178.length]) === 1 && Math.abs(top.items[0].x - first[0].x) <= 5 && top.items[0].text.length <= 65 && top.y - first[0].y <= Math.max(24, first[0].fontSize * 2.8) ? top : void 0;
|
|
5507
5533
|
const tableRows = [...title ? [title] : [], ...body.flatMap((b) => b.rows)];
|
|
5508
5534
|
const cells = [
|
|
5509
5535
|
...title ? [[{ text: title.items[0].text, colSpan: 2, rowSpan: 1 }, { text: "", colSpan: 1, rowSpan: 1 }]] : [],
|
|
@@ -5559,12 +5585,12 @@ function isTwoColumnProse(r) {
|
|
|
5559
5585
|
if (t.rows < (ocr ? 6 : 8)) return false;
|
|
5560
5586
|
const dense = [];
|
|
5561
5587
|
for (let c = 0; c < t.cols; c++) {
|
|
5562
|
-
const filled = t.cells.filter((row) => _optionalChain([row, 'access',
|
|
5588
|
+
const filled = t.cells.filter((row) => _optionalChain([row, 'access', _179 => _179[c], 'optionalAccess', _180 => _180.text, 'access', _181 => _181.trim, 'call', _182 => _182()])).length;
|
|
5563
5589
|
if (filled / t.rows >= 0.3) dense.push(c);
|
|
5564
5590
|
}
|
|
5565
5591
|
if (dense.length !== 2) return false;
|
|
5566
5592
|
for (const c of dense) {
|
|
5567
|
-
const lens = t.cells.map((row) => _nullishCoalesce(_optionalChain([row, 'access',
|
|
5593
|
+
const lens = t.cells.map((row) => _nullishCoalesce(_optionalChain([row, 'access', _183 => _183[c], 'optionalAccess', _184 => _184.text, 'access', _185 => _185.replace, 'call', _186 => _186(/\s+/g, ""), 'access', _187 => _187.length]), () => ( 0))).filter((n) => n > 0);
|
|
5568
5594
|
const avg = lens.reduce((s, v) => s + v, 0) / (lens.length || 1);
|
|
5569
5595
|
if (avg < (ocr ? 15 : 12)) return false;
|
|
5570
5596
|
}
|
|
@@ -5810,7 +5836,22 @@ function mergeOverlappingRows(rows) {
|
|
|
5810
5836
|
}
|
|
5811
5837
|
function isFragmentRow(row, host) {
|
|
5812
5838
|
if (!row.items.every((i) => i.text.length <= 8)) return false;
|
|
5813
|
-
|
|
5839
|
+
if (row.items.length <= 3) return true;
|
|
5840
|
+
if (row.items.length > 16 || !row.items.every((i) => PREFIX_SCRIPT.test(i.text.trim()))) return false;
|
|
5841
|
+
const sorted = [...row.items].sort((a, b) => a.x - b.x);
|
|
5842
|
+
for (let k = 0, start = 0; k < sorted.length; k++) {
|
|
5843
|
+
const next = sorted[k + 1];
|
|
5844
|
+
if (next && next.x - (sorted[k].x + sorted[k].w) <= sorted[k].fontSize * 0.7) continue;
|
|
5845
|
+
const run = sorted.slice(start, k + 1);
|
|
5846
|
+
const end = run[run.length - 1];
|
|
5847
|
+
const runOk = run.length > 1 && host.items.some((h) => {
|
|
5848
|
+
const before = h.x - (end.x + end.w);
|
|
5849
|
+
return before <= h.fontSize * 0.6 && before >= -h.fontSize * 0.1 && scriptRunFits(run, h);
|
|
5850
|
+
});
|
|
5851
|
+
if (!runOk && !run.every((i) => host.items.some((h) => scriptAttached(i, h)))) return false;
|
|
5852
|
+
start = k + 1;
|
|
5853
|
+
}
|
|
5854
|
+
return true;
|
|
5814
5855
|
}
|
|
5815
5856
|
function scriptAttached(i, h) {
|
|
5816
5857
|
const after = i.x - (h.x + h.w), before = h.x - (i.x + i.w);
|
|
@@ -6026,7 +6067,7 @@ function assignRowItems(items, columns, numCols, headerFace) {
|
|
|
6026
6067
|
const runs = [];
|
|
6027
6068
|
for (const it of sorted) {
|
|
6028
6069
|
const last = runs[runs.length - 1];
|
|
6029
|
-
const prev = _optionalChain([last, 'optionalAccess',
|
|
6070
|
+
const prev = _optionalChain([last, 'optionalAccess', _188 => _188[last.length - 1]]);
|
|
6030
6071
|
if (prev && it.x - (prev.x + prev.w) <= Math.max(0.5, it.fontSize * 0.05) && !it.hasSpaceBefore) last.push(it);
|
|
6031
6072
|
else runs.push([it]);
|
|
6032
6073
|
}
|
|
@@ -6077,7 +6118,7 @@ function assignRowItems(items, columns, numCols, headerFace) {
|
|
|
6077
6118
|
assignedGroups.add(gi);
|
|
6078
6119
|
usedCols.add(ci);
|
|
6079
6120
|
}
|
|
6080
|
-
const colOf = groups.map((g) => _nullishCoalesce(_optionalChain([result, 'access',
|
|
6121
|
+
const colOf = groups.map((g) => _nullishCoalesce(_optionalChain([result, 'access', _189 => _189.find, 'call', _190 => _190((a) => a.items === g), 'optionalAccess', _191 => _191.col]), () => ( -1)));
|
|
6081
6122
|
if (groups.length <= numCols && colOf.some((c, g) => g > 0 && c < colOf[g - 1])) {
|
|
6082
6123
|
const G = groups.length, cost = (g, c2) => Math.abs(groupCenters[g] - colCenters[c2]);
|
|
6083
6124
|
const best = groups.map(() => new Array(numCols).fill(Infinity)), from = groups.map(() => new Array(numCols).fill(-1));
|
|
@@ -6114,7 +6155,7 @@ function assignRowItems(items, columns, numCols, headerFace) {
|
|
|
6114
6155
|
function buildClusterTable(rows, columns, pageNum, lex) {
|
|
6115
6156
|
const numRows = rows.length;
|
|
6116
6157
|
if (numRows < MIN_ROWS || columns.length < MIN_COLS) return null;
|
|
6117
|
-
const headFaces = new Set(_optionalChain([rows, 'access',
|
|
6158
|
+
const headFaces = new Set(_optionalChain([rows, 'access', _192 => _192[0], 'optionalAccess', _193 => _193.items, 'access', _194 => _194.map, 'call', _195 => _195((i) => i.fontName)]));
|
|
6118
6159
|
const headerFace = headFaces.size === 1 && rows.slice(1).every((row) => row.items.every((i) => !headFaces.has(i.fontName))) ? [...headFaces][0] : void 0;
|
|
6119
6160
|
const assigned = rows.map((row, r) => assignRowItems(row.items, columns, columns.length, r === 0 ? headerFace : void 0));
|
|
6120
6161
|
const cuts = supportedOcrColumnCuts(assigned);
|
|
@@ -6185,7 +6226,7 @@ function buildClusterTable(rows, columns, pageNum, lex) {
|
|
|
6185
6226
|
const nonEmptyCols = cells[r].filter((c) => c.text.trim()).length;
|
|
6186
6227
|
if (nonEmptyCols !== 1) continue;
|
|
6187
6228
|
if (cells[r][0].text.trim() !== "") continue;
|
|
6188
|
-
const contentText = _optionalChain([cells, 'access',
|
|
6229
|
+
const contentText = _optionalChain([cells, 'access', _196 => _196[r], 'access', _197 => _197.find, 'call', _198 => _198((c) => c.text.trim()), 'optionalAccess', _199 => _199.text, 'access', _200 => _200.trim, 'call', _201 => _201()]) || "";
|
|
6189
6230
|
if (/^[○●▶\-·]/.test(contentText)) continue;
|
|
6190
6231
|
for (let pr = r - 1; pr >= 0; pr--) {
|
|
6191
6232
|
if (cells[pr].some((c) => c.text.trim())) {
|
|
@@ -6418,7 +6459,7 @@ function stackedTableBands(items) {
|
|
|
6418
6459
|
const caption = (start, end) => lines.slice(start, end).some((line) => /^Table\s+\d+\s*[:.]/i.test(mergeLineSimple(line).trim()));
|
|
6419
6460
|
while (runs.length > 0 && !caption(runs[runs.length - 1].end, lines.length)) runs.pop();
|
|
6420
6461
|
if (runs.length < 2) return null;
|
|
6421
|
-
if (runs.some((run, i) => !caption(run.end, _nullishCoalesce(_optionalChain([runs, 'access',
|
|
6462
|
+
if (runs.some((run, i) => !caption(run.end, _nullishCoalesce(_optionalChain([runs, 'access', _202 => _202[i + 1], 'optionalAccess', _203 => _203.start]), () => ( lines.length))))) return null;
|
|
6422
6463
|
const tables = runs.map((run) => lines.slice(run.start, run.end).flat());
|
|
6423
6464
|
const between = runs.slice(0, -1).map((run, i) => lines.slice(run.end, runs[i + 1].start).flat());
|
|
6424
6465
|
const tail = lines.slice(runs[runs.length - 1].end);
|
|
@@ -6686,7 +6727,7 @@ function splitTrailingColumnRegion(items) {
|
|
|
6686
6727
|
}
|
|
6687
6728
|
function panelBlocks(items, panel, pageNum) {
|
|
6688
6729
|
const lines = groupByY([...items].sort((a, b) => b.y - a.y || a.x - b.x));
|
|
6689
|
-
const faceOf = (line) => _nullishCoalesce(_optionalChain([dominantStyle, 'call',
|
|
6730
|
+
const faceOf = (line) => _nullishCoalesce(_optionalChain([dominantStyle, 'call', _204 => _204(line), 'optionalAccess', _205 => _205.fontName]), () => ( ""));
|
|
6690
6731
|
const runs = [];
|
|
6691
6732
|
for (const line of lines) {
|
|
6692
6733
|
const last = runs[runs.length - 1];
|
|
@@ -6893,7 +6934,7 @@ function validWrapBands(items, bands) {
|
|
|
6893
6934
|
}
|
|
6894
6935
|
function inheritedWrapBands(items) {
|
|
6895
6936
|
const source = XY_WRAP_ITEMS.get(items[0]);
|
|
6896
|
-
const present = _optionalChain([source, 'optionalAccess',
|
|
6937
|
+
const present = _optionalChain([source, 'optionalAccess', _206 => _206.length]) === items.length ? new Set(items) : null;
|
|
6897
6938
|
const sameLeaf = present && source.every((item) => present.has(item));
|
|
6898
6939
|
return sameLeaf ? validWrapBands(items, _nullishCoalesce(XY_WRAP_BANDS.get(items[0]), () => ( []))) : [];
|
|
6899
6940
|
}
|
|
@@ -6928,7 +6969,7 @@ function splitsLoneRowTail(items, x) {
|
|
|
6928
6969
|
const tail = right[0], box = computeBBox(items, 0), tailBox = computeBBox(tail, 0);
|
|
6929
6970
|
const head = left.find((r) => Math.abs(r[0].y - tail[0].y) <= 2);
|
|
6930
6971
|
if (!head) return false;
|
|
6931
|
-
const headBox = computeBBox(head, 0), fs = _nullishCoalesce(_optionalChain([dominantStyle, 'call',
|
|
6972
|
+
const headBox = computeBBox(head, 0), fs = _nullishCoalesce(_optionalChain([dominantStyle, 'call', _207 => _207(tail), 'optionalAccess', _208 => _208.fontSize]), () => ( 10));
|
|
6932
6973
|
const gap = tailBox.x - (headBox.x + headBox.width), fills = tailBox.x + tailBox.width >= box.x + box.width - fs;
|
|
6933
6974
|
if (gap <= fs * 3 && fills && headBox.width >= box.width / 2) return true;
|
|
6934
6975
|
const text = [...head, ...tail].map((i) => i.text).join("");
|
|
@@ -6944,7 +6985,7 @@ function wrappedLineBands(items, inherited, lex) {
|
|
|
6944
6985
|
left: box.x,
|
|
6945
6986
|
right: box.x + box.width,
|
|
6946
6987
|
y: row.reduce((n, i) => n + i.y, 0) / row.length,
|
|
6947
|
-
fontSize: _nullishCoalesce(_optionalChain([dominantStyle, 'call',
|
|
6988
|
+
fontSize: _nullishCoalesce(_optionalChain([dominantStyle, 'call', _209 => _209(row), 'optionalAccess', _210 => _210.fontSize]), () => ( 0)),
|
|
6948
6989
|
sources: row.map((item) => ({ item, state: { ...item } }))
|
|
6949
6990
|
};
|
|
6950
6991
|
});
|
|
@@ -7080,10 +7121,10 @@ function pushLineParagraphs(out, yLines, pageNum, lex) {
|
|
|
7080
7121
|
const lines = attachDropCaps(yLines).map((items) => ({ items, text: mergeLineSimple(items) })).filter((l) => l.text.trim());
|
|
7081
7122
|
const geo = lines.map((l) => {
|
|
7082
7123
|
const b = computeBBox(l.items, pageNum);
|
|
7083
|
-
return { text: l.text, left: b.x, right: b.x + b.width, y: l.items.reduce((s, i) => s + i.y, 0) / l.items.length, fontSize: _nullishCoalesce(_optionalChain([dominantStyle, 'call',
|
|
7124
|
+
return { text: l.text, left: b.x, right: b.x + b.width, y: l.items.reduce((s, i) => s + i.y, 0) / l.items.length, fontSize: _nullishCoalesce(_optionalChain([dominantStyle, 'call', _211 => _211(l.items), 'optionalAccess', _212 => _212.fontSize]), () => ( 0)) };
|
|
7084
7125
|
});
|
|
7085
7126
|
const joins = bodyLineJoins(geo, lex);
|
|
7086
|
-
const first = _optionalChain([lines, 'access',
|
|
7127
|
+
const first = _optionalChain([lines, 'access', _213 => _213[0], 'optionalAccess', _214 => _214.items, 'access', _215 => _215[0]]);
|
|
7087
7128
|
const bands = first ? _nullishCoalesce(XY_WRAP_BANDS.get(first), () => ( [])) : [];
|
|
7088
7129
|
const hasBand = (top, bottom) => {
|
|
7089
7130
|
let lo = 0, hi = bands.length;
|
|
@@ -7160,15 +7201,15 @@ function computeMedianFontSizeFromFreq(freq) {
|
|
|
7160
7201
|
function detectHeadings(blocks, medianFontSize) {
|
|
7161
7202
|
for (let bi = 0; bi < blocks.length; bi++) {
|
|
7162
7203
|
const block = blocks[bi];
|
|
7163
|
-
if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access',
|
|
7204
|
+
if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access', _216 => _216.style, 'optionalAccess', _217 => _217.fontSize])) continue;
|
|
7164
7205
|
const text = block.text.trim();
|
|
7165
7206
|
if (text.length === 0 || text.length > 200) continue;
|
|
7166
7207
|
if (/^\d+$/.test(text) && !isChapterNumber(block, blocks[bi + 1], medianFontSize)) continue;
|
|
7167
7208
|
const ratio = block.style.fontSize / medianFontSize;
|
|
7168
7209
|
let level = 0;
|
|
7169
|
-
if (ratio >=
|
|
7170
|
-
else if (ratio >=
|
|
7171
|
-
else if (ratio >=
|
|
7210
|
+
if (ratio >= _chunkXM4VBVYHcjs.HEADING_RATIO_H1) level = 1;
|
|
7211
|
+
else if (ratio >= _chunkXM4VBVYHcjs.HEADING_RATIO_H2) level = 2;
|
|
7212
|
+
else if (ratio >= _chunkXM4VBVYHcjs.HEADING_RATIO_H3) level = 3;
|
|
7172
7213
|
if (level > 0) {
|
|
7173
7214
|
block.type = "heading";
|
|
7174
7215
|
block.level = level;
|
|
@@ -7177,21 +7218,21 @@ function detectHeadings(blocks, medianFontSize) {
|
|
|
7177
7218
|
}
|
|
7178
7219
|
}
|
|
7179
7220
|
function isChapterNumber(block, next, medianFontSize) {
|
|
7180
|
-
const size = _nullishCoalesce(_optionalChain([block, 'access',
|
|
7181
|
-
const nextSize = _nullishCoalesce(_optionalChain([next, 'optionalAccess',
|
|
7182
|
-
const text = _nullishCoalesce(_optionalChain([next, 'optionalAccess',
|
|
7183
|
-
const a = block.bbox, b = _optionalChain([next, 'optionalAccess',
|
|
7184
|
-
return /^\d{1,2}$/.test(_nullishCoalesce(_optionalChain([block, 'access',
|
|
7221
|
+
const size = _nullishCoalesce(_optionalChain([block, 'access', _218 => _218.style, 'optionalAccess', _219 => _219.fontSize]), () => ( 0));
|
|
7222
|
+
const nextSize = _nullishCoalesce(_optionalChain([next, 'optionalAccess', _220 => _220.style, 'optionalAccess', _221 => _221.fontSize]), () => ( 0));
|
|
7223
|
+
const text = _nullishCoalesce(_optionalChain([next, 'optionalAccess', _222 => _222.text, 'optionalAccess', _223 => _223.trim, 'call', _224 => _224()]), () => ( ""));
|
|
7224
|
+
const a = block.bbox, b = _optionalChain([next, 'optionalAccess', _225 => _225.bbox]);
|
|
7225
|
+
return /^\d{1,2}$/.test(_nullishCoalesce(_optionalChain([block, 'access', _226 => _226.text, 'optionalAccess', _227 => _227.trim, 'call', _228 => _228()]), () => ( ""))) && size >= medianFontSize * 2.5 && !!next && (next.type === "paragraph" || next.type === "heading") && next.pageNumber === block.pageNumber && nextSize >= medianFontSize * _chunkXM4VBVYHcjs.HEADING_RATIO_H1 && text.length > 0 && text.length <= 80 && !/^[\d\s.]+$/.test(text) && !!a && !!b && a.y > b.y && a.y - (b.y + b.height) <= size * 2;
|
|
7185
7226
|
}
|
|
7186
7227
|
function mergeStackedHeadingLines(blocks, medianFontSize) {
|
|
7187
7228
|
for (let i = 0; i < blocks.length - 1; ) {
|
|
7188
7229
|
const a = blocks[i], b = blocks[i + 1];
|
|
7189
7230
|
const ab = a.bbox, bb = b.bbox;
|
|
7190
|
-
const af = _nullishCoalesce(_optionalChain([a, 'access',
|
|
7231
|
+
const af = _nullishCoalesce(_optionalChain([a, 'access', _229 => _229.style, 'optionalAccess', _230 => _230.fontSize]), () => ( 0)), bf = _nullishCoalesce(_optionalChain([b, 'access', _231 => _231.style, 'optionalAccess', _232 => _232.fontSize]), () => ( 0));
|
|
7191
7232
|
const gap = ab && bb ? ab.y - (bb.y + bb.height) : Infinity;
|
|
7192
|
-
const centered = ab && bb && _optionalChain([a, 'access',
|
|
7233
|
+
const centered = ab && bb && _optionalChain([a, 'access', _233 => _233.style, 'optionalAccess', _234 => _234.fontName]) === _optionalChain([b, 'access', _235 => _235.style, 'optionalAccess', _236 => _236.fontName]) && Math.abs(ab.x + ab.width / 2 - (bb.x + bb.width / 2)) <= Math.max(5, af * 0.5);
|
|
7193
7234
|
const sameAnchor = ab && bb && Math.abs(ab.x - bb.x) <= 5;
|
|
7194
|
-
const wrapped = sameAnchor && _optionalChain([a, 'access',
|
|
7235
|
+
const wrapped = sameAnchor && _optionalChain([a, 'access', _237 => _237.style, 'optionalAccess', _238 => _238.fontName]) === _optionalChain([b, 'access', _239 => _239.style, 'optionalAccess', _240 => _240.fontName]) && af === bf && ab.width >= bb.width * 0.95 && (_nullishCoalesce(_optionalChain([a, 'access', _241 => _241.text, 'optionalAccess', _242 => _242.trim, 'call', _243 => _243(), 'access', _244 => _244.split, 'call', _245 => _245(/\s+/), 'access', _246 => _246.length]), () => ( 0))) >= 3;
|
|
7195
7236
|
const displayStack = centered && gap <= Math.min(af, bf) * 0.3 && Math.max(af, bf) <= Math.min(af, bf) * 1.45;
|
|
7196
7237
|
if (a.type !== "heading" || b.type !== "heading" || !a.text || !b.text || /^\d+$/.test(a.text.trim()) || !ab || !bb || ab.page !== bb.page || !(sameAnchor && af >= medianFontSize * 2 && bf >= medianFontSize * 2) && !wrapped && !(centered && af >= medianFontSize * 1.25 && bf >= medianFontSize * 1.25) || Math.abs(af - bf) > Math.max(af, bf) * 0.15 && !displayStack || gap < -2 || gap > Math.max(af, bf) * 0.45 || a.text.length > (centered ? 120 : 50) || b.text.length > (centered ? 120 : 50)) {
|
|
7197
7238
|
i++;
|
|
@@ -7220,25 +7261,25 @@ function detectTypographyHeadings(blocks) {
|
|
|
7220
7261
|
if (page.some((block) => block.type === "heading")) continue;
|
|
7221
7262
|
const faceWeight = /* @__PURE__ */ new Map();
|
|
7222
7263
|
for (const block of page) {
|
|
7223
|
-
if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access',
|
|
7264
|
+
if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access', _247 => _247.style, 'optionalAccess', _248 => _248.fontName])) continue;
|
|
7224
7265
|
const faces = FACE_CHARS.get(block);
|
|
7225
7266
|
if (faces) for (const [face, n] of faces) faceWeight.set(face, (_nullishCoalesce(faceWeight.get(face), () => ( 0))) + n);
|
|
7226
7267
|
else faceWeight.set(block.style.fontName, (_nullishCoalesce(faceWeight.get(block.style.fontName), () => ( 0))) + block.text.length);
|
|
7227
7268
|
}
|
|
7228
|
-
const bodyFace = _optionalChain([[...faceWeight], 'access',
|
|
7269
|
+
const bodyFace = _optionalChain([[...faceWeight], 'access', _249 => _249.sort, 'call', _250 => _250((a, b) => b[1] - a[1]), 'access', _251 => _251[0], 'optionalAccess', _252 => _252[0]]);
|
|
7229
7270
|
if (!bodyFace || (_nullishCoalesce(faceWeight.get(bodyFace), () => ( 0))) < 250) continue;
|
|
7230
7271
|
const sizeWeight = /* @__PURE__ */ new Map();
|
|
7231
7272
|
for (const block of page) {
|
|
7232
|
-
if (block.type !== "paragraph" || !_optionalChain([block, 'access',
|
|
7273
|
+
if (block.type !== "paragraph" || !_optionalChain([block, 'access', _253 => _253.style, 'optionalAccess', _254 => _254.fontSize])) continue;
|
|
7233
7274
|
const faces = FACE_CHARS.get(block);
|
|
7234
|
-
const chars = faces ? _nullishCoalesce(faces.get(bodyFace), () => ( 0)) : block.style.fontName === bodyFace ? _nullishCoalesce(_optionalChain([block, 'access',
|
|
7275
|
+
const chars = faces ? _nullishCoalesce(faces.get(bodyFace), () => ( 0)) : block.style.fontName === bodyFace ? _nullishCoalesce(_optionalChain([block, 'access', _255 => _255.text, 'optionalAccess', _256 => _256.length]), () => ( 0)) : 0;
|
|
7235
7276
|
if (chars) sizeWeight.set(block.style.fontSize, (_nullishCoalesce(sizeWeight.get(block.style.fontSize), () => ( 0))) + chars);
|
|
7236
7277
|
}
|
|
7237
|
-
const bodySize = _nullishCoalesce(_optionalChain([[...sizeWeight], 'access',
|
|
7278
|
+
const bodySize = _nullishCoalesce(_optionalChain([[...sizeWeight], 'access', _257 => _257.sort, 'call', _258 => _258((a, b) => b[1] - a[1]), 'access', _259 => _259[0], 'optionalAccess', _260 => _260[0]]), () => ( 0));
|
|
7238
7279
|
for (let i = 0; i < page.length; i++) {
|
|
7239
7280
|
const block = page[i];
|
|
7240
7281
|
const { text, bbox, style } = block;
|
|
7241
|
-
if (block.type !== "paragraph" || !text || !bbox || !_optionalChain([style, 'optionalAccess',
|
|
7282
|
+
if (block.type !== "paragraph" || !text || !bbox || !_optionalChain([style, 'optionalAccess', _261 => _261.fontName]) || !style.fontSize) continue;
|
|
7242
7283
|
const title = text.trim();
|
|
7243
7284
|
const numbered = /^\d+(?:\.\d+)*\.?\s+[A-Z가-힣]/.test(title);
|
|
7244
7285
|
const faces = FACE_CHARS.get(block);
|
|
@@ -7268,16 +7309,16 @@ function detectDocumentStyleHeadings(blocks) {
|
|
|
7268
7309
|
for (const page of byPage.values()) {
|
|
7269
7310
|
const faceChars = /* @__PURE__ */ new Map();
|
|
7270
7311
|
for (const block of page) {
|
|
7271
|
-
if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access',
|
|
7312
|
+
if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access', _262 => _262.style, 'optionalAccess', _263 => _263.fontName])) continue;
|
|
7272
7313
|
faceChars.set(block.style.fontName, (_nullishCoalesce(faceChars.get(block.style.fontName), () => ( 0))) + block.text.length);
|
|
7273
7314
|
}
|
|
7274
|
-
const bodyFace = _optionalChain([[...faceChars], 'access',
|
|
7315
|
+
const bodyFace = _optionalChain([[...faceChars], 'access', _264 => _264.sort, 'call', _265 => _265((a, b) => b[1] - a[1]), 'access', _266 => _266[0], 'optionalAccess', _267 => _267[0]]);
|
|
7275
7316
|
if (!bodyFace || (_nullishCoalesce(faceChars.get(bodyFace), () => ( 0))) < 100) continue;
|
|
7276
|
-
const labels = page.filter((b) => b.type === "paragraph" && b.text && b.bbox && _optionalChain([b, 'access',
|
|
7317
|
+
const labels = page.filter((b) => b.type === "paragraph" && b.text && b.bbox && _optionalChain([b, 'access', _268 => _268.style, 'optionalAccess', _269 => _269.fontName]) && b.style.fontName !== bodyFace && b.text.trim().length >= 3 && b.text.trim().length <= 40);
|
|
7277
7318
|
for (const label of labels) {
|
|
7278
|
-
const peers = labels.filter((b) => _optionalChain([b, 'access',
|
|
7319
|
+
const peers = labels.filter((b) => _optionalChain([b, 'access', _270 => _270.style, 'optionalAccess', _271 => _271.fontName]) === _optionalChain([label, 'access', _272 => _272.style, 'optionalAccess', _273 => _273.fontName]) && Math.abs(b.bbox.y - label.bbox.y) <= 3 && Math.abs(b.bbox.x - label.bbox.x) >= 60);
|
|
7279
7320
|
if (peers.length < 2) continue;
|
|
7280
|
-
const value = page.find((b) => b.type === "paragraph" && b.bbox && _optionalChain([b, 'access',
|
|
7321
|
+
const value = page.find((b) => b.type === "paragraph" && b.bbox && _optionalChain([b, 'access', _274 => _274.style, 'optionalAccess', _275 => _275.fontName]) !== _optionalChain([label, 'access', _276 => _276.style, 'optionalAccess', _277 => _277.fontName]) && b.bbox.x >= label.bbox.x - 5 && b.bbox.x <= label.bbox.x + 20 && b.bbox.y < label.bbox.y && label.bbox.y - (b.bbox.y + b.bbox.height) <= 60);
|
|
7281
7322
|
if (value) {
|
|
7282
7323
|
label.type = "heading";
|
|
7283
7324
|
label.level = 2;
|
|
@@ -7286,7 +7327,7 @@ function detectDocumentStyleHeadings(blocks) {
|
|
|
7286
7327
|
const first = page.find((b) => b.type !== "image" && b.type !== "separator");
|
|
7287
7328
|
const second = page[page.indexOf(first) + 1];
|
|
7288
7329
|
const third = page[page.indexOf(first) + 2];
|
|
7289
|
-
if (!first || !second || !third || first.type !== "list" && first.type !== "paragraph" || second.type !== "paragraph" || !first.text || !second.text || !first.bbox || !second.bbox || !_optionalChain([first, 'access',
|
|
7330
|
+
if (!first || !second || !third || first.type !== "list" && first.type !== "paragraph" || second.type !== "paragraph" || !first.text || !second.text || !first.bbox || !second.bbox || !_optionalChain([first, 'access', _278 => _278.style, 'optionalAccess', _279 => _279.fontName]) || !_optionalChain([second, 'access', _280 => _280.style, 'optionalAccess', _281 => _281.fontName]) || !/^\d+(?:\.\d+)*\.\s+/.test(first.text.trim()) || first.style.fontName === bodyFace || second.style.fontName === bodyFace || first.text.length + second.text.length > 140 || Math.abs(first.bbox.x - second.bbox.x) > 30 || first.bbox.y - (second.bbox.y + second.bbox.height) > (_nullishCoalesce(first.style.fontSize, () => ( 0))) * 1.5 || _optionalChain([third, 'access', _282 => _282.style, 'optionalAccess', _283 => _283.fontName]) !== bodyFace) continue;
|
|
7290
7331
|
first.type = "heading";
|
|
7291
7332
|
first.level = 1;
|
|
7292
7333
|
first.text = `${first.text.trim()} ${second.text.trim()}`;
|
|
@@ -7310,18 +7351,18 @@ function detectSiblingStyleHeadings(blocks) {
|
|
|
7310
7351
|
for (const page of byPage.values()) {
|
|
7311
7352
|
const bodyChars = /* @__PURE__ */ new Map();
|
|
7312
7353
|
for (const block of page) {
|
|
7313
|
-
if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access',
|
|
7354
|
+
if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access', _284 => _284.style, 'optionalAccess', _285 => _285.fontName])) continue;
|
|
7314
7355
|
const face = block.style.fontName;
|
|
7315
7356
|
bodyChars.set(face, (_nullishCoalesce(bodyChars.get(face), () => ( 0))) + block.text.length);
|
|
7316
7357
|
}
|
|
7317
|
-
const bodyFace = _optionalChain([[...bodyChars], 'access',
|
|
7318
|
-
const anchors = page.filter((b) => b.type === "heading" && b.text && _optionalChain([b, 'access',
|
|
7358
|
+
const bodyFace = _optionalChain([[...bodyChars], 'access', _286 => _286.sort, 'call', _287 => _287((a, b) => b[1] - a[1]), 'access', _288 => _288[0], 'optionalAccess', _289 => _289[0]]);
|
|
7359
|
+
const anchors = page.filter((b) => b.type === "heading" && b.text && _optionalChain([b, 'access', _290 => _290.style, 'optionalAccess', _291 => _291.fontName]) && b.style.fontName !== bodyFace);
|
|
7319
7360
|
for (const anchor of anchors) {
|
|
7320
7361
|
const numbered = /^([A-Z])\.\d+\s+/.exec(anchor.text.trim());
|
|
7321
7362
|
const lettered = /^([A-Z])\s+/.exec(anchor.text.trim());
|
|
7322
|
-
const peers = anchors.filter((b) => _optionalChain([b, 'access',
|
|
7363
|
+
const peers = anchors.filter((b) => _optionalChain([b, 'access', _292 => _292.style, 'optionalAccess', _293 => _293.fontName]) === _optionalChain([anchor, 'access', _294 => _294.style, 'optionalAccess', _295 => _295.fontName]) && Math.abs((_nullishCoalesce(_optionalChain([b, 'access', _296 => _296.style, 'optionalAccess', _297 => _297.fontSize]), () => ( 0))) - (_nullishCoalesce(_optionalChain([anchor, 'access', _298 => _298.style, 'optionalAccess', _299 => _299.fontSize]), () => ( 0)))) < 0.5);
|
|
7323
7364
|
if (peers.length < 2 && !numbered && !lettered) continue;
|
|
7324
|
-
const candidates = page.filter((b) => b.type === "paragraph" && b.text && b.bbox && _optionalChain([b, 'access',
|
|
7365
|
+
const candidates = page.filter((b) => b.type === "paragraph" && b.text && b.bbox && _optionalChain([b, 'access', _300 => _300.style, 'optionalAccess', _301 => _301.fontName]) === _optionalChain([anchor, 'access', _302 => _302.style, 'optionalAccess', _303 => _303.fontName]) && Math.abs((_nullishCoalesce(_optionalChain([b, 'access', _304 => _304.style, 'optionalAccess', _305 => _305.fontSize]), () => ( 0))) - (_nullishCoalesce(_optionalChain([anchor, 'access', _306 => _306.style, 'optionalAccess', _307 => _307.fontSize]), () => ( 0)))) < 0.5 && b.text.trim().length >= 3 && b.text.trim().length <= 80 && b.bbox.height <= (_nullishCoalesce(_optionalChain([b, 'access', _308 => _308.style, 'optionalAccess', _309 => _309.fontSize]), () => ( 0))) * 1.6 && /^[A-Z]/.test(b.text.trim()) && !/[.!?:;,]$/.test(b.text.trim()) && !/^(?:Table|Figure|Fig\.?|Appendix)\s+\d/i.test(b.text.trim()));
|
|
7325
7366
|
const siblings = candidates.filter((b) => numbered ? new RegExp(`^${numbered[1]}\\.\\d+\\s+`).test(b.text.trim()) : lettered ? /^[A-Z]\s+/.test(b.text.trim()) && Math.abs(anchor.bbox.x - b.bbox.x) < 8 : peers.some((h) => h.bbox && Math.abs(h.bbox.x - b.bbox.x) < 8));
|
|
7326
7367
|
if (siblings.length < (numbered || lettered ? 1 : 2)) continue;
|
|
7327
7368
|
for (const sibling of siblings) {
|
|
@@ -7340,13 +7381,13 @@ function detectRepeatedPageLabels(blocks) {
|
|
|
7340
7381
|
}
|
|
7341
7382
|
for (const page of byPage.values()) {
|
|
7342
7383
|
const bodyChars = /* @__PURE__ */ new Map();
|
|
7343
|
-
for (const b of page) if (b.type === "paragraph" && b.text && _optionalChain([b, 'access',
|
|
7384
|
+
for (const b of page) if (b.type === "paragraph" && b.text && _optionalChain([b, 'access', _310 => _310.style, 'optionalAccess', _311 => _311.fontName])) {
|
|
7344
7385
|
const faces = FACE_CHARS.get(b);
|
|
7345
7386
|
if (faces) for (const [face, n] of faces) bodyChars.set(face, (_nullishCoalesce(bodyChars.get(face), () => ( 0))) + n);
|
|
7346
7387
|
else bodyChars.set(b.style.fontName, (_nullishCoalesce(bodyChars.get(b.style.fontName), () => ( 0))) + b.text.length);
|
|
7347
7388
|
}
|
|
7348
|
-
const bodyFace = _optionalChain([[...bodyChars], 'access',
|
|
7349
|
-
const candidates = page.filter((b) => b.type === "paragraph" && b.text && b.bbox && _optionalChain([b, 'access',
|
|
7389
|
+
const bodyFace = _optionalChain([[...bodyChars], 'access', _312 => _312.sort, 'call', _313 => _313((a, b) => b[1] - a[1]), 'access', _314 => _314[0], 'optionalAccess', _315 => _315[0]]);
|
|
7390
|
+
const candidates = page.filter((b) => b.type === "paragraph" && b.text && b.bbox && _optionalChain([b, 'access', _316 => _316.style, 'optionalAccess', _317 => _317.fontName]) && b.style.fontName !== bodyFace && b.bbox.height <= (_nullishCoalesce(b.style.fontSize, () => ( 0))) * 1.6 && b.text.trim().length >= 5 && b.text.trim().length <= 80);
|
|
7350
7391
|
const groups = /* @__PURE__ */ new Map();
|
|
7351
7392
|
for (const b of candidates) {
|
|
7352
7393
|
const key = `${b.style.fontName}:${b.style.fontSize}`;
|
|
@@ -7382,19 +7423,19 @@ function detectPageLeadHeadings(blocks) {
|
|
|
7382
7423
|
for (const page of byPage.values()) {
|
|
7383
7424
|
const content = page.filter((b) => b.type !== "image" && b.type !== "separator" && !(b.type === "paragraph" && !b.style));
|
|
7384
7425
|
const [first, second, third] = content;
|
|
7385
|
-
if (!_optionalChain([first, 'optionalAccess',
|
|
7426
|
+
if (!_optionalChain([first, 'optionalAccess', _318 => _318.bbox]) || !first.text || !_optionalChain([first, 'access', _319 => _319.style, 'optionalAccess', _320 => _320.fontSize]) || !second) continue;
|
|
7386
7427
|
const firstText = first.text.trim();
|
|
7387
7428
|
const captionLike = /^(?:Figure|Fig\.?|Table|표|그림)\s*\d/i;
|
|
7388
7429
|
const hasImage = page.some((b) => b.type === "image");
|
|
7389
|
-
const firstIsTitle = first.type === "paragraph" && firstText.length >= 5 && firstText.length <= 80 && first.bbox.height <= first.style.fontSize * 1.6 && (/^(?:CONTENTS|Table of Contents)$/i.test(firstText) || hasImage && /^[A-Z]/.test(firstText) && !captionLike.test(firstText) && second.type === "paragraph" && /^[A-Z]/.test(_nullishCoalesce(_optionalChain([second, 'access',
|
|
7430
|
+
const firstIsTitle = first.type === "paragraph" && firstText.length >= 5 && firstText.length <= 80 && first.bbox.height <= first.style.fontSize * 1.6 && (/^(?:CONTENTS|Table of Contents)$/i.test(firstText) || hasImage && /^[A-Z]/.test(firstText) && !captionLike.test(firstText) && second.type === "paragraph" && /^[A-Z]/.test(_nullishCoalesce(_optionalChain([second, 'access', _321 => _321.text, 'optionalAccess', _322 => _322.trim, 'call', _323 => _323()]), () => ( ""))) && (_nullishCoalesce(_optionalChain([second, 'access', _324 => _324.text, 'optionalAccess', _325 => _325.length]), () => ( 0))) >= 100 && second.bbox && first.bbox.y - (second.bbox.y + second.bbox.height) >= first.style.fontSize);
|
|
7390
7431
|
const firstAboveProse = first.type === "paragraph" && firstText.length >= 5 && firstText.length <= 80 && first.bbox.height <= first.style.fontSize * 2 && second.type === "paragraph" && second.bbox && second.bbox.height >= first.style.fontSize * 4 && Math.abs(first.bbox.x - second.bbox.x) <= first.style.fontSize * 2 && first.bbox.y - (second.bbox.y + second.bbox.height) >= first.style.fontSize * 2 && !captionLike.test(firstText) && !/^(?:doi:|https?:|www\.)/i.test(firstText);
|
|
7391
|
-
const firstIsSection = first.type === "list" && /^\d+\.\s+[A-Z][A-Z\s]{12,}$/.test(firstText) && second.type === "paragraph" && (_nullishCoalesce(_optionalChain([second, 'access',
|
|
7432
|
+
const firstIsSection = first.type === "list" && /^\d+\.\s+[A-Z][A-Z\s]{12,}$/.test(firstText) && second.type === "paragraph" && (_nullishCoalesce(_optionalChain([second, 'access', _326 => _326.text, 'optionalAccess', _327 => _327.length]), () => ( 0))) >= 100;
|
|
7392
7433
|
if (firstIsTitle || firstAboveProse || firstIsSection) {
|
|
7393
7434
|
first.type = "heading";
|
|
7394
7435
|
first.level = 1;
|
|
7395
7436
|
}
|
|
7396
|
-
if (first.type !== "heading" || captionLike.test(firstText) || second.type !== "paragraph" || !second.text || !second.bbox || !_optionalChain([second, 'access',
|
|
7397
|
-
const distinctFace = _optionalChain([third, 'access',
|
|
7437
|
+
if (first.type !== "heading" || captionLike.test(firstText) || second.type !== "paragraph" || !second.text || !second.bbox || !_optionalChain([second, 'access', _328 => _328.style, 'optionalAccess', _329 => _329.fontName]) || !second.style.fontSize || !_optionalChain([third, 'optionalAccess', _330 => _330.text]) || !third.bbox || second.text.trim().length < 5 || second.text.trim().length > 80 || captionLike.test(second.text.trim()) || /^(?:doi:|https?:)/i.test(second.text.trim()) || second.bbox.height > second.style.fontSize * 1.6 || Math.abs(second.bbox.x - third.bbox.x) > 30) continue;
|
|
7438
|
+
const distinctFace = _optionalChain([third, 'access', _331 => _331.style, 'optionalAccess', _332 => _332.fontName]) !== second.style.fontName;
|
|
7398
7439
|
const namedContents = /^Table of Contents$/i.test(second.text.trim());
|
|
7399
7440
|
if (distinctFace && third.text.length >= 60 || namedContents) {
|
|
7400
7441
|
second.type = "heading";
|
|
@@ -7405,24 +7446,24 @@ function detectPageLeadHeadings(blocks) {
|
|
|
7405
7446
|
function refineDocumentStyleHeadings(blocks) {
|
|
7406
7447
|
const faceChars = /* @__PURE__ */ new Map();
|
|
7407
7448
|
for (const block of blocks) {
|
|
7408
|
-
if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access',
|
|
7449
|
+
if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access', _333 => _333.style, 'optionalAccess', _334 => _334.fontName])) continue;
|
|
7409
7450
|
faceChars.set(block.style.fontName, (_nullishCoalesce(faceChars.get(block.style.fontName), () => ( 0))) + block.text.length);
|
|
7410
7451
|
}
|
|
7411
7452
|
const [bodyFace, bodyChars] = _nullishCoalesce([...faceChars].sort((a, b) => b[1] - a[1])[0], () => ( []));
|
|
7412
7453
|
if (!bodyFace || !bodyChars || bodyChars < 300) return;
|
|
7413
7454
|
for (let i = 0; i < blocks.length; i++) {
|
|
7414
7455
|
const block = blocks[i];
|
|
7415
|
-
const text = _nullishCoalesce(_optionalChain([block, 'access',
|
|
7456
|
+
const text = _nullishCoalesce(_optionalChain([block, 'access', _335 => _335.text, 'optionalAccess', _336 => _336.trim, 'call', _337 => _337()]), () => ( ""));
|
|
7416
7457
|
if (block.type === "heading" && /(?:https?:\/\/|www\.|^arxiv:|^doi:)/i.test(text)) {
|
|
7417
7458
|
block.type = "paragraph";
|
|
7418
7459
|
block.level = void 0;
|
|
7419
7460
|
continue;
|
|
7420
7461
|
}
|
|
7421
7462
|
const box = block.bbox, style = block.style;
|
|
7422
|
-
if (block.type !== "paragraph" || !box || !_optionalChain([style, 'optionalAccess',
|
|
7463
|
+
if (block.type !== "paragraph" || !box || !_optionalChain([style, 'optionalAccess', _338 => _338.fontName]) || !style.fontSize || style.fontName === bodyFace || (_nullishCoalesce(faceChars.get(style.fontName), () => ( 0))) > bodyChars * 0.25 || text.length < 3 || text.length > 70 || text.includes("\n") || box.height > style.fontSize * 1.6 || /^(?:table|figure|fig\.?|source|doi:|arxiv:|https?:|www\.|[•●○▪▫⮚*∗†])/i.test(text) || /(?:https?:\/\/|www\.|@|[=¼≪þ])/i.test(text) || /^definition\s+\d+[.:]?\s+.*\b(?:is|are|means)\b/i.test(text) || /^[\d\s.,:%+\-–]+$/.test(text)) continue;
|
|
7423
7464
|
const previous = blocks[i - 1], next = blocks[i + 1];
|
|
7424
|
-
const pb = _optionalChain([previous, 'optionalAccess',
|
|
7425
|
-
if (!pb || !nb || previous.pageNumber !== block.pageNumber || next.pageNumber !== block.pageNumber || previous.type !== "paragraph" && previous.type !== "heading" || next.type !== "paragraph" || _optionalChain([next, 'access',
|
|
7465
|
+
const pb = _optionalChain([previous, 'optionalAccess', _339 => _339.bbox]), nb = _optionalChain([next, 'optionalAccess', _340 => _340.bbox]);
|
|
7466
|
+
if (!pb || !nb || previous.pageNumber !== block.pageNumber || next.pageNumber !== block.pageNumber || previous.type !== "paragraph" && previous.type !== "heading" || next.type !== "paragraph" || _optionalChain([next, 'access', _341 => _341.style, 'optionalAccess', _342 => _342.fontName]) !== bodyFace || !next.text || next.text.length < 40 || style.fontSize < (_nullishCoalesce(next.style.fontSize, () => ( 0))) * 0.95 || pb.y - (box.y + box.height) < style.fontSize * 0.5 || box.y - (nb.y + nb.height) < 0 || box.y - (nb.y + nb.height) > style.fontSize * 2 || box.x + box.width / 2 < nb.x - 10 || box.x + box.width / 2 > nb.x + nb.width + 10) continue;
|
|
7426
7467
|
block.type = "heading";
|
|
7427
7468
|
block.level = 2;
|
|
7428
7469
|
}
|
|
@@ -7472,7 +7513,7 @@ function detectMarkerHeadings(blocks) {
|
|
|
7472
7513
|
block.level = 4;
|
|
7473
7514
|
continue;
|
|
7474
7515
|
}
|
|
7475
|
-
if (/^[가-힣]{2,6}$/.test(text) && _optionalChain([block, 'access',
|
|
7516
|
+
if (/^[가-힣]{2,6}$/.test(text) && _optionalChain([block, 'access', _343 => _343.style, 'optionalAccess', _344 => _344.fontSize])) {
|
|
7476
7517
|
const prev = blocks[i - 1];
|
|
7477
7518
|
const next = blocks[i + 1];
|
|
7478
7519
|
const prevIsStructural = !prev || prev.type === "table" || prev.type === "heading" || prev.type === "separator";
|
|
@@ -7513,7 +7554,7 @@ function detectTableCaptions(blocks) {
|
|
|
7513
7554
|
block.table.caption = blocks[i - 1].text.trim();
|
|
7514
7555
|
blocks.splice(i - 1, 1);
|
|
7515
7556
|
i--;
|
|
7516
|
-
} else if (isCaptionCandidate(blocks[i + 1], block) && _optionalChain([blocks, 'access',
|
|
7557
|
+
} else if (isCaptionCandidate(blocks[i + 1], block) && _optionalChain([blocks, 'access', _345 => _345[i + 2], 'optionalAccess', _346 => _346.type]) !== "table") {
|
|
7517
7558
|
const cap = blocks[i + 1].bbox, tbl = block.bbox;
|
|
7518
7559
|
block.table.caption = blocks[i + 1].text.trim();
|
|
7519
7560
|
if (cap && tbl && cap.y + cap.height <= tbl.y + 1) block.table.captionBelow = true;
|
|
@@ -7598,7 +7639,7 @@ function detectKoreanListBlocks(blocks) {
|
|
|
7598
7639
|
}
|
|
7599
7640
|
const listType = label.family === "arabicDot" ? "ordered" : "unordered";
|
|
7600
7641
|
const listBlock = { ...b, type: "list", listType };
|
|
7601
|
-
const pb = _optionalChain([lastTopLevelList, 'optionalAccess',
|
|
7642
|
+
const pb = _optionalChain([lastTopLevelList, 'optionalAccess', _347 => _347.bbox]), cb = b.bbox;
|
|
7602
7643
|
const notIndented = depth > 0 && !!pb && !!cb && pb.page === cb.page && cb.x >= pb.x + pb.width && cb.y >= pb.y + pb.height;
|
|
7603
7644
|
if (notIndented) familyStack = [label.family];
|
|
7604
7645
|
if (depth === 0 || notIndented) {
|
|
@@ -7756,7 +7797,7 @@ function removeHeaderFooterBlocks(blocks, pageHeights, warnings, notes, tables =
|
|
|
7756
7797
|
const b = blocks[bi];
|
|
7757
7798
|
const cellTexts = b.type === "table" && b.table ? b.table.cells.flat().map((c) => c.text.trim()).filter(Boolean) : [];
|
|
7758
7799
|
const headBox = cellTexts.length <= 4 && !!b.bbox && b.bbox.height <= (_nullishCoalesce(pageHeights.get(b.bbox.page), () => ( Infinity))) * 0.05;
|
|
7759
|
-
const text = !tables ? _optionalChain([b, 'access',
|
|
7800
|
+
const text = !tables ? _optionalChain([b, 'access', _348 => _348.text, 'optionalAccess', _349 => _349.trim, 'call', _350 => _350()]) : cellTexts.length ? (headBox ? [...cellTexts].sort() : cellTexts).join(" | ") : void 0;
|
|
7760
7801
|
if (!b.bbox || !b.pageNumber || !text) continue;
|
|
7761
7802
|
const ph = pageHeights.get(b.bbox.page) || pageHeights.get(b.pageNumber);
|
|
7762
7803
|
if (!ph) continue;
|
|
@@ -7789,7 +7830,7 @@ function removeHeaderFooterBlocks(blocks, pageHeights, warnings, notes, tables =
|
|
|
7789
7830
|
for (const [p, count] of patternCount) {
|
|
7790
7831
|
const pages = [..._nullishCoalesce(patternPages.get(p), () => ( []))];
|
|
7791
7832
|
const span2 = pages.length ? Math.max(...pages) - Math.min(...pages) + 1 : 0;
|
|
7792
|
-
const varying = !tables && (_nullishCoalesce(_optionalChain([patternNumbers, 'access',
|
|
7833
|
+
const varying = !tables && (_nullishCoalesce(_optionalChain([patternNumbers, 'access', _351 => _351.get, 'call', _352 => _352(p), 'optionalAccess', _353 => _353.size]), () => ( 0))) > 1;
|
|
7793
7834
|
const occ = _nullishCoalesce(patternOcc.get(p), () => ( []));
|
|
7794
7835
|
const dense = pages.length >= span2 * 0.4;
|
|
7795
7836
|
const loose = looseVaryingNumber(occ, entries === topEntries) && (entries === bottomEntries || dense || tracksPages(occ));
|
|
@@ -7801,8 +7842,8 @@ function removeHeaderFooterBlocks(blocks, pageHeights, warnings, notes, tables =
|
|
|
7801
7842
|
for (const e of entries) {
|
|
7802
7843
|
const norm = e.text.replace(/\d+/g, "#");
|
|
7803
7844
|
if (!repeatedPatterns.has(norm)) continue;
|
|
7804
|
-
const noteMark = _optionalChain([e, 'access',
|
|
7805
|
-
if (noteMark && _optionalChain([notes, 'optionalAccess',
|
|
7845
|
+
const noteMark = _optionalChain([e, 'access', _354 => _354.text, 'access', _355 => _355.match, 'call', _356 => _356(/^\d{1,3}\)/), 'optionalAccess', _357 => _357[0]]);
|
|
7846
|
+
if (noteMark && _optionalChain([notes, 'optionalAccess', _358 => _358.get, 'call', _359 => _359(e.page), 'optionalAccess', _360 => _360.marks, 'access', _361 => _361.some, 'call', _362 => _362((m) => m.mark === noteMark)])) continue;
|
|
7806
7847
|
const cand = blocks[e.blockIdx];
|
|
7807
7848
|
const cb = cand.bbox;
|
|
7808
7849
|
const tableNote = /^(?:주\s*(?:\d+\s*[).:]|[::])|(?:자료|출처)\s*[::]|\*\s+\S)/.test(e.text.replace(/ \| /g, " ")) && blocks.some((o) => {
|
|
@@ -7816,7 +7857,7 @@ function removeHeaderFooterBlocks(blocks, pageHeights, warnings, notes, tables =
|
|
|
7816
7857
|
if (bi === e.blockIdx) continue;
|
|
7817
7858
|
const o = blocks[bi];
|
|
7818
7859
|
if (!o.bbox || o.bbox.page !== cb.page) continue;
|
|
7819
|
-
const oNorm = _optionalChain([o, 'access',
|
|
7860
|
+
const oNorm = _optionalChain([o, 'access', _363 => _363.text, 'optionalAccess', _364 => _364.trim, 'call', _365 => _365(), 'access', _366 => _366.replace, 'call', _367 => _367(/\d+/g, "#")]);
|
|
7820
7861
|
if (oNorm && repeatedPatterns.has(oNorm)) continue;
|
|
7821
7862
|
const overlap2 = Math.min(cb.y + cb.height, o.bbox.y + o.bbox.height) - Math.max(cb.y, o.bbox.y);
|
|
7822
7863
|
if (overlap2 >= cb.height * 0.5) {
|
|
@@ -7944,7 +7985,7 @@ function recordRowRules(table, cells, bbox, hs) {
|
|
|
7944
7985
|
function markImageCell(cell) {
|
|
7945
7986
|
IMAGE_CELLS.add(cell);
|
|
7946
7987
|
}
|
|
7947
|
-
var emptyCell = (cell) => !cell || !_optionalChain([cell, 'access',
|
|
7988
|
+
var emptyCell = (cell) => !cell || !_optionalChain([cell, 'access', _368 => _368.text, 'optionalAccess', _369 => _369.trim, 'call', _370 => _370()]) && !_optionalChain([cell, 'access', _371 => _371.blocks, 'optionalAccess', _372 => _372.length]) && !IMAGE_CELLS.has(cell);
|
|
7948
7989
|
function trimTable(table) {
|
|
7949
7990
|
let cols = table.cols;
|
|
7950
7991
|
while (cols > 0 && table.cells.every((row) => emptyCell(row[cols - 1]))) cols--;
|
|
@@ -7960,7 +8001,7 @@ function trimTable(table) {
|
|
|
7960
8001
|
function trimTrailingEmptyTableCols(blocks) {
|
|
7961
8002
|
for (const b of blocks) {
|
|
7962
8003
|
if (b.type !== "table" || !b.table) continue;
|
|
7963
|
-
for (const row of b.table.cells) for (const cell of row) if (_optionalChain([cell, 'access',
|
|
8004
|
+
for (const row of b.table.cells) for (const cell of row) if (_optionalChain([cell, 'access', _373 => _373.blocks, 'optionalAccess', _374 => _374.length])) trimTrailingEmptyTableCols(cell.blocks);
|
|
7964
8005
|
trimTable(b.table);
|
|
7965
8006
|
}
|
|
7966
8007
|
}
|
|
@@ -7980,7 +8021,7 @@ function mergeSliverColumns(grid, colXs, maxWidth) {
|
|
|
7980
8021
|
}
|
|
7981
8022
|
const ok = owner.every((row) => {
|
|
7982
8023
|
const o = row[c];
|
|
7983
|
-
return !!o && (o.colSpan > 1 || !o.text.trim() && !_optionalChain([o, 'access',
|
|
8024
|
+
return !!o && (o.colSpan > 1 || !o.text.trim() && !_optionalChain([o, 'access', _375 => _375.blocks, 'optionalAccess', _376 => _376.length]));
|
|
7984
8025
|
});
|
|
7985
8026
|
if (!ok) continue;
|
|
7986
8027
|
const spanning = /* @__PURE__ */ new Set();
|
|
@@ -8007,7 +8048,7 @@ var multiply = (m, t) => [
|
|
|
8007
8048
|
m[1] * t[4] + m[3] * t[5] + m[5]
|
|
8008
8049
|
];
|
|
8009
8050
|
function hollowCircle(image) {
|
|
8010
|
-
if (!_optionalChain([image, 'optionalAccess',
|
|
8051
|
+
if (!_optionalChain([image, 'optionalAccess', _377 => _377.data]) || image.width < 16 || image.width > 128 || image.height < 16 || image.height > 128 || Math.abs(image.width - image.height) > Math.min(image.width, image.height) * 0.1) return false;
|
|
8011
8052
|
const stride = image.kind === _pdfmjs.ImageKind.RGB_24BPP ? 3 : image.kind === _pdfmjs.ImageKind.RGBA_32BPP ? 4 : 0;
|
|
8012
8053
|
const { width, height, data } = image;
|
|
8013
8054
|
if (!stride || data.length < width * height * stride) return false;
|
|
@@ -8072,9 +8113,9 @@ function smallVisibleImagePaints(fnArray, argsArray) {
|
|
|
8072
8113
|
const op = fnArray[i], args = argsArray[i];
|
|
8073
8114
|
if (op === _pdfmjs.OPS.save || op === _pdfmjs.OPS.paintFormXObjectBegin) {
|
|
8074
8115
|
stack.push({ ctm, alpha, clip, unknownClip });
|
|
8075
|
-
const matrix = op === _pdfmjs.OPS.paintFormXObjectBegin ? _optionalChain([args, 'optionalAccess',
|
|
8116
|
+
const matrix = op === _pdfmjs.OPS.paintFormXObjectBegin ? _optionalChain([args, 'optionalAccess', _378 => _378[0]]) : void 0;
|
|
8076
8117
|
if (Array.isArray(matrix) && matrix.length >= 6) ctm = multiply(ctm, matrix);
|
|
8077
|
-
const bounds = op === _pdfmjs.OPS.paintFormXObjectBegin ? _optionalChain([args, 'optionalAccess',
|
|
8118
|
+
const bounds = op === _pdfmjs.OPS.paintFormXObjectBegin ? _optionalChain([args, 'optionalAccess', _379 => _379[1]]) : void 0;
|
|
8078
8119
|
if (Array.isArray(bounds) && bounds.length === 4) {
|
|
8079
8120
|
const box = rectangle(bounds[0], bounds[1], bounds[2] - bounds[0], bounds[3] - bounds[1]);
|
|
8080
8121
|
if (box && ctm[1] === 0 && ctm[2] === 0) intersectClip(box);
|
|
@@ -8082,17 +8123,17 @@ function smallVisibleImagePaints(fnArray, argsArray) {
|
|
|
8082
8123
|
}
|
|
8083
8124
|
} else if (op === _pdfmjs.OPS.restore || op === _pdfmjs.OPS.paintFormXObjectEnd) {
|
|
8084
8125
|
const state = stack.pop();
|
|
8085
|
-
ctm = _nullishCoalesce(_optionalChain([state, 'optionalAccess',
|
|
8086
|
-
alpha = _nullishCoalesce(_optionalChain([state, 'optionalAccess',
|
|
8087
|
-
clip = _nullishCoalesce(_optionalChain([state, 'optionalAccess',
|
|
8088
|
-
unknownClip = _nullishCoalesce(_optionalChain([state, 'optionalAccess',
|
|
8126
|
+
ctm = _nullishCoalesce(_optionalChain([state, 'optionalAccess', _380 => _380.ctm]), () => ( [1, 0, 0, 1, 0, 0]));
|
|
8127
|
+
alpha = _nullishCoalesce(_optionalChain([state, 'optionalAccess', _381 => _381.alpha]), () => ( 1));
|
|
8128
|
+
clip = _nullishCoalesce(_optionalChain([state, 'optionalAccess', _382 => _382.clip]), () => ( null));
|
|
8129
|
+
unknownClip = _nullishCoalesce(_optionalChain([state, 'optionalAccess', _383 => _383.unknownClip]), () => ( false));
|
|
8089
8130
|
} else if (op === _pdfmjs.OPS.setGState) {
|
|
8090
|
-
for (const [key, value] of _nullishCoalesce(_optionalChain([args, 'optionalAccess',
|
|
8131
|
+
for (const [key, value] of _nullishCoalesce(_optionalChain([args, 'optionalAccess', _384 => _384[0]]), () => ( []))) {
|
|
8091
8132
|
if (key === "ca") alpha = typeof value === "number" ? value : 0;
|
|
8092
8133
|
}
|
|
8093
8134
|
} else if (op === _pdfmjs.OPS.constructPath) {
|
|
8094
8135
|
const [operations, coordinates] = args;
|
|
8095
|
-
pathRect = pathRect === void 0 && _optionalChain([operations, 'optionalAccess',
|
|
8136
|
+
pathRect = pathRect === void 0 && _optionalChain([operations, 'optionalAccess', _385 => _385.length]) === 1 && operations[0] === _pdfmjs.OPS.rectangle && _optionalChain([coordinates, 'optionalAccess', _386 => _386.length]) >= 4 && ctm[1] === 0 && ctm[2] === 0 ? rectangle(coordinates[0], coordinates[1], coordinates[2], coordinates[3]) : null;
|
|
8096
8137
|
} else if (op === _pdfmjs.OPS.clip || op === _pdfmjs.OPS.eoClip) pendingClip = true;
|
|
8097
8138
|
else if ([
|
|
8098
8139
|
_pdfmjs.OPS.endPath,
|
|
@@ -8112,7 +8153,7 @@ function smallVisibleImagePaints(fnArray, argsArray) {
|
|
|
8112
8153
|
pendingClip = false;
|
|
8113
8154
|
pathRect = void 0;
|
|
8114
8155
|
} else if (op === _pdfmjs.OPS.transform && Array.isArray(args) && args.length >= 6) ctm = multiply(ctm, args);
|
|
8115
|
-
else if (op === _pdfmjs.OPS.paintImageXObject && typeof _optionalChain([args, 'optionalAccess',
|
|
8156
|
+
else if (op === _pdfmjs.OPS.paintImageXObject && typeof _optionalChain([args, 'optionalAccess', _387 => _387[0]]) === "string") {
|
|
8116
8157
|
if (typeof args[1] !== "number" || typeof args[2] !== "number" || args[1] < 16 || args[1] > 128 || args[2] < 16 || args[2] > 128) continue;
|
|
8117
8158
|
const box = extractImageRegions([_pdfmjs.OPS.transform, _pdfmjs.OPS.paintImageXObject], [ctm, args])[0];
|
|
8118
8159
|
if (!box || ctm[1] !== 0 || ctm[2] !== 0 || alpha < 0.99 || unknownClip || clip && (box.x1 + (box.x2 - box.x1) * 0.03 < clip.x1 || box.y1 + (box.y2 - box.y1) * 0.03 < clip.y1 || box.x2 - (box.x2 - box.x1) * 0.03 > clip.x2 || box.y2 - (box.y2 - box.y1) * 0.03 > clip.y2)) continue;
|
|
@@ -8131,14 +8172,14 @@ async function restoreImageBullets(items, page, fnArray, argsArray, shapes = /*
|
|
|
8131
8172
|
const line = items.filter((item) => !item.isHidden && item.fontSize > 0 && item.x >= box.x2 && item.x - box.x2 <= item.fontSize * 0.7 && Math.abs(item.y + item.h / 2 - (box.y1 + box.y2) / 2) <= item.fontSize * 0.4 && height >= item.fontSize * 0.5 && height <= item.fontSize * 1.2).sort((a, b) => a.x - b.x)[0];
|
|
8132
8173
|
if (!line || /^[○●•◦□■∙]/.test(line.text.trim()) || !/\p{L}/u.test(line.text)) continue;
|
|
8133
8174
|
const row = items.filter((item) => Math.abs(item.y - line.y) <= 2 && item.x >= line.x);
|
|
8134
|
-
if (row.reduce((n, item) => n + (_nullishCoalesce(_optionalChain([item, 'access',
|
|
8175
|
+
if (row.reduce((n, item) => n + (_nullishCoalesce(_optionalChain([item, 'access', _388 => _388.text, 'access', _389 => _389.match, 'call', _390 => _390(/\p{L}/gu), 'optionalAccess', _391 => _391.length]), () => ( 0))), 0) < 12 || items.some((item) => item !== line && Math.abs(item.y - line.y) <= 2 && item.x < line.x)) continue;
|
|
8135
8176
|
candidates.push({ id, x: box.x1, width, line });
|
|
8136
8177
|
}
|
|
8137
8178
|
let restored = 0;
|
|
8138
8179
|
const used = /* @__PURE__ */ new Set();
|
|
8139
8180
|
for (const candidate of candidates) {
|
|
8140
8181
|
const same = candidates.filter((other) => other.id === candidate.id && other.line !== candidate.line && Math.abs(other.line.x - candidate.line.x) <= 1 && Math.abs(other.x - candidate.x) <= 1 && Math.abs(other.width - candidate.width) <= 1 && other.line.fontSize === candidate.line.fontSize && Math.abs(other.line.y - candidate.line.y) >= candidate.line.fontSize * 2);
|
|
8141
|
-
const numbered = items.filter((item) => !item.isHidden && /^[①-⑮]\s*/.test(item.text.trim()) && item.fontName === candidate.line.fontName && item.fontSize === candidate.line.fontSize && Math.abs(item.x - candidate.x) <= 1 && (_nullishCoalesce(_optionalChain([item, 'access',
|
|
8182
|
+
const numbered = items.filter((item) => !item.isHidden && /^[①-⑮]\s*/.test(item.text.trim()) && item.fontName === candidate.line.fontName && item.fontSize === candidate.line.fontSize && Math.abs(item.x - candidate.x) <= 1 && (_nullishCoalesce(_optionalChain([item, 'access', _392 => _392.text, 'access', _393 => _393.match, 'call', _394 => _394(/\p{L}/gu), 'optionalAccess', _395 => _395.length]), () => ( 0))) >= 12).sort((a, b) => b.y - a.y);
|
|
8142
8183
|
const numberedList = numbered.some((item, index) => index > 0 && item.text.trim().charCodeAt(0) === numbered[index - 1].text.trim().charCodeAt(0) + 1);
|
|
8143
8184
|
if (!same.length && !numberedList || used.has(candidate.line)) continue;
|
|
8144
8185
|
if (!shapes.has(candidate.id)) shapes.set(candidate.id, hollowCircle(await resolveImagePixels(page, candidate.id)));
|
|
@@ -8204,7 +8245,7 @@ function groupFlowBoxUnits(blocks, grids, hs, vs, images) {
|
|
|
8204
8245
|
return units;
|
|
8205
8246
|
}
|
|
8206
8247
|
function arrowDirection(image) {
|
|
8207
|
-
if (!_optionalChain([image, 'optionalAccess',
|
|
8248
|
+
if (!_optionalChain([image, 'optionalAccess', _396 => _396.data]) || image.width < 16 || image.width > 128 || image.height < 16 || image.height > 128) return 0;
|
|
8208
8249
|
const { width, height, data } = image;
|
|
8209
8250
|
const stride = image.kind === _pdfmjs.ImageKind.RGB_24BPP ? 3 : image.kind === _pdfmjs.ImageKind.RGBA_32BPP ? 4 : 0;
|
|
8210
8251
|
if (!stride || data.length < width * height * stride) return 0;
|
|
@@ -8272,7 +8313,7 @@ function isSideTabTable(box, table, others, pageWidth, pageHeight) {
|
|
|
8272
8313
|
function removeSideTabs(blocks, pageWidths) {
|
|
8273
8314
|
const edges = /* @__PURE__ */ new Map();
|
|
8274
8315
|
for (const b of blocks) {
|
|
8275
|
-
if (!b.bbox || b.pageNumber === void 0 || [..._nullishCoalesce(_optionalChain([b, 'access',
|
|
8316
|
+
if (!b.bbox || b.pageNumber === void 0 || [..._nullishCoalesce(_optionalChain([b, 'access', _397 => _397.text, 'optionalAccess', _398 => _398.trim, 'call', _399 => _399()]), () => ( ""))].length <= MAX_CHARS) continue;
|
|
8276
8317
|
const e = _nullishCoalesce(edges.get(b.pageNumber), () => ( { lefts: [], rights: [] }));
|
|
8277
8318
|
e.lefts.push(b.bbox.x);
|
|
8278
8319
|
e.rights.push(b.bbox.x + b.bbox.width);
|
|
@@ -8288,7 +8329,7 @@ function removeSideTabs(blocks, pageWidths) {
|
|
|
8288
8329
|
const fallback = all.length ? { left: q(all.map((e) => e.left), 0.5), right: q(all.map((e) => e.right), 0.5) } : void 0;
|
|
8289
8330
|
const key = (b) => {
|
|
8290
8331
|
const w = b.pageNumber !== void 0 ? pageWidths.get(b.pageNumber) : void 0;
|
|
8291
|
-
const text = _optionalChain([b, 'access',
|
|
8332
|
+
const text = _optionalChain([b, 'access', _400 => _400.text, 'optionalAccess', _401 => _401.trim, 'call', _402 => _402()]);
|
|
8292
8333
|
const area = _nullishCoalesce((b.pageNumber !== void 0 ? body.get(b.pageNumber) : void 0), () => ( fallback));
|
|
8293
8334
|
if (b.type === "table") {
|
|
8294
8335
|
if (!w || !b.bbox || !b.table || !SIDE_TAB_TABLES.has(b.table)) return null;
|
|
@@ -8954,16 +8995,16 @@ function isProseSpread(items) {
|
|
|
8954
8995
|
for (let i = 1; i < sorted.length; i++) {
|
|
8955
8996
|
gaps.push(sorted[i].x - (sorted[i - 1].x + sorted[i - 1].w));
|
|
8956
8997
|
}
|
|
8957
|
-
const maxGap =
|
|
8998
|
+
const maxGap = _chunkQIVOVMECcjs.safeMax.call(void 0, gaps);
|
|
8958
8999
|
const avgLen = items.reduce((s, i) => s + i.text.length, 0) / items.length;
|
|
8959
9000
|
if (items.length >= 4 && maxGap < 40 && avgLen < 5) return true;
|
|
8960
|
-
const minGap =
|
|
9001
|
+
const minGap = _chunkQIVOVMECcjs.safeMin.call(void 0, gaps);
|
|
8961
9002
|
return minGap > 0 && maxGap - minGap <= Math.max(2, maxGap * 0.15) && (items.filter((i) => /^\P{L}*\p{Ll}/u.test(i.text)).length * 2 >= items.length || items.some((i) => /\p{L}[,.;:]["”’)]?$/u.test(i.text)));
|
|
8962
9003
|
}
|
|
8963
9004
|
function detectColumns(yLines) {
|
|
8964
9005
|
const allItems = yLines.flat();
|
|
8965
9006
|
if (allItems.length === 0) return null;
|
|
8966
|
-
const pageWidth =
|
|
9007
|
+
const pageWidth = _chunkQIVOVMECcjs.safeMax.call(void 0, allItems.map((i) => i.x + i.w)) - _chunkQIVOVMECcjs.safeMin.call(void 0, allItems.map((i) => i.x));
|
|
8967
9008
|
if (pageWidth < 100) return null;
|
|
8968
9009
|
let bigoLineIdx = -1;
|
|
8969
9010
|
for (let i = 0; i < yLines.length; i++) {
|
|
@@ -9188,7 +9229,7 @@ var UNDER_BOX_PAIR_MAX_EM = 2.2;
|
|
|
9188
9229
|
var UNDER_BOX_PAIR_OVERLAP = 0.8;
|
|
9189
9230
|
function markUnderlineItems(items, horizontals, verticals, nonRules) {
|
|
9190
9231
|
const underlines = [];
|
|
9191
|
-
if (_optionalChain([nonRules, 'optionalAccess',
|
|
9232
|
+
if (_optionalChain([nonRules, 'optionalAccess', _403 => _403.size])) horizontals = horizontals.filter((line) => !nonRules.has(line));
|
|
9192
9233
|
if (items.length === 0 || horizontals.length === 0) return underlines;
|
|
9193
9234
|
const tightOwners = /* @__PURE__ */ new Map();
|
|
9194
9235
|
const tightlyOwned = (line) => {
|
|
@@ -9294,7 +9335,7 @@ function hasBoxTopPair(line, maxH, horizontals, cellItems) {
|
|
|
9294
9335
|
if (ow <= 0) continue;
|
|
9295
9336
|
const overlap2 = Math.min(line.x2, o.x2) - Math.max(line.x1, o.x1);
|
|
9296
9337
|
if (overlap2 / Math.max(w, ow) < UNDER_BOX_PAIR_OVERLAP) continue;
|
|
9297
|
-
const covered = _nullishCoalesce(_optionalChain([cellItems, 'optionalAccess',
|
|
9338
|
+
const covered = _nullishCoalesce(_optionalChain([cellItems, 'optionalAccess', _404 => _404.reduce, 'call', _405 => _405((sum, item) => {
|
|
9298
9339
|
const below = item.y - o.y1;
|
|
9299
9340
|
if (below < 0.5 || below > 3 || !item.text.trim()) return sum;
|
|
9300
9341
|
return sum + Math.max(0, Math.min(o.x2, item.x + item.w) - Math.max(o.x1, item.x));
|
|
@@ -9361,13 +9402,13 @@ function partTex(group) {
|
|
|
9361
9402
|
const base = Math.min(...g.filter((i) => i.fontSize >= size * SCRIPT_SIZE_RATIO).map((i) => i.y));
|
|
9362
9403
|
let s = "", run = "";
|
|
9363
9404
|
const flush = () => {
|
|
9364
|
-
if (run) s +=
|
|
9405
|
+
if (run) s += _chunkXM4VBVYHcjs.toTex.call(void 0, run);
|
|
9365
9406
|
run = "";
|
|
9366
9407
|
};
|
|
9367
9408
|
g.forEach((it, k) => {
|
|
9368
9409
|
if (it.fontSize < size * SCRIPT_SIZE_RATIO && it.y - base >= size * SCRIPT_RISE_EM) {
|
|
9369
9410
|
flush();
|
|
9370
|
-
s += `^{${
|
|
9411
|
+
s += `^{${_chunkXM4VBVYHcjs.toTex.call(void 0, it.text)}}`;
|
|
9371
9412
|
return;
|
|
9372
9413
|
}
|
|
9373
9414
|
if (k && it.x - (g[k - 1].x + g[k - 1].w) > spaceGapThreshold(it.fontSize)) run += " ";
|
|
@@ -9540,12 +9581,12 @@ function rebuildUnitLine(items, grid) {
|
|
|
9540
9581
|
function prependUnitRow(cells, cols, line, usedItems) {
|
|
9541
9582
|
const text = cleanCellText(line.map((item) => item.text).join(""));
|
|
9542
9583
|
cells.unshift(Array.from({ length: cols }, (_, c) => ({ text: c === 0 ? text : "", colSpan: c === 0 ? cols : 1, rowSpan: 1 })));
|
|
9543
|
-
for (const cell of cells[0])
|
|
9584
|
+
for (const cell of cells[0]) _chunkXM4VBVYHcjs.CELL_EDGES.set(cell, NO_EDGES);
|
|
9544
9585
|
for (const item of line) usedItems.add(item);
|
|
9545
9586
|
}
|
|
9546
9587
|
function attachUnitRow(items, grid, cells, cols, usedItems) {
|
|
9547
9588
|
const all = cells.flat();
|
|
9548
|
-
if (all.filter((c) => c.text.trim()).length * 2 < all.length || UNIT.test(_nullishCoalesce(_optionalChain([cells, 'access',
|
|
9589
|
+
if (all.filter((c) => c.text.trim()).length * 2 < all.length || UNIT.test(_nullishCoalesce(_optionalChain([cells, 'access', _406 => _406[0], 'optionalAccess', _407 => _407[0], 'optionalAccess', _408 => _408.text]), () => ( "")))) return false;
|
|
9549
9590
|
const above = items.filter((it) => !usedItems.has(it) && it.y >= grid.bbox.y2 && it.y - grid.bbox.y2 <= 8 && it.x >= grid.bbox.x1 - 3 && it.x + it.w <= grid.bbox.x2 + 3);
|
|
9550
9591
|
let nearest = Infinity;
|
|
9551
9592
|
for (const it of above) nearest = Math.min(nearest, it.y);
|
|
@@ -9580,7 +9621,7 @@ function closeShadedTableEdges(clipGrids, horizontals, verticals, fillRects) {
|
|
|
9580
9621
|
let hs = horizontals, vs = verticals;
|
|
9581
9622
|
const restored = [];
|
|
9582
9623
|
for (const grid of clipGrids) {
|
|
9583
|
-
if (grid.clipParent || grid.rowYs.length !== 2 || grid.colXs.length < 3 || !_optionalChain([grid, 'access',
|
|
9624
|
+
if (grid.clipParent || grid.rowYs.length !== 2 || grid.colXs.length < 3 || !_optionalChain([grid, 'access', _409 => _409.cells, 'optionalAccess', _410 => _410.length]) || grid.cells.some((c) => c.filler || c.rowSpan !== 1 || c.colSpan !== 1)) continue;
|
|
9584
9625
|
const { x1, x2, y1: mid, y2: top } = grid.bbox;
|
|
9585
9626
|
if (!grid.cells.every((c) => fillRects.some((f) => near2(f.x1, c.bbox.x1) && near2(f.x2, c.bbox.x2) && near2(f.y1, c.bbox.y1) && near2(f.y2, c.bbox.y2)))) continue;
|
|
9586
9627
|
const topRule = hs.find((h) => near2(h.y1, top) && near2(h.x1, x1) && near2(h.x2, x2));
|
|
@@ -10044,7 +10085,7 @@ function takeFrameSpanningText(items, cutX, pageNum, lex) {
|
|
|
10044
10085
|
const rows = groupByY([...items].sort((a, b) => b.y - a.y || a.x - b.x)).map((line) => {
|
|
10045
10086
|
const runs = [];
|
|
10046
10087
|
for (const item of [...line].sort((a, b) => a.x - b.x)) {
|
|
10047
|
-
const run = runs[runs.length - 1], prev = _optionalChain([run, 'optionalAccess',
|
|
10088
|
+
const run = runs[runs.length - 1], prev = _optionalChain([run, 'optionalAccess', _411 => _411[run.length - 1]]);
|
|
10048
10089
|
if (prev && item.x - (prev.x + prev.w) <= Math.max(prev.fontSize, item.fontSize) * 0.6) run.push(item);
|
|
10049
10090
|
else runs.push([item]);
|
|
10050
10091
|
}
|
|
@@ -10088,7 +10129,7 @@ function groupFrameParagraphUnits(units, frames) {
|
|
|
10088
10129
|
for (const unit of units) for (const block of unit) source.set(block, unit);
|
|
10089
10130
|
const members = /* @__PURE__ */ new Map(), emitted = /* @__PURE__ */ new Set();
|
|
10090
10131
|
for (const frame of frames) {
|
|
10091
|
-
if (frame.length < 2 || frame.some((block) => block.type !== "paragraph" || _optionalChain([source, 'access',
|
|
10132
|
+
if (frame.length < 2 || frame.some((block) => block.type !== "paragraph" || _optionalChain([source, 'access', _412 => _412.get, 'call', _413 => _413(block), 'optionalAccess', _414 => _414.length]) !== 1)) continue;
|
|
10092
10133
|
for (const block of frame) members.set(block, frame);
|
|
10093
10134
|
}
|
|
10094
10135
|
const out = [];
|
|
@@ -10101,7 +10142,7 @@ function groupFrameParagraphUnits(units, frames) {
|
|
|
10101
10142
|
}
|
|
10102
10143
|
}
|
|
10103
10144
|
for (const unit of out) {
|
|
10104
|
-
if (unit.length < 2 || _optionalChain([FRAME_READING_UNITS, 'access',
|
|
10145
|
+
if (unit.length < 2 || _optionalChain([FRAME_READING_UNITS, 'access', _415 => _415.get, 'call', _416 => _416(unit[0]), 'optionalAccess', _417 => _417.blocks]) === unit) continue;
|
|
10105
10146
|
const bs = unit.map((b) => b.bbox).filter((b) => !!b);
|
|
10106
10147
|
if (bs.length !== unit.length) continue;
|
|
10107
10148
|
const x = Math.min(...bs.map((b) => b.x)), y = Math.min(...bs.map((b) => b.y));
|
|
@@ -10118,14 +10159,14 @@ function groupFrameParagraphUnits(units, frames) {
|
|
|
10118
10159
|
function recordFrameTitle(table, source, pageNum) {
|
|
10119
10160
|
if (!CLIP_TABLES.has(table) || table.rows !== 1 || table.cols !== 3 || source.length < 2) return;
|
|
10120
10161
|
const cells = table.cells[0];
|
|
10121
|
-
if (cells.length !== 3 || cells.some((c) => c.colSpan !== 1 || c.rowSpan !== 1 || _optionalChain([c, 'access',
|
|
10162
|
+
if (cells.length !== 3 || cells.some((c) => c.colSpan !== 1 || c.rowSpan !== 1 || _optionalChain([c, 'access', _418 => _418.blocks, 'optionalAccess', _419 => _419.length]) || c.text.includes("\n"))) return;
|
|
10122
10163
|
const [label, spacer, title] = cells;
|
|
10123
10164
|
if (!/^(?:붙임|별첨|첨부|부록)\s*\d{1,3}$/.test(label.text.trim()) || spacer.text.trim() || !title.text.trim()) return;
|
|
10124
10165
|
if (cells.some((c) => {
|
|
10125
|
-
const e =
|
|
10166
|
+
const e = _chunkXM4VBVYHcjs.CELL_EDGES.get(c);
|
|
10126
10167
|
return !e || e.t || e.b || e.l || e.r;
|
|
10127
10168
|
})) return;
|
|
10128
|
-
const xs = TABLE_COLXS.get(table), style = dominantStyle(source), fs = _nullishCoalesce(_optionalChain([style, 'optionalAccess',
|
|
10169
|
+
const xs = TABLE_COLXS.get(table), style = dominantStyle(source), fs = _nullishCoalesce(_optionalChain([style, 'optionalAccess', _420 => _420.fontSize]), () => ( 0));
|
|
10129
10170
|
if (!xs || xs.length !== 4 || fs <= 0) return;
|
|
10130
10171
|
const width = xs[3] - xs[0], gap = xs[2] - xs[1];
|
|
10131
10172
|
if (width < fs * 12 || gap <= 0 || gap > fs * 1.5 || xs[1] - xs[0] > width * 0.25 || xs[3] - xs[2] < width * 0.6) return;
|
|
@@ -10189,7 +10230,7 @@ function extendNestedShadedHeaders(clipGrids, lineGrids, horizontals, verticals,
|
|
|
10189
10230
|
const extended = [];
|
|
10190
10231
|
for (let i = 0; i < clipGrids.length; i++) {
|
|
10191
10232
|
const c = clipGrids[i], parent = c.clipParent;
|
|
10192
|
-
if (!parent || c.rowYs.length !== 2 || c.colXs.length < 3 || !_optionalChain([c, 'access',
|
|
10233
|
+
if (!parent || c.rowYs.length !== 2 || c.colXs.length < 3 || !_optionalChain([c, 'access', _421 => _421.cells, 'optionalAccess', _422 => _422.length]) || c.cells.some((cell) => cell.filler || cell.rowSpan !== 1 || cell.colSpan !== 1)) continue;
|
|
10193
10234
|
if (!clipGrids.some((g) => g.rowYs.length === 2 && g.colXs.length === 2 && near2(g.bbox.x1, parent.x1) && near2(g.bbox.x2, parent.x2) && near2(g.bbox.y1, parent.y1) && near2(g.bbox.y2, parent.y2))) continue;
|
|
10194
10235
|
if (!c.cells.every((cell) => fills.some((f) => near2(f.x1, cell.bbox.x1) && near2(f.x2, cell.bbox.x2) && near2(f.y1, cell.bbox.y1) && near2(f.y2, cell.bbox.y2)))) continue;
|
|
10195
10236
|
const host = lineGrids.find((l) => l.rowYs.length > 2 && l.colXs.length === c.colXs.length && c.colXs.every((x, k) => near2(x, l.colXs[k])) && c.rowYs.every((y, k) => near2(y, l.rowYs[k])) && contains4(parent, l.bbox) && l.rowYs.every((y) => horizontals.some((h) => near2(h.y1, y) && near2(h.x1, l.bbox.x1) && near2(h.x2, l.bbox.x2))) && l.colXs.every((x) => verticals.some((v) => near2(v.x1, x) && v.y1 <= l.bbox.y1 + 1.5 && v.y2 >= l.bbox.y2 - 1.5)) && !clipGrids.some((o) => o !== c && !contains4(o.bbox, l.bbox) && Math.min(o.bbox.x2, l.bbox.x2) > Math.max(o.bbox.x1, l.bbox.x1) && Math.min(o.bbox.y2, l.bbox.y2) > Math.max(o.bbox.y1, l.bbox.y1)));
|
|
@@ -10212,7 +10253,7 @@ function attachSideTabBlocks(tab, body, pageNum) {
|
|
|
10212
10253
|
bbox: computeBBox(items, pageNum),
|
|
10213
10254
|
style: dominantStyle(items)
|
|
10214
10255
|
});
|
|
10215
|
-
const prefix = ordered.filter((g) => !_optionalChain([caps, 'optionalAccess',
|
|
10256
|
+
const prefix = ordered.filter((g) => !_optionalChain([caps, 'optionalAccess', _423 => _423.has, 'call', _424 => _424(g)])).map((g) => ({
|
|
10216
10257
|
type: "paragraph",
|
|
10217
10258
|
text: g.text.trim(),
|
|
10218
10259
|
pageNumber: pageNum,
|
|
@@ -10221,7 +10262,7 @@ function attachSideTabBlocks(tab, body, pageNum) {
|
|
|
10221
10262
|
}));
|
|
10222
10263
|
const groups = /* @__PURE__ */ new Map();
|
|
10223
10264
|
for (const g of ordered) {
|
|
10224
|
-
const cap = _optionalChain([caps, 'optionalAccess',
|
|
10265
|
+
const cap = _optionalChain([caps, 'optionalAccess', _425 => _425.get, 'call', _426 => _426(g)]);
|
|
10225
10266
|
if (cap) groups.set(cap, [..._nullishCoalesce(groups.get(cap), () => ( [])), g]);
|
|
10226
10267
|
}
|
|
10227
10268
|
for (const [cap, glyphs] of groups) {
|
|
@@ -10253,7 +10294,7 @@ function extractPageBlocksWithLines(items, pageNum, opList, pageWidth, pageHeigh
|
|
|
10253
10294
|
let prev = null;
|
|
10254
10295
|
for (const line of streamLines(items)) {
|
|
10255
10296
|
lex.addLine(mergeLineSimple(line));
|
|
10256
|
-
const fs = _nullishCoalesce(_optionalChain([dominantStyle, 'call',
|
|
10297
|
+
const fs = _nullishCoalesce(_optionalChain([dominantStyle, 'call', _427 => _427(line), 'optionalAccess', _428 => _428.fontSize]), () => ( 0));
|
|
10257
10298
|
const left = Math.min(...line.map((i) => i.x)), right = Math.max(...line.map((i) => i.x + i.w));
|
|
10258
10299
|
const y = line.reduce((n, i) => n + i.y, 0) / line.length;
|
|
10259
10300
|
const wide = fs > 0 && right - left >= 12 * fs;
|
|
@@ -10267,7 +10308,7 @@ function extractPageBlocksWithLines(items, pageNum, opList, pageWidth, pageHeigh
|
|
|
10267
10308
|
const filled = fillBlanks(items, horizontals, verticals);
|
|
10268
10309
|
items = filled.items;
|
|
10269
10310
|
horizontals = filled.horizontals;
|
|
10270
|
-
const prevPage = _optionalChain([carry, 'optionalAccess',
|
|
10311
|
+
const prevPage = _optionalChain([carry, 'optionalAccess', _429 => _429.page]) === pageNum - 1 ? carry.clip : void 0;
|
|
10271
10312
|
const images = extractImageRegions(opList.fnArray, opList.argsArray);
|
|
10272
10313
|
const clipRects = images.length ? withoutImageOnlyClips(extracted.clipRects, images) : extracted.clipRects;
|
|
10273
10314
|
const clipResult = detectTables ? buildClipCellGrids(clipRects, horizontals, verticals, pageWidth, pageHeight, items.map((it) => ({ x: it.x + it.w / 2, y: it.y + it.h / 2 })), extracted.fillRects, prevPage) : { grids: [], containers: [], page: void 0 };
|
|
@@ -10573,7 +10614,7 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
|
|
|
10573
10614
|
const nested = pendingNested.length ? takePendingNested(pendingNested, cell.bbox, !!grid.cells) : [];
|
|
10574
10615
|
const lone = nested.length === 1 && !cellItems.length ? nested[0] : null;
|
|
10575
10616
|
const cw = cell.bbox.x2 - cell.bbox.x1;
|
|
10576
|
-
if (_optionalChain([lone, 'optionalAccess',
|
|
10617
|
+
if (_optionalChain([lone, 'optionalAccess', _430 => _430.table]) && lone.bbox && lone.table.rows === 1 && lone.table.cols === 1 && CLIP_TABLES.has(lone.table) && !_optionalChain([lone, 'access', _431 => _431.table, 'access', _432 => _432.cells, 'access', _433 => _433[0], 'access', _434 => _434[0], 'access', _435 => _435.blocks, 'optionalAccess', _436 => _436.some, 'call', _437 => _437((b2) => b2.type === "table")]) && lone.bbox.width >= cw * 0.9 && /^[^\n]{1,30}$/.test(lone.table.cells[0][0].text.trim())) {
|
|
10577
10618
|
irGrid[cell.row][cell.col] = { text: lone.table.cells[0][0].text, colSpan: cell.colSpan, rowSpan: cell.rowSpan };
|
|
10578
10619
|
takeClipCellEdges(cell, irGrid[cell.row][cell.col]);
|
|
10579
10620
|
continue;
|
|
@@ -10623,10 +10664,10 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
|
|
|
10623
10664
|
const ls = irGrid.slice(1).flat().flatMap((c) => c.text.split("\n")).map((t) => t.trim()).filter(Boolean);
|
|
10624
10665
|
const numericLine = (t) => {
|
|
10625
10666
|
const cs = t.replace(/\s+/g, "");
|
|
10626
|
-
return cs.length > 0 && (_nullishCoalesce(_optionalChain([cs, 'access',
|
|
10667
|
+
return cs.length > 0 && (_nullishCoalesce(_optionalChain([cs, 'access', _438 => _438.match, 'call', _439 => _439(/[\d.,%()+\-−–—△▲▽▼]/g), 'optionalAccess', _440 => _440.length]), () => ( 0))) >= cs.length * 0.85;
|
|
10627
10668
|
};
|
|
10628
10669
|
const labelValueLine = (t) => {
|
|
10629
|
-
const hangul = _nullishCoalesce(_optionalChain([t, 'access',
|
|
10670
|
+
const hangul = _nullishCoalesce(_optionalChain([t, 'access', _441 => _441.match, 'call', _442 => _442(/[가-힣]/g), 'optionalAccess', _443 => _443.length]), () => ( 0));
|
|
10630
10671
|
return hangul > 0 && hangul <= 6 && /\d,\d{3}/.test(t) && numericLine(t.replace(/[가-힣()]/g, ""));
|
|
10631
10672
|
};
|
|
10632
10673
|
const bulletLine = (t) => /^\s*[○◦•□■▪]/.test(t) || /^\s*-\s*[^\d\s.,−-]/.test(t) && t.replace(/\s+/g, "").length > 7;
|
|
@@ -10636,14 +10677,14 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
|
|
|
10636
10677
|
const share = ls.filter((t) => numericLine(t) || lvLines.has(t)).length / ls.length;
|
|
10637
10678
|
if (share >= 0.5) return true;
|
|
10638
10679
|
const colShares = Array.from({ length: numCols }, (_, c) => {
|
|
10639
|
-
const cl = irGrid.slice(1).flatMap((row) => (_nullishCoalesce(_optionalChain([row, 'access',
|
|
10680
|
+
const cl = irGrid.slice(1).flatMap((row) => (_nullishCoalesce(_optionalChain([row, 'access', _444 => _444[c], 'optionalAccess', _445 => _445.text]), () => ( ""))).split("\n")).map((t) => t.trim()).filter(Boolean);
|
|
10640
10681
|
return cl.length ? cl.filter(numericLine).length / cl.length : null;
|
|
10641
10682
|
}).filter((v) => v !== null);
|
|
10642
10683
|
return share >= 0.35 && colShares.some((v) => v >= 0.8) && colShares.every((v) => v >= 0.8 || v <= 0.2);
|
|
10643
10684
|
})();
|
|
10644
10685
|
const layoutProse = irGrid.some((row) => row.some((c) => c.colSpan >= numCols - 1 && c.text.length > 60));
|
|
10645
10686
|
const maxRows = numericBody ? layoutProse ? OCR_NUMERIC_MAX_ROWS_FRAMED : OCR_NUMERIC_MAX_ROWS : 5;
|
|
10646
|
-
const proseLine = (t) => (_nullishCoalesce(_optionalChain([t, 'access',
|
|
10687
|
+
const proseLine = (t) => (_nullishCoalesce(_optionalChain([t, 'access', _446 => _446.match, 'call', _447 => _447(/[가-힣]/g), 'optionalAccess', _448 => _448.length]), () => ( 0))) > 6 && !/^[-−]?[\d,.]+$/.test(t.replace(/\s+/g, ""));
|
|
10647
10688
|
const proseCols = numRows === 2 ? (_nullishCoalesce(irGrid[1], () => ( []))).filter((c) => {
|
|
10648
10689
|
const ls = c.text.split("\n").map((t) => t.trim()).filter(Boolean);
|
|
10649
10690
|
return ls.length >= 3 && ls.filter(proseLine).length >= ls.length * 0.6;
|
|
@@ -10664,8 +10705,8 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
|
|
|
10664
10705
|
finalGrid = rebuilt.map((row, i) => {
|
|
10665
10706
|
const o = kept.get(i);
|
|
10666
10707
|
return row.map((rawText, c) => {
|
|
10667
|
-
const src = o === void 0 ? void 0 : _optionalChain([irGrid, 'access',
|
|
10668
|
-
return { text: cleanCellText(rawText), colSpan: _nullishCoalesce(_optionalChain([src, 'optionalAccess',
|
|
10708
|
+
const src = o === void 0 ? void 0 : _optionalChain([irGrid, 'access', _449 => _449[o], 'optionalAccess', _450 => _450[c]]);
|
|
10709
|
+
return { text: cleanCellText(rawText), colSpan: _nullishCoalesce(_optionalChain([src, 'optionalAccess', _451 => _451.colSpan]), () => ( 1)), rowSpan: src ? spanRows(o, src.rowSpan) : 1 };
|
|
10669
10710
|
});
|
|
10670
10711
|
});
|
|
10671
10712
|
finalRows = finalGrid.length;
|
|
@@ -10685,14 +10726,14 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
|
|
|
10685
10726
|
if (!assignedItems.has(textItems[ti]) && !inExpanded(textItems[ti])) usedItems.delete(owners[ti]);
|
|
10686
10727
|
}
|
|
10687
10728
|
}
|
|
10688
|
-
if (unitLine.length > 0 && rebuiltUsed && !/^\s*\(\s*단위\s*[::]/.test(_nullishCoalesce(_optionalChain([finalGrid, 'access',
|
|
10729
|
+
if (unitLine.length > 0 && rebuiltUsed && !/^\s*\(\s*단위\s*[::]/.test(_nullishCoalesce(_optionalChain([finalGrid, 'access', _452 => _452[0], 'optionalAccess', _453 => _453[0], 'optionalAccess', _454 => _454.text]), () => ( "")))) {
|
|
10689
10730
|
prependUnitRow(finalGrid, numCols, unitLine, usedItems);
|
|
10690
10731
|
finalRows++;
|
|
10691
10732
|
}
|
|
10692
10733
|
if (!rebuiltUsed && attachUnitRow(items, grid, finalGrid, numCols, usedItems)) finalRows++;
|
|
10693
10734
|
let semanticOneColumn = false;
|
|
10694
10735
|
if (!grid.cells && !nestedAttached && numCols === 1 && numGridRows >= 2) {
|
|
10695
|
-
const populatedRows = finalGrid.filter((row) => _optionalChain([row, 'access',
|
|
10736
|
+
const populatedRows = finalGrid.filter((row) => _optionalChain([row, 'access', _455 => _455[0], 'optionalAccess', _456 => _456.text, 'access', _457 => _457.trim, 'call', _458 => _458()]));
|
|
10696
10737
|
if (populatedRows.length >= 4) {
|
|
10697
10738
|
const fontSizes = tableItems.map((item) => item.fontSize).filter((size) => size > 0).sort((a, b) => a - b);
|
|
10698
10739
|
const medianFont = _nullishCoalesce(fontSizes[Math.floor(fontSizes.length / 2)], () => ( 0));
|
|
@@ -10790,7 +10831,7 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
|
|
|
10790
10831
|
height: grid.bbox.y2 - grid.bbox.y1
|
|
10791
10832
|
};
|
|
10792
10833
|
if (numRows === 1 && numCols === 1 && gridW < pageWidth * 0.35) {
|
|
10793
|
-
const prose = _nullishCoalesce(_optionalChain([finalGrid, 'access',
|
|
10834
|
+
const prose = _nullishCoalesce(_optionalChain([finalGrid, 'access', _459 => _459[0], 'optionalAccess', _460 => _460[0], 'optionalAccess', _461 => _461.text]), () => ( ""));
|
|
10794
10835
|
const besideLines = (side) => new Set(side.map((it) => Math.round(it.y / 3))).size;
|
|
10795
10836
|
const rightLines = items.filter((it) => it.x >= grid.bbox.x2 + 3 && it.y >= grid.bbox.y1 && it.y <= grid.bbox.y2);
|
|
10796
10837
|
const leftLines = items.filter((it) => it.x + it.w <= grid.bbox.x1 - 3 && it.y >= grid.bbox.y1 && it.y <= grid.bbox.y2);
|
|
@@ -10809,8 +10850,8 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
|
|
|
10809
10850
|
}
|
|
10810
10851
|
}
|
|
10811
10852
|
if (!grid.cells && !nestedAttached && shouldDemoteTable(irTable)) {
|
|
10812
|
-
const paragraphs = numRows === 1 && numCols === 1 ? _optionalChain([irTable, 'access',
|
|
10813
|
-
if (_optionalChain([paragraphs, 'optionalAccess',
|
|
10853
|
+
const paragraphs = numRows === 1 && numCols === 1 ? _optionalChain([irTable, 'access', _462 => _462.cells, 'access', _463 => _463[0], 'optionalAccess', _464 => _464[0], 'optionalAccess', _465 => _465.blocks]) : void 0;
|
|
10854
|
+
if (_optionalChain([paragraphs, 'optionalAccess', _466 => _466.length])) {
|
|
10814
10855
|
blocks.push(...paragraphs);
|
|
10815
10856
|
frameParagraphUnits.push(paragraphs);
|
|
10816
10857
|
recordFrameReadingUnit(paragraphs, tableBbox);
|
|
@@ -10857,7 +10898,7 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
|
|
|
10857
10898
|
const clusterResults = (proseColumns ? [] : detectClusterTables(clusterItems, pageNum, void 0, lex)).filter((cr) => {
|
|
10858
10899
|
const b = cr.bbox;
|
|
10859
10900
|
const overlapX = (x) => Math.min(x.x + x.width, b.x + b.width) - Math.max(x.x, b.x);
|
|
10860
|
-
return !blocks.some((x) => x.bbox && x.bbox.y >= b.y - 2 && x.bbox.y + x.bbox.height <= b.y + b.height + 2 && (x.type === "paragraph" ? (_nullishCoalesce(_optionalChain([x, 'access',
|
|
10901
|
+
return !blocks.some((x) => x.bbox && x.bbox.y >= b.y - 2 && x.bbox.y + x.bbox.height <= b.y + b.height + 2 && (x.type === "paragraph" ? (_nullishCoalesce(_optionalChain([x, 'access', _467 => _467.text, 'optionalAccess', _468 => _468.match, 'call', _469 => _469(/\p{L}/gu), 'optionalAccess', _470 => _470.length]), () => ( 0))) >= 10 && overlapX(x.bbox) >= 0.8 * b.width : x.type === "table" && !ocrPage && _optionalChain([x, 'access', _471 => _471.table, 'optionalAccess', _472 => _472.cols]) === cr.table.cols && overlapX(x.bbox) >= 0.5 * Math.min(x.bbox.width, b.width)));
|
|
10861
10902
|
});
|
|
10862
10903
|
if (clusterResults.length > 0) {
|
|
10863
10904
|
const ciToIdx = /* @__PURE__ */ new Map();
|
|
@@ -10894,7 +10935,7 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
|
|
|
10894
10935
|
groupSizes.push(1);
|
|
10895
10936
|
}
|
|
10896
10937
|
const allY = remaining.map((i) => i.y);
|
|
10897
|
-
const pageH =
|
|
10938
|
+
const pageH = _chunkQIVOVMECcjs.safeMax.call(void 0, allY) - _chunkQIVOVMECcjs.safeMin.call(void 0, allY);
|
|
10898
10939
|
const gapThreshold = Math.max(15, pageH * 0.03);
|
|
10899
10940
|
const sides = frameColumnTextBands(remaining, spanning, gx);
|
|
10900
10941
|
const textBlocks = [];
|
|
@@ -10910,7 +10951,7 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
|
|
|
10910
10951
|
finalTextBlocks.push(...detectListBlocks(textBlocks));
|
|
10911
10952
|
} else {
|
|
10912
10953
|
const allY = remaining.map((i) => i.y);
|
|
10913
|
-
const pageH =
|
|
10954
|
+
const pageH = _chunkQIVOVMECcjs.safeMax.call(void 0, allY) - _chunkQIVOVMECcjs.safeMin.call(void 0, allY);
|
|
10914
10955
|
const gapThreshold = Math.max(15, pageH * 0.03);
|
|
10915
10956
|
const groups = xyCutOrder(remaining, gapThreshold, 0, void 0, 0, lex);
|
|
10916
10957
|
const textBlocks = [];
|
|
@@ -11272,7 +11313,7 @@ function extractPageBlocksFallback(items, pageNum, fullPage = false, detectTable
|
|
|
11272
11313
|
blocks.push(...columnTextToBlocks(tableText, pageNum, bbox, dominantStyle(items)));
|
|
11273
11314
|
} else {
|
|
11274
11315
|
const allY = items.map((i) => i.y);
|
|
11275
|
-
const pageHeight =
|
|
11316
|
+
const pageHeight = _chunkQIVOVMECcjs.safeMax.call(void 0, allY) - _chunkQIVOVMECcjs.safeMin.call(void 0, allY);
|
|
11276
11317
|
const gapThreshold = Math.max(15, pageHeight * 0.03);
|
|
11277
11318
|
const orderedGroups = proseCutX !== null ? splitTwoColumnProse(items, proseCutX) : xyCutOrder(items, gapThreshold, 0, void 0, minGap, lex);
|
|
11278
11319
|
for (const group of orderedGroups) {
|
|
@@ -11329,19 +11370,19 @@ function mergeOcrImageRegions(blocks, page, regions, ocrBlocks) {
|
|
|
11329
11370
|
const overlapH = Math.max(0, Math.min(b.y + b.height, region.y2) - Math.max(b.y, region.y1));
|
|
11330
11371
|
return overlapW * overlapH >= b.width * b.height * 0.8;
|
|
11331
11372
|
});
|
|
11332
|
-
const labels = candidates.filter((b) => b.type === "paragraph" && b.bbox.height <= 24 && (_nullishCoalesce(_optionalChain([b, 'access',
|
|
11373
|
+
const labels = candidates.filter((b) => b.type === "paragraph" && b.bbox.height <= 24 && (_nullishCoalesce(_optionalChain([b, 'access', _473 => _473.text, 'optionalAccess', _474 => _474.match, 'call', _475 => _475(/[\p{L}\p{N}]/gu), 'optionalAccess', _476 => _476.length]), () => ( 0))) >= 2);
|
|
11333
11374
|
const axisFragments = rotatedAxisFragments(candidates);
|
|
11334
11375
|
const accepted = candidates.filter((b) => {
|
|
11335
|
-
if (b.type === "paragraph") return (_nullishCoalesce(_optionalChain([b, 'access',
|
|
11376
|
+
if (b.type === "paragraph") return (_nullishCoalesce(_optionalChain([b, 'access', _477 => _477.text, 'optionalAccess', _478 => _478.match, 'call', _479 => _479(/[\p{L}\p{N}]/gu), 'optionalAccess', _480 => _480.length]), () => ( 0))) >= 2 || !axisFragments.has(b) && (supportedDiagramLabel(b, labels, region) || axisTick(b, candidates));
|
|
11336
11377
|
const t = b.table;
|
|
11337
11378
|
if (b.type !== "table" || !t || UNRULED_REGION_TABLES.has(b)) return false;
|
|
11338
11379
|
const lone = t.cells.filter((row) => row.filter((c) => c.text.trim()).length === 1 && row.some((c) => c.colSpan === t.cols)).length;
|
|
11339
11380
|
if (t.rows >= 2 && lone * 2 >= t.rows) return false;
|
|
11340
11381
|
if (t.rows === 1 && t.cols === 1) {
|
|
11341
|
-
const text = _nullishCoalesce(_optionalChain([t, 'access',
|
|
11342
|
-
return (_nullishCoalesce(_optionalChain([text, 'access',
|
|
11382
|
+
const text = _nullishCoalesce(_optionalChain([t, 'access', _481 => _481.cells, 'access', _482 => _482[0], 'optionalAccess', _483 => _483[0], 'optionalAccess', _484 => _484.text]), () => ( ""));
|
|
11383
|
+
return (_nullishCoalesce(_optionalChain([text, 'access', _485 => _485.match, 'call', _486 => _486(/\n/g), 'optionalAccess', _487 => _487.length]), () => ( 0))) >= 5 && (_nullishCoalesce(_optionalChain([text, 'access', _488 => _488.match, 'call', _489 => _489(/\d/g), 'optionalAccess', _490 => _490.length]), () => ( 0))) >= text.length * 0.25;
|
|
11343
11384
|
}
|
|
11344
|
-
const headerLabels = _nullishCoalesce(_optionalChain([t, 'access',
|
|
11385
|
+
const headerLabels = _nullishCoalesce(_optionalChain([t, 'access', _491 => _491.cells, 'access', _492 => _492[0], 'optionalAccess', _493 => _493.filter, 'call', _494 => _494((c) => c.text.replace(/[^A-Za-z가-힣]/g, "").length >= 2), 'access', _495 => _495.length]), () => ( 0));
|
|
11345
11386
|
return t.rows >= 2 && t.cols >= 2 && headerLabels >= t.cols * 0.75 && t.cells.slice(1).some((row) => row.filter((c) => c.text.trim()).length >= 2);
|
|
11346
11387
|
});
|
|
11347
11388
|
const selected = candidates.flatMap((b) => accepted.includes(b) ? [b] : b.type === "table" && b.table ? rowParagraphs(b).filter((p) => /[\p{L}\p{N}]{2}/u.test(_nullishCoalesce(p.text, () => ( "")))) : []);
|
|
@@ -11358,14 +11399,14 @@ function mergeOcrImageRegions(blocks, page, regions, ocrBlocks) {
|
|
|
11358
11399
|
for (const block of selected) {
|
|
11359
11400
|
if (seen2.has(block)) continue;
|
|
11360
11401
|
const frame = FRAME_READING_UNITS.get(block);
|
|
11361
|
-
const source = _optionalChain([frame, 'optionalAccess',
|
|
11402
|
+
const source = _optionalChain([frame, 'optionalAccess', _496 => _496.blocks, 'access', _497 => _497.every, 'call', _498 => _498((member) => selectedSet.has(member))]) ? frame.blocks : [block];
|
|
11362
11403
|
source.forEach((member) => seen2.add(member));
|
|
11363
11404
|
const available = source.filter((member) => !hasOriginal(member));
|
|
11364
11405
|
const units = frame && available.length === source.length && source === frame.blocks ? [{ blocks: available, bbox: frame.bbox, atomic: true }] : available.map((member) => ({ blocks: [member], bbox: member.bbox, atomic: false }));
|
|
11365
11406
|
for (const unit of units) {
|
|
11366
11407
|
const b = unit.bbox;
|
|
11367
11408
|
const index = blocks.findIndex((existing) => {
|
|
11368
|
-
const e = _nullishCoalesce(_optionalChain([FRAME_READING_UNITS, 'access',
|
|
11409
|
+
const e = _nullishCoalesce(_optionalChain([FRAME_READING_UNITS, 'access', _499 => _499.get, 'call', _500 => _500(existing), 'optionalAccess', _501 => _501.bbox]), () => ( existing.bbox));
|
|
11369
11410
|
if (existing.pageNumber !== page || !e) return false;
|
|
11370
11411
|
const beside = e.y < region.y2 && e.y + e.height > region.y1 && e.x >= region.x2 - 1;
|
|
11371
11412
|
if (placedHere.has(existing) && Math.abs(e.y + e.height / 2 - b.y - b.height / 2) <= Math.min(e.height, b.height) * 0.25) return e.x > b.x;
|
|
@@ -11383,16 +11424,16 @@ function mergeOcrImageRegions(blocks, page, regions, ocrBlocks) {
|
|
|
11383
11424
|
}
|
|
11384
11425
|
function axisTick(block, candidates) {
|
|
11385
11426
|
const b = block.bbox;
|
|
11386
|
-
if (!/^\d$/u.test(_nullishCoalesce(_optionalChain([block, 'access',
|
|
11387
|
-
const numeric = candidates.filter((o) => o !== block && o.type === "paragraph" && o.bbox && /^[\d\s.,%+−-]+$/u.test(_nullishCoalesce(_optionalChain([o, 'access',
|
|
11427
|
+
if (!/^\d$/u.test(_nullishCoalesce(_optionalChain([block, 'access', _502 => _502.text, 'optionalAccess', _503 => _503.trim, 'call', _504 => _504()]), () => ( "")))) return false;
|
|
11428
|
+
const numeric = candidates.filter((o) => o !== block && o.type === "paragraph" && o.bbox && /^[\d\s.,%+−-]+$/u.test(_nullishCoalesce(_optionalChain([o, 'access', _505 => _505.text, 'optionalAccess', _506 => _506.trim, 'call', _507 => _507()]), () => ( ""))) && /\d/u.test(_nullishCoalesce(o.text, () => ( ""))) && Math.max(o.bbox.height, b.height) <= Math.min(o.bbox.height, b.height) * 2);
|
|
11388
11429
|
const cy = b.y + b.height / 2, right = b.x + b.width;
|
|
11389
11430
|
const row = numeric.filter((o) => Math.abs(o.bbox.y + o.bbox.height / 2 - cy) <= Math.min(o.bbox.height, b.height) * 0.35);
|
|
11390
11431
|
const column = numeric.filter((o) => Math.abs(o.bbox.x + o.bbox.width - right) <= Math.max(o.bbox.height, b.height) * 0.5);
|
|
11391
11432
|
return row.length >= 2 || column.length >= 2;
|
|
11392
11433
|
}
|
|
11393
11434
|
function supportedDiagramLabel(block, labels, region) {
|
|
11394
|
-
const b = block.bbox, text = _nullishCoalesce(_optionalChain([block, 'access',
|
|
11395
|
-
if (!b || !/^[\p{L}\p{N}]$/u.test(text) || b.height < 4 || b.width < 1 || b.width > b.height * 2 || b.x < region.x1 || b.y < region.y1 || b.x + b.width > region.x2 || b.y + b.height > region.y2 || b.width * b.height > (region.x2 - region.x1) * (region.y2 - region.y1) * 5e-3 || labels.length < 3 || !labels.some((l) => /\p{L}{3}/u.test(_nullishCoalesce(l.text, () => ( "")))) || labels.filter((l) => !/\p{L}/u.test(_nullishCoalesce(l.text, () => ( ""))) && (_nullishCoalesce(_optionalChain([l, 'access',
|
|
11435
|
+
const b = block.bbox, text = _nullishCoalesce(_optionalChain([block, 'access', _508 => _508.text, 'optionalAccess', _509 => _509.trim, 'call', _510 => _510()]), () => ( ""));
|
|
11436
|
+
if (!b || !/^[\p{L}\p{N}]$/u.test(text) || b.height < 4 || b.width < 1 || b.width > b.height * 2 || b.x < region.x1 || b.y < region.y1 || b.x + b.width > region.x2 || b.y + b.height > region.y2 || b.width * b.height > (region.x2 - region.x1) * (region.y2 - region.y1) * 5e-3 || labels.length < 3 || !labels.some((l) => /\p{L}{3}/u.test(_nullishCoalesce(l.text, () => ( "")))) || labels.filter((l) => !/\p{L}/u.test(_nullishCoalesce(l.text, () => ( ""))) && (_nullishCoalesce(_optionalChain([l, 'access', _511 => _511.text, 'optionalAccess', _512 => _512.match, 'call', _513 => _513(/\p{N}/gu), 'optionalAccess', _514 => _514.length]), () => ( 0))) >= 2).length < 2) return false;
|
|
11396
11437
|
let above = false, below = false;
|
|
11397
11438
|
for (const label of labels) {
|
|
11398
11439
|
const a = label.bbox, em = Math.max(b.height, a.height);
|
|
@@ -11407,7 +11448,7 @@ function rotatedAxisFragments(candidates) {
|
|
|
11407
11448
|
const paragraphs = candidates.filter((b) => b.type === "paragraph" && b.bbox.height <= 24);
|
|
11408
11449
|
const axes = [];
|
|
11409
11450
|
for (const block of paragraphs) {
|
|
11410
|
-
const b = block.bbox, text = _nullishCoalesce(_optionalChain([block, 'access',
|
|
11451
|
+
const b = block.bbox, text = _nullishCoalesce(_optionalChain([block, 'access', _515 => _515.text, 'optionalAccess', _516 => _516.trim, 'call', _517 => _517()]), () => ( ""));
|
|
11411
11452
|
if (!/^[\d\s.,%+−-]+$/u.test(text) || !/\d/u.test(text) || b.width > b.height * 6) continue;
|
|
11412
11453
|
const axis = axes.find((a) => Math.abs(a[0].bbox.x + a[0].bbox.width - b.x - b.width) <= Math.max(a[0].bbox.height, b.height) * 0.5);
|
|
11413
11454
|
if (axis) axis.push(block);
|
|
@@ -11424,8 +11465,8 @@ function rotatedAxisFragments(candidates) {
|
|
|
11424
11465
|
const em = Math.max(...axis.map((a) => a.bbox.height)), right = axis[0].bbox.x + axis[0].bbox.width;
|
|
11425
11466
|
if (top - bottom < em * 6) continue;
|
|
11426
11467
|
const left = paragraphs.filter((block) => {
|
|
11427
|
-
const b = block.bbox, text = _nullishCoalesce(_optionalChain([block, 'access',
|
|
11428
|
-
return /\p{Script=Latin}/u.test(text) && (_nullishCoalesce(_optionalChain([text, 'access',
|
|
11468
|
+
const b = block.bbox, text = _nullishCoalesce(_optionalChain([block, 'access', _518 => _518.text, 'optionalAccess', _519 => _519.trim, 'call', _520 => _520()]), () => ( ""));
|
|
11469
|
+
return /\p{Script=Latin}/u.test(text) && (_nullishCoalesce(_optionalChain([text, 'access', _521 => _521.match, 'call', _522 => _522(/[\p{L}\p{N}]/gu), 'optionalAccess', _523 => _523.length]), () => ( 0))) <= 3 && b.width <= b.height * 3 && b.x + b.width >= right - em * 6 && b.x + b.width <= right - Math.max(em, b.height) && b.y >= bottom && b.y + b.height <= top;
|
|
11429
11470
|
});
|
|
11430
11471
|
const stack = left.filter((a) => left.some((b) => {
|
|
11431
11472
|
if (a === b || !aligned(a, b)) return false;
|
|
@@ -11435,7 +11476,7 @@ function rotatedAxisFragments(candidates) {
|
|
|
11435
11476
|
if (stack.length < 2) continue;
|
|
11436
11477
|
for (const block of paragraphs) {
|
|
11437
11478
|
const b = block.bbox;
|
|
11438
|
-
if (b.y >= bottom && b.y + b.height <= top && b.x + b.width >= right - em * 6 && b.x + b.width <= right - Math.max(em, b.height) && /^[\p{L}\p{N}]$/u.test(_nullishCoalesce(_optionalChain([block, 'access',
|
|
11479
|
+
if (b.y >= bottom && b.y + b.height <= top && b.x + b.width >= right - em * 6 && b.x + b.width <= right - Math.max(em, b.height) && /^[\p{L}\p{N}]$/u.test(_nullishCoalesce(_optionalChain([block, 'access', _524 => _524.text, 'optionalAccess', _525 => _525.trim, 'call', _526 => _526()]), () => ( ""))) && stack.some((s) => aligned(s, block))) fragments.add(block);
|
|
11439
11480
|
}
|
|
11440
11481
|
}
|
|
11441
11482
|
return fragments;
|
|
@@ -11542,4 +11583,4 @@ function rowParagraphs(block) {
|
|
|
11542
11583
|
|
|
11543
11584
|
|
|
11544
11585
|
exports.DEFAULT_OCR_MODELS = DEFAULT_OCR_MODELS; exports.resolveOcrModels = resolveOcrModels; exports.handwritingFallbackModels = handwritingFallbackModels; exports.ocrSelectionKey = ocrSelectionKey; exports.ocrSourcePath = ocrSourcePath; exports.ensureOcrModelsFor = ensureOcrModelsFor; exports.ocrModelsCached = ocrModelsCached; exports.parseCharacterDict = parseCharacterDict; exports.grayCrop = grayCrop; exports.inkStats = inkStats; exports.splitRowBands = splitRowBands; exports.leadingTriangle = leadingTriangle; exports.arrowGlyph = arrowGlyph; exports.leaderRuns = leaderRuns; exports.inkBounds = inkBounds; exports.bracketFeatures = bracketFeatures; exports.slantedPair = slantedPair; exports.romanStems = romanStems; exports.circledAt = circledAt; exports.ringBoxes = ringBoxes; exports.quoteHead = quoteHead; exports.edgeTrim = edgeTrim; exports.tallInkCount = tallInkCount; exports.gapGlyphs = gapGlyphs; exports.ringBullet = ringBullet; exports.dashRatio = dashRatio; exports.leadingRing = leadingRing; exports.discAt = discAt; exports.serifOne = serifOne; exports.starRun = starRun; exports.bracketShape = bracketShape; exports.leadingBullet = leadingBullet; exports.stackedGlyphBands = stackedGlyphBands; exports.rememberOcrTextGaps = rememberOcrTextGaps; exports.copyOcrTextGaps = copyOcrTextGaps; exports.findOcrTextGaps = findOcrTextGaps; exports.extractLines = extractLines; exports.extractImageRegions = extractImageRegions; exports.NO_EDGES = NO_EDGES; exports.hasOpenCellSeam = hasOpenCellSeam; exports.joinCellEdges = joinCellEdges; exports.filterHiddenText = filterHiddenText; exports.collapseEvenSpacing = collapseEvenSpacing; exports.computeBBox = computeBBox; exports.dominantStyle = dominantStyle; exports.normalizeItems = normalizeItems; exports.groupByY = groupByY; exports.mergeLineSimple = mergeLineSimple; exports.WrapLexicon = WrapLexicon; exports.startsNewItem = startsNewItem; exports.wrapJoiner = wrapJoiner; exports.joinPageBreakWraps = joinPageBreakWraps; exports.splitPageBreakWraps = splitPageBreakWraps; exports.latinSoftWrap = latinSoftWrap; exports.TOC_BLOCKS = TOC_BLOCKS; exports.computeMedianFontSizeFromFreq = computeMedianFontSizeFromFreq; exports.detectHeadings = detectHeadings; exports.mergeStackedHeadingLines = mergeStackedHeadingLines; exports.detectTypographyHeadings = detectTypographyHeadings; exports.detectDocumentStyleHeadings = detectDocumentStyleHeadings; exports.detectSiblingStyleHeadings = detectSiblingStyleHeadings; exports.detectRepeatedPageLabels = detectRepeatedPageLabels; exports.detectPageLeadHeadings = detectPageLeadHeadings; exports.refineDocumentStyleHeadings = refineDocumentStyleHeadings; exports.detectMarkerHeadings = detectMarkerHeadings; exports.detectTableCaptions = detectTableCaptions; exports.detectKoreanListBlocks = detectKoreanListBlocks; exports.removeHeaderFooterBlocks = removeHeaderFooterBlocks; exports.runningLinePatterns = runningLinePatterns; exports.stripAbsorbedRunningLines = stripAbsorbedRunningLines; exports.CLIP_TABLES = CLIP_TABLES; exports.FRAME_TITLE_BLOCKS = FRAME_TITLE_BLOCKS; exports.TABLE_COLXS = TABLE_COLXS; exports.TABLE_ROWYS = TABLE_ROWYS; exports.TABLE_TAIL = TABLE_TAIL; exports.PART_COLXS = PART_COLXS; exports.EMPTY_PARTS = EMPTY_PARTS; exports.IMAGE_CELLS = IMAGE_CELLS; exports.FILLER_CELLS = FILLER_CELLS; exports.CONT_PARTS = CONT_PARTS; exports.CELL_LINES = CELL_LINES; exports.ROW_RULES = ROW_RULES; exports.trimTrailingEmptyTableCols = trimTrailingEmptyTableCols; exports.restoreImageBullets = restoreImageBullets; exports.detectRightArrowRegions = detectRightArrowRegions; exports.removeSideTabs = removeSideTabs; exports.extractPageBlocksWithLines = extractPageBlocksWithLines; exports.UNRULED_REGION_TABLES = UNRULED_REGION_TABLES; exports.mergeOcrImageRegions = mergeOcrImageRegions;
|
|
11545
|
-
//# sourceMappingURL=chunk-
|
|
11586
|
+
//# sourceMappingURL=chunk-HHRQX733.cjs.map
|