kordoc 4.24.71 → 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 +3 -3
- package/dist/{-F7GLIIGT.js → -S32WDXC4.js} +21 -21
- package/dist/{chunk-GFAWIBHG.js → chunk-2SUWIRWH.js} +10 -10
- package/dist/{chunk-T7MHZIFG.js → chunk-4ECEC6FD.js} +23 -4
- package/dist/chunk-4ECEC6FD.js.map +1 -0
- package/dist/{chunk-DSCT67WF.js → chunk-4GPZVPYG.js} +3 -3
- package/dist/{chunk-UJQRIX4L.js → chunk-4Q7L4IDD.js} +2 -2
- package/dist/{chunk-RUUUGCXS.js → chunk-4QOTRR5Z.js} +6 -6
- package/dist/{chunk-AUHQRRKM.js → chunk-4UL2KIOH.js} +3 -3
- package/dist/{chunk-YJ2YVG6N.cjs → chunk-5CYWVW3V.cjs} +88 -88
- package/dist/{chunk-YJ2YVG6N.cjs.map → chunk-5CYWVW3V.cjs.map} +1 -1
- package/dist/{chunk-IMT5TVVM.js → chunk-6DIACQ3R.js} +2 -2
- package/dist/{chunk-OJK4FLS5.js → chunk-6GQGU57N.js} +3 -3
- package/dist/{chunk-WMA4GJHC.js → chunk-7N2L6FBB.js} +5 -5
- package/dist/{chunk-5WWGC5SG.js → chunk-BD75GPTM.js} +2 -2
- package/dist/{chunk-2OF2YWIZ.js → chunk-BJCTFKEU.js} +2 -2
- package/dist/{chunk-MHXPW72E.js → chunk-C3USRXCH.js} +2 -2
- package/dist/{chunk-NPBNJCXZ.js → chunk-C4K2XCGX.js} +2 -2
- package/dist/{chunk-H2VOH7X3.cjs → chunk-COG4POSK.cjs} +199 -180
- package/dist/chunk-COG4POSK.cjs.map +1 -0
- package/dist/{chunk-O7PJFEOC.js → chunk-CQUOEZBJ.js} +2 -2
- package/dist/{chunk-2VBRCIPI.js → chunk-DIHV6CDK.js} +2 -2
- package/dist/{chunk-KGCJNPAI.js → chunk-FKCSNCWC.js} +5 -5
- package/dist/{chunk-2CPEW6WC.js → chunk-FTPYYLCR.js} +3 -3
- package/dist/{chunk-7KVDHXP2.js → chunk-G3TKEQZ3.js} +4 -4
- package/dist/{chunk-TYGZ6O2A.js → chunk-GAZDWFRT.js} +11 -11
- package/dist/{chunk-HIYRMYAS.js → chunk-GK4OHUV5.js} +2 -2
- package/dist/{chunk-LNWURZ2Z.js → chunk-GOQWCHX5.js} +7 -7
- package/dist/{chunk-ZPJZXTEG.js → chunk-IPYSZ2WD.js} +6 -6
- package/dist/{chunk-BNP3WXTB.cjs → chunk-JE4NCQIN.cjs} +3 -3
- package/dist/{chunk-BNP3WXTB.cjs.map → chunk-JE4NCQIN.cjs.map} +1 -1
- package/dist/{chunk-YTDHH362.js → chunk-JEPTA64I.js} +2 -2
- package/dist/{chunk-OW2XKTQA.cjs → chunk-L4GCUYDS.cjs} +8 -8
- package/dist/{chunk-OW2XKTQA.cjs.map → chunk-L4GCUYDS.cjs.map} +1 -1
- package/dist/{chunk-EZNUMAAJ.js → chunk-LINC7S3M.js} +2 -2
- package/dist/{chunk-6ZA4V4QS.js → chunk-MCO77XJN.js} +2 -2
- package/dist/{chunk-KLUI4SAZ.js → chunk-MHYFBIS5.js} +2 -2
- package/dist/{chunk-GRCIFCGC.js → chunk-NHWWNRQT.js} +2 -2
- package/dist/{chunk-RWU3Y5YK.js → chunk-O4MTW4JH.js} +18 -16
- package/dist/chunk-O4MTW4JH.js.map +1 -0
- package/dist/{chunk-M27VBFO6.js → chunk-SGQC3BVV.js} +22 -3
- package/dist/chunk-SGQC3BVV.js.map +1 -0
- package/dist/{chunk-OUHMNF2A.js → chunk-SNNM4GFE.js} +2 -2
- package/dist/{chunk-SK5AOGYK.cjs → chunk-TDNYBCPC.cjs} +104 -104
- package/dist/{chunk-SK5AOGYK.cjs.map → chunk-TDNYBCPC.cjs.map} +1 -1
- package/dist/{chunk-YTP7FPA5.cjs → chunk-U2K3WVR5.cjs} +3 -3
- package/dist/{chunk-YTP7FPA5.cjs.map → chunk-U2K3WVR5.cjs.map} +1 -1
- package/dist/{chunk-D4UFBXMT.js → chunk-U6CZ5IGF.js} +2 -2
- package/dist/{chunk-YPRIJDH6.js → chunk-UOML7PVK.js} +2 -2
- package/dist/{chunk-QK5KCWLE.js → chunk-VRJ3CABR.js} +2 -2
- package/dist/{chunk-YISBYF7X.cjs → chunk-WWTG5JUI.cjs} +58 -58
- package/dist/{chunk-YISBYF7X.cjs.map → chunk-WWTG5JUI.cjs.map} +1 -1
- package/dist/{chunk-SMEBVDM2.js → chunk-WXKUE2MU.js} +5 -5
- package/dist/{chunk-BHYBZSOC.js → chunk-YZXGUJFI.js} +2 -2
- package/dist/{chunk-LFTO5QAP.cjs → chunk-ZTVH2HQ5.cjs} +2 -2
- package/dist/{chunk-LFTO5QAP.cjs.map → chunk-ZTVH2HQ5.cjs.map} +1 -1
- package/dist/chunks-XNCDYMWO.js +11 -0
- package/dist/cli.js +45 -45
- package/dist/{formula-RTPZD2IM.cjs → formula-BLK43PWB.cjs} +41 -11
- package/dist/formula-BLK43PWB.cjs.map +1 -0
- package/dist/{formula-UJF4RZ6W.js → formula-E5QNTLM3.js} +35 -5
- package/dist/formula-E5QNTLM3.js.map +1 -0
- package/dist/{formula-3PJYUQMG.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-INMUN6KB.cjs.map → generator-APR6DUTL.cjs.map} +1 -1
- package/dist/generator-IOGPVCG2.js +18 -0
- package/dist/{hancom-RYIZHWJ5.js → hancom-BCYRSFDF.js} +2 -2
- package/dist/{hancom-MVPEYI4X.cjs → hancom-DJTR4HYI.cjs} +5 -5
- package/dist/{hancom-MVPEYI4X.cjs.map → hancom-DJTR4HYI.cjs.map} +1 -1
- package/dist/{hancom-P3SUQXM4.js → hancom-HLLJXF2H.js} +2 -2
- package/dist/{image-ocr-GL5YVCNU.js → image-ocr-B5SIBPET.js} +10 -10
- package/dist/{image-ocr-ZS4EMQN3.cjs → image-ocr-HCT57HQA.cjs} +28 -28
- package/dist/{image-ocr-ZS4EMQN3.cjs.map → image-ocr-HCT57HQA.cjs.map} +1 -1
- package/dist/{image-ocr-ZXLHPQI2.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-VCUAKBF3.js → model-bundle-KB7GFS7J.js} +5 -5
- package/dist/{models-UACAGYBI.js → models-A6PYBE2Q.js} +5 -5
- package/dist/{parse-worker-v2-LJB4QXGF.js → parse-worker-v2-OSOABIQB.js} +22 -22
- package/dist/{parser-5GZUD22P.js → parser-E2ZCR6UV.js} +12 -12
- package/dist/{parser-HCZD4DUO.js → parser-F7Q2ENVO.js} +9 -9
- package/dist/{parser-T4HAQ3QW.cjs → parser-JQXLIKOT.cjs} +166 -166
- package/dist/{parser-T4HAQ3QW.cjs.map → parser-JQXLIKOT.cjs.map} +1 -1
- package/dist/pdf-ocr-AV7FKNFZ.cjs +43 -0
- package/dist/{pdf-ocr-H4DKZSOB.cjs.map → pdf-ocr-AV7FKNFZ.cjs.map} +1 -1
- package/dist/{pdf-ocr-JXVGK5MR.js → pdf-ocr-B6QVPBMI.js} +6 -6
- package/dist/{pdf-ocr-YCMC2VL4.js → pdf-ocr-RY6UZ5PG.js} +9 -9
- package/dist/{profile-io-MVTEOXAU.js → profile-io-FX2SDCMR.js} +3 -3
- package/dist/{rasterize-VWT3C3RW.js → rasterize-ZJAMZCQM.js} +3 -3
- package/dist/{redact-doc-SU3JDC6F.js → redact-doc-DNXUF4WL.js} +21 -21
- package/dist/{render-D5N4FKWB.js → render-FQ2LMZIL.js} +12 -12
- package/dist/{rewrite-fallback-QXTWSPGY.js → rewrite-fallback-QNLQXJRS.js} +13 -13
- package/dist/seal-6LBVNZYX.js +16 -0
- package/dist/{setup-TXNJYX6P.js → setup-2VMN6LBY.js} +3 -3
- package/dist/to-hwpx-2RENWAWF.cjs +16 -0
- package/dist/{to-hwpx-KZTTH7EY.cjs.map → to-hwpx-2RENWAWF.cjs.map} +1 -1
- package/dist/{to-hwpx-YHGVFTBO.js → to-hwpx-DS6DH5WH.js} +4 -4
- package/dist/{to-hwpx-Z7NHUMUD.js → to-hwpx-H7B6CEN5.js} +7 -7
- package/dist/visual-3H3HGNOW.js +38 -0
- package/dist/{watch-EI5QYDT2.js → watch-53NVSD5Z.js} +22 -22
- package/package.json +1 -1
- package/dist/chunk-H2VOH7X3.cjs.map +0 -1
- package/dist/chunk-M27VBFO6.js.map +0 -1
- package/dist/chunk-RWU3Y5YK.js.map +0 -1
- package/dist/chunk-T7MHZIFG.js.map +0 -1
- package/dist/chunks-JAD5Z5YY.js +0 -11
- package/dist/formula-3PJYUQMG.js.map +0 -1
- package/dist/formula-RTPZD2IM.cjs.map +0 -1
- package/dist/formula-UJF4RZ6W.js.map +0 -1
- package/dist/generator-EB2436BE.js +0 -18
- package/dist/generator-INMUN6KB.cjs +0 -12
- package/dist/generator-K5KMPSLC.js +0 -11
- package/dist/memo-JNMSGIO7.js +0 -17
- package/dist/pdf-ocr-H4DKZSOB.cjs +0 -43
- package/dist/seal-Q3BD6CRB.js +0 -16
- package/dist/to-hwpx-KZTTH7EY.cjs +0 -16
- package/dist/visual-LNHFYJDL.js +0 -38
- /package/dist/{-F7GLIIGT.js.map → -S32WDXC4.js.map} +0 -0
- /package/dist/{chunk-GFAWIBHG.js.map → chunk-2SUWIRWH.js.map} +0 -0
- /package/dist/{chunk-DSCT67WF.js.map → chunk-4GPZVPYG.js.map} +0 -0
- /package/dist/{chunk-UJQRIX4L.js.map → chunk-4Q7L4IDD.js.map} +0 -0
- /package/dist/{chunk-RUUUGCXS.js.map → chunk-4QOTRR5Z.js.map} +0 -0
- /package/dist/{chunk-AUHQRRKM.js.map → chunk-4UL2KIOH.js.map} +0 -0
- /package/dist/{chunk-IMT5TVVM.js.map → chunk-6DIACQ3R.js.map} +0 -0
- /package/dist/{chunk-OJK4FLS5.js.map → chunk-6GQGU57N.js.map} +0 -0
- /package/dist/{chunk-WMA4GJHC.js.map → chunk-7N2L6FBB.js.map} +0 -0
- /package/dist/{chunk-5WWGC5SG.js.map → chunk-BD75GPTM.js.map} +0 -0
- /package/dist/{chunk-2OF2YWIZ.js.map → chunk-BJCTFKEU.js.map} +0 -0
- /package/dist/{chunk-MHXPW72E.js.map → chunk-C3USRXCH.js.map} +0 -0
- /package/dist/{chunk-NPBNJCXZ.js.map → chunk-C4K2XCGX.js.map} +0 -0
- /package/dist/{chunk-O7PJFEOC.js.map → chunk-CQUOEZBJ.js.map} +0 -0
- /package/dist/{chunk-2VBRCIPI.js.map → chunk-DIHV6CDK.js.map} +0 -0
- /package/dist/{chunk-KGCJNPAI.js.map → chunk-FKCSNCWC.js.map} +0 -0
- /package/dist/{chunk-2CPEW6WC.js.map → chunk-FTPYYLCR.js.map} +0 -0
- /package/dist/{chunk-7KVDHXP2.js.map → chunk-G3TKEQZ3.js.map} +0 -0
- /package/dist/{chunk-TYGZ6O2A.js.map → chunk-GAZDWFRT.js.map} +0 -0
- /package/dist/{chunk-HIYRMYAS.js.map → chunk-GK4OHUV5.js.map} +0 -0
- /package/dist/{chunk-LNWURZ2Z.js.map → chunk-GOQWCHX5.js.map} +0 -0
- /package/dist/{chunk-ZPJZXTEG.js.map → chunk-IPYSZ2WD.js.map} +0 -0
- /package/dist/{chunk-YTDHH362.js.map → chunk-JEPTA64I.js.map} +0 -0
- /package/dist/{chunk-EZNUMAAJ.js.map → chunk-LINC7S3M.js.map} +0 -0
- /package/dist/{chunk-6ZA4V4QS.js.map → chunk-MCO77XJN.js.map} +0 -0
- /package/dist/{chunk-KLUI4SAZ.js.map → chunk-MHYFBIS5.js.map} +0 -0
- /package/dist/{chunk-GRCIFCGC.js.map → chunk-NHWWNRQT.js.map} +0 -0
- /package/dist/{chunk-OUHMNF2A.js.map → chunk-SNNM4GFE.js.map} +0 -0
- /package/dist/{chunk-D4UFBXMT.js.map → chunk-U6CZ5IGF.js.map} +0 -0
- /package/dist/{chunk-YPRIJDH6.js.map → chunk-UOML7PVK.js.map} +0 -0
- /package/dist/{chunk-QK5KCWLE.js.map → chunk-VRJ3CABR.js.map} +0 -0
- /package/dist/{chunk-SMEBVDM2.js.map → chunk-WXKUE2MU.js.map} +0 -0
- /package/dist/{chunk-BHYBZSOC.js.map → chunk-YZXGUJFI.js.map} +0 -0
- /package/dist/{chunks-JAD5Z5YY.js.map → chunks-XNCDYMWO.js.map} +0 -0
- /package/dist/{generator-EB2436BE.js.map → generator-5VFDO4CB.js.map} +0 -0
- /package/dist/{generator-K5KMPSLC.js.map → generator-IOGPVCG2.js.map} +0 -0
- /package/dist/{hancom-RYIZHWJ5.js.map → hancom-BCYRSFDF.js.map} +0 -0
- /package/dist/{hancom-P3SUQXM4.js.map → hancom-HLLJXF2H.js.map} +0 -0
- /package/dist/{image-ocr-GL5YVCNU.js.map → image-ocr-B5SIBPET.js.map} +0 -0
- /package/dist/{image-ocr-ZXLHPQI2.js.map → image-ocr-QSSVO27L.js.map} +0 -0
- /package/dist/{memo-JNMSGIO7.js.map → memo-R5CO35OZ.js.map} +0 -0
- /package/dist/{model-bundle-VCUAKBF3.js.map → model-bundle-KB7GFS7J.js.map} +0 -0
- /package/dist/{models-UACAGYBI.js.map → models-A6PYBE2Q.js.map} +0 -0
- /package/dist/{parse-worker-v2-LJB4QXGF.js.map → parse-worker-v2-OSOABIQB.js.map} +0 -0
- /package/dist/{parser-5GZUD22P.js.map → parser-E2ZCR6UV.js.map} +0 -0
- /package/dist/{parser-HCZD4DUO.js.map → parser-F7Q2ENVO.js.map} +0 -0
- /package/dist/{pdf-ocr-JXVGK5MR.js.map → pdf-ocr-B6QVPBMI.js.map} +0 -0
- /package/dist/{pdf-ocr-YCMC2VL4.js.map → pdf-ocr-RY6UZ5PG.js.map} +0 -0
- /package/dist/{profile-io-MVTEOXAU.js.map → profile-io-FX2SDCMR.js.map} +0 -0
- /package/dist/{rasterize-VWT3C3RW.js.map → rasterize-ZJAMZCQM.js.map} +0 -0
- /package/dist/{redact-doc-SU3JDC6F.js.map → redact-doc-DNXUF4WL.js.map} +0 -0
- /package/dist/{render-D5N4FKWB.js.map → render-FQ2LMZIL.js.map} +0 -0
- /package/dist/{rewrite-fallback-QXTWSPGY.js.map → rewrite-fallback-QNLQXJRS.js.map} +0 -0
- /package/dist/{seal-Q3BD6CRB.js.map → seal-6LBVNZYX.js.map} +0 -0
- /package/dist/{setup-TXNJYX6P.js.map → setup-2VMN6LBY.js.map} +0 -0
- /package/dist/{to-hwpx-YHGVFTBO.js.map → to-hwpx-DS6DH5WH.js.map} +0 -0
- /package/dist/{to-hwpx-Z7NHUMUD.js.map → to-hwpx-H7B6CEN5.js.map} +0 -0
- /package/dist/{visual-LNHFYJDL.js.map → visual-3H3HGNOW.js.map} +0 -0
- /package/dist/{watch-EI5QYDT2.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 _chunkYTP7FPA5cjs = require('./chunk-YTP7FPA5.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) {
|
|
@@ -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])]);
|
|
3826
|
+
if (joins != null) return joins ? "" : " ";
|
|
3827
|
+
}
|
|
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()]);
|
|
3811
3830
|
if (joins != null) return joins ? "" : " ";
|
|
3812
3831
|
}
|
|
3813
|
-
const ev = _optionalChain([lex, 'optionalAccess',
|
|
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,7 +3965,7 @@ 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
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()));
|
|
@@ -4123,7 +4142,7 @@ function cellTextToString(items, wrap) {
|
|
|
4123
4142
|
const merged = mergeSuperscriptRows(lines).map((line) => sortLineByX(line));
|
|
4124
4143
|
const textLines = merged.map((s) => {
|
|
4125
4144
|
if (s.length === 1) return s[0].text;
|
|
4126
|
-
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;
|
|
4127
4146
|
const evenSpaced = detectEvenSpacedItems(s, true);
|
|
4128
4147
|
const tracked = trackedSpaces(s);
|
|
4129
4148
|
const hangulLine = s.some((it) => /[가-힣]/.test(it.text));
|
|
@@ -4139,7 +4158,7 @@ function cellTextToString(items, wrap) {
|
|
|
4139
4158
|
result += s[j].text;
|
|
4140
4159
|
} else if (s[j].hasSpaceBefore && exactGap(s[j - 1], s[j], gap) >= avgFs * 0.05) {
|
|
4141
4160
|
result += " " + s[j].text;
|
|
4142
|
-
} else if (gap > spaceGapThreshold(avgFs) || _optionalChain([tracked, 'optionalAccess',
|
|
4161
|
+
} else if (gap > spaceGapThreshold(avgFs) || _optionalChain([tracked, 'optionalAccess', _129 => _129[j]])) {
|
|
4143
4162
|
result += " " + s[j].text;
|
|
4144
4163
|
} else {
|
|
4145
4164
|
result += s[j].text;
|
|
@@ -4266,12 +4285,12 @@ function markEvenRun(items, visible, result, start, end) {
|
|
|
4266
4285
|
}
|
|
4267
4286
|
function mergeCellTextLines(textLines, wrap) {
|
|
4268
4287
|
if (textLines.length <= 1) return textLines[0] || "";
|
|
4269
|
-
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)));
|
|
4270
4289
|
const merged = [textLines[0]];
|
|
4271
4290
|
for (let i = 1; i < textLines.length; i++) {
|
|
4272
4291
|
const prev = merged[merged.length - 1];
|
|
4273
4292
|
const curr = textLines[i];
|
|
4274
|
-
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(" ")) {
|
|
4275
4294
|
merged[merged.length - 1] = prev + curr;
|
|
4276
4295
|
} else if (curr.trim().length <= 3 && /^[)\]%}]/.test(curr.trim())) {
|
|
4277
4296
|
merged[merged.length - 1] = prev + curr.trim();
|
|
@@ -4411,34 +4430,34 @@ function normalizeUndersegmentedTable(originalCells, colXs, items, rowYs, kept,
|
|
|
4411
4430
|
if (numRows > maxRows || numCols < MIN_UNDERSEGMENTED_COLUMNS) return null;
|
|
4412
4431
|
if (items.length === 0) return null;
|
|
4413
4432
|
if (numRows >= 3) {
|
|
4414
|
-
if (_optionalChain([rowYs, 'optionalAccess',
|
|
4433
|
+
if (_optionalChain([rowYs, 'optionalAccess', _136 => _136.length]) !== numRows + 1) return null;
|
|
4415
4434
|
const rebuilt2 = [];
|
|
4416
4435
|
let expanded = 0;
|
|
4417
4436
|
const ocr = items.every((it) => it.fontName === "ocr");
|
|
4418
4437
|
for (let r = 0; r < numRows; r++) {
|
|
4419
4438
|
const row = originalCells[r].map((cell) => cell.text);
|
|
4420
4439
|
if (r === 0 || numRows === 3 && r === 1) {
|
|
4421
|
-
_optionalChain([kept, 'optionalAccess',
|
|
4440
|
+
_optionalChain([kept, 'optionalAccess', _137 => _137.set, 'call', _138 => _138(rebuilt2.length, r)]);
|
|
4422
4441
|
rebuilt2.push(row);
|
|
4423
4442
|
continue;
|
|
4424
4443
|
}
|
|
4425
4444
|
const span2 = Math.min(numRows - r, Math.max(1, ...originalCells[r].map((cell) => _nullishCoalesce(cell.rowSpan, () => ( 1)))));
|
|
4426
4445
|
const filled = originalCells[r].filter((cell) => cell.text.trim());
|
|
4427
4446
|
const spanning = filled.filter((cell) => (_nullishCoalesce(cell.rowSpan, () => ( 1))) >= span2);
|
|
4428
|
-
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));
|
|
4429
4448
|
const band = span2 > 1 && (loose || originalCells.slice(r + 1, r + span2).every((cells) => cells.every((cell) => !cell.text.trim()))) ? span2 : 1;
|
|
4430
4449
|
const rowItems = items.filter((item) => itemCenterY(item) <= rowYs[r] + 1 && itemCenterY(item) >= rowYs[r + band] - 1);
|
|
4431
4450
|
const body = normalizeUndersegmentedTable([originalCells[r]], colXs, rowItems, void 0, void 0, void 0, band > 1 ? 2 : MIN_ALIGNED_LINES);
|
|
4432
4451
|
if (body) {
|
|
4433
4452
|
originalCells[r].forEach((cell, c) => {
|
|
4434
4453
|
const cols = Array.from({ length: Math.max(1, _nullishCoalesce(cell.colSpan, () => ( 1))) }, (_, k) => c + k);
|
|
4435
|
-
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;
|
|
4436
4455
|
});
|
|
4437
4456
|
rebuilt2.push(...body);
|
|
4438
4457
|
expanded++;
|
|
4439
4458
|
r += band - 1;
|
|
4440
4459
|
} else {
|
|
4441
|
-
_optionalChain([kept, 'optionalAccess',
|
|
4460
|
+
_optionalChain([kept, 'optionalAccess', _145 => _145.set, 'call', _146 => _146(rebuilt2.length, r)]);
|
|
4442
4461
|
rebuilt2.push(row);
|
|
4443
4462
|
}
|
|
4444
4463
|
}
|
|
@@ -4522,7 +4541,7 @@ function sortLineByX(items) {
|
|
|
4522
4541
|
e++;
|
|
4523
4542
|
}
|
|
4524
4543
|
const run = items.slice(s, e), seqs = run.map((i) => i.seq);
|
|
4525
|
-
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);
|
|
4526
4545
|
if (e - s > 1 && seqs.every((q) => q !== void 0) && ok) {
|
|
4527
4546
|
run.sort((a, b) => a.seq - b.seq);
|
|
4528
4547
|
for (let k = 0; k < run.length; k++) items[s + k] = run[k];
|
|
@@ -4597,7 +4616,7 @@ function dominantStyle(items) {
|
|
|
4597
4616
|
let maxCount = 0, dominantSize = 0;
|
|
4598
4617
|
for (const i of items) {
|
|
4599
4618
|
if (i.fontSize <= 0) continue;
|
|
4600
|
-
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)));
|
|
4601
4620
|
freq.set(i.fontSize, count);
|
|
4602
4621
|
if (count > maxCount) {
|
|
4603
4622
|
maxCount = count;
|
|
@@ -4605,7 +4624,7 @@ function dominantStyle(items) {
|
|
|
4605
4624
|
}
|
|
4606
4625
|
}
|
|
4607
4626
|
if (dominantSize === 0) return void 0;
|
|
4608
|
-
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;
|
|
4609
4628
|
return fontName ? { fontSize: dominantSize, fontName } : { fontSize: dominantSize };
|
|
4610
4629
|
}
|
|
4611
4630
|
function normalizeItems(rawItems) {
|
|
@@ -4760,7 +4779,7 @@ function splitAroundOverlays(c, overlays) {
|
|
|
4760
4779
|
const ov = overlays.filter((o) => {
|
|
4761
4780
|
for (let at = c.text.indexOf(o.text); at >= 0; at = c.text.indexOf(o.text, at + 1)) {
|
|
4762
4781
|
const prefix = c.text.slice(0, at);
|
|
4763
|
-
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;
|
|
4764
4783
|
if (Math.abs(est - o.x) <= OVERLAY_DUP_EM * fs) return false;
|
|
4765
4784
|
}
|
|
4766
4785
|
return true;
|
|
@@ -4922,7 +4941,7 @@ function trackedSpaces(sorted, med = trackingShift([sorted])) {
|
|
|
4922
4941
|
});
|
|
4923
4942
|
}
|
|
4924
4943
|
function mergeLineSimple(items) {
|
|
4925
|
-
if (items.length <= 1) return _optionalChain([items, 'access',
|
|
4944
|
+
if (items.length <= 1) return _optionalChain([items, 'access', _160 => _160[0], 'optionalAccess', _161 => _161.text]) || "";
|
|
4926
4945
|
const sorted = sortLineByX([...items]);
|
|
4927
4946
|
const tracked = trackedSpaces(sorted);
|
|
4928
4947
|
const isEvenSpaced = detectEvenSpacedItems(sorted);
|
|
@@ -4957,7 +4976,7 @@ function mergeLineSimple(items) {
|
|
|
4957
4976
|
result += sorted[i].text;
|
|
4958
4977
|
continue;
|
|
4959
4978
|
}
|
|
4960
|
-
if (gap > spaceGapThreshold(avgFs) || _optionalChain([tracked, 'optionalAccess',
|
|
4979
|
+
if (gap > spaceGapThreshold(avgFs) || _optionalChain([tracked, 'optionalAccess', _162 => _162[i]])) result += " ";
|
|
4961
4980
|
result += sorted[i].text;
|
|
4962
4981
|
}
|
|
4963
4982
|
return result;
|
|
@@ -5014,7 +5033,7 @@ function isProseTable(table) {
|
|
|
5014
5033
|
if (!(long > 0 && long >= total * 0.5 && longRows >= rows * 0.4)) return false;
|
|
5015
5034
|
for (let c = 0; c < table.cols; c++) {
|
|
5016
5035
|
const filled = table.cells.map((row) => row[c]).filter((cell) => cell && cell.colSpan < table.cols && cell.text.trim()).map((cell) => cell.text.trim());
|
|
5017
|
-
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;
|
|
5018
5037
|
}
|
|
5019
5038
|
return true;
|
|
5020
5039
|
}
|
|
@@ -5043,7 +5062,7 @@ var TICK = /^-?[\d,]+(?:\.\d+)?%?$/;
|
|
|
5043
5062
|
var QUANTITY = /^[-−–]?[\d,]*\.?\d+%?$/;
|
|
5044
5063
|
var quantity = (token) => Number(token.replace(/^[−–]/, "-").replace(/[,%]/g, ""));
|
|
5045
5064
|
function isValueAxisColumn(table, c) {
|
|
5046
|
-
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+/)));
|
|
5047
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));
|
|
5048
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)]) {
|
|
5049
5068
|
const run = fallingRun(ticks);
|
|
@@ -5076,7 +5095,7 @@ function isChartTable(table, ocr = false) {
|
|
|
5076
5095
|
if (numeric < texts.length * 0.5) return false;
|
|
5077
5096
|
if (ocr && table.cols >= 3 && table.cells.slice(0, 3).some((row) => row.filter((cell) => /[가-힣]{2}/.test(cell.text)).length >= 2)) return false;
|
|
5078
5097
|
for (let c = 0; c < table.cols; c++) {
|
|
5079
|
-
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;
|
|
5080
5099
|
}
|
|
5081
5100
|
const values = texts.filter((text) => text.split(/\s+/).every((token) => QUANTITY.test(token))).length;
|
|
5082
5101
|
const cells = table.rows * table.cols;
|
|
@@ -5085,7 +5104,7 @@ function isChartTable(table, ocr = false) {
|
|
|
5085
5104
|
function isProseFragmentTable(table) {
|
|
5086
5105
|
const texts = table.cells.flat().map((cell) => cell.text.trim()).filter(Boolean);
|
|
5087
5106
|
if (texts.length < 4) return false;
|
|
5088
|
-
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));
|
|
5089
5108
|
if (texts.filter((text) => hangul(text) >= 2).length < texts.length * 0.7) return false;
|
|
5090
5109
|
if (texts.length >= 12 && texts.filter((text) => hangul(text) >= 15 && !text.includes("\n")).length >= texts.length * 0.4) return true;
|
|
5091
5110
|
return texts.filter((text) => /(?:[다요고서는을를에게지며면어아야니까던]|[.,?!])$/.test(text)).length >= texts.length * 0.3;
|
|
@@ -5138,7 +5157,7 @@ function clusterCellLines(items) {
|
|
|
5138
5157
|
}
|
|
5139
5158
|
var WRAP_INDENT_MAX = 3;
|
|
5140
5159
|
function joinClusterCellLines(lines, box, lex) {
|
|
5141
|
-
let out = _nullishCoalesce(_optionalChain([lines, 'access',
|
|
5160
|
+
let out = _nullishCoalesce(_optionalChain([lines, 'access', _173 => _173[0], 'optionalAccess', _174 => _174.text]), () => ( ""));
|
|
5142
5161
|
for (let i = 1; i < lines.length; i++) {
|
|
5143
5162
|
const a = lines[i - 1], b = lines[i];
|
|
5144
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) === "";
|
|
@@ -5483,7 +5502,7 @@ function detectAlignedTwoColumnTables(rows, pageNum) {
|
|
|
5483
5502
|
continue;
|
|
5484
5503
|
}
|
|
5485
5504
|
const top = rows[i - 1];
|
|
5486
|
-
const title = _optionalChain([top, 'optionalAccess',
|
|
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;
|
|
5487
5506
|
const tableRows = [...title ? [title] : [], ...body.flatMap((b) => b.rows)];
|
|
5488
5507
|
const cells = [
|
|
5489
5508
|
...title ? [[{ text: title.items[0].text, colSpan: 2, rowSpan: 1 }, { text: "", colSpan: 1, rowSpan: 1 }]] : [],
|
|
@@ -5539,12 +5558,12 @@ function isTwoColumnProse(r) {
|
|
|
5539
5558
|
if (t.rows < (ocr ? 6 : 8)) return false;
|
|
5540
5559
|
const dense = [];
|
|
5541
5560
|
for (let c = 0; c < t.cols; c++) {
|
|
5542
|
-
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;
|
|
5543
5562
|
if (filled / t.rows >= 0.3) dense.push(c);
|
|
5544
5563
|
}
|
|
5545
5564
|
if (dense.length !== 2) return false;
|
|
5546
5565
|
for (const c of dense) {
|
|
5547
|
-
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);
|
|
5548
5567
|
const avg = lens.reduce((s, v) => s + v, 0) / (lens.length || 1);
|
|
5549
5568
|
if (avg < (ocr ? 15 : 12)) return false;
|
|
5550
5569
|
}
|
|
@@ -6006,7 +6025,7 @@ function assignRowItems(items, columns, numCols, headerFace) {
|
|
|
6006
6025
|
const runs = [];
|
|
6007
6026
|
for (const it of sorted) {
|
|
6008
6027
|
const last = runs[runs.length - 1];
|
|
6009
|
-
const prev = _optionalChain([last, 'optionalAccess',
|
|
6028
|
+
const prev = _optionalChain([last, 'optionalAccess', _186 => _186[last.length - 1]]);
|
|
6010
6029
|
if (prev && it.x - (prev.x + prev.w) <= Math.max(0.5, it.fontSize * 0.05) && !it.hasSpaceBefore) last.push(it);
|
|
6011
6030
|
else runs.push([it]);
|
|
6012
6031
|
}
|
|
@@ -6057,7 +6076,7 @@ function assignRowItems(items, columns, numCols, headerFace) {
|
|
|
6057
6076
|
assignedGroups.add(gi);
|
|
6058
6077
|
usedCols.add(ci);
|
|
6059
6078
|
}
|
|
6060
|
-
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)));
|
|
6061
6080
|
if (groups.length <= numCols && colOf.some((c, g) => g > 0 && c < colOf[g - 1])) {
|
|
6062
6081
|
const G = groups.length, cost = (g, c2) => Math.abs(groupCenters[g] - colCenters[c2]);
|
|
6063
6082
|
const best = groups.map(() => new Array(numCols).fill(Infinity)), from = groups.map(() => new Array(numCols).fill(-1));
|
|
@@ -6094,7 +6113,7 @@ function assignRowItems(items, columns, numCols, headerFace) {
|
|
|
6094
6113
|
function buildClusterTable(rows, columns, pageNum, lex) {
|
|
6095
6114
|
const numRows = rows.length;
|
|
6096
6115
|
if (numRows < MIN_ROWS || columns.length < MIN_COLS) return null;
|
|
6097
|
-
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)]));
|
|
6098
6117
|
const headerFace = headFaces.size === 1 && rows.slice(1).every((row) => row.items.every((i) => !headFaces.has(i.fontName))) ? [...headFaces][0] : void 0;
|
|
6099
6118
|
const assigned = rows.map((row, r) => assignRowItems(row.items, columns, columns.length, r === 0 ? headerFace : void 0));
|
|
6100
6119
|
const cuts = supportedOcrColumnCuts(assigned);
|
|
@@ -6165,7 +6184,7 @@ function buildClusterTable(rows, columns, pageNum, lex) {
|
|
|
6165
6184
|
const nonEmptyCols = cells[r].filter((c) => c.text.trim()).length;
|
|
6166
6185
|
if (nonEmptyCols !== 1) continue;
|
|
6167
6186
|
if (cells[r][0].text.trim() !== "") continue;
|
|
6168
|
-
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()]) || "";
|
|
6169
6188
|
if (/^[○●▶\-·]/.test(contentText)) continue;
|
|
6170
6189
|
for (let pr = r - 1; pr >= 0; pr--) {
|
|
6171
6190
|
if (cells[pr].some((c) => c.text.trim())) {
|
|
@@ -6398,7 +6417,7 @@ function stackedTableBands(items) {
|
|
|
6398
6417
|
const caption = (start, end) => lines.slice(start, end).some((line) => /^Table\s+\d+\s*[:.]/i.test(mergeLineSimple(line).trim()));
|
|
6399
6418
|
while (runs.length > 0 && !caption(runs[runs.length - 1].end, lines.length)) runs.pop();
|
|
6400
6419
|
if (runs.length < 2) return null;
|
|
6401
|
-
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;
|
|
6402
6421
|
const tables = runs.map((run) => lines.slice(run.start, run.end).flat());
|
|
6403
6422
|
const between = runs.slice(0, -1).map((run, i) => lines.slice(run.end, runs[i + 1].start).flat());
|
|
6404
6423
|
const tail = lines.slice(runs[runs.length - 1].end);
|
|
@@ -6666,7 +6685,7 @@ function splitTrailingColumnRegion(items) {
|
|
|
6666
6685
|
}
|
|
6667
6686
|
function panelBlocks(items, panel, pageNum) {
|
|
6668
6687
|
const lines = groupByY([...items].sort((a, b) => b.y - a.y || a.x - b.x));
|
|
6669
|
-
const faceOf = (line) => _nullishCoalesce(_optionalChain([dominantStyle, 'call',
|
|
6688
|
+
const faceOf = (line) => _nullishCoalesce(_optionalChain([dominantStyle, 'call', _202 => _202(line), 'optionalAccess', _203 => _203.fontName]), () => ( ""));
|
|
6670
6689
|
const runs = [];
|
|
6671
6690
|
for (const line of lines) {
|
|
6672
6691
|
const last = runs[runs.length - 1];
|
|
@@ -6873,7 +6892,7 @@ function validWrapBands(items, bands) {
|
|
|
6873
6892
|
}
|
|
6874
6893
|
function inheritedWrapBands(items) {
|
|
6875
6894
|
const source = XY_WRAP_ITEMS.get(items[0]);
|
|
6876
|
-
const present = _optionalChain([source, 'optionalAccess',
|
|
6895
|
+
const present = _optionalChain([source, 'optionalAccess', _204 => _204.length]) === items.length ? new Set(items) : null;
|
|
6877
6896
|
const sameLeaf = present && source.every((item) => present.has(item));
|
|
6878
6897
|
return sameLeaf ? validWrapBands(items, _nullishCoalesce(XY_WRAP_BANDS.get(items[0]), () => ( []))) : [];
|
|
6879
6898
|
}
|
|
@@ -6908,7 +6927,7 @@ function splitsLoneRowTail(items, x) {
|
|
|
6908
6927
|
const tail = right[0], box = computeBBox(items, 0), tailBox = computeBBox(tail, 0);
|
|
6909
6928
|
const head = left.find((r) => Math.abs(r[0].y - tail[0].y) <= 2);
|
|
6910
6929
|
if (!head) return false;
|
|
6911
|
-
const headBox = computeBBox(head, 0), fs = _nullishCoalesce(_optionalChain([dominantStyle, 'call',
|
|
6930
|
+
const headBox = computeBBox(head, 0), fs = _nullishCoalesce(_optionalChain([dominantStyle, 'call', _205 => _205(tail), 'optionalAccess', _206 => _206.fontSize]), () => ( 10));
|
|
6912
6931
|
const gap = tailBox.x - (headBox.x + headBox.width), fills = tailBox.x + tailBox.width >= box.x + box.width - fs;
|
|
6913
6932
|
if (gap <= fs * 3 && fills && headBox.width >= box.width / 2) return true;
|
|
6914
6933
|
const text = [...head, ...tail].map((i) => i.text).join("");
|
|
@@ -6924,7 +6943,7 @@ function wrappedLineBands(items, inherited, lex) {
|
|
|
6924
6943
|
left: box.x,
|
|
6925
6944
|
right: box.x + box.width,
|
|
6926
6945
|
y: row.reduce((n, i) => n + i.y, 0) / row.length,
|
|
6927
|
-
fontSize: _nullishCoalesce(_optionalChain([dominantStyle, 'call',
|
|
6946
|
+
fontSize: _nullishCoalesce(_optionalChain([dominantStyle, 'call', _207 => _207(row), 'optionalAccess', _208 => _208.fontSize]), () => ( 0)),
|
|
6928
6947
|
sources: row.map((item) => ({ item, state: { ...item } }))
|
|
6929
6948
|
};
|
|
6930
6949
|
});
|
|
@@ -7060,10 +7079,10 @@ function pushLineParagraphs(out, yLines, pageNum, lex) {
|
|
|
7060
7079
|
const lines = attachDropCaps(yLines).map((items) => ({ items, text: mergeLineSimple(items) })).filter((l) => l.text.trim());
|
|
7061
7080
|
const geo = lines.map((l) => {
|
|
7062
7081
|
const b = computeBBox(l.items, pageNum);
|
|
7063
|
-
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)) };
|
|
7064
7083
|
});
|
|
7065
7084
|
const joins = bodyLineJoins(geo, lex);
|
|
7066
|
-
const first = _optionalChain([lines, 'access',
|
|
7085
|
+
const first = _optionalChain([lines, 'access', _211 => _211[0], 'optionalAccess', _212 => _212.items, 'access', _213 => _213[0]]);
|
|
7067
7086
|
const bands = first ? _nullishCoalesce(XY_WRAP_BANDS.get(first), () => ( [])) : [];
|
|
7068
7087
|
const hasBand = (top, bottom) => {
|
|
7069
7088
|
let lo = 0, hi = bands.length;
|
|
@@ -7140,15 +7159,15 @@ function computeMedianFontSizeFromFreq(freq) {
|
|
|
7140
7159
|
function detectHeadings(blocks, medianFontSize) {
|
|
7141
7160
|
for (let bi = 0; bi < blocks.length; bi++) {
|
|
7142
7161
|
const block = blocks[bi];
|
|
7143
|
-
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;
|
|
7144
7163
|
const text = block.text.trim();
|
|
7145
7164
|
if (text.length === 0 || text.length > 200) continue;
|
|
7146
7165
|
if (/^\d+$/.test(text) && !isChapterNumber(block, blocks[bi + 1], medianFontSize)) continue;
|
|
7147
7166
|
const ratio = block.style.fontSize / medianFontSize;
|
|
7148
7167
|
let level = 0;
|
|
7149
|
-
if (ratio >=
|
|
7150
|
-
else if (ratio >=
|
|
7151
|
-
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;
|
|
7152
7171
|
if (level > 0) {
|
|
7153
7172
|
block.type = "heading";
|
|
7154
7173
|
block.level = level;
|
|
@@ -7157,21 +7176,21 @@ function detectHeadings(blocks, medianFontSize) {
|
|
|
7157
7176
|
}
|
|
7158
7177
|
}
|
|
7159
7178
|
function isChapterNumber(block, next, medianFontSize) {
|
|
7160
|
-
const size = _nullishCoalesce(_optionalChain([block, 'access',
|
|
7161
|
-
const nextSize = _nullishCoalesce(_optionalChain([next, 'optionalAccess',
|
|
7162
|
-
const text = _nullishCoalesce(_optionalChain([next, 'optionalAccess',
|
|
7163
|
-
const a = block.bbox, b = _optionalChain([next, 'optionalAccess',
|
|
7164
|
-
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;
|
|
7165
7184
|
}
|
|
7166
7185
|
function mergeStackedHeadingLines(blocks, medianFontSize) {
|
|
7167
7186
|
for (let i = 0; i < blocks.length - 1; ) {
|
|
7168
7187
|
const a = blocks[i], b = blocks[i + 1];
|
|
7169
7188
|
const ab = a.bbox, bb = b.bbox;
|
|
7170
|
-
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));
|
|
7171
7190
|
const gap = ab && bb ? ab.y - (bb.y + bb.height) : Infinity;
|
|
7172
|
-
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);
|
|
7173
7192
|
const sameAnchor = ab && bb && Math.abs(ab.x - bb.x) <= 5;
|
|
7174
|
-
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;
|
|
7175
7194
|
const displayStack = centered && gap <= Math.min(af, bf) * 0.3 && Math.max(af, bf) <= Math.min(af, bf) * 1.45;
|
|
7176
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)) {
|
|
7177
7196
|
i++;
|
|
@@ -7200,25 +7219,25 @@ function detectTypographyHeadings(blocks) {
|
|
|
7200
7219
|
if (page.some((block) => block.type === "heading")) continue;
|
|
7201
7220
|
const faceWeight = /* @__PURE__ */ new Map();
|
|
7202
7221
|
for (const block of page) {
|
|
7203
|
-
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;
|
|
7204
7223
|
const faces = FACE_CHARS.get(block);
|
|
7205
7224
|
if (faces) for (const [face, n] of faces) faceWeight.set(face, (_nullishCoalesce(faceWeight.get(face), () => ( 0))) + n);
|
|
7206
7225
|
else faceWeight.set(block.style.fontName, (_nullishCoalesce(faceWeight.get(block.style.fontName), () => ( 0))) + block.text.length);
|
|
7207
7226
|
}
|
|
7208
|
-
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]]);
|
|
7209
7228
|
if (!bodyFace || (_nullishCoalesce(faceWeight.get(bodyFace), () => ( 0))) < 250) continue;
|
|
7210
7229
|
const sizeWeight = /* @__PURE__ */ new Map();
|
|
7211
7230
|
for (const block of page) {
|
|
7212
|
-
if (block.type !== "paragraph" || !_optionalChain([block, 'access',
|
|
7231
|
+
if (block.type !== "paragraph" || !_optionalChain([block, 'access', _251 => _251.style, 'optionalAccess', _252 => _252.fontSize])) continue;
|
|
7213
7232
|
const faces = FACE_CHARS.get(block);
|
|
7214
|
-
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;
|
|
7215
7234
|
if (chars) sizeWeight.set(block.style.fontSize, (_nullishCoalesce(sizeWeight.get(block.style.fontSize), () => ( 0))) + chars);
|
|
7216
7235
|
}
|
|
7217
|
-
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));
|
|
7218
7237
|
for (let i = 0; i < page.length; i++) {
|
|
7219
7238
|
const block = page[i];
|
|
7220
7239
|
const { text, bbox, style } = block;
|
|
7221
|
-
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;
|
|
7222
7241
|
const title = text.trim();
|
|
7223
7242
|
const numbered = /^\d+(?:\.\d+)*\.?\s+[A-Z가-힣]/.test(title);
|
|
7224
7243
|
const faces = FACE_CHARS.get(block);
|
|
@@ -7248,16 +7267,16 @@ function detectDocumentStyleHeadings(blocks) {
|
|
|
7248
7267
|
for (const page of byPage.values()) {
|
|
7249
7268
|
const faceChars = /* @__PURE__ */ new Map();
|
|
7250
7269
|
for (const block of page) {
|
|
7251
|
-
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;
|
|
7252
7271
|
faceChars.set(block.style.fontName, (_nullishCoalesce(faceChars.get(block.style.fontName), () => ( 0))) + block.text.length);
|
|
7253
7272
|
}
|
|
7254
|
-
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]]);
|
|
7255
7274
|
if (!bodyFace || (_nullishCoalesce(faceChars.get(bodyFace), () => ( 0))) < 100) continue;
|
|
7256
|
-
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);
|
|
7257
7276
|
for (const label of labels) {
|
|
7258
|
-
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);
|
|
7259
7278
|
if (peers.length < 2) continue;
|
|
7260
|
-
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);
|
|
7261
7280
|
if (value) {
|
|
7262
7281
|
label.type = "heading";
|
|
7263
7282
|
label.level = 2;
|
|
@@ -7266,7 +7285,7 @@ function detectDocumentStyleHeadings(blocks) {
|
|
|
7266
7285
|
const first = page.find((b) => b.type !== "image" && b.type !== "separator");
|
|
7267
7286
|
const second = page[page.indexOf(first) + 1];
|
|
7268
7287
|
const third = page[page.indexOf(first) + 2];
|
|
7269
|
-
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;
|
|
7270
7289
|
first.type = "heading";
|
|
7271
7290
|
first.level = 1;
|
|
7272
7291
|
first.text = `${first.text.trim()} ${second.text.trim()}`;
|
|
@@ -7290,18 +7309,18 @@ function detectSiblingStyleHeadings(blocks) {
|
|
|
7290
7309
|
for (const page of byPage.values()) {
|
|
7291
7310
|
const bodyChars = /* @__PURE__ */ new Map();
|
|
7292
7311
|
for (const block of page) {
|
|
7293
|
-
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;
|
|
7294
7313
|
const face = block.style.fontName;
|
|
7295
7314
|
bodyChars.set(face, (_nullishCoalesce(bodyChars.get(face), () => ( 0))) + block.text.length);
|
|
7296
7315
|
}
|
|
7297
|
-
const bodyFace = _optionalChain([[...bodyChars], 'access',
|
|
7298
|
-
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);
|
|
7299
7318
|
for (const anchor of anchors) {
|
|
7300
7319
|
const numbered = /^([A-Z])\.\d+\s+/.exec(anchor.text.trim());
|
|
7301
7320
|
const lettered = /^([A-Z])\s+/.exec(anchor.text.trim());
|
|
7302
|
-
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);
|
|
7303
7322
|
if (peers.length < 2 && !numbered && !lettered) continue;
|
|
7304
|
-
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()));
|
|
7305
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));
|
|
7306
7325
|
if (siblings.length < (numbered || lettered ? 1 : 2)) continue;
|
|
7307
7326
|
for (const sibling of siblings) {
|
|
@@ -7320,13 +7339,13 @@ function detectRepeatedPageLabels(blocks) {
|
|
|
7320
7339
|
}
|
|
7321
7340
|
for (const page of byPage.values()) {
|
|
7322
7341
|
const bodyChars = /* @__PURE__ */ new Map();
|
|
7323
|
-
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])) {
|
|
7324
7343
|
const faces = FACE_CHARS.get(b);
|
|
7325
7344
|
if (faces) for (const [face, n] of faces) bodyChars.set(face, (_nullishCoalesce(bodyChars.get(face), () => ( 0))) + n);
|
|
7326
7345
|
else bodyChars.set(b.style.fontName, (_nullishCoalesce(bodyChars.get(b.style.fontName), () => ( 0))) + b.text.length);
|
|
7327
7346
|
}
|
|
7328
|
-
const bodyFace = _optionalChain([[...bodyChars], 'access',
|
|
7329
|
-
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);
|
|
7330
7349
|
const groups = /* @__PURE__ */ new Map();
|
|
7331
7350
|
for (const b of candidates) {
|
|
7332
7351
|
const key = `${b.style.fontName}:${b.style.fontSize}`;
|
|
@@ -7362,19 +7381,19 @@ function detectPageLeadHeadings(blocks) {
|
|
|
7362
7381
|
for (const page of byPage.values()) {
|
|
7363
7382
|
const content = page.filter((b) => b.type !== "image" && b.type !== "separator" && !(b.type === "paragraph" && !b.style));
|
|
7364
7383
|
const [first, second, third] = content;
|
|
7365
|
-
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;
|
|
7366
7385
|
const firstText = first.text.trim();
|
|
7367
7386
|
const captionLike = /^(?:Figure|Fig\.?|Table|표|그림)\s*\d/i;
|
|
7368
7387
|
const hasImage = page.some((b) => b.type === "image");
|
|
7369
|
-
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);
|
|
7370
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);
|
|
7371
|
-
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;
|
|
7372
7391
|
if (firstIsTitle || firstAboveProse || firstIsSection) {
|
|
7373
7392
|
first.type = "heading";
|
|
7374
7393
|
first.level = 1;
|
|
7375
7394
|
}
|
|
7376
|
-
if (first.type !== "heading" || captionLike.test(firstText) || second.type !== "paragraph" || !second.text || !second.bbox || !_optionalChain([second, 'access',
|
|
7377
|
-
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;
|
|
7378
7397
|
const namedContents = /^Table of Contents$/i.test(second.text.trim());
|
|
7379
7398
|
if (distinctFace && third.text.length >= 60 || namedContents) {
|
|
7380
7399
|
second.type = "heading";
|
|
@@ -7385,24 +7404,24 @@ function detectPageLeadHeadings(blocks) {
|
|
|
7385
7404
|
function refineDocumentStyleHeadings(blocks) {
|
|
7386
7405
|
const faceChars = /* @__PURE__ */ new Map();
|
|
7387
7406
|
for (const block of blocks) {
|
|
7388
|
-
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;
|
|
7389
7408
|
faceChars.set(block.style.fontName, (_nullishCoalesce(faceChars.get(block.style.fontName), () => ( 0))) + block.text.length);
|
|
7390
7409
|
}
|
|
7391
7410
|
const [bodyFace, bodyChars] = _nullishCoalesce([...faceChars].sort((a, b) => b[1] - a[1])[0], () => ( []));
|
|
7392
7411
|
if (!bodyFace || !bodyChars || bodyChars < 300) return;
|
|
7393
7412
|
for (let i = 0; i < blocks.length; i++) {
|
|
7394
7413
|
const block = blocks[i];
|
|
7395
|
-
const text = _nullishCoalesce(_optionalChain([block, 'access',
|
|
7414
|
+
const text = _nullishCoalesce(_optionalChain([block, 'access', _333 => _333.text, 'optionalAccess', _334 => _334.trim, 'call', _335 => _335()]), () => ( ""));
|
|
7396
7415
|
if (block.type === "heading" && /(?:https?:\/\/|www\.|^arxiv:|^doi:)/i.test(text)) {
|
|
7397
7416
|
block.type = "paragraph";
|
|
7398
7417
|
block.level = void 0;
|
|
7399
7418
|
continue;
|
|
7400
7419
|
}
|
|
7401
7420
|
const box = block.bbox, style = block.style;
|
|
7402
|
-
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;
|
|
7403
7422
|
const previous = blocks[i - 1], next = blocks[i + 1];
|
|
7404
|
-
const pb = _optionalChain([previous, 'optionalAccess',
|
|
7405
|
-
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;
|
|
7406
7425
|
block.type = "heading";
|
|
7407
7426
|
block.level = 2;
|
|
7408
7427
|
}
|
|
@@ -7452,7 +7471,7 @@ function detectMarkerHeadings(blocks) {
|
|
|
7452
7471
|
block.level = 4;
|
|
7453
7472
|
continue;
|
|
7454
7473
|
}
|
|
7455
|
-
if (/^[가-힣]{2,6}$/.test(text) && _optionalChain([block, 'access',
|
|
7474
|
+
if (/^[가-힣]{2,6}$/.test(text) && _optionalChain([block, 'access', _341 => _341.style, 'optionalAccess', _342 => _342.fontSize])) {
|
|
7456
7475
|
const prev = blocks[i - 1];
|
|
7457
7476
|
const next = blocks[i + 1];
|
|
7458
7477
|
const prevIsStructural = !prev || prev.type === "table" || prev.type === "heading" || prev.type === "separator";
|
|
@@ -7493,7 +7512,7 @@ function detectTableCaptions(blocks) {
|
|
|
7493
7512
|
block.table.caption = blocks[i - 1].text.trim();
|
|
7494
7513
|
blocks.splice(i - 1, 1);
|
|
7495
7514
|
i--;
|
|
7496
|
-
} 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") {
|
|
7497
7516
|
const cap = blocks[i + 1].bbox, tbl = block.bbox;
|
|
7498
7517
|
block.table.caption = blocks[i + 1].text.trim();
|
|
7499
7518
|
if (cap && tbl && cap.y + cap.height <= tbl.y + 1) block.table.captionBelow = true;
|
|
@@ -7578,7 +7597,7 @@ function detectKoreanListBlocks(blocks) {
|
|
|
7578
7597
|
}
|
|
7579
7598
|
const listType = label.family === "arabicDot" ? "ordered" : "unordered";
|
|
7580
7599
|
const listBlock = { ...b, type: "list", listType };
|
|
7581
|
-
const pb = _optionalChain([lastTopLevelList, 'optionalAccess',
|
|
7600
|
+
const pb = _optionalChain([lastTopLevelList, 'optionalAccess', _345 => _345.bbox]), cb = b.bbox;
|
|
7582
7601
|
const notIndented = depth > 0 && !!pb && !!cb && pb.page === cb.page && cb.x >= pb.x + pb.width && cb.y >= pb.y + pb.height;
|
|
7583
7602
|
if (notIndented) familyStack = [label.family];
|
|
7584
7603
|
if (depth === 0 || notIndented) {
|
|
@@ -7736,7 +7755,7 @@ function removeHeaderFooterBlocks(blocks, pageHeights, warnings, notes, tables =
|
|
|
7736
7755
|
const b = blocks[bi];
|
|
7737
7756
|
const cellTexts = b.type === "table" && b.table ? b.table.cells.flat().map((c) => c.text.trim()).filter(Boolean) : [];
|
|
7738
7757
|
const headBox = cellTexts.length <= 4 && !!b.bbox && b.bbox.height <= (_nullishCoalesce(pageHeights.get(b.bbox.page), () => ( Infinity))) * 0.05;
|
|
7739
|
-
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;
|
|
7740
7759
|
if (!b.bbox || !b.pageNumber || !text) continue;
|
|
7741
7760
|
const ph = pageHeights.get(b.bbox.page) || pageHeights.get(b.pageNumber);
|
|
7742
7761
|
if (!ph) continue;
|
|
@@ -7769,7 +7788,7 @@ function removeHeaderFooterBlocks(blocks, pageHeights, warnings, notes, tables =
|
|
|
7769
7788
|
for (const [p, count] of patternCount) {
|
|
7770
7789
|
const pages = [..._nullishCoalesce(patternPages.get(p), () => ( []))];
|
|
7771
7790
|
const span2 = pages.length ? Math.max(...pages) - Math.min(...pages) + 1 : 0;
|
|
7772
|
-
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;
|
|
7773
7792
|
const occ = _nullishCoalesce(patternOcc.get(p), () => ( []));
|
|
7774
7793
|
const dense = pages.length >= span2 * 0.4;
|
|
7775
7794
|
const loose = looseVaryingNumber(occ, entries === topEntries) && (entries === bottomEntries || dense || tracksPages(occ));
|
|
@@ -7781,8 +7800,8 @@ function removeHeaderFooterBlocks(blocks, pageHeights, warnings, notes, tables =
|
|
|
7781
7800
|
for (const e of entries) {
|
|
7782
7801
|
const norm = e.text.replace(/\d+/g, "#");
|
|
7783
7802
|
if (!repeatedPatterns.has(norm)) continue;
|
|
7784
|
-
const noteMark = _optionalChain([e, 'access',
|
|
7785
|
-
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;
|
|
7786
7805
|
const cand = blocks[e.blockIdx];
|
|
7787
7806
|
const cb = cand.bbox;
|
|
7788
7807
|
const tableNote = /^(?:주\s*(?:\d+\s*[).:]|[::])|(?:자료|출처)\s*[::]|\*\s+\S)/.test(e.text.replace(/ \| /g, " ")) && blocks.some((o) => {
|
|
@@ -7796,7 +7815,7 @@ function removeHeaderFooterBlocks(blocks, pageHeights, warnings, notes, tables =
|
|
|
7796
7815
|
if (bi === e.blockIdx) continue;
|
|
7797
7816
|
const o = blocks[bi];
|
|
7798
7817
|
if (!o.bbox || o.bbox.page !== cb.page) continue;
|
|
7799
|
-
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, "#")]);
|
|
7800
7819
|
if (oNorm && repeatedPatterns.has(oNorm)) continue;
|
|
7801
7820
|
const overlap2 = Math.min(cb.y + cb.height, o.bbox.y + o.bbox.height) - Math.max(cb.y, o.bbox.y);
|
|
7802
7821
|
if (overlap2 >= cb.height * 0.5) {
|
|
@@ -7924,7 +7943,7 @@ function recordRowRules(table, cells, bbox, hs) {
|
|
|
7924
7943
|
function markImageCell(cell) {
|
|
7925
7944
|
IMAGE_CELLS.add(cell);
|
|
7926
7945
|
}
|
|
7927
|
-
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);
|
|
7928
7947
|
function trimTable(table) {
|
|
7929
7948
|
let cols = table.cols;
|
|
7930
7949
|
while (cols > 0 && table.cells.every((row) => emptyCell(row[cols - 1]))) cols--;
|
|
@@ -7940,7 +7959,7 @@ function trimTable(table) {
|
|
|
7940
7959
|
function trimTrailingEmptyTableCols(blocks) {
|
|
7941
7960
|
for (const b of blocks) {
|
|
7942
7961
|
if (b.type !== "table" || !b.table) continue;
|
|
7943
|
-
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);
|
|
7944
7963
|
trimTable(b.table);
|
|
7945
7964
|
}
|
|
7946
7965
|
}
|
|
@@ -7960,7 +7979,7 @@ function mergeSliverColumns(grid, colXs, maxWidth) {
|
|
|
7960
7979
|
}
|
|
7961
7980
|
const ok = owner.every((row) => {
|
|
7962
7981
|
const o = row[c];
|
|
7963
|
-
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]));
|
|
7964
7983
|
});
|
|
7965
7984
|
if (!ok) continue;
|
|
7966
7985
|
const spanning = /* @__PURE__ */ new Set();
|
|
@@ -7987,7 +8006,7 @@ var multiply = (m, t) => [
|
|
|
7987
8006
|
m[1] * t[4] + m[3] * t[5] + m[5]
|
|
7988
8007
|
];
|
|
7989
8008
|
function hollowCircle(image) {
|
|
7990
|
-
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;
|
|
7991
8010
|
const stride = image.kind === _pdfmjs.ImageKind.RGB_24BPP ? 3 : image.kind === _pdfmjs.ImageKind.RGBA_32BPP ? 4 : 0;
|
|
7992
8011
|
const { width, height, data } = image;
|
|
7993
8012
|
if (!stride || data.length < width * height * stride) return false;
|
|
@@ -8052,9 +8071,9 @@ function smallVisibleImagePaints(fnArray, argsArray) {
|
|
|
8052
8071
|
const op = fnArray[i], args = argsArray[i];
|
|
8053
8072
|
if (op === _pdfmjs.OPS.save || op === _pdfmjs.OPS.paintFormXObjectBegin) {
|
|
8054
8073
|
stack.push({ ctm, alpha, clip, unknownClip });
|
|
8055
|
-
const matrix = op === _pdfmjs.OPS.paintFormXObjectBegin ? _optionalChain([args, 'optionalAccess',
|
|
8074
|
+
const matrix = op === _pdfmjs.OPS.paintFormXObjectBegin ? _optionalChain([args, 'optionalAccess', _376 => _376[0]]) : void 0;
|
|
8056
8075
|
if (Array.isArray(matrix) && matrix.length >= 6) ctm = multiply(ctm, matrix);
|
|
8057
|
-
const bounds = op === _pdfmjs.OPS.paintFormXObjectBegin ? _optionalChain([args, 'optionalAccess',
|
|
8076
|
+
const bounds = op === _pdfmjs.OPS.paintFormXObjectBegin ? _optionalChain([args, 'optionalAccess', _377 => _377[1]]) : void 0;
|
|
8058
8077
|
if (Array.isArray(bounds) && bounds.length === 4) {
|
|
8059
8078
|
const box = rectangle(bounds[0], bounds[1], bounds[2] - bounds[0], bounds[3] - bounds[1]);
|
|
8060
8079
|
if (box && ctm[1] === 0 && ctm[2] === 0) intersectClip(box);
|
|
@@ -8062,17 +8081,17 @@ function smallVisibleImagePaints(fnArray, argsArray) {
|
|
|
8062
8081
|
}
|
|
8063
8082
|
} else if (op === _pdfmjs.OPS.restore || op === _pdfmjs.OPS.paintFormXObjectEnd) {
|
|
8064
8083
|
const state = stack.pop();
|
|
8065
|
-
ctm = _nullishCoalesce(_optionalChain([state, 'optionalAccess',
|
|
8066
|
-
alpha = _nullishCoalesce(_optionalChain([state, 'optionalAccess',
|
|
8067
|
-
clip = _nullishCoalesce(_optionalChain([state, 'optionalAccess',
|
|
8068
|
-
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));
|
|
8069
8088
|
} else if (op === _pdfmjs.OPS.setGState) {
|
|
8070
|
-
for (const [key, value] of _nullishCoalesce(_optionalChain([args, 'optionalAccess',
|
|
8089
|
+
for (const [key, value] of _nullishCoalesce(_optionalChain([args, 'optionalAccess', _382 => _382[0]]), () => ( []))) {
|
|
8071
8090
|
if (key === "ca") alpha = typeof value === "number" ? value : 0;
|
|
8072
8091
|
}
|
|
8073
8092
|
} else if (op === _pdfmjs.OPS.constructPath) {
|
|
8074
8093
|
const [operations, coordinates] = args;
|
|
8075
|
-
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;
|
|
8076
8095
|
} else if (op === _pdfmjs.OPS.clip || op === _pdfmjs.OPS.eoClip) pendingClip = true;
|
|
8077
8096
|
else if ([
|
|
8078
8097
|
_pdfmjs.OPS.endPath,
|
|
@@ -8092,7 +8111,7 @@ function smallVisibleImagePaints(fnArray, argsArray) {
|
|
|
8092
8111
|
pendingClip = false;
|
|
8093
8112
|
pathRect = void 0;
|
|
8094
8113
|
} else if (op === _pdfmjs.OPS.transform && Array.isArray(args) && args.length >= 6) ctm = multiply(ctm, args);
|
|
8095
|
-
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") {
|
|
8096
8115
|
if (typeof args[1] !== "number" || typeof args[2] !== "number" || args[1] < 16 || args[1] > 128 || args[2] < 16 || args[2] > 128) continue;
|
|
8097
8116
|
const box = extractImageRegions([_pdfmjs.OPS.transform, _pdfmjs.OPS.paintImageXObject], [ctm, args])[0];
|
|
8098
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;
|
|
@@ -8111,14 +8130,14 @@ async function restoreImageBullets(items, page, fnArray, argsArray, shapes = /*
|
|
|
8111
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];
|
|
8112
8131
|
if (!line || /^[○●•◦□■∙]/.test(line.text.trim()) || !/\p{L}/u.test(line.text)) continue;
|
|
8113
8132
|
const row = items.filter((item) => Math.abs(item.y - line.y) <= 2 && item.x >= line.x);
|
|
8114
|
-
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;
|
|
8115
8134
|
candidates.push({ id, x: box.x1, width, line });
|
|
8116
8135
|
}
|
|
8117
8136
|
let restored = 0;
|
|
8118
8137
|
const used = /* @__PURE__ */ new Set();
|
|
8119
8138
|
for (const candidate of candidates) {
|
|
8120
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);
|
|
8121
|
-
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);
|
|
8122
8141
|
const numberedList = numbered.some((item, index) => index > 0 && item.text.trim().charCodeAt(0) === numbered[index - 1].text.trim().charCodeAt(0) + 1);
|
|
8123
8142
|
if (!same.length && !numberedList || used.has(candidate.line)) continue;
|
|
8124
8143
|
if (!shapes.has(candidate.id)) shapes.set(candidate.id, hollowCircle(await resolveImagePixels(page, candidate.id)));
|
|
@@ -8184,7 +8203,7 @@ function groupFlowBoxUnits(blocks, grids, hs, vs, images) {
|
|
|
8184
8203
|
return units;
|
|
8185
8204
|
}
|
|
8186
8205
|
function arrowDirection(image) {
|
|
8187
|
-
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;
|
|
8188
8207
|
const { width, height, data } = image;
|
|
8189
8208
|
const stride = image.kind === _pdfmjs.ImageKind.RGB_24BPP ? 3 : image.kind === _pdfmjs.ImageKind.RGBA_32BPP ? 4 : 0;
|
|
8190
8209
|
if (!stride || data.length < width * height * stride) return 0;
|
|
@@ -8252,7 +8271,7 @@ function isSideTabTable(box, table, others, pageWidth, pageHeight) {
|
|
|
8252
8271
|
function removeSideTabs(blocks, pageWidths) {
|
|
8253
8272
|
const edges = /* @__PURE__ */ new Map();
|
|
8254
8273
|
for (const b of blocks) {
|
|
8255
|
-
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;
|
|
8256
8275
|
const e = _nullishCoalesce(edges.get(b.pageNumber), () => ( { lefts: [], rights: [] }));
|
|
8257
8276
|
e.lefts.push(b.bbox.x);
|
|
8258
8277
|
e.rights.push(b.bbox.x + b.bbox.width);
|
|
@@ -8268,7 +8287,7 @@ function removeSideTabs(blocks, pageWidths) {
|
|
|
8268
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;
|
|
8269
8288
|
const key = (b) => {
|
|
8270
8289
|
const w = b.pageNumber !== void 0 ? pageWidths.get(b.pageNumber) : void 0;
|
|
8271
|
-
const text = _optionalChain([b, 'access',
|
|
8290
|
+
const text = _optionalChain([b, 'access', _398 => _398.text, 'optionalAccess', _399 => _399.trim, 'call', _400 => _400()]);
|
|
8272
8291
|
const area = _nullishCoalesce((b.pageNumber !== void 0 ? body.get(b.pageNumber) : void 0), () => ( fallback));
|
|
8273
8292
|
if (b.type === "table") {
|
|
8274
8293
|
if (!w || !b.bbox || !b.table || !SIDE_TAB_TABLES.has(b.table)) return null;
|
|
@@ -8934,16 +8953,16 @@ function isProseSpread(items) {
|
|
|
8934
8953
|
for (let i = 1; i < sorted.length; i++) {
|
|
8935
8954
|
gaps.push(sorted[i].x - (sorted[i - 1].x + sorted[i - 1].w));
|
|
8936
8955
|
}
|
|
8937
|
-
const maxGap =
|
|
8956
|
+
const maxGap = _chunkZTVH2HQ5cjs.safeMax.call(void 0, gaps);
|
|
8938
8957
|
const avgLen = items.reduce((s, i) => s + i.text.length, 0) / items.length;
|
|
8939
8958
|
if (items.length >= 4 && maxGap < 40 && avgLen < 5) return true;
|
|
8940
|
-
const minGap =
|
|
8959
|
+
const minGap = _chunkZTVH2HQ5cjs.safeMin.call(void 0, gaps);
|
|
8941
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)));
|
|
8942
8961
|
}
|
|
8943
8962
|
function detectColumns(yLines) {
|
|
8944
8963
|
const allItems = yLines.flat();
|
|
8945
8964
|
if (allItems.length === 0) return null;
|
|
8946
|
-
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));
|
|
8947
8966
|
if (pageWidth < 100) return null;
|
|
8948
8967
|
let bigoLineIdx = -1;
|
|
8949
8968
|
for (let i = 0; i < yLines.length; i++) {
|
|
@@ -9168,7 +9187,7 @@ var UNDER_BOX_PAIR_MAX_EM = 2.2;
|
|
|
9168
9187
|
var UNDER_BOX_PAIR_OVERLAP = 0.8;
|
|
9169
9188
|
function markUnderlineItems(items, horizontals, verticals, nonRules) {
|
|
9170
9189
|
const underlines = [];
|
|
9171
|
-
if (_optionalChain([nonRules, 'optionalAccess',
|
|
9190
|
+
if (_optionalChain([nonRules, 'optionalAccess', _401 => _401.size])) horizontals = horizontals.filter((line) => !nonRules.has(line));
|
|
9172
9191
|
if (items.length === 0 || horizontals.length === 0) return underlines;
|
|
9173
9192
|
const tightOwners = /* @__PURE__ */ new Map();
|
|
9174
9193
|
const tightlyOwned = (line) => {
|
|
@@ -9274,7 +9293,7 @@ function hasBoxTopPair(line, maxH, horizontals, cellItems) {
|
|
|
9274
9293
|
if (ow <= 0) continue;
|
|
9275
9294
|
const overlap2 = Math.min(line.x2, o.x2) - Math.max(line.x1, o.x1);
|
|
9276
9295
|
if (overlap2 / Math.max(w, ow) < UNDER_BOX_PAIR_OVERLAP) continue;
|
|
9277
|
-
const covered = _nullishCoalesce(_optionalChain([cellItems, 'optionalAccess',
|
|
9296
|
+
const covered = _nullishCoalesce(_optionalChain([cellItems, 'optionalAccess', _402 => _402.reduce, 'call', _403 => _403((sum, item) => {
|
|
9278
9297
|
const below = item.y - o.y1;
|
|
9279
9298
|
if (below < 0.5 || below > 3 || !item.text.trim()) return sum;
|
|
9280
9299
|
return sum + Math.max(0, Math.min(o.x2, item.x + item.w) - Math.max(o.x1, item.x));
|
|
@@ -9341,13 +9360,13 @@ function partTex(group) {
|
|
|
9341
9360
|
const base = Math.min(...g.filter((i) => i.fontSize >= size * SCRIPT_SIZE_RATIO).map((i) => i.y));
|
|
9342
9361
|
let s = "", run = "";
|
|
9343
9362
|
const flush = () => {
|
|
9344
|
-
if (run) s +=
|
|
9363
|
+
if (run) s += _chunkL4GCUYDScjs.toTex.call(void 0, run);
|
|
9345
9364
|
run = "";
|
|
9346
9365
|
};
|
|
9347
9366
|
g.forEach((it, k) => {
|
|
9348
9367
|
if (it.fontSize < size * SCRIPT_SIZE_RATIO && it.y - base >= size * SCRIPT_RISE_EM) {
|
|
9349
9368
|
flush();
|
|
9350
|
-
s += `^{${
|
|
9369
|
+
s += `^{${_chunkL4GCUYDScjs.toTex.call(void 0, it.text)}}`;
|
|
9351
9370
|
return;
|
|
9352
9371
|
}
|
|
9353
9372
|
if (k && it.x - (g[k - 1].x + g[k - 1].w) > spaceGapThreshold(it.fontSize)) run += " ";
|
|
@@ -9520,12 +9539,12 @@ function rebuildUnitLine(items, grid) {
|
|
|
9520
9539
|
function prependUnitRow(cells, cols, line, usedItems) {
|
|
9521
9540
|
const text = cleanCellText(line.map((item) => item.text).join(""));
|
|
9522
9541
|
cells.unshift(Array.from({ length: cols }, (_, c) => ({ text: c === 0 ? text : "", colSpan: c === 0 ? cols : 1, rowSpan: 1 })));
|
|
9523
|
-
for (const cell of cells[0])
|
|
9542
|
+
for (const cell of cells[0]) _chunkL4GCUYDScjs.CELL_EDGES.set(cell, NO_EDGES);
|
|
9524
9543
|
for (const item of line) usedItems.add(item);
|
|
9525
9544
|
}
|
|
9526
9545
|
function attachUnitRow(items, grid, cells, cols, usedItems) {
|
|
9527
9546
|
const all = cells.flat();
|
|
9528
|
-
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;
|
|
9529
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);
|
|
9530
9549
|
let nearest = Infinity;
|
|
9531
9550
|
for (const it of above) nearest = Math.min(nearest, it.y);
|
|
@@ -9560,7 +9579,7 @@ function closeShadedTableEdges(clipGrids, horizontals, verticals, fillRects) {
|
|
|
9560
9579
|
let hs = horizontals, vs = verticals;
|
|
9561
9580
|
const restored = [];
|
|
9562
9581
|
for (const grid of clipGrids) {
|
|
9563
|
-
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;
|
|
9564
9583
|
const { x1, x2, y1: mid, y2: top } = grid.bbox;
|
|
9565
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;
|
|
9566
9585
|
const topRule = hs.find((h) => near2(h.y1, top) && near2(h.x1, x1) && near2(h.x2, x2));
|
|
@@ -10024,7 +10043,7 @@ function takeFrameSpanningText(items, cutX, pageNum, lex) {
|
|
|
10024
10043
|
const rows = groupByY([...items].sort((a, b) => b.y - a.y || a.x - b.x)).map((line) => {
|
|
10025
10044
|
const runs = [];
|
|
10026
10045
|
for (const item of [...line].sort((a, b) => a.x - b.x)) {
|
|
10027
|
-
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]]);
|
|
10028
10047
|
if (prev && item.x - (prev.x + prev.w) <= Math.max(prev.fontSize, item.fontSize) * 0.6) run.push(item);
|
|
10029
10048
|
else runs.push([item]);
|
|
10030
10049
|
}
|
|
@@ -10068,7 +10087,7 @@ function groupFrameParagraphUnits(units, frames) {
|
|
|
10068
10087
|
for (const unit of units) for (const block of unit) source.set(block, unit);
|
|
10069
10088
|
const members = /* @__PURE__ */ new Map(), emitted = /* @__PURE__ */ new Set();
|
|
10070
10089
|
for (const frame of frames) {
|
|
10071
|
-
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;
|
|
10072
10091
|
for (const block of frame) members.set(block, frame);
|
|
10073
10092
|
}
|
|
10074
10093
|
const out = [];
|
|
@@ -10081,7 +10100,7 @@ function groupFrameParagraphUnits(units, frames) {
|
|
|
10081
10100
|
}
|
|
10082
10101
|
}
|
|
10083
10102
|
for (const unit of out) {
|
|
10084
|
-
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;
|
|
10085
10104
|
const bs = unit.map((b) => b.bbox).filter((b) => !!b);
|
|
10086
10105
|
if (bs.length !== unit.length) continue;
|
|
10087
10106
|
const x = Math.min(...bs.map((b) => b.x)), y = Math.min(...bs.map((b) => b.y));
|
|
@@ -10098,14 +10117,14 @@ function groupFrameParagraphUnits(units, frames) {
|
|
|
10098
10117
|
function recordFrameTitle(table, source, pageNum) {
|
|
10099
10118
|
if (!CLIP_TABLES.has(table) || table.rows !== 1 || table.cols !== 3 || source.length < 2) return;
|
|
10100
10119
|
const cells = table.cells[0];
|
|
10101
|
-
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;
|
|
10102
10121
|
const [label, spacer, title] = cells;
|
|
10103
10122
|
if (!/^(?:붙임|별첨|첨부|부록)\s*\d{1,3}$/.test(label.text.trim()) || spacer.text.trim() || !title.text.trim()) return;
|
|
10104
10123
|
if (cells.some((c) => {
|
|
10105
|
-
const e =
|
|
10124
|
+
const e = _chunkL4GCUYDScjs.CELL_EDGES.get(c);
|
|
10106
10125
|
return !e || e.t || e.b || e.l || e.r;
|
|
10107
10126
|
})) return;
|
|
10108
|
-
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));
|
|
10109
10128
|
if (!xs || xs.length !== 4 || fs <= 0) return;
|
|
10110
10129
|
const width = xs[3] - xs[0], gap = xs[2] - xs[1];
|
|
10111
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;
|
|
@@ -10169,7 +10188,7 @@ function extendNestedShadedHeaders(clipGrids, lineGrids, horizontals, verticals,
|
|
|
10169
10188
|
const extended = [];
|
|
10170
10189
|
for (let i = 0; i < clipGrids.length; i++) {
|
|
10171
10190
|
const c = clipGrids[i], parent = c.clipParent;
|
|
10172
|
-
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;
|
|
10173
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;
|
|
10174
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;
|
|
10175
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)));
|
|
@@ -10192,7 +10211,7 @@ function attachSideTabBlocks(tab, body, pageNum) {
|
|
|
10192
10211
|
bbox: computeBBox(items, pageNum),
|
|
10193
10212
|
style: dominantStyle(items)
|
|
10194
10213
|
});
|
|
10195
|
-
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) => ({
|
|
10196
10215
|
type: "paragraph",
|
|
10197
10216
|
text: g.text.trim(),
|
|
10198
10217
|
pageNumber: pageNum,
|
|
@@ -10201,7 +10220,7 @@ function attachSideTabBlocks(tab, body, pageNum) {
|
|
|
10201
10220
|
}));
|
|
10202
10221
|
const groups = /* @__PURE__ */ new Map();
|
|
10203
10222
|
for (const g of ordered) {
|
|
10204
|
-
const cap = _optionalChain([caps, 'optionalAccess',
|
|
10223
|
+
const cap = _optionalChain([caps, 'optionalAccess', _423 => _423.get, 'call', _424 => _424(g)]);
|
|
10205
10224
|
if (cap) groups.set(cap, [..._nullishCoalesce(groups.get(cap), () => ( [])), g]);
|
|
10206
10225
|
}
|
|
10207
10226
|
for (const [cap, glyphs] of groups) {
|
|
@@ -10233,7 +10252,7 @@ function extractPageBlocksWithLines(items, pageNum, opList, pageWidth, pageHeigh
|
|
|
10233
10252
|
let prev = null;
|
|
10234
10253
|
for (const line of streamLines(items)) {
|
|
10235
10254
|
lex.addLine(mergeLineSimple(line));
|
|
10236
|
-
const fs = _nullishCoalesce(_optionalChain([dominantStyle, 'call',
|
|
10255
|
+
const fs = _nullishCoalesce(_optionalChain([dominantStyle, 'call', _425 => _425(line), 'optionalAccess', _426 => _426.fontSize]), () => ( 0));
|
|
10237
10256
|
const left = Math.min(...line.map((i) => i.x)), right = Math.max(...line.map((i) => i.x + i.w));
|
|
10238
10257
|
const y = line.reduce((n, i) => n + i.y, 0) / line.length;
|
|
10239
10258
|
const wide = fs > 0 && right - left >= 12 * fs;
|
|
@@ -10247,7 +10266,7 @@ function extractPageBlocksWithLines(items, pageNum, opList, pageWidth, pageHeigh
|
|
|
10247
10266
|
const filled = fillBlanks(items, horizontals, verticals);
|
|
10248
10267
|
items = filled.items;
|
|
10249
10268
|
horizontals = filled.horizontals;
|
|
10250
|
-
const prevPage = _optionalChain([carry, 'optionalAccess',
|
|
10269
|
+
const prevPage = _optionalChain([carry, 'optionalAccess', _427 => _427.page]) === pageNum - 1 ? carry.clip : void 0;
|
|
10251
10270
|
const images = extractImageRegions(opList.fnArray, opList.argsArray);
|
|
10252
10271
|
const clipRects = images.length ? withoutImageOnlyClips(extracted.clipRects, images) : extracted.clipRects;
|
|
10253
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 };
|
|
@@ -10545,7 +10564,7 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
|
|
|
10545
10564
|
const nested = pendingNested.length ? takePendingNested(pendingNested, cell.bbox, !!grid.cells) : [];
|
|
10546
10565
|
const lone = nested.length === 1 && !cellItems.length ? nested[0] : null;
|
|
10547
10566
|
const cw = cell.bbox.x2 - cell.bbox.x1;
|
|
10548
|
-
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())) {
|
|
10549
10568
|
irGrid[cell.row][cell.col] = { text: lone.table.cells[0][0].text, colSpan: cell.colSpan, rowSpan: cell.rowSpan };
|
|
10550
10569
|
takeClipCellEdges(cell, irGrid[cell.row][cell.col]);
|
|
10551
10570
|
continue;
|
|
@@ -10595,10 +10614,10 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
|
|
|
10595
10614
|
const ls = irGrid.slice(1).flat().flatMap((c) => c.text.split("\n")).map((t) => t.trim()).filter(Boolean);
|
|
10596
10615
|
const numericLine = (t) => {
|
|
10597
10616
|
const cs = t.replace(/\s+/g, "");
|
|
10598
|
-
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;
|
|
10599
10618
|
};
|
|
10600
10619
|
const labelValueLine = (t) => {
|
|
10601
|
-
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));
|
|
10602
10621
|
return hangul > 0 && hangul <= 6 && /\d,\d{3}/.test(t) && numericLine(t.replace(/[가-힣()]/g, ""));
|
|
10603
10622
|
};
|
|
10604
10623
|
const bulletLine = (t) => /^\s*[○◦•□■▪]/.test(t) || /^\s*-\s*[^\d\s.,−-]/.test(t) && t.replace(/\s+/g, "").length > 7;
|
|
@@ -10608,14 +10627,14 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
|
|
|
10608
10627
|
const share = ls.filter((t) => numericLine(t) || lvLines.has(t)).length / ls.length;
|
|
10609
10628
|
if (share >= 0.5) return true;
|
|
10610
10629
|
const colShares = Array.from({ length: numCols }, (_, c) => {
|
|
10611
|
-
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);
|
|
10612
10631
|
return cl.length ? cl.filter(numericLine).length / cl.length : null;
|
|
10613
10632
|
}).filter((v) => v !== null);
|
|
10614
10633
|
return share >= 0.35 && colShares.some((v) => v >= 0.8) && colShares.every((v) => v >= 0.8 || v <= 0.2);
|
|
10615
10634
|
})();
|
|
10616
10635
|
const layoutProse = irGrid.some((row) => row.some((c) => c.colSpan >= numCols - 1 && c.text.length > 60));
|
|
10617
10636
|
const maxRows = numericBody ? layoutProse ? OCR_NUMERIC_MAX_ROWS_FRAMED : OCR_NUMERIC_MAX_ROWS : 5;
|
|
10618
|
-
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, ""));
|
|
10619
10638
|
const proseCols = numRows === 2 ? (_nullishCoalesce(irGrid[1], () => ( []))).filter((c) => {
|
|
10620
10639
|
const ls = c.text.split("\n").map((t) => t.trim()).filter(Boolean);
|
|
10621
10640
|
return ls.length >= 3 && ls.filter(proseLine).length >= ls.length * 0.6;
|
|
@@ -10636,8 +10655,8 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
|
|
|
10636
10655
|
finalGrid = rebuilt.map((row, i) => {
|
|
10637
10656
|
const o = kept.get(i);
|
|
10638
10657
|
return row.map((rawText, c) => {
|
|
10639
|
-
const src = o === void 0 ? void 0 : _optionalChain([irGrid, 'access',
|
|
10640
|
-
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 };
|
|
10641
10660
|
});
|
|
10642
10661
|
});
|
|
10643
10662
|
finalRows = finalGrid.length;
|
|
@@ -10657,14 +10676,14 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
|
|
|
10657
10676
|
if (!assignedItems.has(textItems[ti]) && !inExpanded(textItems[ti])) usedItems.delete(owners[ti]);
|
|
10658
10677
|
}
|
|
10659
10678
|
}
|
|
10660
|
-
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]), () => ( "")))) {
|
|
10661
10680
|
prependUnitRow(finalGrid, numCols, unitLine, usedItems);
|
|
10662
10681
|
finalRows++;
|
|
10663
10682
|
}
|
|
10664
10683
|
if (!rebuiltUsed && attachUnitRow(items, grid, finalGrid, numCols, usedItems)) finalRows++;
|
|
10665
10684
|
let semanticOneColumn = false;
|
|
10666
10685
|
if (!grid.cells && !nestedAttached && numCols === 1 && numGridRows >= 2) {
|
|
10667
|
-
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()]));
|
|
10668
10687
|
if (populatedRows.length >= 4) {
|
|
10669
10688
|
const fontSizes = tableItems.map((item) => item.fontSize).filter((size) => size > 0).sort((a, b) => a - b);
|
|
10670
10689
|
const medianFont = _nullishCoalesce(fontSizes[Math.floor(fontSizes.length / 2)], () => ( 0));
|
|
@@ -10762,7 +10781,7 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
|
|
|
10762
10781
|
height: grid.bbox.y2 - grid.bbox.y1
|
|
10763
10782
|
};
|
|
10764
10783
|
if (numRows === 1 && numCols === 1 && gridW < pageWidth * 0.35) {
|
|
10765
|
-
const prose = _nullishCoalesce(_optionalChain([finalGrid, 'access',
|
|
10784
|
+
const prose = _nullishCoalesce(_optionalChain([finalGrid, 'access', _457 => _457[0], 'optionalAccess', _458 => _458[0], 'optionalAccess', _459 => _459.text]), () => ( ""));
|
|
10766
10785
|
const besideLines = (side) => new Set(side.map((it) => Math.round(it.y / 3))).size;
|
|
10767
10786
|
const rightLines = items.filter((it) => it.x >= grid.bbox.x2 + 3 && it.y >= grid.bbox.y1 && it.y <= grid.bbox.y2);
|
|
10768
10787
|
const leftLines = items.filter((it) => it.x + it.w <= grid.bbox.x1 - 3 && it.y >= grid.bbox.y1 && it.y <= grid.bbox.y2);
|
|
@@ -10781,8 +10800,8 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
|
|
|
10781
10800
|
}
|
|
10782
10801
|
}
|
|
10783
10802
|
if (!grid.cells && !nestedAttached && shouldDemoteTable(irTable)) {
|
|
10784
|
-
const paragraphs = numRows === 1 && numCols === 1 ? _optionalChain([irTable, 'access',
|
|
10785
|
-
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])) {
|
|
10786
10805
|
blocks.push(...paragraphs);
|
|
10787
10806
|
frameParagraphUnits.push(paragraphs);
|
|
10788
10807
|
recordFrameReadingUnit(paragraphs, tableBbox);
|
|
@@ -10829,7 +10848,7 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
|
|
|
10829
10848
|
const clusterResults = (proseColumns ? [] : detectClusterTables(clusterItems, pageNum, void 0, lex)).filter((cr) => {
|
|
10830
10849
|
const b = cr.bbox;
|
|
10831
10850
|
const overlapX = (x) => Math.min(x.x + x.width, b.x + b.width) - Math.max(x.x, b.x);
|
|
10832
|
-
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)));
|
|
10833
10852
|
});
|
|
10834
10853
|
if (clusterResults.length > 0) {
|
|
10835
10854
|
const ciToIdx = /* @__PURE__ */ new Map();
|
|
@@ -10866,7 +10885,7 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
|
|
|
10866
10885
|
groupSizes.push(1);
|
|
10867
10886
|
}
|
|
10868
10887
|
const allY = remaining.map((i) => i.y);
|
|
10869
|
-
const pageH =
|
|
10888
|
+
const pageH = _chunkZTVH2HQ5cjs.safeMax.call(void 0, allY) - _chunkZTVH2HQ5cjs.safeMin.call(void 0, allY);
|
|
10870
10889
|
const gapThreshold = Math.max(15, pageH * 0.03);
|
|
10871
10890
|
const sides = frameColumnTextBands(remaining, spanning, gx);
|
|
10872
10891
|
const textBlocks = [];
|
|
@@ -10882,7 +10901,7 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
|
|
|
10882
10901
|
finalTextBlocks.push(...detectListBlocks(textBlocks));
|
|
10883
10902
|
} else {
|
|
10884
10903
|
const allY = remaining.map((i) => i.y);
|
|
10885
|
-
const pageH =
|
|
10904
|
+
const pageH = _chunkZTVH2HQ5cjs.safeMax.call(void 0, allY) - _chunkZTVH2HQ5cjs.safeMin.call(void 0, allY);
|
|
10886
10905
|
const gapThreshold = Math.max(15, pageH * 0.03);
|
|
10887
10906
|
const groups = xyCutOrder(remaining, gapThreshold, 0, void 0, 0, lex);
|
|
10888
10907
|
const textBlocks = [];
|
|
@@ -11244,7 +11263,7 @@ function extractPageBlocksFallback(items, pageNum, fullPage = false, detectTable
|
|
|
11244
11263
|
blocks.push(...columnTextToBlocks(tableText, pageNum, bbox, dominantStyle(items)));
|
|
11245
11264
|
} else {
|
|
11246
11265
|
const allY = items.map((i) => i.y);
|
|
11247
|
-
const pageHeight =
|
|
11266
|
+
const pageHeight = _chunkZTVH2HQ5cjs.safeMax.call(void 0, allY) - _chunkZTVH2HQ5cjs.safeMin.call(void 0, allY);
|
|
11248
11267
|
const gapThreshold = Math.max(15, pageHeight * 0.03);
|
|
11249
11268
|
const orderedGroups = proseCutX !== null ? splitTwoColumnProse(items, proseCutX) : xyCutOrder(items, gapThreshold, 0, void 0, minGap, lex);
|
|
11250
11269
|
for (const group of orderedGroups) {
|
|
@@ -11301,19 +11320,19 @@ function mergeOcrImageRegions(blocks, page, regions, ocrBlocks) {
|
|
|
11301
11320
|
const overlapH = Math.max(0, Math.min(b.y + b.height, region.y2) - Math.max(b.y, region.y1));
|
|
11302
11321
|
return overlapW * overlapH >= b.width * b.height * 0.8;
|
|
11303
11322
|
});
|
|
11304
|
-
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);
|
|
11305
11324
|
const axisFragments = rotatedAxisFragments(candidates);
|
|
11306
11325
|
const accepted = candidates.filter((b) => {
|
|
11307
|
-
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));
|
|
11308
11327
|
const t = b.table;
|
|
11309
11328
|
if (b.type !== "table" || !t || UNRULED_REGION_TABLES.has(b)) return false;
|
|
11310
11329
|
const lone = t.cells.filter((row) => row.filter((c) => c.text.trim()).length === 1 && row.some((c) => c.colSpan === t.cols)).length;
|
|
11311
11330
|
if (t.rows >= 2 && lone * 2 >= t.rows) return false;
|
|
11312
11331
|
if (t.rows === 1 && t.cols === 1) {
|
|
11313
|
-
const text = _nullishCoalesce(_optionalChain([t, 'access',
|
|
11314
|
-
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;
|
|
11315
11334
|
}
|
|
11316
|
-
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));
|
|
11317
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);
|
|
11318
11337
|
});
|
|
11319
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, () => ( "")))) : []);
|
|
@@ -11330,14 +11349,14 @@ function mergeOcrImageRegions(blocks, page, regions, ocrBlocks) {
|
|
|
11330
11349
|
for (const block of selected) {
|
|
11331
11350
|
if (seen2.has(block)) continue;
|
|
11332
11351
|
const frame = FRAME_READING_UNITS.get(block);
|
|
11333
|
-
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];
|
|
11334
11353
|
source.forEach((member) => seen2.add(member));
|
|
11335
11354
|
const available = source.filter((member) => !hasOriginal(member));
|
|
11336
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 }));
|
|
11337
11356
|
for (const unit of units) {
|
|
11338
11357
|
const b = unit.bbox;
|
|
11339
11358
|
const index = blocks.findIndex((existing) => {
|
|
11340
|
-
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));
|
|
11341
11360
|
if (existing.pageNumber !== page || !e) return false;
|
|
11342
11361
|
const beside = e.y < region.y2 && e.y + e.height > region.y1 && e.x >= region.x2 - 1;
|
|
11343
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;
|
|
@@ -11355,16 +11374,16 @@ function mergeOcrImageRegions(blocks, page, regions, ocrBlocks) {
|
|
|
11355
11374
|
}
|
|
11356
11375
|
function axisTick(block, candidates) {
|
|
11357
11376
|
const b = block.bbox;
|
|
11358
|
-
if (!/^\d$/u.test(_nullishCoalesce(_optionalChain([block, 'access',
|
|
11359
|
-
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);
|
|
11360
11379
|
const cy = b.y + b.height / 2, right = b.x + b.width;
|
|
11361
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);
|
|
11362
11381
|
const column = numeric.filter((o) => Math.abs(o.bbox.x + o.bbox.width - right) <= Math.max(o.bbox.height, b.height) * 0.5);
|
|
11363
11382
|
return row.length >= 2 || column.length >= 2;
|
|
11364
11383
|
}
|
|
11365
11384
|
function supportedDiagramLabel(block, labels, region) {
|
|
11366
|
-
const b = block.bbox, text = _nullishCoalesce(_optionalChain([block, 'access',
|
|
11367
|
-
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;
|
|
11368
11387
|
let above = false, below = false;
|
|
11369
11388
|
for (const label of labels) {
|
|
11370
11389
|
const a = label.bbox, em = Math.max(b.height, a.height);
|
|
@@ -11379,7 +11398,7 @@ function rotatedAxisFragments(candidates) {
|
|
|
11379
11398
|
const paragraphs = candidates.filter((b) => b.type === "paragraph" && b.bbox.height <= 24);
|
|
11380
11399
|
const axes = [];
|
|
11381
11400
|
for (const block of paragraphs) {
|
|
11382
|
-
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()]), () => ( ""));
|
|
11383
11402
|
if (!/^[\d\s.,%+−-]+$/u.test(text) || !/\d/u.test(text) || b.width > b.height * 6) continue;
|
|
11384
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);
|
|
11385
11404
|
if (axis) axis.push(block);
|
|
@@ -11396,8 +11415,8 @@ function rotatedAxisFragments(candidates) {
|
|
|
11396
11415
|
const em = Math.max(...axis.map((a) => a.bbox.height)), right = axis[0].bbox.x + axis[0].bbox.width;
|
|
11397
11416
|
if (top - bottom < em * 6) continue;
|
|
11398
11417
|
const left = paragraphs.filter((block) => {
|
|
11399
|
-
const b = block.bbox, text = _nullishCoalesce(_optionalChain([block, 'access',
|
|
11400
|
-
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;
|
|
11401
11420
|
});
|
|
11402
11421
|
const stack = left.filter((a) => left.some((b) => {
|
|
11403
11422
|
if (a === b || !aligned(a, b)) return false;
|
|
@@ -11407,7 +11426,7 @@ function rotatedAxisFragments(candidates) {
|
|
|
11407
11426
|
if (stack.length < 2) continue;
|
|
11408
11427
|
for (const block of paragraphs) {
|
|
11409
11428
|
const b = block.bbox;
|
|
11410
|
-
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);
|
|
11411
11430
|
}
|
|
11412
11431
|
}
|
|
11413
11432
|
return fragments;
|
|
@@ -11514,4 +11533,4 @@ function rowParagraphs(block) {
|
|
|
11514
11533
|
|
|
11515
11534
|
|
|
11516
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;
|
|
11517
|
-
//# sourceMappingURL=chunk-
|
|
11536
|
+
//# sourceMappingURL=chunk-COG4POSK.cjs.map
|