kordoc 4.24.70 → 4.24.72
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 +4 -4
- package/dist/{-JPBHAOIR.js → -S32WDXC4.js} +21 -21
- package/dist/{chunk-TAATW772.js → chunk-2SUWIRWH.js} +10 -10
- package/dist/{chunk-G5YCISXC.js → chunk-4ECEC6FD.js} +80 -33
- package/dist/chunk-4ECEC6FD.js.map +1 -0
- package/dist/{chunk-JVVTJDJY.js → chunk-4GPZVPYG.js} +3 -3
- package/dist/{chunk-OHSTI6C3.js → chunk-4Q7L4IDD.js} +2 -2
- package/dist/{chunk-6T6VP4AQ.js → chunk-4QOTRR5Z.js} +6 -6
- package/dist/{chunk-UMVD6PRZ.js → chunk-4UL2KIOH.js} +3 -3
- package/dist/{chunk-JLMNWMZJ.cjs → chunk-5CYWVW3V.cjs} +88 -88
- package/dist/{chunk-JLMNWMZJ.cjs.map → chunk-5CYWVW3V.cjs.map} +1 -1
- package/dist/{chunk-LEITYWHM.js → chunk-6DIACQ3R.js} +2 -2
- package/dist/{chunk-KV5YT6L4.js → chunk-6GQGU57N.js} +3 -3
- package/dist/{chunk-O2RV2FMS.js → chunk-7N2L6FBB.js} +5 -5
- package/dist/{chunk-FPGY6TH2.js → chunk-BD75GPTM.js} +2 -2
- package/dist/{chunk-R6J7X4ND.js → chunk-BJCTFKEU.js} +2 -2
- package/dist/{chunk-6SQF5PAM.js → chunk-C3USRXCH.js} +2 -2
- package/dist/{chunk-G3UCY3T7.js → chunk-C4K2XCGX.js} +2 -2
- package/dist/{chunk-EESBEBUC.cjs → chunk-COG4POSK.cjs} +256 -209
- package/dist/chunk-COG4POSK.cjs.map +1 -0
- package/dist/{chunk-7CLI2Y6A.js → chunk-CQUOEZBJ.js} +2 -2
- package/dist/{chunk-YY54476T.js → chunk-DIHV6CDK.js} +2 -2
- package/dist/{chunk-VZ2J3654.js → chunk-FKCSNCWC.js} +5 -5
- package/dist/{chunk-KET32GPP.js → chunk-FTPYYLCR.js} +3 -3
- package/dist/{chunk-XHBJCOWB.js → chunk-G3TKEQZ3.js} +4 -4
- package/dist/{chunk-WVQDRZF5.js → chunk-GAZDWFRT.js} +11 -11
- package/dist/{chunk-QTRQ4KM3.js → chunk-GK4OHUV5.js} +2 -2
- package/dist/{chunk-ZMPNA2W7.js → chunk-GOQWCHX5.js} +7 -7
- package/dist/{chunk-RTQ2N6DG.js → chunk-IPYSZ2WD.js} +6 -6
- package/dist/{chunk-XRZERCPJ.cjs → chunk-JE4NCQIN.cjs} +3 -3
- package/dist/{chunk-XRZERCPJ.cjs.map → chunk-JE4NCQIN.cjs.map} +1 -1
- package/dist/{chunk-HUKGGV5M.js → chunk-JEPTA64I.js} +2 -2
- package/dist/{chunk-A5MTYCTO.cjs → chunk-L4GCUYDS.cjs} +8 -8
- package/dist/{chunk-A5MTYCTO.cjs.map → chunk-L4GCUYDS.cjs.map} +1 -1
- package/dist/{chunk-MIERFAOB.js → chunk-LINC7S3M.js} +2 -2
- package/dist/{chunk-N426QQP6.js → chunk-MCO77XJN.js} +2 -2
- package/dist/{chunk-Q4DDUA7U.js → chunk-MHYFBIS5.js} +2 -2
- package/dist/{chunk-6PVJCEF7.js → chunk-NHWWNRQT.js} +2 -2
- package/dist/{chunk-YG42FESS.js → chunk-O4MTW4JH.js} +18 -16
- package/dist/chunk-O4MTW4JH.js.map +1 -0
- package/dist/{chunk-N6XPJBIS.js → chunk-SGQC3BVV.js} +79 -32
- package/dist/chunk-SGQC3BVV.js.map +1 -0
- package/dist/{chunk-UD7DB4U3.js → chunk-SNNM4GFE.js} +2 -2
- package/dist/{chunk-OTIYXYOL.cjs → chunk-TDNYBCPC.cjs} +104 -104
- package/dist/{chunk-OTIYXYOL.cjs.map → chunk-TDNYBCPC.cjs.map} +1 -1
- package/dist/{chunk-NIFJSZR7.cjs → chunk-U2K3WVR5.cjs} +3 -3
- package/dist/{chunk-NIFJSZR7.cjs.map → chunk-U2K3WVR5.cjs.map} +1 -1
- package/dist/{chunk-MU7YOHDK.js → chunk-U6CZ5IGF.js} +2 -2
- package/dist/{chunk-ICK4R4HF.js → chunk-UOML7PVK.js} +2 -2
- package/dist/{chunk-CVH5PB65.js → chunk-VRJ3CABR.js} +2 -2
- package/dist/{chunk-7D6KEQNU.cjs → chunk-WWTG5JUI.cjs} +58 -58
- package/dist/{chunk-7D6KEQNU.cjs.map → chunk-WWTG5JUI.cjs.map} +1 -1
- package/dist/{chunk-VCRBRUCO.js → chunk-WXKUE2MU.js} +5 -5
- package/dist/{chunk-6UNCF3PJ.js → chunk-YZXGUJFI.js} +2 -2
- package/dist/{chunk-3EPX46NF.cjs → chunk-ZTVH2HQ5.cjs} +2 -2
- package/dist/{chunk-3EPX46NF.cjs.map → chunk-ZTVH2HQ5.cjs.map} +1 -1
- package/dist/chunks-XNCDYMWO.js +11 -0
- package/dist/cli.js +45 -45
- package/dist/{formula-BVDS6XNY.cjs → formula-BLK43PWB.cjs} +41 -11
- package/dist/formula-BLK43PWB.cjs.map +1 -0
- package/dist/{formula-BJU6ZM3X.js → formula-E5QNTLM3.js} +35 -5
- package/dist/formula-E5QNTLM3.js.map +1 -0
- package/dist/{formula-ESTBYQ67.js → formula-WVFBIXND.js} +36 -6
- package/dist/formula-WVFBIXND.js.map +1 -0
- package/dist/generator-5VFDO4CB.js +11 -0
- package/dist/generator-APR6DUTL.cjs +12 -0
- package/dist/{generator-JBGS3C5H.cjs.map → generator-APR6DUTL.cjs.map} +1 -1
- package/dist/generator-IOGPVCG2.js +18 -0
- package/dist/{hancom-FINYE4NT.js → hancom-BCYRSFDF.js} +2 -2
- package/dist/{hancom-YC2LGVBP.cjs → hancom-DJTR4HYI.cjs} +5 -5
- package/dist/{hancom-YC2LGVBP.cjs.map → hancom-DJTR4HYI.cjs.map} +1 -1
- package/dist/{hancom-TE4NLTFM.js → hancom-HLLJXF2H.js} +2 -2
- package/dist/{image-ocr-TB5QRYYM.js → image-ocr-B5SIBPET.js} +10 -10
- package/dist/{image-ocr-T77T2NQO.cjs → image-ocr-HCT57HQA.cjs} +28 -28
- package/dist/{image-ocr-T77T2NQO.cjs.map → image-ocr-HCT57HQA.cjs.map} +1 -1
- package/dist/{image-ocr-L256UYPI.js → image-ocr-QSSVO27L.js} +7 -7
- package/dist/index.cjs +1118 -1116
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +12 -10
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +36 -36
- package/dist/memo-R5CO35OZ.js +17 -0
- package/dist/{model-bundle-THGO5EUW.js → model-bundle-KB7GFS7J.js} +5 -5
- package/dist/{models-MKIZDK2U.js → models-A6PYBE2Q.js} +5 -5
- package/dist/{parse-worker-v2-MGNDWJDE.js → parse-worker-v2-OSOABIQB.js} +22 -22
- package/dist/{parser-C6EZWRQM.js → parser-E2ZCR6UV.js} +12 -12
- package/dist/{parser-EULDI5W6.js → parser-F7Q2ENVO.js} +9 -9
- package/dist/{parser-IC2X7P2S.cjs → parser-JQXLIKOT.cjs} +166 -166
- package/dist/{parser-IC2X7P2S.cjs.map → parser-JQXLIKOT.cjs.map} +1 -1
- package/dist/pdf-ocr-AV7FKNFZ.cjs +43 -0
- package/dist/{pdf-ocr-7SNY67NL.cjs.map → pdf-ocr-AV7FKNFZ.cjs.map} +1 -1
- package/dist/{pdf-ocr-LQ5SYFCE.js → pdf-ocr-B6QVPBMI.js} +6 -6
- package/dist/{pdf-ocr-4Y6VPEZC.js → pdf-ocr-RY6UZ5PG.js} +9 -9
- package/dist/{profile-io-SDJTSIFY.js → profile-io-FX2SDCMR.js} +3 -3
- package/dist/{rasterize-TGFUBV6B.js → rasterize-ZJAMZCQM.js} +3 -3
- package/dist/{redact-doc-X5WKER3O.js → redact-doc-DNXUF4WL.js} +21 -21
- package/dist/{render-6KIT7GYL.js → render-FQ2LMZIL.js} +12 -12
- package/dist/{rewrite-fallback-ARYCZKU6.js → rewrite-fallback-QNLQXJRS.js} +13 -13
- package/dist/seal-6LBVNZYX.js +16 -0
- package/dist/{setup-ZEMI2HI4.js → setup-2VMN6LBY.js} +3 -3
- package/dist/to-hwpx-2RENWAWF.cjs +16 -0
- package/dist/{to-hwpx-MVDTG25O.cjs.map → to-hwpx-2RENWAWF.cjs.map} +1 -1
- package/dist/{to-hwpx-QRVTR6VA.js → to-hwpx-DS6DH5WH.js} +4 -4
- package/dist/{to-hwpx-XCS6LSWE.js → to-hwpx-H7B6CEN5.js} +7 -7
- package/dist/visual-3H3HGNOW.js +38 -0
- package/dist/{watch-LFL26YPL.js → watch-53NVSD5Z.js} +22 -22
- package/package.json +1 -1
- package/dist/chunk-EESBEBUC.cjs.map +0 -1
- package/dist/chunk-G5YCISXC.js.map +0 -1
- package/dist/chunk-N6XPJBIS.js.map +0 -1
- package/dist/chunk-YG42FESS.js.map +0 -1
- package/dist/chunks-7ABYRV7K.js +0 -11
- package/dist/formula-BJU6ZM3X.js.map +0 -1
- package/dist/formula-BVDS6XNY.cjs.map +0 -1
- package/dist/formula-ESTBYQ67.js.map +0 -1
- package/dist/generator-B5RBQFEP.js +0 -18
- package/dist/generator-JBGS3C5H.cjs +0 -12
- package/dist/generator-NZFUFJL4.js +0 -11
- package/dist/memo-VDT6J2FA.js +0 -17
- package/dist/pdf-ocr-7SNY67NL.cjs +0 -43
- package/dist/seal-4IPGOMFX.js +0 -16
- package/dist/to-hwpx-MVDTG25O.cjs +0 -16
- package/dist/visual-4D32BQGS.js +0 -38
- /package/dist/{-JPBHAOIR.js.map → -S32WDXC4.js.map} +0 -0
- /package/dist/{chunk-TAATW772.js.map → chunk-2SUWIRWH.js.map} +0 -0
- /package/dist/{chunk-JVVTJDJY.js.map → chunk-4GPZVPYG.js.map} +0 -0
- /package/dist/{chunk-OHSTI6C3.js.map → chunk-4Q7L4IDD.js.map} +0 -0
- /package/dist/{chunk-6T6VP4AQ.js.map → chunk-4QOTRR5Z.js.map} +0 -0
- /package/dist/{chunk-UMVD6PRZ.js.map → chunk-4UL2KIOH.js.map} +0 -0
- /package/dist/{chunk-LEITYWHM.js.map → chunk-6DIACQ3R.js.map} +0 -0
- /package/dist/{chunk-KV5YT6L4.js.map → chunk-6GQGU57N.js.map} +0 -0
- /package/dist/{chunk-O2RV2FMS.js.map → chunk-7N2L6FBB.js.map} +0 -0
- /package/dist/{chunk-FPGY6TH2.js.map → chunk-BD75GPTM.js.map} +0 -0
- /package/dist/{chunk-R6J7X4ND.js.map → chunk-BJCTFKEU.js.map} +0 -0
- /package/dist/{chunk-6SQF5PAM.js.map → chunk-C3USRXCH.js.map} +0 -0
- /package/dist/{chunk-G3UCY3T7.js.map → chunk-C4K2XCGX.js.map} +0 -0
- /package/dist/{chunk-7CLI2Y6A.js.map → chunk-CQUOEZBJ.js.map} +0 -0
- /package/dist/{chunk-YY54476T.js.map → chunk-DIHV6CDK.js.map} +0 -0
- /package/dist/{chunk-VZ2J3654.js.map → chunk-FKCSNCWC.js.map} +0 -0
- /package/dist/{chunk-KET32GPP.js.map → chunk-FTPYYLCR.js.map} +0 -0
- /package/dist/{chunk-XHBJCOWB.js.map → chunk-G3TKEQZ3.js.map} +0 -0
- /package/dist/{chunk-WVQDRZF5.js.map → chunk-GAZDWFRT.js.map} +0 -0
- /package/dist/{chunk-QTRQ4KM3.js.map → chunk-GK4OHUV5.js.map} +0 -0
- /package/dist/{chunk-ZMPNA2W7.js.map → chunk-GOQWCHX5.js.map} +0 -0
- /package/dist/{chunk-RTQ2N6DG.js.map → chunk-IPYSZ2WD.js.map} +0 -0
- /package/dist/{chunk-HUKGGV5M.js.map → chunk-JEPTA64I.js.map} +0 -0
- /package/dist/{chunk-MIERFAOB.js.map → chunk-LINC7S3M.js.map} +0 -0
- /package/dist/{chunk-N426QQP6.js.map → chunk-MCO77XJN.js.map} +0 -0
- /package/dist/{chunk-Q4DDUA7U.js.map → chunk-MHYFBIS5.js.map} +0 -0
- /package/dist/{chunk-6PVJCEF7.js.map → chunk-NHWWNRQT.js.map} +0 -0
- /package/dist/{chunk-UD7DB4U3.js.map → chunk-SNNM4GFE.js.map} +0 -0
- /package/dist/{chunk-MU7YOHDK.js.map → chunk-U6CZ5IGF.js.map} +0 -0
- /package/dist/{chunk-ICK4R4HF.js.map → chunk-UOML7PVK.js.map} +0 -0
- /package/dist/{chunk-CVH5PB65.js.map → chunk-VRJ3CABR.js.map} +0 -0
- /package/dist/{chunk-VCRBRUCO.js.map → chunk-WXKUE2MU.js.map} +0 -0
- /package/dist/{chunk-6UNCF3PJ.js.map → chunk-YZXGUJFI.js.map} +0 -0
- /package/dist/{chunks-7ABYRV7K.js.map → chunks-XNCDYMWO.js.map} +0 -0
- /package/dist/{generator-B5RBQFEP.js.map → generator-5VFDO4CB.js.map} +0 -0
- /package/dist/{generator-NZFUFJL4.js.map → generator-IOGPVCG2.js.map} +0 -0
- /package/dist/{hancom-FINYE4NT.js.map → hancom-BCYRSFDF.js.map} +0 -0
- /package/dist/{hancom-TE4NLTFM.js.map → hancom-HLLJXF2H.js.map} +0 -0
- /package/dist/{image-ocr-TB5QRYYM.js.map → image-ocr-B5SIBPET.js.map} +0 -0
- /package/dist/{image-ocr-L256UYPI.js.map → image-ocr-QSSVO27L.js.map} +0 -0
- /package/dist/{memo-VDT6J2FA.js.map → memo-R5CO35OZ.js.map} +0 -0
- /package/dist/{model-bundle-THGO5EUW.js.map → model-bundle-KB7GFS7J.js.map} +0 -0
- /package/dist/{models-MKIZDK2U.js.map → models-A6PYBE2Q.js.map} +0 -0
- /package/dist/{parse-worker-v2-MGNDWJDE.js.map → parse-worker-v2-OSOABIQB.js.map} +0 -0
- /package/dist/{parser-C6EZWRQM.js.map → parser-E2ZCR6UV.js.map} +0 -0
- /package/dist/{parser-EULDI5W6.js.map → parser-F7Q2ENVO.js.map} +0 -0
- /package/dist/{pdf-ocr-4Y6VPEZC.js.map → pdf-ocr-B6QVPBMI.js.map} +0 -0
- /package/dist/{pdf-ocr-LQ5SYFCE.js.map → pdf-ocr-RY6UZ5PG.js.map} +0 -0
- /package/dist/{profile-io-SDJTSIFY.js.map → profile-io-FX2SDCMR.js.map} +0 -0
- /package/dist/{rasterize-TGFUBV6B.js.map → rasterize-ZJAMZCQM.js.map} +0 -0
- /package/dist/{redact-doc-X5WKER3O.js.map → redact-doc-DNXUF4WL.js.map} +0 -0
- /package/dist/{render-6KIT7GYL.js.map → render-FQ2LMZIL.js.map} +0 -0
- /package/dist/{rewrite-fallback-ARYCZKU6.js.map → rewrite-fallback-QNLQXJRS.js.map} +0 -0
- /package/dist/{seal-4IPGOMFX.js.map → seal-6LBVNZYX.js.map} +0 -0
- /package/dist/{setup-ZEMI2HI4.js.map → setup-2VMN6LBY.js.map} +0 -0
- /package/dist/{to-hwpx-QRVTR6VA.js.map → to-hwpx-DS6DH5WH.js.map} +0 -0
- /package/dist/{to-hwpx-XCS6LSWE.js.map → to-hwpx-H7B6CEN5.js.map} +0 -0
- /package/dist/{visual-4D32BQGS.js.map → visual-3H3HGNOW.js.map} +0 -0
- /package/dist/{watch-LFL26YPL.js.map → watch-53NVSD5Z.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 _chunkU2K3WVR5cjs = require('./chunk-U2K3WVR5.cjs');
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
@@ -9,11 +9,11 @@ var _chunkNIFJSZR7cjs = require('./chunk-NIFJSZR7.cjs');
|
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _chunkL4GCUYDScjs = require('./chunk-L4GCUYDS.cjs');
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
|
|
16
|
-
var
|
|
16
|
+
var _chunkZTVH2HQ5cjs = require('./chunk-ZTVH2HQ5.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 _chunkU2K3WVR5cjs.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 _chunkU2K3WVR5cjs.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) _chunkL4GCUYDScjs.CELL_EDGES.set(to, e);
|
|
3418
3418
|
}
|
|
3419
3419
|
function hasOpenCellSeam(a, b) {
|
|
3420
|
-
const u =
|
|
3420
|
+
const u = _chunkL4GCUYDScjs.CELL_EDGES.get(a), d = _chunkL4GCUYDScjs.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 = _chunkL4GCUYDScjs.CELL_EDGES.get(a), d = _chunkL4GCUYDScjs.CELL_EDGES.get(b);
|
|
3425
3425
|
if (!u || !d) return;
|
|
3426
|
-
|
|
3426
|
+
_chunkL4GCUYDScjs.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 _chunkL4GCUYDScjs.tidyScriptTags.call(void 0, out);
|
|
3612
3612
|
}
|
|
3613
3613
|
|
|
3614
3614
|
// src/pdf/line-wrap.ts
|
|
@@ -3624,7 +3624,7 @@ var bump2 = (m, k1, k2) => {
|
|
|
3624
3624
|
if (!inner) m.set(k1, inner = /* @__PURE__ */ new Map());
|
|
3625
3625
|
bump(inner, k2);
|
|
3626
3626
|
};
|
|
3627
|
-
var WrapLexicon = (_class = class {constructor() { _class.prototype.__init.call(this);_class.prototype.__init2.call(this);_class.prototype.__init3.call(this);_class.prototype.__init4.call(this);_class.prototype.__init5.call(this);_class.prototype.__init6.call(this);_class.prototype.__init7.call(this);_class.prototype.__init8.call(this);_class.prototype.__init9.call(this);_class.prototype.__init10.call(this); }
|
|
3627
|
+
var WrapLexicon = (_class = class {constructor() { _class.prototype.__init.call(this);_class.prototype.__init2.call(this);_class.prototype.__init3.call(this);_class.prototype.__init4.call(this);_class.prototype.__init5.call(this);_class.prototype.__init6.call(this);_class.prototype.__init7.call(this);_class.prototype.__init8.call(this);_class.prototype.__init9.call(this);_class.prototype.__init10.call(this);_class.prototype.__init11.call(this); }
|
|
3628
3628
|
__init() {this.joined1 = /* @__PURE__ */ new Map()}
|
|
3629
3629
|
__init2() {this.joined2 = /* @__PURE__ */ new Map()}
|
|
3630
3630
|
__init3() {this.spaced1 = /* @__PURE__ */ new Map()}
|
|
@@ -3642,6 +3642,8 @@ var WrapLexicon = (_class = class {constructor() { _class.prototype.__init.call(
|
|
|
3642
3642
|
__init9() {this.cites = /* @__PURE__ */ new Map()}
|
|
3643
3643
|
/** 쪽 줄 흐름에서 넓은 줄 사이 기준선 간격(글자 크기별) — 줄 둘뿐인 묶음은 묶음 안에 견줄 간격이 없어 넓은 줄 간격 본문을 문단 경계로 봤다 */
|
|
3644
3644
|
__init10() {this.pitches = []}
|
|
3645
|
+
/** 줄 안 한글 바로 뒤 여는 괄호 — 붙여 쓴 "주택(아파트)" 수와 띄운 "주택 (아파트)" 수 */
|
|
3646
|
+
__init11() {this.parens = { joined: 0, spaced: 0 }}
|
|
3645
3647
|
/** 줄 흐름의 이웃한 넓은 두 줄(같은 글자 크기) 사이 간격 하나를 더한다 */
|
|
3646
3648
|
addPitch(fontSize, pitch) {
|
|
3647
3649
|
if (fontSize > 0 && pitch > 0 && pitch < 4 * fontSize) this.pitches.push({ fs: fontSize, pitch });
|
|
@@ -3654,6 +3656,8 @@ var WrapLexicon = (_class = class {constructor() { _class.prototype.__init.call(
|
|
|
3654
3656
|
/** 줄 글 한 줄을 증거로 더한다 — 탭(큰 갭)으로 나뉜 조각은 다른 칸·단이라 조각 사이는 어절 경계 증거로 쓰지 않는다 */
|
|
3655
3657
|
addLine(text) {
|
|
3656
3658
|
for (const seg of text.replace(MARKUP, "").split(" ")) {
|
|
3659
|
+
this.parens.joined += _nullishCoalesce(_optionalChain([seg, 'access', _59 => _59.match, 'call', _60 => _60(/[가-힣]\(/g), 'optionalAccess', _61 => _61.length]), () => ( 0));
|
|
3660
|
+
this.parens.spaced += _nullishCoalesce(_optionalChain([seg, 'access', _62 => _62.match, 'call', _63 => _63(/[가-힣] \(/g), 'optionalAccess', _64 => _64.length]), () => ( 0));
|
|
3657
3661
|
for (const m of seg.matchAll(CITE_LINK)) {
|
|
3658
3662
|
const c = _nullishCoalesce(this.cites.get(m[1]), () => ( { joined: 0, spaced: 0 }));
|
|
3659
3663
|
if (m[2]) c.spaced++;
|
|
@@ -3665,12 +3669,12 @@ var WrapLexicon = (_class = class {constructor() { _class.prototype.__init.call(
|
|
|
3665
3669
|
const t = toks[i], n = t.length;
|
|
3666
3670
|
if (i > 0 && i < toks.length - 1) {
|
|
3667
3671
|
bump(this.words, t);
|
|
3668
|
-
const run = _nullishCoalesce(_optionalChain([t, 'access',
|
|
3672
|
+
const run = _nullishCoalesce(_optionalChain([t, 'access', _65 => _65.match, 'call', _66 => _66(/^[가-힣]+/), 'optionalAccess', _67 => _67[0]]), () => ( ""));
|
|
3669
3673
|
for (let j = 2; j <= Math.min(run.length, 6); j++) this.heads.add(run.slice(0, j));
|
|
3670
3674
|
}
|
|
3671
3675
|
if (i + 1 < toks.length) {
|
|
3672
3676
|
this.pairs.add(t + " " + toks[i + 1]);
|
|
3673
|
-
const tail = _optionalChain([t, 'access',
|
|
3677
|
+
const tail = _optionalChain([t, 'access', _68 => _68.match, 'call', _69 => _69(/[가-힣]+$/), 'optionalAccess', _70 => _70[0]]);
|
|
3674
3678
|
if (tail) this.spacedHeads.add(tail + " " + toks[i + 1].charAt(0));
|
|
3675
3679
|
}
|
|
3676
3680
|
for (let a = 0; a + 1 < n; a++) {
|
|
@@ -3691,6 +3695,13 @@ var WrapLexicon = (_class = class {constructor() { _class.prototype.__init.call(
|
|
|
3691
3695
|
const c = this.cites.get(unit);
|
|
3692
3696
|
return !c || c.joined === c.spaced ? null : c.joined > c.spaced;
|
|
3693
3697
|
}
|
|
3698
|
+
/** 한글 뒤 여는 괄호로 꺾인 줄을 붙일까 — 문서 줄 안에서 붙여 쓴 쪽이 셋 넘고 띄운 쪽의 네 배 넘으면 true, 거꾸로면 false, 그 밖 null */
|
|
3699
|
+
parenJoins() {
|
|
3700
|
+
const { joined, spaced } = this.parens;
|
|
3701
|
+
if (joined >= 3 && joined >= 4 * spaced) return true;
|
|
3702
|
+
if (spaced >= 3 && spaced >= 4 * joined) return false;
|
|
3703
|
+
return null;
|
|
3704
|
+
}
|
|
3694
3705
|
/** 문서 줄 안에서 홀로 선 어절로 나온 적 있나 */
|
|
3695
3706
|
isWord(word) {
|
|
3696
3707
|
return (_nullishCoalesce(this.words.get(word), () => ( 0))) > 0;
|
|
@@ -3699,6 +3710,10 @@ var WrapLexicon = (_class = class {constructor() { _class.prototype.__init.call(
|
|
|
3699
3710
|
joinedWord(left, right) {
|
|
3700
3711
|
return this.isWord(left + right) && !this.pairs.has(left + " " + right);
|
|
3701
3712
|
}
|
|
3713
|
+
/** 두 어절을 줄 안에서 띄어 쓴 이웃으로 쓴 적 있나 */
|
|
3714
|
+
spacedPair(left, right) {
|
|
3715
|
+
return this.pairs.has(left + " " + right);
|
|
3716
|
+
}
|
|
3702
3717
|
/** 줄 안 어절이 이 한글로 시작한 적 있나 */
|
|
3703
3718
|
startsWord(head) {
|
|
3704
3719
|
return this.heads.has(head);
|
|
@@ -3712,14 +3727,14 @@ var WrapLexicon = (_class = class {constructor() { _class.prototype.__init.call(
|
|
|
3712
3727
|
const n = left.length;
|
|
3713
3728
|
if (n < 2 || right.length < 2) return null;
|
|
3714
3729
|
const k1 = pairKey(left.charCodeAt(n - 2), left.charCodeAt(n - 1)), k2 = pairKey(right.charCodeAt(0), right.charCodeAt(1));
|
|
3715
|
-
return decideCounts(_nullishCoalesce(_optionalChain([this, 'access',
|
|
3730
|
+
return decideCounts(_nullishCoalesce(_optionalChain([this, 'access', _71 => _71.joined2, 'access', _72 => _72.get, 'call', _73 => _73(k1), 'optionalAccess', _74 => _74.get, 'call', _75 => _75(k2)]), () => ( 0)), _nullishCoalesce(_optionalChain([this, 'access', _76 => _76.spaced2, 'access', _77 => _77.get, 'call', _78 => _78(k1), 'optionalAccess', _79 => _79.get, 'call', _80 => _80(k2)]), () => ( 0)));
|
|
3716
3731
|
}
|
|
3717
3732
|
/** 꺾인 자리 증거: "" 붙음 · " " 띄움 · null 모름 (두 글자 증거가 갈리거나 없으면 한 글자) */
|
|
3718
3733
|
evidence(left, right) {
|
|
3719
3734
|
const n = left.length;
|
|
3720
3735
|
if (n >= 2 && right.length >= 2) {
|
|
3721
3736
|
const k1 = pairKey(left.charCodeAt(n - 2), left.charCodeAt(n - 1)), k2 = pairKey(right.charCodeAt(0), right.charCodeAt(1));
|
|
3722
|
-
const v = decideCounts(_nullishCoalesce(_optionalChain([this, 'access',
|
|
3737
|
+
const v = decideCounts(_nullishCoalesce(_optionalChain([this, 'access', _81 => _81.joined2, 'access', _82 => _82.get, 'call', _83 => _83(k1), 'optionalAccess', _84 => _84.get, 'call', _85 => _85(k2)]), () => ( 0)), _nullishCoalesce(_optionalChain([this, 'access', _86 => _86.spaced2, 'access', _87 => _87.get, 'call', _88 => _88(k1), 'optionalAccess', _89 => _89.get, 'call', _90 => _90(k2)]), () => ( 0)));
|
|
3723
3738
|
if (v !== null) return v;
|
|
3724
3739
|
}
|
|
3725
3740
|
if (n && right.length) {
|
|
@@ -3778,7 +3793,7 @@ function particleContinues(left, rightWord) {
|
|
|
3778
3793
|
if (ADNOMINAL_HAN.test(right)) return h.length >= 2 && !auxBefore(h) && !/(?:는|은|한|다|어|년)$/.test(h);
|
|
3779
3794
|
return VERB_FORM.test(right) && !auxBefore(h) && !((last === "\uC774" || last === "\uAC00" && h.length >= 3) && BECOME.test(right));
|
|
3780
3795
|
}
|
|
3781
|
-
var ITEM_HEAD = /^(?:[□■◆◇○●◎◦▪▫•※▶▷►❍❏❑✓✔➢➤☞]|[①-⑳]|[
|
|
3796
|
+
var ITEM_HEAD = /^(?:[□■◆◇○●◎◦▪▫•※▶▷►❍❏❑✓✔➢➤☞]|[①-⑳]|[-–·∙ㆍ*#](?=\s)|\(?\d{1,2}[.)](?!\d)|\(?[가-하][.)]|\([가-하\d]{1,2}\)|[ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩ]|제\d+[조항호장절])/;
|
|
3782
3797
|
function startsNewItem(prevText, nextText) {
|
|
3783
3798
|
const t = nextText.replace(MARKUP, "").trimStart();
|
|
3784
3799
|
const prev = prevText.replace(MARKUP, "").trimEnd();
|
|
@@ -3800,17 +3815,21 @@ function wrapJoiner(prevText, nextText, lex, heads = true) {
|
|
|
3800
3815
|
if (particleContinues(left, right)) return "";
|
|
3801
3816
|
if (endsAsWord(left)) return " ";
|
|
3802
3817
|
if (/[A-Za-z]-$/.test(left) && /^[A-Za-z]/.test(right) && !/[가-힣]/.test(prev + next)) {
|
|
3803
|
-
return _optionalChain([lex, 'optionalAccess',
|
|
3818
|
+
return _optionalChain([lex, 'optionalAccess', _91 => _91.joinedWord, 'call', _92 => _92(left, right.replace(/[.,;:!?)]*$/, ""))]) ? "" : " ";
|
|
3804
3819
|
}
|
|
3805
3820
|
if (/[·ㆍ‧-]/.test(a) && !/[·ㆍ‧…]{2}$/.test(prev) && /[가-힣A-Za-z0-9]/.test(b)) return "";
|
|
3806
3821
|
if (/[A-Za-z]/.test(a) && /[A-Za-z]/.test(b) || /\d/.test(a) && /\d/.test(b)) return " ";
|
|
3807
3822
|
if (/(?:^|[^가-힣])제$/.test(left) && /^\d+(?:조|항|호|목|장|절|편|관)/.test(right)) return "";
|
|
3808
3823
|
const cite = left.match(/제\d+(조|항|호)(?:의\d+)?$/);
|
|
3809
3824
|
if (cite && /^제\d+(?:항|호|목)/.test(right)) {
|
|
3810
|
-
const joins = _optionalChain([lex, 'optionalAccess',
|
|
3825
|
+
const joins = _optionalChain([lex, 'optionalAccess', _93 => _93.citationJoins, 'call', _94 => _94(cite[1])]);
|
|
3811
3826
|
if (joins != null) return joins ? "" : " ";
|
|
3812
3827
|
}
|
|
3813
|
-
|
|
3828
|
+
if (heads && b === "(" && /[가-힣]$/.test(left) && !endsAsWord(left) && !/(?:함|음|됨|임|다)$/.test(left) && !/^\([^()]*\)\s*$/.test(next) && !/^\([^()]*\s[^()]*\)\s/.test(next) && !_optionalChain([lex, 'optionalAccess', _95 => _95.spacedPair, 'call', _96 => _96(left, right)])) {
|
|
3829
|
+
const joins = _optionalChain([lex, 'optionalAccess', _97 => _97.parenJoins, 'call', _98 => _98()]);
|
|
3830
|
+
if (joins != null) return joins ? "" : " ";
|
|
3831
|
+
}
|
|
3832
|
+
const ev = _optionalChain([lex, 'optionalAccess', _99 => _99.evidence, 'call', _100 => _100(left, right)]);
|
|
3814
3833
|
if (ev != null) return ev;
|
|
3815
3834
|
if (lex && /[가-힣A-Za-z0-9]$/.test(left) && /^[가-힣A-Za-z0-9]/.test(right) && lex.joinedWord(left, right.replace(/[.,)」』’”;:]+$/, ""))) return "";
|
|
3816
3835
|
if (/\d$/.test(left) && COUNTER.test(right)) return "";
|
|
@@ -3818,7 +3837,7 @@ function wrapJoiner(prevText, nextText, lex, heads = true) {
|
|
|
3818
3837
|
const r1 = right.replace(/[.,)」』’”]+$/, "");
|
|
3819
3838
|
if (lex && /[가-힣]$/.test(left) && /^[가-힣]$/.test(r1) && !STANDALONE_SYLLABLE.test(r1) && !lex.isWord(r1) && !lex.isWord(right)) return "";
|
|
3820
3839
|
if (lex && heads) {
|
|
3821
|
-
const tail = _optionalChain([left, 'access',
|
|
3840
|
+
const tail = _optionalChain([left, 'access', _101 => _101.match, 'call', _102 => _102(/[가-힣]+$/), 'optionalAccess', _103 => _103[0]]), run = _optionalChain([right, 'access', _104 => _104.match, 'call', _105 => _105(/^[가-힣]+/), 'optionalAccess', _106 => _106[0]]);
|
|
3822
3841
|
if (tail && run && !STANDALONE_SYLLABLE.test(tail) && lex.startsWord(tail + run.slice(0, 2)) && !lex.spacedHead(tail, run[0])) return "";
|
|
3823
3842
|
if (/[가-힣]{2}$/.test(left) && /^\([^()\s]*\)/.test(right) && !endsAsWord(left) && !/(?:함|음|됨|임|다)$/.test(left) && !BARE_UNIT_PAREN.test(right) && !/^\(\d/.test(right)) return "";
|
|
3824
3843
|
}
|
|
@@ -3855,14 +3874,14 @@ function joinPageBreakWraps(blocks, lex) {
|
|
|
3855
3874
|
const last = a.bbox && PARA_LAST_LINE.get(a.bbox), fs = last ? last.fontSize : 0;
|
|
3856
3875
|
const hang = !/[가-힣]/.test(a.text) && CJK.test(a.text.replace(MARKUP, "").trimEnd().slice(-1)) ? fs : 0;
|
|
3857
3876
|
if (!last || fs <= 0 || (_nullishCoalesce(pageRight.get(a.pageNumber), () => ( Infinity))) - last.right >= BODY_FULL_TOL * fs + hang) continue;
|
|
3858
|
-
if (last.width < BODY_MIN_WIDTH_EM * fs || Math.abs((_nullishCoalesce(_optionalChain([b, 'access',
|
|
3877
|
+
if (last.width < BODY_MIN_WIDTH_EM * fs || Math.abs((_nullishCoalesce(_optionalChain([b, 'access', _107 => _107.style, 'optionalAccess', _108 => _108.fontSize]), () => ( 0))) - fs) > 0.15 * fs) continue;
|
|
3859
3878
|
const bt = b.text.replace(MARKUP, "");
|
|
3860
3879
|
if (startsNewItem(a.text, b.text) || PAGE_REF_TAIL.test(a.text) || PAGE_ITEM_HEAD.test(bt)) continue;
|
|
3861
3880
|
if (PAGE_HEAD_MARK.test(bt) && !(/^[\u25a0-\u25ff]/.test(bt) && a.text.includes(bt[0]))) continue;
|
|
3862
3881
|
const firstLeft = b.bbox && PARA_FIRST_LEFT.get(b.bbox);
|
|
3863
3882
|
const indented = firstLeft === void 0 || firstLeft - (_nullishCoalesce(pageLeft.get(b.pageNumber), () => ( firstLeft))) >= 0.3 * fs;
|
|
3864
3883
|
if (indented && SENTENCE_END.test(a.text.replace(MARKUP, "").trimEnd())) continue;
|
|
3865
|
-
if (Math.round(_nullishCoalesce(_optionalChain([b, 'access',
|
|
3884
|
+
if (Math.round(_nullishCoalesce(_optionalChain([b, 'access', _109 => _109.style, 'optionalAccess', _110 => _110.fontSize]), () => ( 0))) !== Math.round(fs) && titleLike(b.text)) continue;
|
|
3866
3885
|
if (/\t/.test(a.text.slice(a.text.lastIndexOf("\n") + 1).replace(/^\S{1,8}\t/, "")) && titleLike(bt.trim().split("\n")[0])) continue;
|
|
3867
3886
|
const joined = wrapJoiner(a.text, b.text, lex);
|
|
3868
3887
|
const head = a.text, joiner = joined === "" && last.spaceAfter ? " " : joined;
|
|
@@ -3878,9 +3897,9 @@ function joinPageBreakWraps(blocks, lex) {
|
|
|
3878
3897
|
}
|
|
3879
3898
|
function footnoteBetween(a, f, b) {
|
|
3880
3899
|
if (f.type !== "paragraph" || !f.text || !a.pageNumber || f.pageNumber !== a.pageNumber || b.pageNumber !== a.pageNumber + 1) return false;
|
|
3881
|
-
const afs = _nullishCoalesce(_optionalChain([a, 'access',
|
|
3900
|
+
const afs = _nullishCoalesce(_optionalChain([a, 'access', _111 => _111.style, 'optionalAccess', _112 => _112.fontSize]), () => ( 0)), ffs = _nullishCoalesce(_optionalChain([f, 'access', _113 => _113.style, 'optionalAccess', _114 => _114.fontSize]), () => ( 0));
|
|
3882
3901
|
if (!afs || !ffs || ffs > afs * 0.95 || !a.bbox || !f.bbox || f.bbox.y + f.bbox.height > a.bbox.y + 1) return false;
|
|
3883
|
-
const at = _nullishCoalesce(_optionalChain([a, 'access',
|
|
3902
|
+
const at = _nullishCoalesce(_optionalChain([a, 'access', _115 => _115.text, 'optionalAccess', _116 => _116.replace, 'call', _117 => _117(MARKUP, ""), 'access', _118 => _118.trimEnd, 'call', _119 => _119()]), () => ( ""));
|
|
3884
3903
|
if (/[가-힣]/.test(at) || SENTENCE_END.test(at)) return false;
|
|
3885
3904
|
return /^(?:\d{1,2}\)?\s|\*|※)/.test(f.text.replace(MARKUP, "").trimStart());
|
|
3886
3905
|
}
|
|
@@ -3920,7 +3939,7 @@ function bodyLineJoins(lines, lex) {
|
|
|
3920
3939
|
for (const l of lines) if (!HANGING.test(l.text) && l.right > inner) inner = l.right;
|
|
3921
3940
|
const full = (l) => right - l.right < BODY_FULL_TOL * l.fontSize || right - inner <= 1.2 * l.fontSize && inner - l.right < BODY_FULL_TOL * l.fontSize;
|
|
3922
3941
|
const nextWordNoRoom = (a, b) => {
|
|
3923
|
-
const w = _optionalChain([b, 'access',
|
|
3942
|
+
const w = _optionalChain([b, 'access', _120 => _120.text, 'access', _121 => _121.trim, 'call', _122 => _122(), 'access', _123 => _123.match, 'call', _124 => _124(/^\S+/), 'optionalAccess', _125 => _125[0]]);
|
|
3924
3943
|
const n = [...b.text.trim()].length;
|
|
3925
3944
|
if (!w || n === 0) return false;
|
|
3926
3945
|
const em = (b.right - b.left) / n;
|
|
@@ -3946,14 +3965,18 @@ function bodyLineJoins(lines, lex) {
|
|
|
3946
3965
|
const a = lines[i], b = lines[i + 1];
|
|
3947
3966
|
const fs = a.fontSize;
|
|
3948
3967
|
const own = i === i1 ? p2 : p1;
|
|
3949
|
-
const others = Number.isFinite(own) ? own : _nullishCoalesce(_optionalChain([lex, 'optionalAccess',
|
|
3968
|
+
const others = Number.isFinite(own) ? own : _nullishCoalesce(_optionalChain([lex, 'optionalAccess', _126 => _126.bodyPitch, 'call', _127 => _127(fs)]), () => ( Infinity));
|
|
3950
3969
|
const maxPitch = Number.isFinite(others) ? Math.min(BODY_MAX_PITCH_ABS_EM * fs, Math.max(BODY_MAX_PITCH_EM * fs, others * BODY_PITCH_REL)) : BODY_MAX_PITCH_EM * fs;
|
|
3951
3970
|
const wordWrap = ragged && !full(a) && nextWordNoRoom(a, b) && !MULTI_LEVEL_NUMBER.test(b.text.trimStart());
|
|
3952
|
-
const wraps = fs > 0 && (full(a) || wordWrap) && a.right - a.left >= BODY_MIN_WIDTH_EM * fs && a.y - b.y > 0 && a.y - b.y < maxPitch && Math.abs(b.fontSize - fs) <= 0.15 * fs && !startsNewItem(a.text, b.text) && !(SENTENCE_END.test(a.text.trimEnd()) && MULTI_LEVEL_NUMBER.test(b.text.trimStart()));
|
|
3971
|
+
const wraps = fs > 0 && (full(a) || wordWrap) && a.right - a.left >= BODY_MIN_WIDTH_EM * fs && a.y - b.y > 0 && (a.y - b.y < maxPitch || indentedCjkFirstLine(a, b, fs)) && Math.abs(b.fontSize - fs) <= 0.15 * fs && !startsNewItem(a.text, b.text) && !(SENTENCE_END.test(a.text.trimEnd()) && MULTI_LEVEL_NUMBER.test(b.text.trimStart()));
|
|
3953
3972
|
out.push(!wraps ? "\n" : wordWrap ? unspacedCjkBoundary(a.text, b.text) ? "" : " " : wrapJoiner(a.text, b.text, lex));
|
|
3954
3973
|
}
|
|
3955
3974
|
return out;
|
|
3956
3975
|
}
|
|
3976
|
+
function indentedCjkFirstLine(a, b, fs) {
|
|
3977
|
+
const cjk = (t) => !/[가-힣]/.test(t) && /[\u3040-\u30ff\u3400-\u9fff]/.test(t);
|
|
3978
|
+
return cjk(a.text) && cjk(b.text) && b.left < a.left - fs && a.y - b.y < BODY_MAX_PITCH_ABS_EM * fs && b.fontSize >= 0.95 * a.fontSize && !/^(?:\d{1,2}\)?\s|[*※])/.test(b.text.trimStart());
|
|
3979
|
+
}
|
|
3957
3980
|
var CELL_PAD_MAX = 6;
|
|
3958
3981
|
function cellLineWraps(box, contentLeft, prevRight, fontSize, nextFirstCharW) {
|
|
3959
3982
|
const pad = Math.min(CELL_PAD_MAX, Math.max(0, contentLeft - box.x1));
|
|
@@ -4119,7 +4142,7 @@ function cellTextToString(items, wrap) {
|
|
|
4119
4142
|
const merged = mergeSuperscriptRows(lines).map((line) => sortLineByX(line));
|
|
4120
4143
|
const textLines = merged.map((s) => {
|
|
4121
4144
|
if (s.length === 1) return s[0].text;
|
|
4122
|
-
if (s.length === 2 && /^[가-힣]$/.test(s[0].text) && /^[가-힣]$/.test(s[1].text) && !!_optionalChain([wrap, 'optionalAccess',
|
|
4145
|
+
if (s.length === 2 && /^[가-힣]$/.test(s[0].text) && /^[가-힣]$/.test(s[1].text) && !!_optionalChain([wrap, 'optionalAccess', _128 => _128.lex]) && (wrap.lex.isWord(s[0].text + s[1].text) || wrap.lex.evidence(s[0].text, s[1].text) === "" || REGION_LABELS.has(s[0].text + s[1].text)) && s[1].x - (s[0].x + s[0].w) >= Math.max(s[0].fontSize, s[1].fontSize) * 1.5 && s[1].x + s[1].w - s[0].x >= wrap.box.x2 - wrap.box.x1 - Math.max(s[0].fontSize, s[1].fontSize) * 2) return s[0].text + s[1].text;
|
|
4123
4146
|
const evenSpaced = detectEvenSpacedItems(s, true);
|
|
4124
4147
|
const tracked = trackedSpaces(s);
|
|
4125
4148
|
const hangulLine = s.some((it) => /[가-힣]/.test(it.text));
|
|
@@ -4135,7 +4158,7 @@ function cellTextToString(items, wrap) {
|
|
|
4135
4158
|
result += s[j].text;
|
|
4136
4159
|
} else if (s[j].hasSpaceBefore && exactGap(s[j - 1], s[j], gap) >= avgFs * 0.05) {
|
|
4137
4160
|
result += " " + s[j].text;
|
|
4138
|
-
} else if (gap > spaceGapThreshold(avgFs) || _optionalChain([tracked, 'optionalAccess',
|
|
4161
|
+
} else if (gap > spaceGapThreshold(avgFs) || _optionalChain([tracked, 'optionalAccess', _129 => _129[j]])) {
|
|
4139
4162
|
result += " " + s[j].text;
|
|
4140
4163
|
} else {
|
|
4141
4164
|
result += s[j].text;
|
|
@@ -4262,12 +4285,12 @@ function markEvenRun(items, visible, result, start, end) {
|
|
|
4262
4285
|
}
|
|
4263
4286
|
function mergeCellTextLines(textLines, wrap) {
|
|
4264
4287
|
if (textLines.length <= 1) return textLines[0] || "";
|
|
4265
|
-
const numberWrapped = (k) => !!_optionalChain([wrap, 'optionalAccess',
|
|
4288
|
+
const numberWrapped = (k) => !!_optionalChain([wrap, 'optionalAccess', _130 => _130.wraps, 'access', _131 => _131[k]]) && (_nullishCoalesce(_optionalChain([wrap, 'access', _132 => _132.wide, 'optionalAccess', _133 => _133[k]]), () => ( true)));
|
|
4266
4289
|
const merged = [textLines[0]];
|
|
4267
4290
|
for (let i = 1; i < textLines.length; i++) {
|
|
4268
4291
|
const prev = merged[merged.length - 1];
|
|
4269
4292
|
const curr = textLines[i];
|
|
4270
|
-
if (wrap ? wrap.wraps[i - 1] && !_optionalChain([wrap, 'access',
|
|
4293
|
+
if (wrap ? wrap.wraps[i - 1] && !_optionalChain([wrap, 'access', _134 => _134.spaced, 'optionalAccess', _135 => _135[i - 1]]) && !startsNewItem(prev, curr) && wrapJoiner(prev, curr, wrap.lex, false) === "" : /[가-힣]$/.test(prev) && /^[가-힣]+$/.test(curr) && curr.length <= 8 && !curr.includes(" ")) {
|
|
4271
4294
|
merged[merged.length - 1] = prev + curr;
|
|
4272
4295
|
} else if (curr.trim().length <= 3 && /^[)\]%}]/.test(curr.trim())) {
|
|
4273
4296
|
merged[merged.length - 1] = prev + curr.trim();
|
|
@@ -4407,34 +4430,34 @@ function normalizeUndersegmentedTable(originalCells, colXs, items, rowYs, kept,
|
|
|
4407
4430
|
if (numRows > maxRows || numCols < MIN_UNDERSEGMENTED_COLUMNS) return null;
|
|
4408
4431
|
if (items.length === 0) return null;
|
|
4409
4432
|
if (numRows >= 3) {
|
|
4410
|
-
if (_optionalChain([rowYs, 'optionalAccess',
|
|
4433
|
+
if (_optionalChain([rowYs, 'optionalAccess', _136 => _136.length]) !== numRows + 1) return null;
|
|
4411
4434
|
const rebuilt2 = [];
|
|
4412
4435
|
let expanded = 0;
|
|
4413
4436
|
const ocr = items.every((it) => it.fontName === "ocr");
|
|
4414
4437
|
for (let r = 0; r < numRows; r++) {
|
|
4415
4438
|
const row = originalCells[r].map((cell) => cell.text);
|
|
4416
4439
|
if (r === 0 || numRows === 3 && r === 1) {
|
|
4417
|
-
_optionalChain([kept, 'optionalAccess',
|
|
4440
|
+
_optionalChain([kept, 'optionalAccess', _137 => _137.set, 'call', _138 => _138(rebuilt2.length, r)]);
|
|
4418
4441
|
rebuilt2.push(row);
|
|
4419
4442
|
continue;
|
|
4420
4443
|
}
|
|
4421
4444
|
const span2 = Math.min(numRows - r, Math.max(1, ...originalCells[r].map((cell) => _nullishCoalesce(cell.rowSpan, () => ( 1)))));
|
|
4422
4445
|
const filled = originalCells[r].filter((cell) => cell.text.trim());
|
|
4423
4446
|
const spanning = filled.filter((cell) => (_nullishCoalesce(cell.rowSpan, () => ( 1))) >= span2);
|
|
4424
|
-
const loose = ocr && filled.length >= MIN_UNDERSEGMENTED_COLUMNS && spanning.length * 2 > filled.length && originalCells.slice(r + 1, r + span2).every((cells) => cells.every((cell, c) => !cell.text.trim() || (_nullishCoalesce(_optionalChain([originalCells, 'access',
|
|
4447
|
+
const loose = ocr && filled.length >= MIN_UNDERSEGMENTED_COLUMNS && spanning.length * 2 > filled.length && originalCells.slice(r + 1, r + span2).every((cells) => cells.every((cell, c) => !cell.text.trim() || (_nullishCoalesce(_optionalChain([originalCells, 'access', _139 => _139[r], 'access', _140 => _140[c], 'optionalAccess', _141 => _141.rowSpan]), () => ( 1))) === 1));
|
|
4425
4448
|
const band = span2 > 1 && (loose || originalCells.slice(r + 1, r + span2).every((cells) => cells.every((cell) => !cell.text.trim()))) ? span2 : 1;
|
|
4426
4449
|
const rowItems = items.filter((item) => itemCenterY(item) <= rowYs[r] + 1 && itemCenterY(item) >= rowYs[r + band] - 1);
|
|
4427
4450
|
const body = normalizeUndersegmentedTable([originalCells[r]], colXs, rowItems, void 0, void 0, void 0, band > 1 ? 2 : MIN_ALIGNED_LINES);
|
|
4428
4451
|
if (body) {
|
|
4429
4452
|
originalCells[r].forEach((cell, c) => {
|
|
4430
4453
|
const cols = Array.from({ length: Math.max(1, _nullishCoalesce(cell.colSpan, () => ( 1))) }, (_, k) => c + k);
|
|
4431
|
-
if (cell.text.trim() && body.every((cells) => cols.every((k) => !_optionalChain([cells, 'access',
|
|
4454
|
+
if (cell.text.trim() && body.every((cells) => cols.every((k) => !_optionalChain([cells, 'access', _142 => _142[k], 'optionalAccess', _143 => _143.trim, 'call', _144 => _144()])))) body[0][c] = cell.text;
|
|
4432
4455
|
});
|
|
4433
4456
|
rebuilt2.push(...body);
|
|
4434
4457
|
expanded++;
|
|
4435
4458
|
r += band - 1;
|
|
4436
4459
|
} else {
|
|
4437
|
-
_optionalChain([kept, 'optionalAccess',
|
|
4460
|
+
_optionalChain([kept, 'optionalAccess', _145 => _145.set, 'call', _146 => _146(rebuilt2.length, r)]);
|
|
4438
4461
|
rebuilt2.push(row);
|
|
4439
4462
|
}
|
|
4440
4463
|
}
|
|
@@ -4518,7 +4541,7 @@ function sortLineByX(items) {
|
|
|
4518
4541
|
e++;
|
|
4519
4542
|
}
|
|
4520
4543
|
const run = items.slice(s, e), seqs = run.map((i) => i.seq);
|
|
4521
|
-
const ok = !wide ? !run.some((i) => _optionalChain([i, 'access',
|
|
4544
|
+
const ok = !wide ? !run.some((i) => _optionalChain([i, 'access', _147 => _147.text, 'optionalAccess', _148 => _148.startsWith, 'call', _149 => _149("$")])) : Math.max(...seqs) - Math.min(...seqs) <= 2 * (e - s - 1) && run.every((i) => Math.abs((_nullishCoalesce(i.fontSize, () => ( 0))) - (_nullishCoalesce(run[0].fontSize, () => ( 0)))) <= 0.5);
|
|
4522
4545
|
if (e - s > 1 && seqs.every((q) => q !== void 0) && ok) {
|
|
4523
4546
|
run.sort((a, b) => a.seq - b.seq);
|
|
4524
4547
|
for (let k = 0; k < run.length; k++) items[s + k] = run[k];
|
|
@@ -4533,6 +4556,8 @@ function isCjkLatinAutospace(prevText, nextText, gap, fontSize, hangulLine = fal
|
|
|
4533
4556
|
const a = prevText.replace(/(?:<\/?u>|~~)+$/, "").slice(-1), b = _nullishCoalesce(nextText.replace(/^(?:<\/?u>|~~)+/, "").replace(/^\(/, "")[0], () => ( ""));
|
|
4534
4557
|
const cjk = /[\u3000-\u303f\u3040-\u30ff\u3400-\u9fff\uf900-\ufaff\uff00-\uffef]/, latin = /[A-Za-z0-9]/;
|
|
4535
4558
|
const cjkOrQuote = /[\u3000-\u303f\u3040-\u30ff\u3400-\u9fff\uf900-\ufaff\uff00-\uffef\u2018-\u201f]/;
|
|
4559
|
+
const bare = _nullishCoalesce(nextText.replace(/^(?:<\/?u>|~~)+/, "")[0], () => ( ""));
|
|
4560
|
+
if (bare === "(" && cjk.test(a) || a === ")" && cjk.test(b)) return true;
|
|
4536
4561
|
return cjk.test(a) && latin.test(b) || latin.test(a) && cjk.test(b) || cjkOrQuote.test(a) && cjkOrQuote.test(b) && (cjk.test(a) || cjk.test(b));
|
|
4537
4562
|
}
|
|
4538
4563
|
function filterHiddenText(items, pageWidth, pageHeight, originX = 0, originY = 0) {
|
|
@@ -4591,7 +4616,7 @@ function dominantStyle(items) {
|
|
|
4591
4616
|
let maxCount = 0, dominantSize = 0;
|
|
4592
4617
|
for (const i of items) {
|
|
4593
4618
|
if (i.fontSize <= 0) continue;
|
|
4594
|
-
const count = (freq.get(i.fontSize) || 0) + Math.max(1, _nullishCoalesce(_optionalChain([i, 'access',
|
|
4619
|
+
const count = (freq.get(i.fontSize) || 0) + Math.max(1, _nullishCoalesce(_optionalChain([i, 'access', _150 => _150.text, 'access', _151 => _151.match, 'call', _152 => _152(/[\p{L}\p{N}]/gu), 'optionalAccess', _153 => _153.length]), () => ( 0)));
|
|
4595
4620
|
freq.set(i.fontSize, count);
|
|
4596
4621
|
if (count > maxCount) {
|
|
4597
4622
|
maxCount = count;
|
|
@@ -4599,7 +4624,7 @@ function dominantStyle(items) {
|
|
|
4599
4624
|
}
|
|
4600
4625
|
}
|
|
4601
4626
|
if (dominantSize === 0) return void 0;
|
|
4602
|
-
const fontName = _optionalChain([items, 'access',
|
|
4627
|
+
const fontName = _optionalChain([items, 'access', _154 => _154.find, 'call', _155 => _155((i) => i.fontSize === dominantSize), 'optionalAccess', _156 => _156.fontName]) || void 0;
|
|
4603
4628
|
return fontName ? { fontSize: dominantSize, fontName } : { fontSize: dominantSize };
|
|
4604
4629
|
}
|
|
4605
4630
|
function normalizeItems(rawItems) {
|
|
@@ -4754,7 +4779,7 @@ function splitAroundOverlays(c, overlays) {
|
|
|
4754
4779
|
const ov = overlays.filter((o) => {
|
|
4755
4780
|
for (let at = c.text.indexOf(o.text); at >= 0; at = c.text.indexOf(o.text, at + 1)) {
|
|
4756
4781
|
const prefix = c.text.slice(0, at);
|
|
4757
|
-
const est = c.x + glyphUnits(prefix.replace(/\s+/g, "")) * a0 + (_nullishCoalesce(_optionalChain([prefix, 'access',
|
|
4782
|
+
const est = c.x + glyphUnits(prefix.replace(/\s+/g, "")) * a0 + (_nullishCoalesce(_optionalChain([prefix, 'access', _157 => _157.match, 'call', _158 => _158(/\s+/g), 'optionalAccess', _159 => _159.length]), () => ( 0))) * ws;
|
|
4758
4783
|
if (Math.abs(est - o.x) <= OVERLAY_DUP_EM * fs) return false;
|
|
4759
4784
|
}
|
|
4760
4785
|
return true;
|
|
@@ -4916,7 +4941,7 @@ function trackedSpaces(sorted, med = trackingShift([sorted])) {
|
|
|
4916
4941
|
});
|
|
4917
4942
|
}
|
|
4918
4943
|
function mergeLineSimple(items) {
|
|
4919
|
-
if (items.length <= 1) return _optionalChain([items, 'access',
|
|
4944
|
+
if (items.length <= 1) return _optionalChain([items, 'access', _160 => _160[0], 'optionalAccess', _161 => _161.text]) || "";
|
|
4920
4945
|
const sorted = sortLineByX([...items]);
|
|
4921
4946
|
const tracked = trackedSpaces(sorted);
|
|
4922
4947
|
const isEvenSpaced = detectEvenSpacedItems(sorted);
|
|
@@ -4951,7 +4976,7 @@ function mergeLineSimple(items) {
|
|
|
4951
4976
|
result += sorted[i].text;
|
|
4952
4977
|
continue;
|
|
4953
4978
|
}
|
|
4954
|
-
if (gap > spaceGapThreshold(avgFs) || _optionalChain([tracked, 'optionalAccess',
|
|
4979
|
+
if (gap > spaceGapThreshold(avgFs) || _optionalChain([tracked, 'optionalAccess', _162 => _162[i]])) result += " ";
|
|
4955
4980
|
result += sorted[i].text;
|
|
4956
4981
|
}
|
|
4957
4982
|
return result;
|
|
@@ -5008,7 +5033,7 @@ function isProseTable(table) {
|
|
|
5008
5033
|
if (!(long > 0 && long >= total * 0.5 && longRows >= rows * 0.4)) return false;
|
|
5009
5034
|
for (let c = 0; c < table.cols; c++) {
|
|
5010
5035
|
const filled = table.cells.map((row) => row[c]).filter((cell) => cell && cell.colSpan < table.cols && cell.text.trim()).map((cell) => cell.text.trim());
|
|
5011
|
-
if (filled.length >= 3 && filled.length >= rows * 0.6 && filled.every((text) => text.length <= 30 && (_nullishCoalesce(_optionalChain([text, 'access',
|
|
5036
|
+
if (filled.length >= 3 && filled.length >= rows * 0.6 && filled.every((text) => text.length <= 30 && (_nullishCoalesce(_optionalChain([text, 'access', _163 => _163.match, 'call', _164 => _164(/\p{L}/gu), 'optionalAccess', _165 => _165.length]), () => ( 0))) >= 2)) return false;
|
|
5012
5037
|
}
|
|
5013
5038
|
return true;
|
|
5014
5039
|
}
|
|
@@ -5037,7 +5062,7 @@ var TICK = /^-?[\d,]+(?:\.\d+)?%?$/;
|
|
|
5037
5062
|
var QUANTITY = /^[-−–]?[\d,]*\.?\d+%?$/;
|
|
5038
5063
|
var quantity = (token) => Number(token.replace(/^[−–]/, "-").replace(/[,%]/g, ""));
|
|
5039
5064
|
function isValueAxisColumn(table, c) {
|
|
5040
|
-
const lines = table.cells.flatMap((row) => (_nullishCoalesce(_optionalChain([row, 'access',
|
|
5065
|
+
const lines = table.cells.flatMap((row) => (_nullishCoalesce(_optionalChain([row, 'access', _166 => _166[c], 'optionalAccess', _167 => _167.text]), () => ( ""))).split("\n").map((line) => line.trim().split(/\s+/)));
|
|
5041
5066
|
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));
|
|
5042
5067
|
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)]) {
|
|
5043
5068
|
const run = fallingRun(ticks);
|
|
@@ -5070,7 +5095,7 @@ function isChartTable(table, ocr = false) {
|
|
|
5070
5095
|
if (numeric < texts.length * 0.5) return false;
|
|
5071
5096
|
if (ocr && table.cols >= 3 && table.cells.slice(0, 3).some((row) => row.filter((cell) => /[가-힣]{2}/.test(cell.text)).length >= 2)) return false;
|
|
5072
5097
|
for (let c = 0; c < table.cols; c++) {
|
|
5073
|
-
if (!ocr ? isValueAxisColumn(table, c) : hasValueAxis(table.cells.flatMap((row) => (_nullishCoalesce(_optionalChain([row, 'access',
|
|
5098
|
+
if (!ocr ? isValueAxisColumn(table, c) : hasValueAxis(table.cells.flatMap((row) => (_nullishCoalesce(_optionalChain([row, 'access', _168 => _168[c], 'optionalAccess', _169 => _169.text]), () => ( ""))).split(/\s+/)).filter((t) => TICK.test(t)).map((t) => Number(t.replace(/[,%]/g, ""))))) return true;
|
|
5074
5099
|
}
|
|
5075
5100
|
const values = texts.filter((text) => text.split(/\s+/).every((token) => QUANTITY.test(token))).length;
|
|
5076
5101
|
const cells = table.rows * table.cols;
|
|
@@ -5079,7 +5104,7 @@ function isChartTable(table, ocr = false) {
|
|
|
5079
5104
|
function isProseFragmentTable(table) {
|
|
5080
5105
|
const texts = table.cells.flat().map((cell) => cell.text.trim()).filter(Boolean);
|
|
5081
5106
|
if (texts.length < 4) return false;
|
|
5082
|
-
const hangul = (text) => _nullishCoalesce(_optionalChain([text, 'access',
|
|
5107
|
+
const hangul = (text) => _nullishCoalesce(_optionalChain([text, 'access', _170 => _170.match, 'call', _171 => _171(/[가-힣]/g), 'optionalAccess', _172 => _172.length]), () => ( 0));
|
|
5083
5108
|
if (texts.filter((text) => hangul(text) >= 2).length < texts.length * 0.7) return false;
|
|
5084
5109
|
if (texts.length >= 12 && texts.filter((text) => hangul(text) >= 15 && !text.includes("\n")).length >= texts.length * 0.4) return true;
|
|
5085
5110
|
return texts.filter((text) => /(?:[다요고서는을를에게지며면어아야니까던]|[.,?!])$/.test(text)).length >= texts.length * 0.3;
|
|
@@ -5132,7 +5157,7 @@ function clusterCellLines(items) {
|
|
|
5132
5157
|
}
|
|
5133
5158
|
var WRAP_INDENT_MAX = 3;
|
|
5134
5159
|
function joinClusterCellLines(lines, box, lex) {
|
|
5135
|
-
let out = _nullishCoalesce(_optionalChain([lines, 'access',
|
|
5160
|
+
let out = _nullishCoalesce(_optionalChain([lines, 'access', _173 => _173[0], 'optionalAccess', _174 => _174.text]), () => ( ""));
|
|
5136
5161
|
for (let i = 1; i < lines.length; i++) {
|
|
5137
5162
|
const a = lines[i - 1], b = lines[i];
|
|
5138
5163
|
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) === "";
|
|
@@ -5435,11 +5460,25 @@ function detectCompactStatisticalTables(rows, pageNum) {
|
|
|
5435
5460
|
}
|
|
5436
5461
|
return found;
|
|
5437
5462
|
}
|
|
5463
|
+
function twoColumnCells(row) {
|
|
5464
|
+
const items = [...row.items].sort((a, b) => a.x - b.x);
|
|
5465
|
+
if (items.length <= 2) return items.map((c) => ({ x: c.x, y: c.y, fontSize: c.fontSize, text: c.text }));
|
|
5466
|
+
const out = [];
|
|
5467
|
+
for (const c of items) {
|
|
5468
|
+
const last = out.at(-1), gap = last ? c.x - last.end : Infinity;
|
|
5469
|
+
if (last && gap <= c.fontSize * 1.2) {
|
|
5470
|
+
last.text += (gap > c.fontSize * 0.2 || c.hasSpaceBefore ? " " : "") + c.text;
|
|
5471
|
+
last.end = Math.max(last.end, c.x + c.w);
|
|
5472
|
+
} else out.push({ x: c.x, y: c.y, fontSize: c.fontSize, text: c.text, end: c.x + c.w });
|
|
5473
|
+
}
|
|
5474
|
+
if (out.length === 2 && (out[0].text.length > 20 || out.some((c) => /^\s*[::]|[::]\s*$|\s[::]\s/.test(c.text)))) return [];
|
|
5475
|
+
return out.map(({ end: _end, ...cell }) => cell);
|
|
5476
|
+
}
|
|
5438
5477
|
function detectAlignedTwoColumnTables(rows, pageNum) {
|
|
5439
5478
|
const found = [];
|
|
5440
5479
|
let i = 0;
|
|
5441
5480
|
while (i < rows.length - 2) {
|
|
5442
|
-
const first =
|
|
5481
|
+
const first = twoColumnCells(rows[i]);
|
|
5443
5482
|
if (first.length !== 2 || first.some((c) => !c.text.trim() || c.text.length > 48) || first[1].x - first[0].x < 45 || first[1].x - first[0].x > 260 || /[.!?]$/.test(first[0].text)) {
|
|
5444
5483
|
i++;
|
|
5445
5484
|
continue;
|
|
@@ -5447,23 +5486,28 @@ function detectAlignedTwoColumnTables(rows, pageNum) {
|
|
|
5447
5486
|
const body = [];
|
|
5448
5487
|
let j = i;
|
|
5449
5488
|
for (; j < rows.length; j++) {
|
|
5450
|
-
const cells2 =
|
|
5489
|
+
const cells2 = twoColumnCells(rows[j]);
|
|
5451
5490
|
const previous = body.at(-1);
|
|
5452
|
-
if (
|
|
5453
|
-
|
|
5491
|
+
if (previous && previous.rows.at(-1).y - rows[j].y > Math.max(24, first[0].fontSize * 2.8)) break;
|
|
5492
|
+
if (previous && cells2.length === 1 && Math.abs(cells2[0].x - first[1].x) <= 5 && cells2[0].text.trim()) {
|
|
5493
|
+
previous.rows.push(rows[j]);
|
|
5494
|
+
previous.right.push(cells2[0].text);
|
|
5495
|
+
continue;
|
|
5496
|
+
}
|
|
5497
|
+
if (cells2.length !== 2 || cells2.some((c) => !c.text.trim() || c.text.length > 48) || Math.abs(cells2[0].x - first[0].x) > 5 || Math.abs(cells2[1].x - first[1].x) > 5) break;
|
|
5498
|
+
body.push({ rows: [rows[j]], left: cells2[0].text, right: [cells2[1].text] });
|
|
5454
5499
|
}
|
|
5455
|
-
if (body.length < 3) {
|
|
5500
|
+
if (body.length < 3 || body.filter((b) => !/[\p{L}\p{N}]/u.test(b.right.join(""))).length * 2 >= body.length) {
|
|
5456
5501
|
i++;
|
|
5457
5502
|
continue;
|
|
5458
5503
|
}
|
|
5459
5504
|
const top = rows[i - 1];
|
|
5460
|
-
const title = _optionalChain([top, 'optionalAccess',
|
|
5461
|
-
const tableRows = title ? [title, ...body
|
|
5462
|
-
const cells =
|
|
5463
|
-
|
|
5464
|
-
|
|
5465
|
-
|
|
5466
|
-
});
|
|
5505
|
+
const title = _optionalChain([top, 'optionalAccess', _175 => _175.items, 'access', _176 => _176.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;
|
|
5506
|
+
const tableRows = [...title ? [title] : [], ...body.flatMap((b) => b.rows)];
|
|
5507
|
+
const cells = [
|
|
5508
|
+
...title ? [[{ text: title.items[0].text, colSpan: 2, rowSpan: 1 }, { text: "", colSpan: 1, rowSpan: 1 }]] : [],
|
|
5509
|
+
...body.map((b) => [{ text: b.left, colSpan: 1, rowSpan: 1 }, { text: b.right.join(" "), colSpan: 1, rowSpan: 1 }])
|
|
5510
|
+
];
|
|
5467
5511
|
const usedItems = new Set(tableRows.flatMap((row) => row.items));
|
|
5468
5512
|
const all = [...usedItems];
|
|
5469
5513
|
const minX = Math.min(...all.map((c) => c.x)), minY = Math.min(...all.map((c) => c.y));
|
|
@@ -5514,12 +5558,12 @@ function isTwoColumnProse(r) {
|
|
|
5514
5558
|
if (t.rows < (ocr ? 6 : 8)) return false;
|
|
5515
5559
|
const dense = [];
|
|
5516
5560
|
for (let c = 0; c < t.cols; c++) {
|
|
5517
|
-
const filled = t.cells.filter((row) => _optionalChain([row, 'access',
|
|
5561
|
+
const filled = t.cells.filter((row) => _optionalChain([row, 'access', _177 => _177[c], 'optionalAccess', _178 => _178.text, 'access', _179 => _179.trim, 'call', _180 => _180()])).length;
|
|
5518
5562
|
if (filled / t.rows >= 0.3) dense.push(c);
|
|
5519
5563
|
}
|
|
5520
5564
|
if (dense.length !== 2) return false;
|
|
5521
5565
|
for (const c of dense) {
|
|
5522
|
-
const lens = t.cells.map((row) => _nullishCoalesce(_optionalChain([row, 'access',
|
|
5566
|
+
const lens = t.cells.map((row) => _nullishCoalesce(_optionalChain([row, 'access', _181 => _181[c], 'optionalAccess', _182 => _182.text, 'access', _183 => _183.replace, 'call', _184 => _184(/\s+/g, ""), 'access', _185 => _185.length]), () => ( 0))).filter((n) => n > 0);
|
|
5523
5567
|
const avg = lens.reduce((s, v) => s + v, 0) / (lens.length || 1);
|
|
5524
5568
|
if (avg < (ocr ? 15 : 12)) return false;
|
|
5525
5569
|
}
|
|
@@ -5981,7 +6025,7 @@ function assignRowItems(items, columns, numCols, headerFace) {
|
|
|
5981
6025
|
const runs = [];
|
|
5982
6026
|
for (const it of sorted) {
|
|
5983
6027
|
const last = runs[runs.length - 1];
|
|
5984
|
-
const prev = _optionalChain([last, 'optionalAccess',
|
|
6028
|
+
const prev = _optionalChain([last, 'optionalAccess', _186 => _186[last.length - 1]]);
|
|
5985
6029
|
if (prev && it.x - (prev.x + prev.w) <= Math.max(0.5, it.fontSize * 0.05) && !it.hasSpaceBefore) last.push(it);
|
|
5986
6030
|
else runs.push([it]);
|
|
5987
6031
|
}
|
|
@@ -6032,7 +6076,7 @@ function assignRowItems(items, columns, numCols, headerFace) {
|
|
|
6032
6076
|
assignedGroups.add(gi);
|
|
6033
6077
|
usedCols.add(ci);
|
|
6034
6078
|
}
|
|
6035
|
-
const colOf = groups.map((g) => _nullishCoalesce(_optionalChain([result, 'access',
|
|
6079
|
+
const colOf = groups.map((g) => _nullishCoalesce(_optionalChain([result, 'access', _187 => _187.find, 'call', _188 => _188((a) => a.items === g), 'optionalAccess', _189 => _189.col]), () => ( -1)));
|
|
6036
6080
|
if (groups.length <= numCols && colOf.some((c, g) => g > 0 && c < colOf[g - 1])) {
|
|
6037
6081
|
const G = groups.length, cost = (g, c2) => Math.abs(groupCenters[g] - colCenters[c2]);
|
|
6038
6082
|
const best = groups.map(() => new Array(numCols).fill(Infinity)), from = groups.map(() => new Array(numCols).fill(-1));
|
|
@@ -6069,7 +6113,7 @@ function assignRowItems(items, columns, numCols, headerFace) {
|
|
|
6069
6113
|
function buildClusterTable(rows, columns, pageNum, lex) {
|
|
6070
6114
|
const numRows = rows.length;
|
|
6071
6115
|
if (numRows < MIN_ROWS || columns.length < MIN_COLS) return null;
|
|
6072
|
-
const headFaces = new Set(_optionalChain([rows, 'access',
|
|
6116
|
+
const headFaces = new Set(_optionalChain([rows, 'access', _190 => _190[0], 'optionalAccess', _191 => _191.items, 'access', _192 => _192.map, 'call', _193 => _193((i) => i.fontName)]));
|
|
6073
6117
|
const headerFace = headFaces.size === 1 && rows.slice(1).every((row) => row.items.every((i) => !headFaces.has(i.fontName))) ? [...headFaces][0] : void 0;
|
|
6074
6118
|
const assigned = rows.map((row, r) => assignRowItems(row.items, columns, columns.length, r === 0 ? headerFace : void 0));
|
|
6075
6119
|
const cuts = supportedOcrColumnCuts(assigned);
|
|
@@ -6140,7 +6184,7 @@ function buildClusterTable(rows, columns, pageNum, lex) {
|
|
|
6140
6184
|
const nonEmptyCols = cells[r].filter((c) => c.text.trim()).length;
|
|
6141
6185
|
if (nonEmptyCols !== 1) continue;
|
|
6142
6186
|
if (cells[r][0].text.trim() !== "") continue;
|
|
6143
|
-
const contentText = _optionalChain([cells, 'access',
|
|
6187
|
+
const contentText = _optionalChain([cells, 'access', _194 => _194[r], 'access', _195 => _195.find, 'call', _196 => _196((c) => c.text.trim()), 'optionalAccess', _197 => _197.text, 'access', _198 => _198.trim, 'call', _199 => _199()]) || "";
|
|
6144
6188
|
if (/^[○●▶\-·]/.test(contentText)) continue;
|
|
6145
6189
|
for (let pr = r - 1; pr >= 0; pr--) {
|
|
6146
6190
|
if (cells[pr].some((c) => c.text.trim())) {
|
|
@@ -6373,7 +6417,7 @@ function stackedTableBands(items) {
|
|
|
6373
6417
|
const caption = (start, end) => lines.slice(start, end).some((line) => /^Table\s+\d+\s*[:.]/i.test(mergeLineSimple(line).trim()));
|
|
6374
6418
|
while (runs.length > 0 && !caption(runs[runs.length - 1].end, lines.length)) runs.pop();
|
|
6375
6419
|
if (runs.length < 2) return null;
|
|
6376
|
-
if (runs.some((run, i) => !caption(run.end, _nullishCoalesce(_optionalChain([runs, 'access',
|
|
6420
|
+
if (runs.some((run, i) => !caption(run.end, _nullishCoalesce(_optionalChain([runs, 'access', _200 => _200[i + 1], 'optionalAccess', _201 => _201.start]), () => ( lines.length))))) return null;
|
|
6377
6421
|
const tables = runs.map((run) => lines.slice(run.start, run.end).flat());
|
|
6378
6422
|
const between = runs.slice(0, -1).map((run, i) => lines.slice(run.end, runs[i + 1].start).flat());
|
|
6379
6423
|
const tail = lines.slice(runs[runs.length - 1].end);
|
|
@@ -6641,7 +6685,7 @@ function splitTrailingColumnRegion(items) {
|
|
|
6641
6685
|
}
|
|
6642
6686
|
function panelBlocks(items, panel, pageNum) {
|
|
6643
6687
|
const lines = groupByY([...items].sort((a, b) => b.y - a.y || a.x - b.x));
|
|
6644
|
-
const faceOf = (line) => _nullishCoalesce(_optionalChain([dominantStyle, 'call',
|
|
6688
|
+
const faceOf = (line) => _nullishCoalesce(_optionalChain([dominantStyle, 'call', _202 => _202(line), 'optionalAccess', _203 => _203.fontName]), () => ( ""));
|
|
6645
6689
|
const runs = [];
|
|
6646
6690
|
for (const line of lines) {
|
|
6647
6691
|
const last = runs[runs.length - 1];
|
|
@@ -6688,7 +6732,7 @@ function chartBandGap(group, gap, charts) {
|
|
|
6688
6732
|
const top = Math.max(...group.map((i) => i.y + i.fontSize)), em = Math.max(...group.map((i) => i.fontSize));
|
|
6689
6733
|
return charts.some((c) => x1 >= c.x1 - 2 && x2 <= c.x2 + 2 && top <= c.y1 + 2 && c.y1 - top <= 2 * em) ? gap : 0;
|
|
6690
6734
|
}
|
|
6691
|
-
function xyCutOrder(items, gapThreshold, depth = 0, wrapped, columnGap = 0) {
|
|
6735
|
+
function xyCutOrder(items, gapThreshold, depth = 0, wrapped, columnGap = 0, lex) {
|
|
6692
6736
|
if (items.length === 0) return [];
|
|
6693
6737
|
const newRegion = wrapped === void 0;
|
|
6694
6738
|
wrapped ??= inheritedWrapBands(items);
|
|
@@ -6696,7 +6740,7 @@ function xyCutOrder(items, gapThreshold, depth = 0, wrapped, columnGap = 0) {
|
|
|
6696
6740
|
if (items.length === 2 && depth < MAX_XYCUT_DEPTH) {
|
|
6697
6741
|
const sortedY2 = [...items].sort((a, b) => b.y - a.y);
|
|
6698
6742
|
if (findHorizontalCut(sortedY2, wrapped).gap >= farGap) {
|
|
6699
|
-
if (newRegion) wrapped = wrappedLineBands(items, wrapped);
|
|
6743
|
+
if (newRegion) wrapped = wrappedLineBands(items, wrapped, lex);
|
|
6700
6744
|
const cut = findHorizontalCut(sortedY2, wrapped);
|
|
6701
6745
|
if (cut.gap >= farGap) return [...leaf([sortedY2[0]], wrapped), ...leaf([sortedY2[1]], wrapped)];
|
|
6702
6746
|
}
|
|
@@ -6707,7 +6751,7 @@ function xyCutOrder(items, gapThreshold, depth = 0, wrapped, columnGap = 0) {
|
|
|
6707
6751
|
if (cross.size > 0 && cross.size <= items.length * CROSS_MAX_MASK_RATIO) {
|
|
6708
6752
|
const rest = items.filter((i) => !cross.has(i));
|
|
6709
6753
|
if (rest.length > 0) {
|
|
6710
|
-
const groups = xyCutOrder(rest, gapThreshold, 1, void 0, columnGap);
|
|
6754
|
+
const groups = xyCutOrder(rest, gapThreshold, 1, void 0, columnGap, lex);
|
|
6711
6755
|
return mergeCrossLayoutGroups(groups, [...cross]);
|
|
6712
6756
|
}
|
|
6713
6757
|
}
|
|
@@ -6716,7 +6760,7 @@ function xyCutOrder(items, gapThreshold, depth = 0, wrapped, columnGap = 0) {
|
|
|
6716
6760
|
const sortedY = [...items].sort((a, b) => b.y - a.y);
|
|
6717
6761
|
let hCut = findHorizontalCut(sortedY, wrapped);
|
|
6718
6762
|
if (newRegion && hCut.gap >= minGap) {
|
|
6719
|
-
wrapped = wrappedLineBands(items, wrapped);
|
|
6763
|
+
wrapped = wrappedLineBands(items, wrapped, lex);
|
|
6720
6764
|
hCut = findHorizontalCut(sortedY, wrapped);
|
|
6721
6765
|
}
|
|
6722
6766
|
const vMinGap = Math.max(minGap, columnGap);
|
|
@@ -6727,18 +6771,18 @@ function xyCutOrder(items, gapThreshold, depth = 0, wrapped, columnGap = 0) {
|
|
|
6727
6771
|
if (hValid && vValid) useHorizontal = (vCut.gap <= hCut.gap * 1.5 || staggeredSides(items, vCut.position)) && !gapInsideLongerColumn(items, hCut.position, hCut.gap, vCut.position);
|
|
6728
6772
|
else if (hValid) useHorizontal = true;
|
|
6729
6773
|
else if (vValid) useHorizontal = false;
|
|
6730
|
-
else return _nullishCoalesce(splitEdgeSpannedColumns(items, gapThreshold, depth), () => ( leaf(items, wrapped)));
|
|
6774
|
+
else return _nullishCoalesce(splitEdgeSpannedColumns(items, gapThreshold, depth, lex), () => ( leaf(items, wrapped)));
|
|
6731
6775
|
if (useHorizontal) {
|
|
6732
6776
|
const upper = items.filter((i) => i.y > hCut.position);
|
|
6733
6777
|
const lower = items.filter((i) => i.y <= hCut.position);
|
|
6734
6778
|
if (upper.length > 0 && lower.length > 0 && upper.length < items.length) {
|
|
6735
|
-
return [...xyCutOrder(upper, gapThreshold, depth + 1, wrapped, columnGap), ...xyCutOrder(lower, gapThreshold, depth + 1, wrapped, columnGap)];
|
|
6779
|
+
return [...xyCutOrder(upper, gapThreshold, depth + 1, wrapped, columnGap, lex), ...xyCutOrder(lower, gapThreshold, depth + 1, wrapped, columnGap, lex)];
|
|
6736
6780
|
}
|
|
6737
6781
|
} else {
|
|
6738
6782
|
const left = items.filter((i) => i.x + i.w / 2 < vCut.position);
|
|
6739
6783
|
const right = items.filter((i) => i.x + i.w / 2 >= vCut.position);
|
|
6740
6784
|
if (left.length > 0 && right.length > 0 && left.length < items.length) {
|
|
6741
|
-
return [...xyCutOrder(left, gapThreshold, depth + 1, void 0, columnGap), ...xyCutOrder(right, gapThreshold, depth + 1, void 0, columnGap)];
|
|
6785
|
+
return [...xyCutOrder(left, gapThreshold, depth + 1, void 0, columnGap, lex), ...xyCutOrder(right, gapThreshold, depth + 1, void 0, columnGap, lex)];
|
|
6742
6786
|
}
|
|
6743
6787
|
}
|
|
6744
6788
|
return leaf(items, wrapped);
|
|
@@ -6848,7 +6892,7 @@ function validWrapBands(items, bands) {
|
|
|
6848
6892
|
}
|
|
6849
6893
|
function inheritedWrapBands(items) {
|
|
6850
6894
|
const source = XY_WRAP_ITEMS.get(items[0]);
|
|
6851
|
-
const present = _optionalChain([source, 'optionalAccess',
|
|
6895
|
+
const present = _optionalChain([source, 'optionalAccess', _204 => _204.length]) === items.length ? new Set(items) : null;
|
|
6852
6896
|
const sameLeaf = present && source.every((item) => present.has(item));
|
|
6853
6897
|
return sameLeaf ? validWrapBands(items, _nullishCoalesce(XY_WRAP_BANDS.get(items[0]), () => ( []))) : [];
|
|
6854
6898
|
}
|
|
@@ -6883,10 +6927,13 @@ function splitsLoneRowTail(items, x) {
|
|
|
6883
6927
|
const tail = right[0], box = computeBBox(items, 0), tailBox = computeBBox(tail, 0);
|
|
6884
6928
|
const head = left.find((r) => Math.abs(r[0].y - tail[0].y) <= 2);
|
|
6885
6929
|
if (!head) return false;
|
|
6886
|
-
const headBox = computeBBox(head, 0), fs = _nullishCoalesce(_optionalChain([dominantStyle, 'call',
|
|
6887
|
-
|
|
6930
|
+
const headBox = computeBBox(head, 0), fs = _nullishCoalesce(_optionalChain([dominantStyle, 'call', _205 => _205(tail), 'optionalAccess', _206 => _206.fontSize]), () => ( 10));
|
|
6931
|
+
const gap = tailBox.x - (headBox.x + headBox.width), fills = tailBox.x + tailBox.width >= box.x + box.width - fs;
|
|
6932
|
+
if (gap <= fs * 3 && fills && headBox.width >= box.width / 2) return true;
|
|
6933
|
+
const text = [...head, ...tail].map((i) => i.text).join("");
|
|
6934
|
+
return !/[가-힣]/.test(text) && /[\u3040-\u30ff\u3400-\u9fff]/.test(text) && gap <= fs * 4 && fills && headBox.x <= box.x + fs;
|
|
6888
6935
|
}
|
|
6889
|
-
function wrappedLineBands(items, inherited) {
|
|
6936
|
+
function wrappedLineBands(items, inherited, lex) {
|
|
6890
6937
|
const rows = groupByY(items);
|
|
6891
6938
|
const records = tocRecordBoundaries(rows);
|
|
6892
6939
|
const lines = rows.map((row) => {
|
|
@@ -6896,11 +6943,11 @@ function wrappedLineBands(items, inherited) {
|
|
|
6896
6943
|
left: box.x,
|
|
6897
6944
|
right: box.x + box.width,
|
|
6898
6945
|
y: row.reduce((n, i) => n + i.y, 0) / row.length,
|
|
6899
|
-
fontSize: _nullishCoalesce(_optionalChain([dominantStyle, 'call',
|
|
6946
|
+
fontSize: _nullishCoalesce(_optionalChain([dominantStyle, 'call', _207 => _207(row), 'optionalAccess', _208 => _208.fontSize]), () => ( 0)),
|
|
6900
6947
|
sources: row.map((item) => ({ item, state: { ...item } }))
|
|
6901
6948
|
};
|
|
6902
6949
|
});
|
|
6903
|
-
const joins = bodyLineJoins(lines);
|
|
6950
|
+
const joins = bodyLineJoins(lines, lex);
|
|
6904
6951
|
const fresh = lines.slice(0, -1).flatMap((line, i) => joins[i] === "\n" || records.has(i) || line.text.trim() === lines[i + 1].text.trim() ? [] : [{ top: line.y, bottom: lines[i + 1].y, sources: [...line.sources, ...lines[i + 1].sources] }]);
|
|
6905
6952
|
const freshKeys = new Set(fresh.map((b) => `${b.top}:${b.bottom}`));
|
|
6906
6953
|
return [...inherited.filter((b) => !freshKeys.has(`${b.top}:${b.bottom}`)), ...fresh].sort((a, b) => b.top - a.top);
|
|
@@ -6994,7 +7041,7 @@ function isProseGutter(items, x) {
|
|
|
6994
7041
|
const [l0, l1] = span2(left), [r0, r1] = span2(right);
|
|
6995
7042
|
return Math.min(l1, r1) - Math.max(l0, r0) >= Math.min(l1 - l0, r1 - r0) * 0.5;
|
|
6996
7043
|
}
|
|
6997
|
-
function splitEdgeSpannedColumns(items, gapThreshold, depth) {
|
|
7044
|
+
function splitEdgeSpannedColumns(items, gapThreshold, depth, lex) {
|
|
6998
7045
|
let minX = Infinity, maxX = -Infinity;
|
|
6999
7046
|
for (const i of items) {
|
|
7000
7047
|
minX = Math.min(minX, i.x);
|
|
@@ -7012,8 +7059,8 @@ function splitEdgeSpannedColumns(items, gapThreshold, depth) {
|
|
|
7012
7059
|
const left = rest.filter((i) => i.x + i.w / 2 < cut.position), right = rest.filter((i) => i.x + i.w / 2 >= cut.position);
|
|
7013
7060
|
return [
|
|
7014
7061
|
...above.length ? [above] : [],
|
|
7015
|
-
...xyCutOrder(left, gapThreshold, depth + 1),
|
|
7016
|
-
...xyCutOrder(right, gapThreshold, depth + 1),
|
|
7062
|
+
...xyCutOrder(left, gapThreshold, depth + 1, void 0, 0, lex),
|
|
7063
|
+
...xyCutOrder(right, gapThreshold, depth + 1, void 0, 0, lex),
|
|
7017
7064
|
...below.length ? [below] : []
|
|
7018
7065
|
];
|
|
7019
7066
|
}
|
|
@@ -7032,10 +7079,10 @@ function pushLineParagraphs(out, yLines, pageNum, lex) {
|
|
|
7032
7079
|
const lines = attachDropCaps(yLines).map((items) => ({ items, text: mergeLineSimple(items) })).filter((l) => l.text.trim());
|
|
7033
7080
|
const geo = lines.map((l) => {
|
|
7034
7081
|
const b = computeBBox(l.items, pageNum);
|
|
7035
|
-
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',
|
|
7082
|
+
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', _209 => _209(l.items), 'optionalAccess', _210 => _210.fontSize]), () => ( 0)) };
|
|
7036
7083
|
});
|
|
7037
7084
|
const joins = bodyLineJoins(geo, lex);
|
|
7038
|
-
const first = _optionalChain([lines, 'access',
|
|
7085
|
+
const first = _optionalChain([lines, 'access', _211 => _211[0], 'optionalAccess', _212 => _212.items, 'access', _213 => _213[0]]);
|
|
7039
7086
|
const bands = first ? _nullishCoalesce(XY_WRAP_BANDS.get(first), () => ( [])) : [];
|
|
7040
7087
|
const hasBand = (top, bottom) => {
|
|
7041
7088
|
let lo = 0, hi = bands.length;
|
|
@@ -7112,15 +7159,15 @@ function computeMedianFontSizeFromFreq(freq) {
|
|
|
7112
7159
|
function detectHeadings(blocks, medianFontSize) {
|
|
7113
7160
|
for (let bi = 0; bi < blocks.length; bi++) {
|
|
7114
7161
|
const block = blocks[bi];
|
|
7115
|
-
if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access',
|
|
7162
|
+
if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access', _214 => _214.style, 'optionalAccess', _215 => _215.fontSize])) continue;
|
|
7116
7163
|
const text = block.text.trim();
|
|
7117
7164
|
if (text.length === 0 || text.length > 200) continue;
|
|
7118
7165
|
if (/^\d+$/.test(text) && !isChapterNumber(block, blocks[bi + 1], medianFontSize)) continue;
|
|
7119
7166
|
const ratio = block.style.fontSize / medianFontSize;
|
|
7120
7167
|
let level = 0;
|
|
7121
|
-
if (ratio >=
|
|
7122
|
-
else if (ratio >=
|
|
7123
|
-
else if (ratio >=
|
|
7168
|
+
if (ratio >= _chunkL4GCUYDScjs.HEADING_RATIO_H1) level = 1;
|
|
7169
|
+
else if (ratio >= _chunkL4GCUYDScjs.HEADING_RATIO_H2) level = 2;
|
|
7170
|
+
else if (ratio >= _chunkL4GCUYDScjs.HEADING_RATIO_H3) level = 3;
|
|
7124
7171
|
if (level > 0) {
|
|
7125
7172
|
block.type = "heading";
|
|
7126
7173
|
block.level = level;
|
|
@@ -7129,21 +7176,21 @@ function detectHeadings(blocks, medianFontSize) {
|
|
|
7129
7176
|
}
|
|
7130
7177
|
}
|
|
7131
7178
|
function isChapterNumber(block, next, medianFontSize) {
|
|
7132
|
-
const size = _nullishCoalesce(_optionalChain([block, 'access',
|
|
7133
|
-
const nextSize = _nullishCoalesce(_optionalChain([next, 'optionalAccess',
|
|
7134
|
-
const text = _nullishCoalesce(_optionalChain([next, 'optionalAccess',
|
|
7135
|
-
const a = block.bbox, b = _optionalChain([next, 'optionalAccess',
|
|
7136
|
-
return /^\d{1,2}$/.test(_nullishCoalesce(_optionalChain([block, 'access',
|
|
7179
|
+
const size = _nullishCoalesce(_optionalChain([block, 'access', _216 => _216.style, 'optionalAccess', _217 => _217.fontSize]), () => ( 0));
|
|
7180
|
+
const nextSize = _nullishCoalesce(_optionalChain([next, 'optionalAccess', _218 => _218.style, 'optionalAccess', _219 => _219.fontSize]), () => ( 0));
|
|
7181
|
+
const text = _nullishCoalesce(_optionalChain([next, 'optionalAccess', _220 => _220.text, 'optionalAccess', _221 => _221.trim, 'call', _222 => _222()]), () => ( ""));
|
|
7182
|
+
const a = block.bbox, b = _optionalChain([next, 'optionalAccess', _223 => _223.bbox]);
|
|
7183
|
+
return /^\d{1,2}$/.test(_nullishCoalesce(_optionalChain([block, 'access', _224 => _224.text, 'optionalAccess', _225 => _225.trim, 'call', _226 => _226()]), () => ( ""))) && size >= medianFontSize * 2.5 && !!next && (next.type === "paragraph" || next.type === "heading") && next.pageNumber === block.pageNumber && nextSize >= medianFontSize * _chunkL4GCUYDScjs.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;
|
|
7137
7184
|
}
|
|
7138
7185
|
function mergeStackedHeadingLines(blocks, medianFontSize) {
|
|
7139
7186
|
for (let i = 0; i < blocks.length - 1; ) {
|
|
7140
7187
|
const a = blocks[i], b = blocks[i + 1];
|
|
7141
7188
|
const ab = a.bbox, bb = b.bbox;
|
|
7142
|
-
const af = _nullishCoalesce(_optionalChain([a, 'access',
|
|
7189
|
+
const af = _nullishCoalesce(_optionalChain([a, 'access', _227 => _227.style, 'optionalAccess', _228 => _228.fontSize]), () => ( 0)), bf = _nullishCoalesce(_optionalChain([b, 'access', _229 => _229.style, 'optionalAccess', _230 => _230.fontSize]), () => ( 0));
|
|
7143
7190
|
const gap = ab && bb ? ab.y - (bb.y + bb.height) : Infinity;
|
|
7144
|
-
const centered = ab && bb && _optionalChain([a, 'access',
|
|
7191
|
+
const centered = ab && bb && _optionalChain([a, 'access', _231 => _231.style, 'optionalAccess', _232 => _232.fontName]) === _optionalChain([b, 'access', _233 => _233.style, 'optionalAccess', _234 => _234.fontName]) && Math.abs(ab.x + ab.width / 2 - (bb.x + bb.width / 2)) <= Math.max(5, af * 0.5);
|
|
7145
7192
|
const sameAnchor = ab && bb && Math.abs(ab.x - bb.x) <= 5;
|
|
7146
|
-
const wrapped = sameAnchor && _optionalChain([a, 'access',
|
|
7193
|
+
const wrapped = sameAnchor && _optionalChain([a, 'access', _235 => _235.style, 'optionalAccess', _236 => _236.fontName]) === _optionalChain([b, 'access', _237 => _237.style, 'optionalAccess', _238 => _238.fontName]) && af === bf && ab.width >= bb.width * 0.95 && (_nullishCoalesce(_optionalChain([a, 'access', _239 => _239.text, 'optionalAccess', _240 => _240.trim, 'call', _241 => _241(), 'access', _242 => _242.split, 'call', _243 => _243(/\s+/), 'access', _244 => _244.length]), () => ( 0))) >= 3;
|
|
7147
7194
|
const displayStack = centered && gap <= Math.min(af, bf) * 0.3 && Math.max(af, bf) <= Math.min(af, bf) * 1.45;
|
|
7148
7195
|
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)) {
|
|
7149
7196
|
i++;
|
|
@@ -7172,25 +7219,25 @@ function detectTypographyHeadings(blocks) {
|
|
|
7172
7219
|
if (page.some((block) => block.type === "heading")) continue;
|
|
7173
7220
|
const faceWeight = /* @__PURE__ */ new Map();
|
|
7174
7221
|
for (const block of page) {
|
|
7175
|
-
if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access',
|
|
7222
|
+
if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access', _245 => _245.style, 'optionalAccess', _246 => _246.fontName])) continue;
|
|
7176
7223
|
const faces = FACE_CHARS.get(block);
|
|
7177
7224
|
if (faces) for (const [face, n] of faces) faceWeight.set(face, (_nullishCoalesce(faceWeight.get(face), () => ( 0))) + n);
|
|
7178
7225
|
else faceWeight.set(block.style.fontName, (_nullishCoalesce(faceWeight.get(block.style.fontName), () => ( 0))) + block.text.length);
|
|
7179
7226
|
}
|
|
7180
|
-
const bodyFace = _optionalChain([[...faceWeight], 'access',
|
|
7227
|
+
const bodyFace = _optionalChain([[...faceWeight], 'access', _247 => _247.sort, 'call', _248 => _248((a, b) => b[1] - a[1]), 'access', _249 => _249[0], 'optionalAccess', _250 => _250[0]]);
|
|
7181
7228
|
if (!bodyFace || (_nullishCoalesce(faceWeight.get(bodyFace), () => ( 0))) < 250) continue;
|
|
7182
7229
|
const sizeWeight = /* @__PURE__ */ new Map();
|
|
7183
7230
|
for (const block of page) {
|
|
7184
|
-
if (block.type !== "paragraph" || !_optionalChain([block, 'access',
|
|
7231
|
+
if (block.type !== "paragraph" || !_optionalChain([block, 'access', _251 => _251.style, 'optionalAccess', _252 => _252.fontSize])) continue;
|
|
7185
7232
|
const faces = FACE_CHARS.get(block);
|
|
7186
|
-
const chars = faces ? _nullishCoalesce(faces.get(bodyFace), () => ( 0)) : block.style.fontName === bodyFace ? _nullishCoalesce(_optionalChain([block, 'access',
|
|
7233
|
+
const chars = faces ? _nullishCoalesce(faces.get(bodyFace), () => ( 0)) : block.style.fontName === bodyFace ? _nullishCoalesce(_optionalChain([block, 'access', _253 => _253.text, 'optionalAccess', _254 => _254.length]), () => ( 0)) : 0;
|
|
7187
7234
|
if (chars) sizeWeight.set(block.style.fontSize, (_nullishCoalesce(sizeWeight.get(block.style.fontSize), () => ( 0))) + chars);
|
|
7188
7235
|
}
|
|
7189
|
-
const bodySize = _nullishCoalesce(_optionalChain([[...sizeWeight], 'access',
|
|
7236
|
+
const bodySize = _nullishCoalesce(_optionalChain([[...sizeWeight], 'access', _255 => _255.sort, 'call', _256 => _256((a, b) => b[1] - a[1]), 'access', _257 => _257[0], 'optionalAccess', _258 => _258[0]]), () => ( 0));
|
|
7190
7237
|
for (let i = 0; i < page.length; i++) {
|
|
7191
7238
|
const block = page[i];
|
|
7192
7239
|
const { text, bbox, style } = block;
|
|
7193
|
-
if (block.type !== "paragraph" || !text || !bbox || !_optionalChain([style, 'optionalAccess',
|
|
7240
|
+
if (block.type !== "paragraph" || !text || !bbox || !_optionalChain([style, 'optionalAccess', _259 => _259.fontName]) || !style.fontSize) continue;
|
|
7194
7241
|
const title = text.trim();
|
|
7195
7242
|
const numbered = /^\d+(?:\.\d+)*\.?\s+[A-Z가-힣]/.test(title);
|
|
7196
7243
|
const faces = FACE_CHARS.get(block);
|
|
@@ -7220,16 +7267,16 @@ function detectDocumentStyleHeadings(blocks) {
|
|
|
7220
7267
|
for (const page of byPage.values()) {
|
|
7221
7268
|
const faceChars = /* @__PURE__ */ new Map();
|
|
7222
7269
|
for (const block of page) {
|
|
7223
|
-
if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access',
|
|
7270
|
+
if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access', _260 => _260.style, 'optionalAccess', _261 => _261.fontName])) continue;
|
|
7224
7271
|
faceChars.set(block.style.fontName, (_nullishCoalesce(faceChars.get(block.style.fontName), () => ( 0))) + block.text.length);
|
|
7225
7272
|
}
|
|
7226
|
-
const bodyFace = _optionalChain([[...faceChars], 'access',
|
|
7273
|
+
const bodyFace = _optionalChain([[...faceChars], 'access', _262 => _262.sort, 'call', _263 => _263((a, b) => b[1] - a[1]), 'access', _264 => _264[0], 'optionalAccess', _265 => _265[0]]);
|
|
7227
7274
|
if (!bodyFace || (_nullishCoalesce(faceChars.get(bodyFace), () => ( 0))) < 100) continue;
|
|
7228
|
-
const labels = page.filter((b) => b.type === "paragraph" && b.text && b.bbox && _optionalChain([b, 'access',
|
|
7275
|
+
const labels = page.filter((b) => b.type === "paragraph" && b.text && b.bbox && _optionalChain([b, 'access', _266 => _266.style, 'optionalAccess', _267 => _267.fontName]) && b.style.fontName !== bodyFace && b.text.trim().length >= 3 && b.text.trim().length <= 40);
|
|
7229
7276
|
for (const label of labels) {
|
|
7230
|
-
const peers = labels.filter((b) => _optionalChain([b, 'access',
|
|
7277
|
+
const peers = labels.filter((b) => _optionalChain([b, 'access', _268 => _268.style, 'optionalAccess', _269 => _269.fontName]) === _optionalChain([label, 'access', _270 => _270.style, 'optionalAccess', _271 => _271.fontName]) && Math.abs(b.bbox.y - label.bbox.y) <= 3 && Math.abs(b.bbox.x - label.bbox.x) >= 60);
|
|
7231
7278
|
if (peers.length < 2) continue;
|
|
7232
|
-
const value = page.find((b) => b.type === "paragraph" && b.bbox && _optionalChain([b, 'access',
|
|
7279
|
+
const value = page.find((b) => b.type === "paragraph" && b.bbox && _optionalChain([b, 'access', _272 => _272.style, 'optionalAccess', _273 => _273.fontName]) !== _optionalChain([label, 'access', _274 => _274.style, 'optionalAccess', _275 => _275.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);
|
|
7233
7280
|
if (value) {
|
|
7234
7281
|
label.type = "heading";
|
|
7235
7282
|
label.level = 2;
|
|
@@ -7238,7 +7285,7 @@ function detectDocumentStyleHeadings(blocks) {
|
|
|
7238
7285
|
const first = page.find((b) => b.type !== "image" && b.type !== "separator");
|
|
7239
7286
|
const second = page[page.indexOf(first) + 1];
|
|
7240
7287
|
const third = page[page.indexOf(first) + 2];
|
|
7241
|
-
if (!first || !second || !third || first.type !== "list" && first.type !== "paragraph" || second.type !== "paragraph" || !first.text || !second.text || !first.bbox || !second.bbox || !_optionalChain([first, 'access',
|
|
7288
|
+
if (!first || !second || !third || first.type !== "list" && first.type !== "paragraph" || second.type !== "paragraph" || !first.text || !second.text || !first.bbox || !second.bbox || !_optionalChain([first, 'access', _276 => _276.style, 'optionalAccess', _277 => _277.fontName]) || !_optionalChain([second, 'access', _278 => _278.style, 'optionalAccess', _279 => _279.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', _280 => _280.style, 'optionalAccess', _281 => _281.fontName]) !== bodyFace) continue;
|
|
7242
7289
|
first.type = "heading";
|
|
7243
7290
|
first.level = 1;
|
|
7244
7291
|
first.text = `${first.text.trim()} ${second.text.trim()}`;
|
|
@@ -7262,18 +7309,18 @@ function detectSiblingStyleHeadings(blocks) {
|
|
|
7262
7309
|
for (const page of byPage.values()) {
|
|
7263
7310
|
const bodyChars = /* @__PURE__ */ new Map();
|
|
7264
7311
|
for (const block of page) {
|
|
7265
|
-
if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access',
|
|
7312
|
+
if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access', _282 => _282.style, 'optionalAccess', _283 => _283.fontName])) continue;
|
|
7266
7313
|
const face = block.style.fontName;
|
|
7267
7314
|
bodyChars.set(face, (_nullishCoalesce(bodyChars.get(face), () => ( 0))) + block.text.length);
|
|
7268
7315
|
}
|
|
7269
|
-
const bodyFace = _optionalChain([[...bodyChars], 'access',
|
|
7270
|
-
const anchors = page.filter((b) => b.type === "heading" && b.text && _optionalChain([b, 'access',
|
|
7316
|
+
const bodyFace = _optionalChain([[...bodyChars], 'access', _284 => _284.sort, 'call', _285 => _285((a, b) => b[1] - a[1]), 'access', _286 => _286[0], 'optionalAccess', _287 => _287[0]]);
|
|
7317
|
+
const anchors = page.filter((b) => b.type === "heading" && b.text && _optionalChain([b, 'access', _288 => _288.style, 'optionalAccess', _289 => _289.fontName]) && b.style.fontName !== bodyFace);
|
|
7271
7318
|
for (const anchor of anchors) {
|
|
7272
7319
|
const numbered = /^([A-Z])\.\d+\s+/.exec(anchor.text.trim());
|
|
7273
7320
|
const lettered = /^([A-Z])\s+/.exec(anchor.text.trim());
|
|
7274
|
-
const peers = anchors.filter((b) => _optionalChain([b, 'access',
|
|
7321
|
+
const peers = anchors.filter((b) => _optionalChain([b, 'access', _290 => _290.style, 'optionalAccess', _291 => _291.fontName]) === _optionalChain([anchor, 'access', _292 => _292.style, 'optionalAccess', _293 => _293.fontName]) && Math.abs((_nullishCoalesce(_optionalChain([b, 'access', _294 => _294.style, 'optionalAccess', _295 => _295.fontSize]), () => ( 0))) - (_nullishCoalesce(_optionalChain([anchor, 'access', _296 => _296.style, 'optionalAccess', _297 => _297.fontSize]), () => ( 0)))) < 0.5);
|
|
7275
7322
|
if (peers.length < 2 && !numbered && !lettered) continue;
|
|
7276
|
-
const candidates = page.filter((b) => b.type === "paragraph" && b.text && b.bbox && _optionalChain([b, 'access',
|
|
7323
|
+
const candidates = page.filter((b) => b.type === "paragraph" && b.text && b.bbox && _optionalChain([b, 'access', _298 => _298.style, 'optionalAccess', _299 => _299.fontName]) === _optionalChain([anchor, 'access', _300 => _300.style, 'optionalAccess', _301 => _301.fontName]) && Math.abs((_nullishCoalesce(_optionalChain([b, 'access', _302 => _302.style, 'optionalAccess', _303 => _303.fontSize]), () => ( 0))) - (_nullishCoalesce(_optionalChain([anchor, 'access', _304 => _304.style, 'optionalAccess', _305 => _305.fontSize]), () => ( 0)))) < 0.5 && b.text.trim().length >= 3 && b.text.trim().length <= 80 && b.bbox.height <= (_nullishCoalesce(_optionalChain([b, 'access', _306 => _306.style, 'optionalAccess', _307 => _307.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()));
|
|
7277
7324
|
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));
|
|
7278
7325
|
if (siblings.length < (numbered || lettered ? 1 : 2)) continue;
|
|
7279
7326
|
for (const sibling of siblings) {
|
|
@@ -7292,13 +7339,13 @@ function detectRepeatedPageLabels(blocks) {
|
|
|
7292
7339
|
}
|
|
7293
7340
|
for (const page of byPage.values()) {
|
|
7294
7341
|
const bodyChars = /* @__PURE__ */ new Map();
|
|
7295
|
-
for (const b of page) if (b.type === "paragraph" && b.text && _optionalChain([b, 'access',
|
|
7342
|
+
for (const b of page) if (b.type === "paragraph" && b.text && _optionalChain([b, 'access', _308 => _308.style, 'optionalAccess', _309 => _309.fontName])) {
|
|
7296
7343
|
const faces = FACE_CHARS.get(b);
|
|
7297
7344
|
if (faces) for (const [face, n] of faces) bodyChars.set(face, (_nullishCoalesce(bodyChars.get(face), () => ( 0))) + n);
|
|
7298
7345
|
else bodyChars.set(b.style.fontName, (_nullishCoalesce(bodyChars.get(b.style.fontName), () => ( 0))) + b.text.length);
|
|
7299
7346
|
}
|
|
7300
|
-
const bodyFace = _optionalChain([[...bodyChars], 'access',
|
|
7301
|
-
const candidates = page.filter((b) => b.type === "paragraph" && b.text && b.bbox && _optionalChain([b, 'access',
|
|
7347
|
+
const bodyFace = _optionalChain([[...bodyChars], 'access', _310 => _310.sort, 'call', _311 => _311((a, b) => b[1] - a[1]), 'access', _312 => _312[0], 'optionalAccess', _313 => _313[0]]);
|
|
7348
|
+
const candidates = page.filter((b) => b.type === "paragraph" && b.text && b.bbox && _optionalChain([b, 'access', _314 => _314.style, 'optionalAccess', _315 => _315.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);
|
|
7302
7349
|
const groups = /* @__PURE__ */ new Map();
|
|
7303
7350
|
for (const b of candidates) {
|
|
7304
7351
|
const key = `${b.style.fontName}:${b.style.fontSize}`;
|
|
@@ -7334,19 +7381,19 @@ function detectPageLeadHeadings(blocks) {
|
|
|
7334
7381
|
for (const page of byPage.values()) {
|
|
7335
7382
|
const content = page.filter((b) => b.type !== "image" && b.type !== "separator" && !(b.type === "paragraph" && !b.style));
|
|
7336
7383
|
const [first, second, third] = content;
|
|
7337
|
-
if (!_optionalChain([first, 'optionalAccess',
|
|
7384
|
+
if (!_optionalChain([first, 'optionalAccess', _316 => _316.bbox]) || !first.text || !_optionalChain([first, 'access', _317 => _317.style, 'optionalAccess', _318 => _318.fontSize]) || !second) continue;
|
|
7338
7385
|
const firstText = first.text.trim();
|
|
7339
7386
|
const captionLike = /^(?:Figure|Fig\.?|Table|표|그림)\s*\d/i;
|
|
7340
7387
|
const hasImage = page.some((b) => b.type === "image");
|
|
7341
|
-
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',
|
|
7388
|
+
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', _319 => _319.text, 'optionalAccess', _320 => _320.trim, 'call', _321 => _321()]), () => ( ""))) && (_nullishCoalesce(_optionalChain([second, 'access', _322 => _322.text, 'optionalAccess', _323 => _323.length]), () => ( 0))) >= 100 && second.bbox && first.bbox.y - (second.bbox.y + second.bbox.height) >= first.style.fontSize);
|
|
7342
7389
|
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);
|
|
7343
|
-
const firstIsSection = first.type === "list" && /^\d+\.\s+[A-Z][A-Z\s]{12,}$/.test(firstText) && second.type === "paragraph" && (_nullishCoalesce(_optionalChain([second, 'access',
|
|
7390
|
+
const firstIsSection = first.type === "list" && /^\d+\.\s+[A-Z][A-Z\s]{12,}$/.test(firstText) && second.type === "paragraph" && (_nullishCoalesce(_optionalChain([second, 'access', _324 => _324.text, 'optionalAccess', _325 => _325.length]), () => ( 0))) >= 100;
|
|
7344
7391
|
if (firstIsTitle || firstAboveProse || firstIsSection) {
|
|
7345
7392
|
first.type = "heading";
|
|
7346
7393
|
first.level = 1;
|
|
7347
7394
|
}
|
|
7348
|
-
if (first.type !== "heading" || captionLike.test(firstText) || second.type !== "paragraph" || !second.text || !second.bbox || !_optionalChain([second, 'access',
|
|
7349
|
-
const distinctFace = _optionalChain([third, 'access',
|
|
7395
|
+
if (first.type !== "heading" || captionLike.test(firstText) || second.type !== "paragraph" || !second.text || !second.bbox || !_optionalChain([second, 'access', _326 => _326.style, 'optionalAccess', _327 => _327.fontName]) || !second.style.fontSize || !_optionalChain([third, 'optionalAccess', _328 => _328.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;
|
|
7396
|
+
const distinctFace = _optionalChain([third, 'access', _329 => _329.style, 'optionalAccess', _330 => _330.fontName]) !== second.style.fontName;
|
|
7350
7397
|
const namedContents = /^Table of Contents$/i.test(second.text.trim());
|
|
7351
7398
|
if (distinctFace && third.text.length >= 60 || namedContents) {
|
|
7352
7399
|
second.type = "heading";
|
|
@@ -7357,24 +7404,24 @@ function detectPageLeadHeadings(blocks) {
|
|
|
7357
7404
|
function refineDocumentStyleHeadings(blocks) {
|
|
7358
7405
|
const faceChars = /* @__PURE__ */ new Map();
|
|
7359
7406
|
for (const block of blocks) {
|
|
7360
|
-
if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access',
|
|
7407
|
+
if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access', _331 => _331.style, 'optionalAccess', _332 => _332.fontName])) continue;
|
|
7361
7408
|
faceChars.set(block.style.fontName, (_nullishCoalesce(faceChars.get(block.style.fontName), () => ( 0))) + block.text.length);
|
|
7362
7409
|
}
|
|
7363
7410
|
const [bodyFace, bodyChars] = _nullishCoalesce([...faceChars].sort((a, b) => b[1] - a[1])[0], () => ( []));
|
|
7364
7411
|
if (!bodyFace || !bodyChars || bodyChars < 300) return;
|
|
7365
7412
|
for (let i = 0; i < blocks.length; i++) {
|
|
7366
7413
|
const block = blocks[i];
|
|
7367
|
-
const text = _nullishCoalesce(_optionalChain([block, 'access',
|
|
7414
|
+
const text = _nullishCoalesce(_optionalChain([block, 'access', _333 => _333.text, 'optionalAccess', _334 => _334.trim, 'call', _335 => _335()]), () => ( ""));
|
|
7368
7415
|
if (block.type === "heading" && /(?:https?:\/\/|www\.|^arxiv:|^doi:)/i.test(text)) {
|
|
7369
7416
|
block.type = "paragraph";
|
|
7370
7417
|
block.level = void 0;
|
|
7371
7418
|
continue;
|
|
7372
7419
|
}
|
|
7373
7420
|
const box = block.bbox, style = block.style;
|
|
7374
|
-
if (block.type !== "paragraph" || !box || !_optionalChain([style, 'optionalAccess',
|
|
7421
|
+
if (block.type !== "paragraph" || !box || !_optionalChain([style, 'optionalAccess', _336 => _336.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;
|
|
7375
7422
|
const previous = blocks[i - 1], next = blocks[i + 1];
|
|
7376
|
-
const pb = _optionalChain([previous, 'optionalAccess',
|
|
7377
|
-
if (!pb || !nb || previous.pageNumber !== block.pageNumber || next.pageNumber !== block.pageNumber || previous.type !== "paragraph" && previous.type !== "heading" || next.type !== "paragraph" || _optionalChain([next, 'access',
|
|
7423
|
+
const pb = _optionalChain([previous, 'optionalAccess', _337 => _337.bbox]), nb = _optionalChain([next, 'optionalAccess', _338 => _338.bbox]);
|
|
7424
|
+
if (!pb || !nb || previous.pageNumber !== block.pageNumber || next.pageNumber !== block.pageNumber || previous.type !== "paragraph" && previous.type !== "heading" || next.type !== "paragraph" || _optionalChain([next, 'access', _339 => _339.style, 'optionalAccess', _340 => _340.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;
|
|
7378
7425
|
block.type = "heading";
|
|
7379
7426
|
block.level = 2;
|
|
7380
7427
|
}
|
|
@@ -7424,7 +7471,7 @@ function detectMarkerHeadings(blocks) {
|
|
|
7424
7471
|
block.level = 4;
|
|
7425
7472
|
continue;
|
|
7426
7473
|
}
|
|
7427
|
-
if (/^[가-힣]{2,6}$/.test(text) && _optionalChain([block, 'access',
|
|
7474
|
+
if (/^[가-힣]{2,6}$/.test(text) && _optionalChain([block, 'access', _341 => _341.style, 'optionalAccess', _342 => _342.fontSize])) {
|
|
7428
7475
|
const prev = blocks[i - 1];
|
|
7429
7476
|
const next = blocks[i + 1];
|
|
7430
7477
|
const prevIsStructural = !prev || prev.type === "table" || prev.type === "heading" || prev.type === "separator";
|
|
@@ -7465,7 +7512,7 @@ function detectTableCaptions(blocks) {
|
|
|
7465
7512
|
block.table.caption = blocks[i - 1].text.trim();
|
|
7466
7513
|
blocks.splice(i - 1, 1);
|
|
7467
7514
|
i--;
|
|
7468
|
-
} else if (isCaptionCandidate(blocks[i + 1], block) && _optionalChain([blocks, 'access',
|
|
7515
|
+
} else if (isCaptionCandidate(blocks[i + 1], block) && _optionalChain([blocks, 'access', _343 => _343[i + 2], 'optionalAccess', _344 => _344.type]) !== "table") {
|
|
7469
7516
|
const cap = blocks[i + 1].bbox, tbl = block.bbox;
|
|
7470
7517
|
block.table.caption = blocks[i + 1].text.trim();
|
|
7471
7518
|
if (cap && tbl && cap.y + cap.height <= tbl.y + 1) block.table.captionBelow = true;
|
|
@@ -7550,7 +7597,7 @@ function detectKoreanListBlocks(blocks) {
|
|
|
7550
7597
|
}
|
|
7551
7598
|
const listType = label.family === "arabicDot" ? "ordered" : "unordered";
|
|
7552
7599
|
const listBlock = { ...b, type: "list", listType };
|
|
7553
|
-
const pb = _optionalChain([lastTopLevelList, 'optionalAccess',
|
|
7600
|
+
const pb = _optionalChain([lastTopLevelList, 'optionalAccess', _345 => _345.bbox]), cb = b.bbox;
|
|
7554
7601
|
const notIndented = depth > 0 && !!pb && !!cb && pb.page === cb.page && cb.x >= pb.x + pb.width && cb.y >= pb.y + pb.height;
|
|
7555
7602
|
if (notIndented) familyStack = [label.family];
|
|
7556
7603
|
if (depth === 0 || notIndented) {
|
|
@@ -7708,7 +7755,7 @@ function removeHeaderFooterBlocks(blocks, pageHeights, warnings, notes, tables =
|
|
|
7708
7755
|
const b = blocks[bi];
|
|
7709
7756
|
const cellTexts = b.type === "table" && b.table ? b.table.cells.flat().map((c) => c.text.trim()).filter(Boolean) : [];
|
|
7710
7757
|
const headBox = cellTexts.length <= 4 && !!b.bbox && b.bbox.height <= (_nullishCoalesce(pageHeights.get(b.bbox.page), () => ( Infinity))) * 0.05;
|
|
7711
|
-
const text = !tables ? _optionalChain([b, 'access',
|
|
7758
|
+
const text = !tables ? _optionalChain([b, 'access', _346 => _346.text, 'optionalAccess', _347 => _347.trim, 'call', _348 => _348()]) : cellTexts.length ? (headBox ? [...cellTexts].sort() : cellTexts).join(" | ") : void 0;
|
|
7712
7759
|
if (!b.bbox || !b.pageNumber || !text) continue;
|
|
7713
7760
|
const ph = pageHeights.get(b.bbox.page) || pageHeights.get(b.pageNumber);
|
|
7714
7761
|
if (!ph) continue;
|
|
@@ -7741,7 +7788,7 @@ function removeHeaderFooterBlocks(blocks, pageHeights, warnings, notes, tables =
|
|
|
7741
7788
|
for (const [p, count] of patternCount) {
|
|
7742
7789
|
const pages = [..._nullishCoalesce(patternPages.get(p), () => ( []))];
|
|
7743
7790
|
const span2 = pages.length ? Math.max(...pages) - Math.min(...pages) + 1 : 0;
|
|
7744
|
-
const varying = !tables && (_nullishCoalesce(_optionalChain([patternNumbers, 'access',
|
|
7791
|
+
const varying = !tables && (_nullishCoalesce(_optionalChain([patternNumbers, 'access', _349 => _349.get, 'call', _350 => _350(p), 'optionalAccess', _351 => _351.size]), () => ( 0))) > 1;
|
|
7745
7792
|
const occ = _nullishCoalesce(patternOcc.get(p), () => ( []));
|
|
7746
7793
|
const dense = pages.length >= span2 * 0.4;
|
|
7747
7794
|
const loose = looseVaryingNumber(occ, entries === topEntries) && (entries === bottomEntries || dense || tracksPages(occ));
|
|
@@ -7753,8 +7800,8 @@ function removeHeaderFooterBlocks(blocks, pageHeights, warnings, notes, tables =
|
|
|
7753
7800
|
for (const e of entries) {
|
|
7754
7801
|
const norm = e.text.replace(/\d+/g, "#");
|
|
7755
7802
|
if (!repeatedPatterns.has(norm)) continue;
|
|
7756
|
-
const noteMark = _optionalChain([e, 'access',
|
|
7757
|
-
if (noteMark && _optionalChain([notes, 'optionalAccess',
|
|
7803
|
+
const noteMark = _optionalChain([e, 'access', _352 => _352.text, 'access', _353 => _353.match, 'call', _354 => _354(/^\d{1,3}\)/), 'optionalAccess', _355 => _355[0]]);
|
|
7804
|
+
if (noteMark && _optionalChain([notes, 'optionalAccess', _356 => _356.get, 'call', _357 => _357(e.page), 'optionalAccess', _358 => _358.marks, 'access', _359 => _359.some, 'call', _360 => _360((m) => m.mark === noteMark)])) continue;
|
|
7758
7805
|
const cand = blocks[e.blockIdx];
|
|
7759
7806
|
const cb = cand.bbox;
|
|
7760
7807
|
const tableNote = /^(?:주\s*(?:\d+\s*[).:]|[::])|(?:자료|출처)\s*[::]|\*\s+\S)/.test(e.text.replace(/ \| /g, " ")) && blocks.some((o) => {
|
|
@@ -7768,7 +7815,7 @@ function removeHeaderFooterBlocks(blocks, pageHeights, warnings, notes, tables =
|
|
|
7768
7815
|
if (bi === e.blockIdx) continue;
|
|
7769
7816
|
const o = blocks[bi];
|
|
7770
7817
|
if (!o.bbox || o.bbox.page !== cb.page) continue;
|
|
7771
|
-
const oNorm = _optionalChain([o, 'access',
|
|
7818
|
+
const oNorm = _optionalChain([o, 'access', _361 => _361.text, 'optionalAccess', _362 => _362.trim, 'call', _363 => _363(), 'access', _364 => _364.replace, 'call', _365 => _365(/\d+/g, "#")]);
|
|
7772
7819
|
if (oNorm && repeatedPatterns.has(oNorm)) continue;
|
|
7773
7820
|
const overlap2 = Math.min(cb.y + cb.height, o.bbox.y + o.bbox.height) - Math.max(cb.y, o.bbox.y);
|
|
7774
7821
|
if (overlap2 >= cb.height * 0.5) {
|
|
@@ -7896,7 +7943,7 @@ function recordRowRules(table, cells, bbox, hs) {
|
|
|
7896
7943
|
function markImageCell(cell) {
|
|
7897
7944
|
IMAGE_CELLS.add(cell);
|
|
7898
7945
|
}
|
|
7899
|
-
var emptyCell = (cell) => !cell || !_optionalChain([cell, 'access',
|
|
7946
|
+
var emptyCell = (cell) => !cell || !_optionalChain([cell, 'access', _366 => _366.text, 'optionalAccess', _367 => _367.trim, 'call', _368 => _368()]) && !_optionalChain([cell, 'access', _369 => _369.blocks, 'optionalAccess', _370 => _370.length]) && !IMAGE_CELLS.has(cell);
|
|
7900
7947
|
function trimTable(table) {
|
|
7901
7948
|
let cols = table.cols;
|
|
7902
7949
|
while (cols > 0 && table.cells.every((row) => emptyCell(row[cols - 1]))) cols--;
|
|
@@ -7912,7 +7959,7 @@ function trimTable(table) {
|
|
|
7912
7959
|
function trimTrailingEmptyTableCols(blocks) {
|
|
7913
7960
|
for (const b of blocks) {
|
|
7914
7961
|
if (b.type !== "table" || !b.table) continue;
|
|
7915
|
-
for (const row of b.table.cells) for (const cell of row) if (_optionalChain([cell, 'access',
|
|
7962
|
+
for (const row of b.table.cells) for (const cell of row) if (_optionalChain([cell, 'access', _371 => _371.blocks, 'optionalAccess', _372 => _372.length])) trimTrailingEmptyTableCols(cell.blocks);
|
|
7916
7963
|
trimTable(b.table);
|
|
7917
7964
|
}
|
|
7918
7965
|
}
|
|
@@ -7932,7 +7979,7 @@ function mergeSliverColumns(grid, colXs, maxWidth) {
|
|
|
7932
7979
|
}
|
|
7933
7980
|
const ok = owner.every((row) => {
|
|
7934
7981
|
const o = row[c];
|
|
7935
|
-
return !!o && (o.colSpan > 1 || !o.text.trim() && !_optionalChain([o, 'access',
|
|
7982
|
+
return !!o && (o.colSpan > 1 || !o.text.trim() && !_optionalChain([o, 'access', _373 => _373.blocks, 'optionalAccess', _374 => _374.length]));
|
|
7936
7983
|
});
|
|
7937
7984
|
if (!ok) continue;
|
|
7938
7985
|
const spanning = /* @__PURE__ */ new Set();
|
|
@@ -7959,7 +8006,7 @@ var multiply = (m, t) => [
|
|
|
7959
8006
|
m[1] * t[4] + m[3] * t[5] + m[5]
|
|
7960
8007
|
];
|
|
7961
8008
|
function hollowCircle(image) {
|
|
7962
|
-
if (!_optionalChain([image, 'optionalAccess',
|
|
8009
|
+
if (!_optionalChain([image, 'optionalAccess', _375 => _375.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;
|
|
7963
8010
|
const stride = image.kind === _pdfmjs.ImageKind.RGB_24BPP ? 3 : image.kind === _pdfmjs.ImageKind.RGBA_32BPP ? 4 : 0;
|
|
7964
8011
|
const { width, height, data } = image;
|
|
7965
8012
|
if (!stride || data.length < width * height * stride) return false;
|
|
@@ -8024,9 +8071,9 @@ function smallVisibleImagePaints(fnArray, argsArray) {
|
|
|
8024
8071
|
const op = fnArray[i], args = argsArray[i];
|
|
8025
8072
|
if (op === _pdfmjs.OPS.save || op === _pdfmjs.OPS.paintFormXObjectBegin) {
|
|
8026
8073
|
stack.push({ ctm, alpha, clip, unknownClip });
|
|
8027
|
-
const matrix = op === _pdfmjs.OPS.paintFormXObjectBegin ? _optionalChain([args, 'optionalAccess',
|
|
8074
|
+
const matrix = op === _pdfmjs.OPS.paintFormXObjectBegin ? _optionalChain([args, 'optionalAccess', _376 => _376[0]]) : void 0;
|
|
8028
8075
|
if (Array.isArray(matrix) && matrix.length >= 6) ctm = multiply(ctm, matrix);
|
|
8029
|
-
const bounds = op === _pdfmjs.OPS.paintFormXObjectBegin ? _optionalChain([args, 'optionalAccess',
|
|
8076
|
+
const bounds = op === _pdfmjs.OPS.paintFormXObjectBegin ? _optionalChain([args, 'optionalAccess', _377 => _377[1]]) : void 0;
|
|
8030
8077
|
if (Array.isArray(bounds) && bounds.length === 4) {
|
|
8031
8078
|
const box = rectangle(bounds[0], bounds[1], bounds[2] - bounds[0], bounds[3] - bounds[1]);
|
|
8032
8079
|
if (box && ctm[1] === 0 && ctm[2] === 0) intersectClip(box);
|
|
@@ -8034,17 +8081,17 @@ function smallVisibleImagePaints(fnArray, argsArray) {
|
|
|
8034
8081
|
}
|
|
8035
8082
|
} else if (op === _pdfmjs.OPS.restore || op === _pdfmjs.OPS.paintFormXObjectEnd) {
|
|
8036
8083
|
const state = stack.pop();
|
|
8037
|
-
ctm = _nullishCoalesce(_optionalChain([state, 'optionalAccess',
|
|
8038
|
-
alpha = _nullishCoalesce(_optionalChain([state, 'optionalAccess',
|
|
8039
|
-
clip = _nullishCoalesce(_optionalChain([state, 'optionalAccess',
|
|
8040
|
-
unknownClip = _nullishCoalesce(_optionalChain([state, 'optionalAccess',
|
|
8084
|
+
ctm = _nullishCoalesce(_optionalChain([state, 'optionalAccess', _378 => _378.ctm]), () => ( [1, 0, 0, 1, 0, 0]));
|
|
8085
|
+
alpha = _nullishCoalesce(_optionalChain([state, 'optionalAccess', _379 => _379.alpha]), () => ( 1));
|
|
8086
|
+
clip = _nullishCoalesce(_optionalChain([state, 'optionalAccess', _380 => _380.clip]), () => ( null));
|
|
8087
|
+
unknownClip = _nullishCoalesce(_optionalChain([state, 'optionalAccess', _381 => _381.unknownClip]), () => ( false));
|
|
8041
8088
|
} else if (op === _pdfmjs.OPS.setGState) {
|
|
8042
|
-
for (const [key, value] of _nullishCoalesce(_optionalChain([args, 'optionalAccess',
|
|
8089
|
+
for (const [key, value] of _nullishCoalesce(_optionalChain([args, 'optionalAccess', _382 => _382[0]]), () => ( []))) {
|
|
8043
8090
|
if (key === "ca") alpha = typeof value === "number" ? value : 0;
|
|
8044
8091
|
}
|
|
8045
8092
|
} else if (op === _pdfmjs.OPS.constructPath) {
|
|
8046
8093
|
const [operations, coordinates] = args;
|
|
8047
|
-
pathRect = pathRect === void 0 && _optionalChain([operations, 'optionalAccess',
|
|
8094
|
+
pathRect = pathRect === void 0 && _optionalChain([operations, 'optionalAccess', _383 => _383.length]) === 1 && operations[0] === _pdfmjs.OPS.rectangle && _optionalChain([coordinates, 'optionalAccess', _384 => _384.length]) >= 4 && ctm[1] === 0 && ctm[2] === 0 ? rectangle(coordinates[0], coordinates[1], coordinates[2], coordinates[3]) : null;
|
|
8048
8095
|
} else if (op === _pdfmjs.OPS.clip || op === _pdfmjs.OPS.eoClip) pendingClip = true;
|
|
8049
8096
|
else if ([
|
|
8050
8097
|
_pdfmjs.OPS.endPath,
|
|
@@ -8064,7 +8111,7 @@ function smallVisibleImagePaints(fnArray, argsArray) {
|
|
|
8064
8111
|
pendingClip = false;
|
|
8065
8112
|
pathRect = void 0;
|
|
8066
8113
|
} else if (op === _pdfmjs.OPS.transform && Array.isArray(args) && args.length >= 6) ctm = multiply(ctm, args);
|
|
8067
|
-
else if (op === _pdfmjs.OPS.paintImageXObject && typeof _optionalChain([args, 'optionalAccess',
|
|
8114
|
+
else if (op === _pdfmjs.OPS.paintImageXObject && typeof _optionalChain([args, 'optionalAccess', _385 => _385[0]]) === "string") {
|
|
8068
8115
|
if (typeof args[1] !== "number" || typeof args[2] !== "number" || args[1] < 16 || args[1] > 128 || args[2] < 16 || args[2] > 128) continue;
|
|
8069
8116
|
const box = extractImageRegions([_pdfmjs.OPS.transform, _pdfmjs.OPS.paintImageXObject], [ctm, args])[0];
|
|
8070
8117
|
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;
|
|
@@ -8083,14 +8130,14 @@ async function restoreImageBullets(items, page, fnArray, argsArray, shapes = /*
|
|
|
8083
8130
|
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];
|
|
8084
8131
|
if (!line || /^[○●•◦□■∙]/.test(line.text.trim()) || !/\p{L}/u.test(line.text)) continue;
|
|
8085
8132
|
const row = items.filter((item) => Math.abs(item.y - line.y) <= 2 && item.x >= line.x);
|
|
8086
|
-
if (row.reduce((n, item) => n + (_nullishCoalesce(_optionalChain([item, 'access',
|
|
8133
|
+
if (row.reduce((n, item) => n + (_nullishCoalesce(_optionalChain([item, 'access', _386 => _386.text, 'access', _387 => _387.match, 'call', _388 => _388(/\p{L}/gu), 'optionalAccess', _389 => _389.length]), () => ( 0))), 0) < 12 || items.some((item) => item !== line && Math.abs(item.y - line.y) <= 2 && item.x < line.x)) continue;
|
|
8087
8134
|
candidates.push({ id, x: box.x1, width, line });
|
|
8088
8135
|
}
|
|
8089
8136
|
let restored = 0;
|
|
8090
8137
|
const used = /* @__PURE__ */ new Set();
|
|
8091
8138
|
for (const candidate of candidates) {
|
|
8092
8139
|
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);
|
|
8093
|
-
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',
|
|
8140
|
+
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', _390 => _390.text, 'access', _391 => _391.match, 'call', _392 => _392(/\p{L}/gu), 'optionalAccess', _393 => _393.length]), () => ( 0))) >= 12).sort((a, b) => b.y - a.y);
|
|
8094
8141
|
const numberedList = numbered.some((item, index) => index > 0 && item.text.trim().charCodeAt(0) === numbered[index - 1].text.trim().charCodeAt(0) + 1);
|
|
8095
8142
|
if (!same.length && !numberedList || used.has(candidate.line)) continue;
|
|
8096
8143
|
if (!shapes.has(candidate.id)) shapes.set(candidate.id, hollowCircle(await resolveImagePixels(page, candidate.id)));
|
|
@@ -8156,7 +8203,7 @@ function groupFlowBoxUnits(blocks, grids, hs, vs, images) {
|
|
|
8156
8203
|
return units;
|
|
8157
8204
|
}
|
|
8158
8205
|
function arrowDirection(image) {
|
|
8159
|
-
if (!_optionalChain([image, 'optionalAccess',
|
|
8206
|
+
if (!_optionalChain([image, 'optionalAccess', _394 => _394.data]) || image.width < 16 || image.width > 128 || image.height < 16 || image.height > 128) return 0;
|
|
8160
8207
|
const { width, height, data } = image;
|
|
8161
8208
|
const stride = image.kind === _pdfmjs.ImageKind.RGB_24BPP ? 3 : image.kind === _pdfmjs.ImageKind.RGBA_32BPP ? 4 : 0;
|
|
8162
8209
|
if (!stride || data.length < width * height * stride) return 0;
|
|
@@ -8224,7 +8271,7 @@ function isSideTabTable(box, table, others, pageWidth, pageHeight) {
|
|
|
8224
8271
|
function removeSideTabs(blocks, pageWidths) {
|
|
8225
8272
|
const edges = /* @__PURE__ */ new Map();
|
|
8226
8273
|
for (const b of blocks) {
|
|
8227
|
-
if (!b.bbox || b.pageNumber === void 0 || [..._nullishCoalesce(_optionalChain([b, 'access',
|
|
8274
|
+
if (!b.bbox || b.pageNumber === void 0 || [..._nullishCoalesce(_optionalChain([b, 'access', _395 => _395.text, 'optionalAccess', _396 => _396.trim, 'call', _397 => _397()]), () => ( ""))].length <= MAX_CHARS) continue;
|
|
8228
8275
|
const e = _nullishCoalesce(edges.get(b.pageNumber), () => ( { lefts: [], rights: [] }));
|
|
8229
8276
|
e.lefts.push(b.bbox.x);
|
|
8230
8277
|
e.rights.push(b.bbox.x + b.bbox.width);
|
|
@@ -8240,7 +8287,7 @@ function removeSideTabs(blocks, pageWidths) {
|
|
|
8240
8287
|
const fallback = all.length ? { left: q(all.map((e) => e.left), 0.5), right: q(all.map((e) => e.right), 0.5) } : void 0;
|
|
8241
8288
|
const key = (b) => {
|
|
8242
8289
|
const w = b.pageNumber !== void 0 ? pageWidths.get(b.pageNumber) : void 0;
|
|
8243
|
-
const text = _optionalChain([b, 'access',
|
|
8290
|
+
const text = _optionalChain([b, 'access', _398 => _398.text, 'optionalAccess', _399 => _399.trim, 'call', _400 => _400()]);
|
|
8244
8291
|
const area = _nullishCoalesce((b.pageNumber !== void 0 ? body.get(b.pageNumber) : void 0), () => ( fallback));
|
|
8245
8292
|
if (b.type === "table") {
|
|
8246
8293
|
if (!w || !b.bbox || !b.table || !SIDE_TAB_TABLES.has(b.table)) return null;
|
|
@@ -8906,16 +8953,16 @@ function isProseSpread(items) {
|
|
|
8906
8953
|
for (let i = 1; i < sorted.length; i++) {
|
|
8907
8954
|
gaps.push(sorted[i].x - (sorted[i - 1].x + sorted[i - 1].w));
|
|
8908
8955
|
}
|
|
8909
|
-
const maxGap =
|
|
8956
|
+
const maxGap = _chunkZTVH2HQ5cjs.safeMax.call(void 0, gaps);
|
|
8910
8957
|
const avgLen = items.reduce((s, i) => s + i.text.length, 0) / items.length;
|
|
8911
8958
|
if (items.length >= 4 && maxGap < 40 && avgLen < 5) return true;
|
|
8912
|
-
const minGap =
|
|
8959
|
+
const minGap = _chunkZTVH2HQ5cjs.safeMin.call(void 0, gaps);
|
|
8913
8960
|
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)));
|
|
8914
8961
|
}
|
|
8915
8962
|
function detectColumns(yLines) {
|
|
8916
8963
|
const allItems = yLines.flat();
|
|
8917
8964
|
if (allItems.length === 0) return null;
|
|
8918
|
-
const pageWidth =
|
|
8965
|
+
const pageWidth = _chunkZTVH2HQ5cjs.safeMax.call(void 0, allItems.map((i) => i.x + i.w)) - _chunkZTVH2HQ5cjs.safeMin.call(void 0, allItems.map((i) => i.x));
|
|
8919
8966
|
if (pageWidth < 100) return null;
|
|
8920
8967
|
let bigoLineIdx = -1;
|
|
8921
8968
|
for (let i = 0; i < yLines.length; i++) {
|
|
@@ -9140,7 +9187,7 @@ var UNDER_BOX_PAIR_MAX_EM = 2.2;
|
|
|
9140
9187
|
var UNDER_BOX_PAIR_OVERLAP = 0.8;
|
|
9141
9188
|
function markUnderlineItems(items, horizontals, verticals, nonRules) {
|
|
9142
9189
|
const underlines = [];
|
|
9143
|
-
if (_optionalChain([nonRules, 'optionalAccess',
|
|
9190
|
+
if (_optionalChain([nonRules, 'optionalAccess', _401 => _401.size])) horizontals = horizontals.filter((line) => !nonRules.has(line));
|
|
9144
9191
|
if (items.length === 0 || horizontals.length === 0) return underlines;
|
|
9145
9192
|
const tightOwners = /* @__PURE__ */ new Map();
|
|
9146
9193
|
const tightlyOwned = (line) => {
|
|
@@ -9246,7 +9293,7 @@ function hasBoxTopPair(line, maxH, horizontals, cellItems) {
|
|
|
9246
9293
|
if (ow <= 0) continue;
|
|
9247
9294
|
const overlap2 = Math.min(line.x2, o.x2) - Math.max(line.x1, o.x1);
|
|
9248
9295
|
if (overlap2 / Math.max(w, ow) < UNDER_BOX_PAIR_OVERLAP) continue;
|
|
9249
|
-
const covered = _nullishCoalesce(_optionalChain([cellItems, 'optionalAccess',
|
|
9296
|
+
const covered = _nullishCoalesce(_optionalChain([cellItems, 'optionalAccess', _402 => _402.reduce, 'call', _403 => _403((sum, item) => {
|
|
9250
9297
|
const below = item.y - o.y1;
|
|
9251
9298
|
if (below < 0.5 || below > 3 || !item.text.trim()) return sum;
|
|
9252
9299
|
return sum + Math.max(0, Math.min(o.x2, item.x + item.w) - Math.max(o.x1, item.x));
|
|
@@ -9313,13 +9360,13 @@ function partTex(group) {
|
|
|
9313
9360
|
const base = Math.min(...g.filter((i) => i.fontSize >= size * SCRIPT_SIZE_RATIO).map((i) => i.y));
|
|
9314
9361
|
let s = "", run = "";
|
|
9315
9362
|
const flush = () => {
|
|
9316
|
-
if (run) s +=
|
|
9363
|
+
if (run) s += _chunkL4GCUYDScjs.toTex.call(void 0, run);
|
|
9317
9364
|
run = "";
|
|
9318
9365
|
};
|
|
9319
9366
|
g.forEach((it, k) => {
|
|
9320
9367
|
if (it.fontSize < size * SCRIPT_SIZE_RATIO && it.y - base >= size * SCRIPT_RISE_EM) {
|
|
9321
9368
|
flush();
|
|
9322
|
-
s += `^{${
|
|
9369
|
+
s += `^{${_chunkL4GCUYDScjs.toTex.call(void 0, it.text)}}`;
|
|
9323
9370
|
return;
|
|
9324
9371
|
}
|
|
9325
9372
|
if (k && it.x - (g[k - 1].x + g[k - 1].w) > spaceGapThreshold(it.fontSize)) run += " ";
|
|
@@ -9492,12 +9539,12 @@ function rebuildUnitLine(items, grid) {
|
|
|
9492
9539
|
function prependUnitRow(cells, cols, line, usedItems) {
|
|
9493
9540
|
const text = cleanCellText(line.map((item) => item.text).join(""));
|
|
9494
9541
|
cells.unshift(Array.from({ length: cols }, (_, c) => ({ text: c === 0 ? text : "", colSpan: c === 0 ? cols : 1, rowSpan: 1 })));
|
|
9495
|
-
for (const cell of cells[0])
|
|
9542
|
+
for (const cell of cells[0]) _chunkL4GCUYDScjs.CELL_EDGES.set(cell, NO_EDGES);
|
|
9496
9543
|
for (const item of line) usedItems.add(item);
|
|
9497
9544
|
}
|
|
9498
9545
|
function attachUnitRow(items, grid, cells, cols, usedItems) {
|
|
9499
9546
|
const all = cells.flat();
|
|
9500
|
-
if (all.filter((c) => c.text.trim()).length * 2 < all.length || UNIT.test(_nullishCoalesce(_optionalChain([cells, 'access',
|
|
9547
|
+
if (all.filter((c) => c.text.trim()).length * 2 < all.length || UNIT.test(_nullishCoalesce(_optionalChain([cells, 'access', _404 => _404[0], 'optionalAccess', _405 => _405[0], 'optionalAccess', _406 => _406.text]), () => ( "")))) return false;
|
|
9501
9548
|
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);
|
|
9502
9549
|
let nearest = Infinity;
|
|
9503
9550
|
for (const it of above) nearest = Math.min(nearest, it.y);
|
|
@@ -9532,7 +9579,7 @@ function closeShadedTableEdges(clipGrids, horizontals, verticals, fillRects) {
|
|
|
9532
9579
|
let hs = horizontals, vs = verticals;
|
|
9533
9580
|
const restored = [];
|
|
9534
9581
|
for (const grid of clipGrids) {
|
|
9535
|
-
if (grid.clipParent || grid.rowYs.length !== 2 || grid.colXs.length < 3 || !_optionalChain([grid, 'access',
|
|
9582
|
+
if (grid.clipParent || grid.rowYs.length !== 2 || grid.colXs.length < 3 || !_optionalChain([grid, 'access', _407 => _407.cells, 'optionalAccess', _408 => _408.length]) || grid.cells.some((c) => c.filler || c.rowSpan !== 1 || c.colSpan !== 1)) continue;
|
|
9536
9583
|
const { x1, x2, y1: mid, y2: top } = grid.bbox;
|
|
9537
9584
|
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;
|
|
9538
9585
|
const topRule = hs.find((h) => near2(h.y1, top) && near2(h.x1, x1) && near2(h.x2, x2));
|
|
@@ -9996,7 +10043,7 @@ function takeFrameSpanningText(items, cutX, pageNum, lex) {
|
|
|
9996
10043
|
const rows = groupByY([...items].sort((a, b) => b.y - a.y || a.x - b.x)).map((line) => {
|
|
9997
10044
|
const runs = [];
|
|
9998
10045
|
for (const item of [...line].sort((a, b) => a.x - b.x)) {
|
|
9999
|
-
const run = runs[runs.length - 1], prev = _optionalChain([run, 'optionalAccess',
|
|
10046
|
+
const run = runs[runs.length - 1], prev = _optionalChain([run, 'optionalAccess', _409 => _409[run.length - 1]]);
|
|
10000
10047
|
if (prev && item.x - (prev.x + prev.w) <= Math.max(prev.fontSize, item.fontSize) * 0.6) run.push(item);
|
|
10001
10048
|
else runs.push([item]);
|
|
10002
10049
|
}
|
|
@@ -10040,7 +10087,7 @@ function groupFrameParagraphUnits(units, frames) {
|
|
|
10040
10087
|
for (const unit of units) for (const block of unit) source.set(block, unit);
|
|
10041
10088
|
const members = /* @__PURE__ */ new Map(), emitted = /* @__PURE__ */ new Set();
|
|
10042
10089
|
for (const frame of frames) {
|
|
10043
|
-
if (frame.length < 2 || frame.some((block) => block.type !== "paragraph" || _optionalChain([source, 'access',
|
|
10090
|
+
if (frame.length < 2 || frame.some((block) => block.type !== "paragraph" || _optionalChain([source, 'access', _410 => _410.get, 'call', _411 => _411(block), 'optionalAccess', _412 => _412.length]) !== 1)) continue;
|
|
10044
10091
|
for (const block of frame) members.set(block, frame);
|
|
10045
10092
|
}
|
|
10046
10093
|
const out = [];
|
|
@@ -10053,7 +10100,7 @@ function groupFrameParagraphUnits(units, frames) {
|
|
|
10053
10100
|
}
|
|
10054
10101
|
}
|
|
10055
10102
|
for (const unit of out) {
|
|
10056
|
-
if (unit.length < 2 || _optionalChain([FRAME_READING_UNITS, 'access',
|
|
10103
|
+
if (unit.length < 2 || _optionalChain([FRAME_READING_UNITS, 'access', _413 => _413.get, 'call', _414 => _414(unit[0]), 'optionalAccess', _415 => _415.blocks]) === unit) continue;
|
|
10057
10104
|
const bs = unit.map((b) => b.bbox).filter((b) => !!b);
|
|
10058
10105
|
if (bs.length !== unit.length) continue;
|
|
10059
10106
|
const x = Math.min(...bs.map((b) => b.x)), y = Math.min(...bs.map((b) => b.y));
|
|
@@ -10070,14 +10117,14 @@ function groupFrameParagraphUnits(units, frames) {
|
|
|
10070
10117
|
function recordFrameTitle(table, source, pageNum) {
|
|
10071
10118
|
if (!CLIP_TABLES.has(table) || table.rows !== 1 || table.cols !== 3 || source.length < 2) return;
|
|
10072
10119
|
const cells = table.cells[0];
|
|
10073
|
-
if (cells.length !== 3 || cells.some((c) => c.colSpan !== 1 || c.rowSpan !== 1 || _optionalChain([c, 'access',
|
|
10120
|
+
if (cells.length !== 3 || cells.some((c) => c.colSpan !== 1 || c.rowSpan !== 1 || _optionalChain([c, 'access', _416 => _416.blocks, 'optionalAccess', _417 => _417.length]) || c.text.includes("\n"))) return;
|
|
10074
10121
|
const [label, spacer, title] = cells;
|
|
10075
10122
|
if (!/^(?:붙임|별첨|첨부|부록)\s*\d{1,3}$/.test(label.text.trim()) || spacer.text.trim() || !title.text.trim()) return;
|
|
10076
10123
|
if (cells.some((c) => {
|
|
10077
|
-
const e =
|
|
10124
|
+
const e = _chunkL4GCUYDScjs.CELL_EDGES.get(c);
|
|
10078
10125
|
return !e || e.t || e.b || e.l || e.r;
|
|
10079
10126
|
})) return;
|
|
10080
|
-
const xs = TABLE_COLXS.get(table), style = dominantStyle(source), fs = _nullishCoalesce(_optionalChain([style, 'optionalAccess',
|
|
10127
|
+
const xs = TABLE_COLXS.get(table), style = dominantStyle(source), fs = _nullishCoalesce(_optionalChain([style, 'optionalAccess', _418 => _418.fontSize]), () => ( 0));
|
|
10081
10128
|
if (!xs || xs.length !== 4 || fs <= 0) return;
|
|
10082
10129
|
const width = xs[3] - xs[0], gap = xs[2] - xs[1];
|
|
10083
10130
|
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;
|
|
@@ -10141,7 +10188,7 @@ function extendNestedShadedHeaders(clipGrids, lineGrids, horizontals, verticals,
|
|
|
10141
10188
|
const extended = [];
|
|
10142
10189
|
for (let i = 0; i < clipGrids.length; i++) {
|
|
10143
10190
|
const c = clipGrids[i], parent = c.clipParent;
|
|
10144
|
-
if (!parent || c.rowYs.length !== 2 || c.colXs.length < 3 || !_optionalChain([c, 'access',
|
|
10191
|
+
if (!parent || c.rowYs.length !== 2 || c.colXs.length < 3 || !_optionalChain([c, 'access', _419 => _419.cells, 'optionalAccess', _420 => _420.length]) || c.cells.some((cell) => cell.filler || cell.rowSpan !== 1 || cell.colSpan !== 1)) continue;
|
|
10145
10192
|
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;
|
|
10146
10193
|
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;
|
|
10147
10194
|
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)));
|
|
@@ -10164,7 +10211,7 @@ function attachSideTabBlocks(tab, body, pageNum) {
|
|
|
10164
10211
|
bbox: computeBBox(items, pageNum),
|
|
10165
10212
|
style: dominantStyle(items)
|
|
10166
10213
|
});
|
|
10167
|
-
const prefix = ordered.filter((g) => !_optionalChain([caps, 'optionalAccess',
|
|
10214
|
+
const prefix = ordered.filter((g) => !_optionalChain([caps, 'optionalAccess', _421 => _421.has, 'call', _422 => _422(g)])).map((g) => ({
|
|
10168
10215
|
type: "paragraph",
|
|
10169
10216
|
text: g.text.trim(),
|
|
10170
10217
|
pageNumber: pageNum,
|
|
@@ -10173,7 +10220,7 @@ function attachSideTabBlocks(tab, body, pageNum) {
|
|
|
10173
10220
|
}));
|
|
10174
10221
|
const groups = /* @__PURE__ */ new Map();
|
|
10175
10222
|
for (const g of ordered) {
|
|
10176
|
-
const cap = _optionalChain([caps, 'optionalAccess',
|
|
10223
|
+
const cap = _optionalChain([caps, 'optionalAccess', _423 => _423.get, 'call', _424 => _424(g)]);
|
|
10177
10224
|
if (cap) groups.set(cap, [..._nullishCoalesce(groups.get(cap), () => ( [])), g]);
|
|
10178
10225
|
}
|
|
10179
10226
|
for (const [cap, glyphs] of groups) {
|
|
@@ -10205,7 +10252,7 @@ function extractPageBlocksWithLines(items, pageNum, opList, pageWidth, pageHeigh
|
|
|
10205
10252
|
let prev = null;
|
|
10206
10253
|
for (const line of streamLines(items)) {
|
|
10207
10254
|
lex.addLine(mergeLineSimple(line));
|
|
10208
|
-
const fs = _nullishCoalesce(_optionalChain([dominantStyle, 'call',
|
|
10255
|
+
const fs = _nullishCoalesce(_optionalChain([dominantStyle, 'call', _425 => _425(line), 'optionalAccess', _426 => _426.fontSize]), () => ( 0));
|
|
10209
10256
|
const left = Math.min(...line.map((i) => i.x)), right = Math.max(...line.map((i) => i.x + i.w));
|
|
10210
10257
|
const y = line.reduce((n, i) => n + i.y, 0) / line.length;
|
|
10211
10258
|
const wide = fs > 0 && right - left >= 12 * fs;
|
|
@@ -10219,7 +10266,7 @@ function extractPageBlocksWithLines(items, pageNum, opList, pageWidth, pageHeigh
|
|
|
10219
10266
|
const filled = fillBlanks(items, horizontals, verticals);
|
|
10220
10267
|
items = filled.items;
|
|
10221
10268
|
horizontals = filled.horizontals;
|
|
10222
|
-
const prevPage = _optionalChain([carry, 'optionalAccess',
|
|
10269
|
+
const prevPage = _optionalChain([carry, 'optionalAccess', _427 => _427.page]) === pageNum - 1 ? carry.clip : void 0;
|
|
10223
10270
|
const images = extractImageRegions(opList.fnArray, opList.argsArray);
|
|
10224
10271
|
const clipRects = images.length ? withoutImageOnlyClips(extracted.clipRects, images) : extracted.clipRects;
|
|
10225
10272
|
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 };
|
|
@@ -10517,7 +10564,7 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
|
|
|
10517
10564
|
const nested = pendingNested.length ? takePendingNested(pendingNested, cell.bbox, !!grid.cells) : [];
|
|
10518
10565
|
const lone = nested.length === 1 && !cellItems.length ? nested[0] : null;
|
|
10519
10566
|
const cw = cell.bbox.x2 - cell.bbox.x1;
|
|
10520
|
-
if (_optionalChain([lone, 'optionalAccess',
|
|
10567
|
+
if (_optionalChain([lone, 'optionalAccess', _428 => _428.table]) && lone.bbox && lone.table.rows === 1 && lone.table.cols === 1 && CLIP_TABLES.has(lone.table) && !_optionalChain([lone, 'access', _429 => _429.table, 'access', _430 => _430.cells, 'access', _431 => _431[0], 'access', _432 => _432[0], 'access', _433 => _433.blocks, 'optionalAccess', _434 => _434.some, 'call', _435 => _435((b2) => b2.type === "table")]) && lone.bbox.width >= cw * 0.9 && /^[^\n]{1,30}$/.test(lone.table.cells[0][0].text.trim())) {
|
|
10521
10568
|
irGrid[cell.row][cell.col] = { text: lone.table.cells[0][0].text, colSpan: cell.colSpan, rowSpan: cell.rowSpan };
|
|
10522
10569
|
takeClipCellEdges(cell, irGrid[cell.row][cell.col]);
|
|
10523
10570
|
continue;
|
|
@@ -10567,10 +10614,10 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
|
|
|
10567
10614
|
const ls = irGrid.slice(1).flat().flatMap((c) => c.text.split("\n")).map((t) => t.trim()).filter(Boolean);
|
|
10568
10615
|
const numericLine = (t) => {
|
|
10569
10616
|
const cs = t.replace(/\s+/g, "");
|
|
10570
|
-
return cs.length > 0 && (_nullishCoalesce(_optionalChain([cs, 'access',
|
|
10617
|
+
return cs.length > 0 && (_nullishCoalesce(_optionalChain([cs, 'access', _436 => _436.match, 'call', _437 => _437(/[\d.,%()+\-−–—△▲▽▼]/g), 'optionalAccess', _438 => _438.length]), () => ( 0))) >= cs.length * 0.85;
|
|
10571
10618
|
};
|
|
10572
10619
|
const labelValueLine = (t) => {
|
|
10573
|
-
const hangul = _nullishCoalesce(_optionalChain([t, 'access',
|
|
10620
|
+
const hangul = _nullishCoalesce(_optionalChain([t, 'access', _439 => _439.match, 'call', _440 => _440(/[가-힣]/g), 'optionalAccess', _441 => _441.length]), () => ( 0));
|
|
10574
10621
|
return hangul > 0 && hangul <= 6 && /\d,\d{3}/.test(t) && numericLine(t.replace(/[가-힣()]/g, ""));
|
|
10575
10622
|
};
|
|
10576
10623
|
const bulletLine = (t) => /^\s*[○◦•□■▪]/.test(t) || /^\s*-\s*[^\d\s.,−-]/.test(t) && t.replace(/\s+/g, "").length > 7;
|
|
@@ -10580,14 +10627,14 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
|
|
|
10580
10627
|
const share = ls.filter((t) => numericLine(t) || lvLines.has(t)).length / ls.length;
|
|
10581
10628
|
if (share >= 0.5) return true;
|
|
10582
10629
|
const colShares = Array.from({ length: numCols }, (_, c) => {
|
|
10583
|
-
const cl = irGrid.slice(1).flatMap((row) => (_nullishCoalesce(_optionalChain([row, 'access',
|
|
10630
|
+
const cl = irGrid.slice(1).flatMap((row) => (_nullishCoalesce(_optionalChain([row, 'access', _442 => _442[c], 'optionalAccess', _443 => _443.text]), () => ( ""))).split("\n")).map((t) => t.trim()).filter(Boolean);
|
|
10584
10631
|
return cl.length ? cl.filter(numericLine).length / cl.length : null;
|
|
10585
10632
|
}).filter((v) => v !== null);
|
|
10586
10633
|
return share >= 0.35 && colShares.some((v) => v >= 0.8) && colShares.every((v) => v >= 0.8 || v <= 0.2);
|
|
10587
10634
|
})();
|
|
10588
10635
|
const layoutProse = irGrid.some((row) => row.some((c) => c.colSpan >= numCols - 1 && c.text.length > 60));
|
|
10589
10636
|
const maxRows = numericBody ? layoutProse ? OCR_NUMERIC_MAX_ROWS_FRAMED : OCR_NUMERIC_MAX_ROWS : 5;
|
|
10590
|
-
const proseLine = (t) => (_nullishCoalesce(_optionalChain([t, 'access',
|
|
10637
|
+
const proseLine = (t) => (_nullishCoalesce(_optionalChain([t, 'access', _444 => _444.match, 'call', _445 => _445(/[가-힣]/g), 'optionalAccess', _446 => _446.length]), () => ( 0))) > 6 && !/^[-−]?[\d,.]+$/.test(t.replace(/\s+/g, ""));
|
|
10591
10638
|
const proseCols = numRows === 2 ? (_nullishCoalesce(irGrid[1], () => ( []))).filter((c) => {
|
|
10592
10639
|
const ls = c.text.split("\n").map((t) => t.trim()).filter(Boolean);
|
|
10593
10640
|
return ls.length >= 3 && ls.filter(proseLine).length >= ls.length * 0.6;
|
|
@@ -10608,8 +10655,8 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
|
|
|
10608
10655
|
finalGrid = rebuilt.map((row, i) => {
|
|
10609
10656
|
const o = kept.get(i);
|
|
10610
10657
|
return row.map((rawText, c) => {
|
|
10611
|
-
const src = o === void 0 ? void 0 : _optionalChain([irGrid, 'access',
|
|
10612
|
-
return { text: cleanCellText(rawText), colSpan: _nullishCoalesce(_optionalChain([src, 'optionalAccess',
|
|
10658
|
+
const src = o === void 0 ? void 0 : _optionalChain([irGrid, 'access', _447 => _447[o], 'optionalAccess', _448 => _448[c]]);
|
|
10659
|
+
return { text: cleanCellText(rawText), colSpan: _nullishCoalesce(_optionalChain([src, 'optionalAccess', _449 => _449.colSpan]), () => ( 1)), rowSpan: src ? spanRows(o, src.rowSpan) : 1 };
|
|
10613
10660
|
});
|
|
10614
10661
|
});
|
|
10615
10662
|
finalRows = finalGrid.length;
|
|
@@ -10629,14 +10676,14 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
|
|
|
10629
10676
|
if (!assignedItems.has(textItems[ti]) && !inExpanded(textItems[ti])) usedItems.delete(owners[ti]);
|
|
10630
10677
|
}
|
|
10631
10678
|
}
|
|
10632
|
-
if (unitLine.length > 0 && rebuiltUsed && !/^\s*\(\s*단위\s*[::]/.test(_nullishCoalesce(_optionalChain([finalGrid, 'access',
|
|
10679
|
+
if (unitLine.length > 0 && rebuiltUsed && !/^\s*\(\s*단위\s*[::]/.test(_nullishCoalesce(_optionalChain([finalGrid, 'access', _450 => _450[0], 'optionalAccess', _451 => _451[0], 'optionalAccess', _452 => _452.text]), () => ( "")))) {
|
|
10633
10680
|
prependUnitRow(finalGrid, numCols, unitLine, usedItems);
|
|
10634
10681
|
finalRows++;
|
|
10635
10682
|
}
|
|
10636
10683
|
if (!rebuiltUsed && attachUnitRow(items, grid, finalGrid, numCols, usedItems)) finalRows++;
|
|
10637
10684
|
let semanticOneColumn = false;
|
|
10638
10685
|
if (!grid.cells && !nestedAttached && numCols === 1 && numGridRows >= 2) {
|
|
10639
|
-
const populatedRows = finalGrid.filter((row) => _optionalChain([row, 'access',
|
|
10686
|
+
const populatedRows = finalGrid.filter((row) => _optionalChain([row, 'access', _453 => _453[0], 'optionalAccess', _454 => _454.text, 'access', _455 => _455.trim, 'call', _456 => _456()]));
|
|
10640
10687
|
if (populatedRows.length >= 4) {
|
|
10641
10688
|
const fontSizes = tableItems.map((item) => item.fontSize).filter((size) => size > 0).sort((a, b) => a - b);
|
|
10642
10689
|
const medianFont = _nullishCoalesce(fontSizes[Math.floor(fontSizes.length / 2)], () => ( 0));
|
|
@@ -10734,7 +10781,7 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
|
|
|
10734
10781
|
height: grid.bbox.y2 - grid.bbox.y1
|
|
10735
10782
|
};
|
|
10736
10783
|
if (numRows === 1 && numCols === 1 && gridW < pageWidth * 0.35) {
|
|
10737
|
-
const prose = _nullishCoalesce(_optionalChain([finalGrid, 'access',
|
|
10784
|
+
const prose = _nullishCoalesce(_optionalChain([finalGrid, 'access', _457 => _457[0], 'optionalAccess', _458 => _458[0], 'optionalAccess', _459 => _459.text]), () => ( ""));
|
|
10738
10785
|
const besideLines = (side) => new Set(side.map((it) => Math.round(it.y / 3))).size;
|
|
10739
10786
|
const rightLines = items.filter((it) => it.x >= grid.bbox.x2 + 3 && it.y >= grid.bbox.y1 && it.y <= grid.bbox.y2);
|
|
10740
10787
|
const leftLines = items.filter((it) => it.x + it.w <= grid.bbox.x1 - 3 && it.y >= grid.bbox.y1 && it.y <= grid.bbox.y2);
|
|
@@ -10753,8 +10800,8 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
|
|
|
10753
10800
|
}
|
|
10754
10801
|
}
|
|
10755
10802
|
if (!grid.cells && !nestedAttached && shouldDemoteTable(irTable)) {
|
|
10756
|
-
const paragraphs = numRows === 1 && numCols === 1 ? _optionalChain([irTable, 'access',
|
|
10757
|
-
if (_optionalChain([paragraphs, 'optionalAccess',
|
|
10803
|
+
const paragraphs = numRows === 1 && numCols === 1 ? _optionalChain([irTable, 'access', _460 => _460.cells, 'access', _461 => _461[0], 'optionalAccess', _462 => _462[0], 'optionalAccess', _463 => _463.blocks]) : void 0;
|
|
10804
|
+
if (_optionalChain([paragraphs, 'optionalAccess', _464 => _464.length])) {
|
|
10758
10805
|
blocks.push(...paragraphs);
|
|
10759
10806
|
frameParagraphUnits.push(paragraphs);
|
|
10760
10807
|
recordFrameReadingUnit(paragraphs, tableBbox);
|
|
@@ -10801,7 +10848,7 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
|
|
|
10801
10848
|
const clusterResults = (proseColumns ? [] : detectClusterTables(clusterItems, pageNum, void 0, lex)).filter((cr) => {
|
|
10802
10849
|
const b = cr.bbox;
|
|
10803
10850
|
const overlapX = (x) => Math.min(x.x + x.width, b.x + b.width) - Math.max(x.x, b.x);
|
|
10804
|
-
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',
|
|
10851
|
+
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', _465 => _465.text, 'optionalAccess', _466 => _466.match, 'call', _467 => _467(/\p{L}/gu), 'optionalAccess', _468 => _468.length]), () => ( 0))) >= 10 && overlapX(x.bbox) >= 0.8 * b.width : x.type === "table" && !ocrPage && _optionalChain([x, 'access', _469 => _469.table, 'optionalAccess', _470 => _470.cols]) === cr.table.cols && overlapX(x.bbox) >= 0.5 * Math.min(x.bbox.width, b.width)));
|
|
10805
10852
|
});
|
|
10806
10853
|
if (clusterResults.length > 0) {
|
|
10807
10854
|
const ciToIdx = /* @__PURE__ */ new Map();
|
|
@@ -10838,13 +10885,13 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
|
|
|
10838
10885
|
groupSizes.push(1);
|
|
10839
10886
|
}
|
|
10840
10887
|
const allY = remaining.map((i) => i.y);
|
|
10841
|
-
const pageH =
|
|
10888
|
+
const pageH = _chunkZTVH2HQ5cjs.safeMax.call(void 0, allY) - _chunkZTVH2HQ5cjs.safeMin.call(void 0, allY);
|
|
10842
10889
|
const gapThreshold = Math.max(15, pageH * 0.03);
|
|
10843
10890
|
const sides = frameColumnTextBands(remaining, spanning, gx);
|
|
10844
10891
|
const textBlocks = [];
|
|
10845
10892
|
for (const side of sides) {
|
|
10846
10893
|
if (side.length === 0) continue;
|
|
10847
|
-
for (const group of xyCutOrder(side, gapThreshold)) {
|
|
10894
|
+
for (const group of xyCutOrder(side, gapThreshold, 0, void 0, 0, lex)) {
|
|
10848
10895
|
if (group.length === 0) continue;
|
|
10849
10896
|
const groupBlocks = extractPageBlocksFallback(group, pageNum, false, true, lex, [], chartBandGap(group, gapThreshold, charts));
|
|
10850
10897
|
for (const b of groupBlocks) textBlocks.push(b);
|
|
@@ -10854,9 +10901,9 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
|
|
|
10854
10901
|
finalTextBlocks.push(...detectListBlocks(textBlocks));
|
|
10855
10902
|
} else {
|
|
10856
10903
|
const allY = remaining.map((i) => i.y);
|
|
10857
|
-
const pageH =
|
|
10904
|
+
const pageH = _chunkZTVH2HQ5cjs.safeMax.call(void 0, allY) - _chunkZTVH2HQ5cjs.safeMin.call(void 0, allY);
|
|
10858
10905
|
const gapThreshold = Math.max(15, pageH * 0.03);
|
|
10859
|
-
const groups = xyCutOrder(remaining, gapThreshold);
|
|
10906
|
+
const groups = xyCutOrder(remaining, gapThreshold, 0, void 0, 0, lex);
|
|
10860
10907
|
const textBlocks = [];
|
|
10861
10908
|
for (const group of groups) {
|
|
10862
10909
|
if (group.length === 0) continue;
|
|
@@ -11216,9 +11263,9 @@ function extractPageBlocksFallback(items, pageNum, fullPage = false, detectTable
|
|
|
11216
11263
|
blocks.push(...columnTextToBlocks(tableText, pageNum, bbox, dominantStyle(items)));
|
|
11217
11264
|
} else {
|
|
11218
11265
|
const allY = items.map((i) => i.y);
|
|
11219
|
-
const pageHeight =
|
|
11266
|
+
const pageHeight = _chunkZTVH2HQ5cjs.safeMax.call(void 0, allY) - _chunkZTVH2HQ5cjs.safeMin.call(void 0, allY);
|
|
11220
11267
|
const gapThreshold = Math.max(15, pageHeight * 0.03);
|
|
11221
|
-
const orderedGroups = proseCutX !== null ? splitTwoColumnProse(items, proseCutX) : xyCutOrder(items, gapThreshold, 0, void 0, minGap);
|
|
11268
|
+
const orderedGroups = proseCutX !== null ? splitTwoColumnProse(items, proseCutX) : xyCutOrder(items, gapThreshold, 0, void 0, minGap, lex);
|
|
11222
11269
|
for (const group of orderedGroups) {
|
|
11223
11270
|
if (group.length === 0) continue;
|
|
11224
11271
|
const yLines = mergeSuperscriptLines(groupByY(group));
|
|
@@ -11273,19 +11320,19 @@ function mergeOcrImageRegions(blocks, page, regions, ocrBlocks) {
|
|
|
11273
11320
|
const overlapH = Math.max(0, Math.min(b.y + b.height, region.y2) - Math.max(b.y, region.y1));
|
|
11274
11321
|
return overlapW * overlapH >= b.width * b.height * 0.8;
|
|
11275
11322
|
});
|
|
11276
|
-
const labels = candidates.filter((b) => b.type === "paragraph" && b.bbox.height <= 24 && (_nullishCoalesce(_optionalChain([b, 'access',
|
|
11323
|
+
const labels = candidates.filter((b) => b.type === "paragraph" && b.bbox.height <= 24 && (_nullishCoalesce(_optionalChain([b, 'access', _471 => _471.text, 'optionalAccess', _472 => _472.match, 'call', _473 => _473(/[\p{L}\p{N}]/gu), 'optionalAccess', _474 => _474.length]), () => ( 0))) >= 2);
|
|
11277
11324
|
const axisFragments = rotatedAxisFragments(candidates);
|
|
11278
11325
|
const accepted = candidates.filter((b) => {
|
|
11279
|
-
if (b.type === "paragraph") return (_nullishCoalesce(_optionalChain([b, 'access',
|
|
11326
|
+
if (b.type === "paragraph") return (_nullishCoalesce(_optionalChain([b, 'access', _475 => _475.text, 'optionalAccess', _476 => _476.match, 'call', _477 => _477(/[\p{L}\p{N}]/gu), 'optionalAccess', _478 => _478.length]), () => ( 0))) >= 2 || !axisFragments.has(b) && (supportedDiagramLabel(b, labels, region) || axisTick(b, candidates));
|
|
11280
11327
|
const t = b.table;
|
|
11281
11328
|
if (b.type !== "table" || !t || UNRULED_REGION_TABLES.has(b)) return false;
|
|
11282
11329
|
const lone = t.cells.filter((row) => row.filter((c) => c.text.trim()).length === 1 && row.some((c) => c.colSpan === t.cols)).length;
|
|
11283
11330
|
if (t.rows >= 2 && lone * 2 >= t.rows) return false;
|
|
11284
11331
|
if (t.rows === 1 && t.cols === 1) {
|
|
11285
|
-
const text = _nullishCoalesce(_optionalChain([t, 'access',
|
|
11286
|
-
return (_nullishCoalesce(_optionalChain([text, 'access',
|
|
11332
|
+
const text = _nullishCoalesce(_optionalChain([t, 'access', _479 => _479.cells, 'access', _480 => _480[0], 'optionalAccess', _481 => _481[0], 'optionalAccess', _482 => _482.text]), () => ( ""));
|
|
11333
|
+
return (_nullishCoalesce(_optionalChain([text, 'access', _483 => _483.match, 'call', _484 => _484(/\n/g), 'optionalAccess', _485 => _485.length]), () => ( 0))) >= 5 && (_nullishCoalesce(_optionalChain([text, 'access', _486 => _486.match, 'call', _487 => _487(/\d/g), 'optionalAccess', _488 => _488.length]), () => ( 0))) >= text.length * 0.25;
|
|
11287
11334
|
}
|
|
11288
|
-
const headerLabels = _nullishCoalesce(_optionalChain([t, 'access',
|
|
11335
|
+
const headerLabels = _nullishCoalesce(_optionalChain([t, 'access', _489 => _489.cells, 'access', _490 => _490[0], 'optionalAccess', _491 => _491.filter, 'call', _492 => _492((c) => c.text.replace(/[^A-Za-z가-힣]/g, "").length >= 2), 'access', _493 => _493.length]), () => ( 0));
|
|
11289
11336
|
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);
|
|
11290
11337
|
});
|
|
11291
11338
|
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, () => ( "")))) : []);
|
|
@@ -11302,14 +11349,14 @@ function mergeOcrImageRegions(blocks, page, regions, ocrBlocks) {
|
|
|
11302
11349
|
for (const block of selected) {
|
|
11303
11350
|
if (seen2.has(block)) continue;
|
|
11304
11351
|
const frame = FRAME_READING_UNITS.get(block);
|
|
11305
|
-
const source = _optionalChain([frame, 'optionalAccess',
|
|
11352
|
+
const source = _optionalChain([frame, 'optionalAccess', _494 => _494.blocks, 'access', _495 => _495.every, 'call', _496 => _496((member) => selectedSet.has(member))]) ? frame.blocks : [block];
|
|
11306
11353
|
source.forEach((member) => seen2.add(member));
|
|
11307
11354
|
const available = source.filter((member) => !hasOriginal(member));
|
|
11308
11355
|
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 }));
|
|
11309
11356
|
for (const unit of units) {
|
|
11310
11357
|
const b = unit.bbox;
|
|
11311
11358
|
const index = blocks.findIndex((existing) => {
|
|
11312
|
-
const e = _nullishCoalesce(_optionalChain([FRAME_READING_UNITS, 'access',
|
|
11359
|
+
const e = _nullishCoalesce(_optionalChain([FRAME_READING_UNITS, 'access', _497 => _497.get, 'call', _498 => _498(existing), 'optionalAccess', _499 => _499.bbox]), () => ( existing.bbox));
|
|
11313
11360
|
if (existing.pageNumber !== page || !e) return false;
|
|
11314
11361
|
const beside = e.y < region.y2 && e.y + e.height > region.y1 && e.x >= region.x2 - 1;
|
|
11315
11362
|
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;
|
|
@@ -11327,16 +11374,16 @@ function mergeOcrImageRegions(blocks, page, regions, ocrBlocks) {
|
|
|
11327
11374
|
}
|
|
11328
11375
|
function axisTick(block, candidates) {
|
|
11329
11376
|
const b = block.bbox;
|
|
11330
|
-
if (!/^\d$/u.test(_nullishCoalesce(_optionalChain([block, 'access',
|
|
11331
|
-
const numeric = candidates.filter((o) => o !== block && o.type === "paragraph" && o.bbox && /^[\d\s.,%+−-]+$/u.test(_nullishCoalesce(_optionalChain([o, 'access',
|
|
11377
|
+
if (!/^\d$/u.test(_nullishCoalesce(_optionalChain([block, 'access', _500 => _500.text, 'optionalAccess', _501 => _501.trim, 'call', _502 => _502()]), () => ( "")))) return false;
|
|
11378
|
+
const numeric = candidates.filter((o) => o !== block && o.type === "paragraph" && o.bbox && /^[\d\s.,%+−-]+$/u.test(_nullishCoalesce(_optionalChain([o, 'access', _503 => _503.text, 'optionalAccess', _504 => _504.trim, 'call', _505 => _505()]), () => ( ""))) && /\d/u.test(_nullishCoalesce(o.text, () => ( ""))) && Math.max(o.bbox.height, b.height) <= Math.min(o.bbox.height, b.height) * 2);
|
|
11332
11379
|
const cy = b.y + b.height / 2, right = b.x + b.width;
|
|
11333
11380
|
const row = numeric.filter((o) => Math.abs(o.bbox.y + o.bbox.height / 2 - cy) <= Math.min(o.bbox.height, b.height) * 0.35);
|
|
11334
11381
|
const column = numeric.filter((o) => Math.abs(o.bbox.x + o.bbox.width - right) <= Math.max(o.bbox.height, b.height) * 0.5);
|
|
11335
11382
|
return row.length >= 2 || column.length >= 2;
|
|
11336
11383
|
}
|
|
11337
11384
|
function supportedDiagramLabel(block, labels, region) {
|
|
11338
|
-
const b = block.bbox, text = _nullishCoalesce(_optionalChain([block, 'access',
|
|
11339
|
-
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',
|
|
11385
|
+
const b = block.bbox, text = _nullishCoalesce(_optionalChain([block, 'access', _506 => _506.text, 'optionalAccess', _507 => _507.trim, 'call', _508 => _508()]), () => ( ""));
|
|
11386
|
+
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', _509 => _509.text, 'optionalAccess', _510 => _510.match, 'call', _511 => _511(/\p{N}/gu), 'optionalAccess', _512 => _512.length]), () => ( 0))) >= 2).length < 2) return false;
|
|
11340
11387
|
let above = false, below = false;
|
|
11341
11388
|
for (const label of labels) {
|
|
11342
11389
|
const a = label.bbox, em = Math.max(b.height, a.height);
|
|
@@ -11351,7 +11398,7 @@ function rotatedAxisFragments(candidates) {
|
|
|
11351
11398
|
const paragraphs = candidates.filter((b) => b.type === "paragraph" && b.bbox.height <= 24);
|
|
11352
11399
|
const axes = [];
|
|
11353
11400
|
for (const block of paragraphs) {
|
|
11354
|
-
const b = block.bbox, text = _nullishCoalesce(_optionalChain([block, 'access',
|
|
11401
|
+
const b = block.bbox, text = _nullishCoalesce(_optionalChain([block, 'access', _513 => _513.text, 'optionalAccess', _514 => _514.trim, 'call', _515 => _515()]), () => ( ""));
|
|
11355
11402
|
if (!/^[\d\s.,%+−-]+$/u.test(text) || !/\d/u.test(text) || b.width > b.height * 6) continue;
|
|
11356
11403
|
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);
|
|
11357
11404
|
if (axis) axis.push(block);
|
|
@@ -11368,8 +11415,8 @@ function rotatedAxisFragments(candidates) {
|
|
|
11368
11415
|
const em = Math.max(...axis.map((a) => a.bbox.height)), right = axis[0].bbox.x + axis[0].bbox.width;
|
|
11369
11416
|
if (top - bottom < em * 6) continue;
|
|
11370
11417
|
const left = paragraphs.filter((block) => {
|
|
11371
|
-
const b = block.bbox, text = _nullishCoalesce(_optionalChain([block, 'access',
|
|
11372
|
-
return /\p{Script=Latin}/u.test(text) && (_nullishCoalesce(_optionalChain([text, 'access',
|
|
11418
|
+
const b = block.bbox, text = _nullishCoalesce(_optionalChain([block, 'access', _516 => _516.text, 'optionalAccess', _517 => _517.trim, 'call', _518 => _518()]), () => ( ""));
|
|
11419
|
+
return /\p{Script=Latin}/u.test(text) && (_nullishCoalesce(_optionalChain([text, 'access', _519 => _519.match, 'call', _520 => _520(/[\p{L}\p{N}]/gu), 'optionalAccess', _521 => _521.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;
|
|
11373
11420
|
});
|
|
11374
11421
|
const stack = left.filter((a) => left.some((b) => {
|
|
11375
11422
|
if (a === b || !aligned(a, b)) return false;
|
|
@@ -11379,7 +11426,7 @@ function rotatedAxisFragments(candidates) {
|
|
|
11379
11426
|
if (stack.length < 2) continue;
|
|
11380
11427
|
for (const block of paragraphs) {
|
|
11381
11428
|
const b = block.bbox;
|
|
11382
|
-
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',
|
|
11429
|
+
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', _522 => _522.text, 'optionalAccess', _523 => _523.trim, 'call', _524 => _524()]), () => ( ""))) && stack.some((s) => aligned(s, block))) fragments.add(block);
|
|
11383
11430
|
}
|
|
11384
11431
|
}
|
|
11385
11432
|
return fragments;
|
|
@@ -11486,4 +11533,4 @@ function rowParagraphs(block) {
|
|
|
11486
11533
|
|
|
11487
11534
|
|
|
11488
11535
|
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;
|
|
11489
|
-
//# sourceMappingURL=chunk-
|
|
11536
|
+
//# sourceMappingURL=chunk-COG4POSK.cjs.map
|