kordoc 4.24.69 → 4.24.71
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/dist/{-KG4BXVPV.js → -F7GLIIGT.js} +21 -21
- package/dist/{chunk-3MQXPZ6R.js → chunk-2CPEW6WC.js} +3 -3
- package/dist/{chunk-3LYXCBQ6.js → chunk-2OF2YWIZ.js} +2 -2
- package/dist/{chunk-PZ7NOQHD.js → chunk-2VBRCIPI.js} +2 -2
- package/dist/{chunk-OWYYRDZR.js → chunk-5WWGC5SG.js} +2 -2
- package/dist/{chunk-LERHV2DV.js → chunk-6ZA4V4QS.js} +2 -2
- package/dist/{chunk-EBBPXRLU.js → chunk-7KVDHXP2.js} +4 -4
- package/dist/{chunk-YBV3DCBB.js → chunk-AUHQRRKM.js} +3 -3
- package/dist/{chunk-6RAP7IYO.js → chunk-BHYBZSOC.js} +2 -2
- package/dist/{chunk-YYGN4RAC.cjs → chunk-BNP3WXTB.cjs} +3 -3
- package/dist/{chunk-YYGN4RAC.cjs.map → chunk-BNP3WXTB.cjs.map} +1 -1
- package/dist/{chunk-53KBBSHJ.js → chunk-D4UFBXMT.js} +2 -2
- package/dist/{chunk-QXZZ37WG.js → chunk-DSCT67WF.js} +3 -3
- package/dist/{chunk-C3OMT5XO.js → chunk-EZNUMAAJ.js} +2 -2
- package/dist/{chunk-4NPX2NIK.js → chunk-GFAWIBHG.js} +10 -10
- package/dist/{chunk-KXVMRGSM.js → chunk-GRCIFCGC.js} +2 -2
- package/dist/{chunk-SQXRRR75.cjs → chunk-H2VOH7X3.cjs} +246 -198
- package/dist/chunk-H2VOH7X3.cjs.map +1 -0
- package/dist/{chunk-AAIU5QXZ.js → chunk-HIYRMYAS.js} +2 -2
- package/dist/{chunk-OYXFVDEL.js → chunk-IMT5TVVM.js} +2 -2
- package/dist/{chunk-KCA54CHN.js → chunk-KGCJNPAI.js} +5 -5
- package/dist/{chunk-EM6II5KB.js → chunk-KLUI4SAZ.js} +2 -2
- package/dist/{chunk-4SKZG3K4.cjs → chunk-LFTO5QAP.cjs} +2 -2
- package/dist/{chunk-4SKZG3K4.cjs.map → chunk-LFTO5QAP.cjs.map} +1 -1
- package/dist/{chunk-4P4ZWHNQ.js → chunk-LNWURZ2Z.js} +7 -7
- package/dist/{chunk-V37SADMF.js → chunk-M27VBFO6.js} +83 -35
- package/dist/chunk-M27VBFO6.js.map +1 -0
- package/dist/{chunk-I776RNAM.js → chunk-MHXPW72E.js} +2 -2
- package/dist/{chunk-YJA4HQUO.js → chunk-NPBNJCXZ.js} +2 -2
- package/dist/{chunk-3APUYEC6.js → chunk-O7PJFEOC.js} +2 -2
- package/dist/{chunk-3CUPBG7W.js → chunk-OJK4FLS5.js} +3 -3
- package/dist/{chunk-U456OELH.js → chunk-OUHMNF2A.js} +2 -2
- package/dist/{chunk-AQSU4NAT.cjs → chunk-OW2XKTQA.cjs} +8 -8
- package/dist/{chunk-AQSU4NAT.cjs.map → chunk-OW2XKTQA.cjs.map} +1 -1
- package/dist/{chunk-ZPSCL2UV.js → chunk-QK5KCWLE.js} +2 -2
- package/dist/{chunk-FQHTZNNA.js → chunk-RUUUGCXS.js} +6 -6
- package/dist/{chunk-MQHAFMEU.js → chunk-RWU3Y5YK.js} +15 -15
- package/dist/{chunk-5ZDXCGBI.cjs → chunk-SK5AOGYK.cjs} +104 -104
- package/dist/{chunk-5ZDXCGBI.cjs.map → chunk-SK5AOGYK.cjs.map} +1 -1
- package/dist/{chunk-6ZWX733V.js → chunk-SMEBVDM2.js} +7 -6
- package/dist/chunk-SMEBVDM2.js.map +1 -0
- package/dist/{chunk-R32ERRRI.js → chunk-T7MHZIFG.js} +84 -36
- package/dist/chunk-T7MHZIFG.js.map +1 -0
- package/dist/{chunk-GMTI7GBK.js → chunk-TYGZ6O2A.js} +11 -11
- package/dist/{chunk-OEBMM2WZ.js → chunk-UJQRIX4L.js} +2 -2
- package/dist/{chunk-XHAM4CGG.js → chunk-WMA4GJHC.js} +7 -6
- package/dist/chunk-WMA4GJHC.js.map +1 -0
- package/dist/{chunk-6T2QXCFD.cjs → chunk-YISBYF7X.cjs} +60 -59
- package/dist/chunk-YISBYF7X.cjs.map +1 -0
- package/dist/{chunk-OZWNUIUS.cjs → chunk-YJ2YVG6N.cjs} +88 -88
- package/dist/{chunk-OZWNUIUS.cjs.map → chunk-YJ2YVG6N.cjs.map} +1 -1
- package/dist/{chunk-JDHX44G4.js → chunk-YPRIJDH6.js} +2 -2
- package/dist/{chunk-ONKURIVQ.js → chunk-YTDHH362.js} +2 -2
- package/dist/{chunk-6RWM6WRI.cjs → chunk-YTP7FPA5.cjs} +3 -3
- package/dist/{chunk-6RWM6WRI.cjs.map → chunk-YTP7FPA5.cjs.map} +1 -1
- package/dist/{chunk-MHRKKMCS.js → chunk-ZPJZXTEG.js} +6 -6
- package/dist/chunks-JAD5Z5YY.js +11 -0
- package/dist/cli.js +45 -45
- package/dist/{formula-ACYUF2DL.js → formula-3PJYUQMG.js} +4 -4
- package/dist/{formula-4HIPZCUM.cjs → formula-RTPZD2IM.cjs} +9 -9
- package/dist/{formula-4HIPZCUM.cjs.map → formula-RTPZD2IM.cjs.map} +1 -1
- package/dist/{formula-TO3RLKBZ.js → formula-UJF4RZ6W.js} +3 -3
- package/dist/generator-EB2436BE.js +18 -0
- package/dist/generator-INMUN6KB.cjs +12 -0
- package/dist/{generator-UAEKNWCY.cjs.map → generator-INMUN6KB.cjs.map} +1 -1
- package/dist/generator-K5KMPSLC.js +11 -0
- package/dist/{hancom-4FAVUJFH.cjs → hancom-MVPEYI4X.cjs} +5 -5
- package/dist/{hancom-4FAVUJFH.cjs.map → hancom-MVPEYI4X.cjs.map} +1 -1
- package/dist/{hancom-JLRWAJ7K.js → hancom-P3SUQXM4.js} +2 -2
- package/dist/{hancom-FCNE5FBM.js → hancom-RYIZHWJ5.js} +2 -2
- package/dist/{image-ocr-53K5Y7RJ.js → image-ocr-GL5YVCNU.js} +10 -10
- package/dist/{image-ocr-HGYEY56S.cjs → image-ocr-ZS4EMQN3.cjs} +28 -28
- package/dist/{image-ocr-HGYEY56S.cjs.map → image-ocr-ZS4EMQN3.cjs.map} +1 -1
- package/dist/{image-ocr-ZIHIC6E7.js → image-ocr-ZXLHPQI2.js} +7 -7
- package/dist/index.cjs +1115 -1115
- package/dist/index.js +9 -9
- package/dist/mcp.js +36 -36
- package/dist/memo-JNMSGIO7.js +17 -0
- package/dist/{model-bundle-VR77PCZE.js → model-bundle-VCUAKBF3.js} +5 -5
- package/dist/{models-CLF7ODRG.js → models-UACAGYBI.js} +5 -5
- package/dist/{parse-worker-v2-WXRS3WBA.js → parse-worker-v2-LJB4QXGF.js} +22 -22
- package/dist/{parser-LKSBUPHG.js → parser-5GZUD22P.js} +12 -12
- package/dist/{parser-H27KVKB7.js → parser-HCZD4DUO.js} +9 -9
- package/dist/{parser-7UHFKMVL.cjs → parser-T4HAQ3QW.cjs} +166 -166
- package/dist/{parser-7UHFKMVL.cjs.map → parser-T4HAQ3QW.cjs.map} +1 -1
- package/dist/pdf-ocr-H4DKZSOB.cjs +43 -0
- package/dist/{pdf-ocr-Z22C7K6C.cjs.map → pdf-ocr-H4DKZSOB.cjs.map} +1 -1
- package/dist/{pdf-ocr-AYLXK6OF.js → pdf-ocr-JXVGK5MR.js} +6 -6
- package/dist/{pdf-ocr-ABMCDMIV.js → pdf-ocr-YCMC2VL4.js} +9 -9
- package/dist/{profile-io-HGOQULXZ.js → profile-io-MVTEOXAU.js} +3 -3
- package/dist/{rasterize-5RWYKMSP.js → rasterize-VWT3C3RW.js} +3 -3
- package/dist/{redact-doc-HNKVSOLJ.js → redact-doc-SU3JDC6F.js} +21 -21
- package/dist/{render-TUDHFNDV.js → render-D5N4FKWB.js} +12 -12
- package/dist/{rewrite-fallback-EWVH2MR4.js → rewrite-fallback-QXTWSPGY.js} +13 -13
- package/dist/seal-Q3BD6CRB.js +16 -0
- package/dist/{setup-5EEOZUUH.js → setup-TXNJYX6P.js} +3 -3
- package/dist/to-hwpx-KZTTH7EY.cjs +16 -0
- package/dist/{to-hwpx-RNZ72ZYF.cjs.map → to-hwpx-KZTTH7EY.cjs.map} +1 -1
- package/dist/{to-hwpx-UHNIAQ2L.js → to-hwpx-YHGVFTBO.js} +4 -4
- package/dist/{to-hwpx-6KY7WGVN.js → to-hwpx-Z7NHUMUD.js} +7 -7
- package/dist/visual-LNHFYJDL.js +38 -0
- package/dist/{watch-SZJOKRCO.js → watch-EI5QYDT2.js} +22 -22
- package/package.json +1 -1
- package/dist/chunk-6T2QXCFD.cjs.map +0 -1
- package/dist/chunk-6ZWX733V.js.map +0 -1
- package/dist/chunk-R32ERRRI.js.map +0 -1
- package/dist/chunk-SQXRRR75.cjs.map +0 -1
- package/dist/chunk-V37SADMF.js.map +0 -1
- package/dist/chunk-XHAM4CGG.js.map +0 -1
- package/dist/chunks-HN36MEGV.js +0 -11
- package/dist/generator-5NUDHWLL.js +0 -11
- package/dist/generator-K2CNNN64.js +0 -18
- package/dist/generator-UAEKNWCY.cjs +0 -12
- package/dist/memo-ALIRNVIU.js +0 -17
- package/dist/pdf-ocr-Z22C7K6C.cjs +0 -43
- package/dist/seal-R6WDXSRI.js +0 -16
- package/dist/to-hwpx-RNZ72ZYF.cjs +0 -16
- package/dist/visual-Z5HND4S7.js +0 -38
- /package/dist/{-KG4BXVPV.js.map → -F7GLIIGT.js.map} +0 -0
- /package/dist/{chunk-3MQXPZ6R.js.map → chunk-2CPEW6WC.js.map} +0 -0
- /package/dist/{chunk-3LYXCBQ6.js.map → chunk-2OF2YWIZ.js.map} +0 -0
- /package/dist/{chunk-PZ7NOQHD.js.map → chunk-2VBRCIPI.js.map} +0 -0
- /package/dist/{chunk-OWYYRDZR.js.map → chunk-5WWGC5SG.js.map} +0 -0
- /package/dist/{chunk-LERHV2DV.js.map → chunk-6ZA4V4QS.js.map} +0 -0
- /package/dist/{chunk-EBBPXRLU.js.map → chunk-7KVDHXP2.js.map} +0 -0
- /package/dist/{chunk-YBV3DCBB.js.map → chunk-AUHQRRKM.js.map} +0 -0
- /package/dist/{chunk-6RAP7IYO.js.map → chunk-BHYBZSOC.js.map} +0 -0
- /package/dist/{chunk-53KBBSHJ.js.map → chunk-D4UFBXMT.js.map} +0 -0
- /package/dist/{chunk-QXZZ37WG.js.map → chunk-DSCT67WF.js.map} +0 -0
- /package/dist/{chunk-C3OMT5XO.js.map → chunk-EZNUMAAJ.js.map} +0 -0
- /package/dist/{chunk-4NPX2NIK.js.map → chunk-GFAWIBHG.js.map} +0 -0
- /package/dist/{chunk-KXVMRGSM.js.map → chunk-GRCIFCGC.js.map} +0 -0
- /package/dist/{chunk-AAIU5QXZ.js.map → chunk-HIYRMYAS.js.map} +0 -0
- /package/dist/{chunk-OYXFVDEL.js.map → chunk-IMT5TVVM.js.map} +0 -0
- /package/dist/{chunk-KCA54CHN.js.map → chunk-KGCJNPAI.js.map} +0 -0
- /package/dist/{chunk-EM6II5KB.js.map → chunk-KLUI4SAZ.js.map} +0 -0
- /package/dist/{chunk-4P4ZWHNQ.js.map → chunk-LNWURZ2Z.js.map} +0 -0
- /package/dist/{chunk-I776RNAM.js.map → chunk-MHXPW72E.js.map} +0 -0
- /package/dist/{chunk-YJA4HQUO.js.map → chunk-NPBNJCXZ.js.map} +0 -0
- /package/dist/{chunk-3APUYEC6.js.map → chunk-O7PJFEOC.js.map} +0 -0
- /package/dist/{chunk-3CUPBG7W.js.map → chunk-OJK4FLS5.js.map} +0 -0
- /package/dist/{chunk-U456OELH.js.map → chunk-OUHMNF2A.js.map} +0 -0
- /package/dist/{chunk-ZPSCL2UV.js.map → chunk-QK5KCWLE.js.map} +0 -0
- /package/dist/{chunk-FQHTZNNA.js.map → chunk-RUUUGCXS.js.map} +0 -0
- /package/dist/{chunk-MQHAFMEU.js.map → chunk-RWU3Y5YK.js.map} +0 -0
- /package/dist/{chunk-GMTI7GBK.js.map → chunk-TYGZ6O2A.js.map} +0 -0
- /package/dist/{chunk-OEBMM2WZ.js.map → chunk-UJQRIX4L.js.map} +0 -0
- /package/dist/{chunk-JDHX44G4.js.map → chunk-YPRIJDH6.js.map} +0 -0
- /package/dist/{chunk-ONKURIVQ.js.map → chunk-YTDHH362.js.map} +0 -0
- /package/dist/{chunk-MHRKKMCS.js.map → chunk-ZPJZXTEG.js.map} +0 -0
- /package/dist/{chunks-HN36MEGV.js.map → chunks-JAD5Z5YY.js.map} +0 -0
- /package/dist/{formula-ACYUF2DL.js.map → formula-3PJYUQMG.js.map} +0 -0
- /package/dist/{formula-TO3RLKBZ.js.map → formula-UJF4RZ6W.js.map} +0 -0
- /package/dist/{generator-5NUDHWLL.js.map → generator-EB2436BE.js.map} +0 -0
- /package/dist/{generator-K2CNNN64.js.map → generator-K5KMPSLC.js.map} +0 -0
- /package/dist/{hancom-JLRWAJ7K.js.map → hancom-P3SUQXM4.js.map} +0 -0
- /package/dist/{hancom-FCNE5FBM.js.map → hancom-RYIZHWJ5.js.map} +0 -0
- /package/dist/{image-ocr-53K5Y7RJ.js.map → image-ocr-GL5YVCNU.js.map} +0 -0
- /package/dist/{image-ocr-ZIHIC6E7.js.map → image-ocr-ZXLHPQI2.js.map} +0 -0
- /package/dist/{memo-ALIRNVIU.js.map → memo-JNMSGIO7.js.map} +0 -0
- /package/dist/{model-bundle-VR77PCZE.js.map → model-bundle-VCUAKBF3.js.map} +0 -0
- /package/dist/{models-CLF7ODRG.js.map → models-UACAGYBI.js.map} +0 -0
- /package/dist/{parse-worker-v2-WXRS3WBA.js.map → parse-worker-v2-LJB4QXGF.js.map} +0 -0
- /package/dist/{parser-LKSBUPHG.js.map → parser-5GZUD22P.js.map} +0 -0
- /package/dist/{parser-H27KVKB7.js.map → parser-HCZD4DUO.js.map} +0 -0
- /package/dist/{pdf-ocr-ABMCDMIV.js.map → pdf-ocr-JXVGK5MR.js.map} +0 -0
- /package/dist/{pdf-ocr-AYLXK6OF.js.map → pdf-ocr-YCMC2VL4.js.map} +0 -0
- /package/dist/{profile-io-HGOQULXZ.js.map → profile-io-MVTEOXAU.js.map} +0 -0
- /package/dist/{rasterize-5RWYKMSP.js.map → rasterize-VWT3C3RW.js.map} +0 -0
- /package/dist/{redact-doc-HNKVSOLJ.js.map → redact-doc-SU3JDC6F.js.map} +0 -0
- /package/dist/{render-TUDHFNDV.js.map → render-D5N4FKWB.js.map} +0 -0
- /package/dist/{rewrite-fallback-EWVH2MR4.js.map → rewrite-fallback-QXTWSPGY.js.map} +0 -0
- /package/dist/{seal-R6WDXSRI.js.map → seal-Q3BD6CRB.js.map} +0 -0
- /package/dist/{setup-5EEOZUUH.js.map → setup-TXNJYX6P.js.map} +0 -0
- /package/dist/{to-hwpx-6KY7WGVN.js.map → to-hwpx-YHGVFTBO.js.map} +0 -0
- /package/dist/{to-hwpx-UHNIAQ2L.js.map → to-hwpx-Z7NHUMUD.js.map} +0 -0
- /package/dist/{visual-Z5HND4S7.js.map → visual-LNHFYJDL.js.map} +0 -0
- /package/dist/{watch-SZJOKRCO.js.map → watch-EI5QYDT2.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 _chunkYTP7FPA5cjs = require('./chunk-YTP7FPA5.cjs');
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
@@ -9,11 +9,11 @@ var _chunk6RWM6WRIcjs = require('./chunk-6RWM6WRI.cjs');
|
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _chunkOW2XKTQAcjs = require('./chunk-OW2XKTQA.cjs');
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
|
|
16
|
-
var
|
|
16
|
+
var _chunkLFTO5QAPcjs = require('./chunk-LFTO5QAP.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 _chunkYTP7FPA5cjs.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 _chunkYTP7FPA5cjs.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) _chunkOW2XKTQAcjs.CELL_EDGES.set(to, e);
|
|
3418
3418
|
}
|
|
3419
3419
|
function hasOpenCellSeam(a, b) {
|
|
3420
|
-
const u =
|
|
3420
|
+
const u = _chunkOW2XKTQAcjs.CELL_EDGES.get(a), d = _chunkOW2XKTQAcjs.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 = _chunkOW2XKTQAcjs.CELL_EDGES.get(a), d = _chunkOW2XKTQAcjs.CELL_EDGES.get(b);
|
|
3425
3425
|
if (!u || !d) return;
|
|
3426
|
-
|
|
3426
|
+
_chunkOW2XKTQAcjs.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 _chunkOW2XKTQAcjs.tidyScriptTags.call(void 0, out);
|
|
3612
3612
|
}
|
|
3613
3613
|
|
|
3614
3614
|
// src/pdf/line-wrap.ts
|
|
@@ -3778,7 +3778,7 @@ function particleContinues(left, rightWord) {
|
|
|
3778
3778
|
if (ADNOMINAL_HAN.test(right)) return h.length >= 2 && !auxBefore(h) && !/(?:는|은|한|다|어|년)$/.test(h);
|
|
3779
3779
|
return VERB_FORM.test(right) && !auxBefore(h) && !((last === "\uC774" || last === "\uAC00" && h.length >= 3) && BECOME.test(right));
|
|
3780
3780
|
}
|
|
3781
|
-
var ITEM_HEAD = /^(?:[□■◆◇○●◎◦▪▫•※▶▷►❍❏❑✓✔➢➤☞]|[①-⑳]|[
|
|
3781
|
+
var ITEM_HEAD = /^(?:[□■◆◇○●◎◦▪▫•※▶▷►❍❏❑✓✔➢➤☞]|[①-⑳]|[-–·∙ㆍ*#](?=\s)|\(?\d{1,2}[.)](?!\d)|\(?[가-하][.)]|\([가-하\d]{1,2}\)|[ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩ]|제\d+[조항호장절])/;
|
|
3782
3782
|
function startsNewItem(prevText, nextText) {
|
|
3783
3783
|
const t = nextText.replace(MARKUP, "").trimStart();
|
|
3784
3784
|
const prev = prevText.replace(MARKUP, "").trimEnd();
|
|
@@ -3848,7 +3848,8 @@ function joinPageBreakWraps(blocks, lex) {
|
|
|
3848
3848
|
pageLeft.set(b.pageNumber, Math.min(_nullishCoalesce(pageLeft.get(b.pageNumber), () => ( Infinity)), b.bbox.x));
|
|
3849
3849
|
}
|
|
3850
3850
|
for (let i = blocks.length - 1; i > 0; i--) {
|
|
3851
|
-
const
|
|
3851
|
+
const note = i >= 2 && footnoteBetween(blocks[i - 2], blocks[i - 1], blocks[i]) ? blocks[i - 1] : null;
|
|
3852
|
+
const a = note ? blocks[i - 2] : blocks[i - 1], b = blocks[i];
|
|
3852
3853
|
if (!a.pageNumber || b.pageNumber !== a.pageNumber + 1 || !a.text || !b.text) continue;
|
|
3853
3854
|
if (a.type !== "paragraph" && a.type !== "list" || b.type !== "paragraph") continue;
|
|
3854
3855
|
const last = a.bbox && PARA_LAST_LINE.get(a.bbox), fs = last ? last.fontSize : 0;
|
|
@@ -3872,8 +3873,17 @@ function joinPageBreakWraps(blocks, lex) {
|
|
|
3872
3873
|
if (bl) PARA_LAST_LINE.set(a.bbox, bl);
|
|
3873
3874
|
else PARA_LAST_LINE.delete(a.bbox);
|
|
3874
3875
|
blocks.splice(i, 1);
|
|
3876
|
+
if (note) i--;
|
|
3875
3877
|
}
|
|
3876
3878
|
}
|
|
3879
|
+
function footnoteBetween(a, f, b) {
|
|
3880
|
+
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', _101 => _101.style, 'optionalAccess', _102 => _102.fontSize]), () => ( 0)), ffs = _nullishCoalesce(_optionalChain([f, 'access', _103 => _103.style, 'optionalAccess', _104 => _104.fontSize]), () => ( 0));
|
|
3882
|
+
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', _105 => _105.text, 'optionalAccess', _106 => _106.replace, 'call', _107 => _107(MARKUP, ""), 'access', _108 => _108.trimEnd, 'call', _109 => _109()]), () => ( ""));
|
|
3884
|
+
if (/[가-힣]/.test(at) || SENTENCE_END.test(at)) return false;
|
|
3885
|
+
return /^(?:\d{1,2}\)?\s|\*|※)/.test(f.text.replace(MARKUP, "").trimStart());
|
|
3886
|
+
}
|
|
3877
3887
|
function splitPageBreakWraps(blocks) {
|
|
3878
3888
|
return blocks.flatMap((b) => {
|
|
3879
3889
|
const cuts = b.bbox && PAGE_BREAK_JOINS.get(b.bbox);
|
|
@@ -3910,7 +3920,7 @@ function bodyLineJoins(lines, lex) {
|
|
|
3910
3920
|
for (const l of lines) if (!HANGING.test(l.text) && l.right > inner) inner = l.right;
|
|
3911
3921
|
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;
|
|
3912
3922
|
const nextWordNoRoom = (a, b) => {
|
|
3913
|
-
const w = _optionalChain([b, 'access',
|
|
3923
|
+
const w = _optionalChain([b, 'access', _110 => _110.text, 'access', _111 => _111.trim, 'call', _112 => _112(), 'access', _113 => _113.match, 'call', _114 => _114(/^\S+/), 'optionalAccess', _115 => _115[0]]);
|
|
3914
3924
|
const n = [...b.text.trim()].length;
|
|
3915
3925
|
if (!w || n === 0) return false;
|
|
3916
3926
|
const em = (b.right - b.left) / n;
|
|
@@ -3936,14 +3946,18 @@ function bodyLineJoins(lines, lex) {
|
|
|
3936
3946
|
const a = lines[i], b = lines[i + 1];
|
|
3937
3947
|
const fs = a.fontSize;
|
|
3938
3948
|
const own = i === i1 ? p2 : p1;
|
|
3939
|
-
const others = Number.isFinite(own) ? own : _nullishCoalesce(_optionalChain([lex, 'optionalAccess',
|
|
3949
|
+
const others = Number.isFinite(own) ? own : _nullishCoalesce(_optionalChain([lex, 'optionalAccess', _116 => _116.bodyPitch, 'call', _117 => _117(fs)]), () => ( Infinity));
|
|
3940
3950
|
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;
|
|
3941
3951
|
const wordWrap = ragged && !full(a) && nextWordNoRoom(a, b) && !MULTI_LEVEL_NUMBER.test(b.text.trimStart());
|
|
3942
|
-
const wraps = fs > 0 && (full(a) || wordWrap) && a.right - a.left >= BODY_MIN_WIDTH_EM * fs && a.y - b.y > 0 && a.y - b.y < maxPitch && Math.abs(b.fontSize - fs) <= 0.15 * fs && !startsNewItem(a.text, b.text) && !(SENTENCE_END.test(a.text.trimEnd()) && MULTI_LEVEL_NUMBER.test(b.text.trimStart()));
|
|
3952
|
+
const wraps = fs > 0 && (full(a) || wordWrap) && a.right - a.left >= BODY_MIN_WIDTH_EM * fs && a.y - b.y > 0 && (a.y - b.y < maxPitch || 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()));
|
|
3943
3953
|
out.push(!wraps ? "\n" : wordWrap ? unspacedCjkBoundary(a.text, b.text) ? "" : " " : wrapJoiner(a.text, b.text, lex));
|
|
3944
3954
|
}
|
|
3945
3955
|
return out;
|
|
3946
3956
|
}
|
|
3957
|
+
function indentedCjkFirstLine(a, b, fs) {
|
|
3958
|
+
const cjk = (t) => !/[가-힣]/.test(t) && /[\u3040-\u30ff\u3400-\u9fff]/.test(t);
|
|
3959
|
+
return cjk(a.text) && cjk(b.text) && b.left < a.left - fs && a.y - b.y < BODY_MAX_PITCH_ABS_EM * fs && b.fontSize >= 0.95 * a.fontSize && !/^(?:\d{1,2}\)?\s|[*※])/.test(b.text.trimStart());
|
|
3960
|
+
}
|
|
3947
3961
|
var CELL_PAD_MAX = 6;
|
|
3948
3962
|
function cellLineWraps(box, contentLeft, prevRight, fontSize, nextFirstCharW) {
|
|
3949
3963
|
const pad = Math.min(CELL_PAD_MAX, Math.max(0, contentLeft - box.x1));
|
|
@@ -4109,7 +4123,7 @@ function cellTextToString(items, wrap) {
|
|
|
4109
4123
|
const merged = mergeSuperscriptRows(lines).map((line) => sortLineByX(line));
|
|
4110
4124
|
const textLines = merged.map((s) => {
|
|
4111
4125
|
if (s.length === 1) return s[0].text;
|
|
4112
|
-
if (s.length === 2 && /^[가-힣]$/.test(s[0].text) && /^[가-힣]$/.test(s[1].text) && !!_optionalChain([wrap, 'optionalAccess',
|
|
4126
|
+
if (s.length === 2 && /^[가-힣]$/.test(s[0].text) && /^[가-힣]$/.test(s[1].text) && !!_optionalChain([wrap, 'optionalAccess', _118 => _118.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;
|
|
4113
4127
|
const evenSpaced = detectEvenSpacedItems(s, true);
|
|
4114
4128
|
const tracked = trackedSpaces(s);
|
|
4115
4129
|
const hangulLine = s.some((it) => /[가-힣]/.test(it.text));
|
|
@@ -4125,7 +4139,7 @@ function cellTextToString(items, wrap) {
|
|
|
4125
4139
|
result += s[j].text;
|
|
4126
4140
|
} else if (s[j].hasSpaceBefore && exactGap(s[j - 1], s[j], gap) >= avgFs * 0.05) {
|
|
4127
4141
|
result += " " + s[j].text;
|
|
4128
|
-
} else if (gap > spaceGapThreshold(avgFs) || _optionalChain([tracked, 'optionalAccess',
|
|
4142
|
+
} else if (gap > spaceGapThreshold(avgFs) || _optionalChain([tracked, 'optionalAccess', _119 => _119[j]])) {
|
|
4129
4143
|
result += " " + s[j].text;
|
|
4130
4144
|
} else {
|
|
4131
4145
|
result += s[j].text;
|
|
@@ -4252,12 +4266,12 @@ function markEvenRun(items, visible, result, start, end) {
|
|
|
4252
4266
|
}
|
|
4253
4267
|
function mergeCellTextLines(textLines, wrap) {
|
|
4254
4268
|
if (textLines.length <= 1) return textLines[0] || "";
|
|
4255
|
-
const numberWrapped = (k) => !!_optionalChain([wrap, 'optionalAccess',
|
|
4269
|
+
const numberWrapped = (k) => !!_optionalChain([wrap, 'optionalAccess', _120 => _120.wraps, 'access', _121 => _121[k]]) && (_nullishCoalesce(_optionalChain([wrap, 'access', _122 => _122.wide, 'optionalAccess', _123 => _123[k]]), () => ( true)));
|
|
4256
4270
|
const merged = [textLines[0]];
|
|
4257
4271
|
for (let i = 1; i < textLines.length; i++) {
|
|
4258
4272
|
const prev = merged[merged.length - 1];
|
|
4259
4273
|
const curr = textLines[i];
|
|
4260
|
-
if (wrap ? wrap.wraps[i - 1] && !_optionalChain([wrap, 'access',
|
|
4274
|
+
if (wrap ? wrap.wraps[i - 1] && !_optionalChain([wrap, 'access', _124 => _124.spaced, 'optionalAccess', _125 => _125[i - 1]]) && !startsNewItem(prev, curr) && wrapJoiner(prev, curr, wrap.lex, false) === "" : /[가-힣]$/.test(prev) && /^[가-힣]+$/.test(curr) && curr.length <= 8 && !curr.includes(" ")) {
|
|
4261
4275
|
merged[merged.length - 1] = prev + curr;
|
|
4262
4276
|
} else if (curr.trim().length <= 3 && /^[)\]%}]/.test(curr.trim())) {
|
|
4263
4277
|
merged[merged.length - 1] = prev + curr.trim();
|
|
@@ -4397,34 +4411,34 @@ function normalizeUndersegmentedTable(originalCells, colXs, items, rowYs, kept,
|
|
|
4397
4411
|
if (numRows > maxRows || numCols < MIN_UNDERSEGMENTED_COLUMNS) return null;
|
|
4398
4412
|
if (items.length === 0) return null;
|
|
4399
4413
|
if (numRows >= 3) {
|
|
4400
|
-
if (_optionalChain([rowYs, 'optionalAccess',
|
|
4414
|
+
if (_optionalChain([rowYs, 'optionalAccess', _126 => _126.length]) !== numRows + 1) return null;
|
|
4401
4415
|
const rebuilt2 = [];
|
|
4402
4416
|
let expanded = 0;
|
|
4403
4417
|
const ocr = items.every((it) => it.fontName === "ocr");
|
|
4404
4418
|
for (let r = 0; r < numRows; r++) {
|
|
4405
4419
|
const row = originalCells[r].map((cell) => cell.text);
|
|
4406
4420
|
if (r === 0 || numRows === 3 && r === 1) {
|
|
4407
|
-
_optionalChain([kept, 'optionalAccess',
|
|
4421
|
+
_optionalChain([kept, 'optionalAccess', _127 => _127.set, 'call', _128 => _128(rebuilt2.length, r)]);
|
|
4408
4422
|
rebuilt2.push(row);
|
|
4409
4423
|
continue;
|
|
4410
4424
|
}
|
|
4411
4425
|
const span2 = Math.min(numRows - r, Math.max(1, ...originalCells[r].map((cell) => _nullishCoalesce(cell.rowSpan, () => ( 1)))));
|
|
4412
4426
|
const filled = originalCells[r].filter((cell) => cell.text.trim());
|
|
4413
4427
|
const spanning = filled.filter((cell) => (_nullishCoalesce(cell.rowSpan, () => ( 1))) >= span2);
|
|
4414
|
-
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',
|
|
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', _129 => _129[r], 'access', _130 => _130[c], 'optionalAccess', _131 => _131.rowSpan]), () => ( 1))) === 1));
|
|
4415
4429
|
const band = span2 > 1 && (loose || originalCells.slice(r + 1, r + span2).every((cells) => cells.every((cell) => !cell.text.trim()))) ? span2 : 1;
|
|
4416
4430
|
const rowItems = items.filter((item) => itemCenterY(item) <= rowYs[r] + 1 && itemCenterY(item) >= rowYs[r + band] - 1);
|
|
4417
4431
|
const body = normalizeUndersegmentedTable([originalCells[r]], colXs, rowItems, void 0, void 0, void 0, band > 1 ? 2 : MIN_ALIGNED_LINES);
|
|
4418
4432
|
if (body) {
|
|
4419
4433
|
originalCells[r].forEach((cell, c) => {
|
|
4420
4434
|
const cols = Array.from({ length: Math.max(1, _nullishCoalesce(cell.colSpan, () => ( 1))) }, (_, k) => c + k);
|
|
4421
|
-
if (cell.text.trim() && body.every((cells) => cols.every((k) => !_optionalChain([cells, 'access',
|
|
4435
|
+
if (cell.text.trim() && body.every((cells) => cols.every((k) => !_optionalChain([cells, 'access', _132 => _132[k], 'optionalAccess', _133 => _133.trim, 'call', _134 => _134()])))) body[0][c] = cell.text;
|
|
4422
4436
|
});
|
|
4423
4437
|
rebuilt2.push(...body);
|
|
4424
4438
|
expanded++;
|
|
4425
4439
|
r += band - 1;
|
|
4426
4440
|
} else {
|
|
4427
|
-
_optionalChain([kept, 'optionalAccess',
|
|
4441
|
+
_optionalChain([kept, 'optionalAccess', _135 => _135.set, 'call', _136 => _136(rebuilt2.length, r)]);
|
|
4428
4442
|
rebuilt2.push(row);
|
|
4429
4443
|
}
|
|
4430
4444
|
}
|
|
@@ -4508,7 +4522,7 @@ function sortLineByX(items) {
|
|
|
4508
4522
|
e++;
|
|
4509
4523
|
}
|
|
4510
4524
|
const run = items.slice(s, e), seqs = run.map((i) => i.seq);
|
|
4511
|
-
const ok = !wide ? !run.some((i) => _optionalChain([i, 'access',
|
|
4525
|
+
const ok = !wide ? !run.some((i) => _optionalChain([i, 'access', _137 => _137.text, 'optionalAccess', _138 => _138.startsWith, 'call', _139 => _139("$")])) : 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);
|
|
4512
4526
|
if (e - s > 1 && seqs.every((q) => q !== void 0) && ok) {
|
|
4513
4527
|
run.sort((a, b) => a.seq - b.seq);
|
|
4514
4528
|
for (let k = 0; k < run.length; k++) items[s + k] = run[k];
|
|
@@ -4520,9 +4534,12 @@ function sortLineByX(items) {
|
|
|
4520
4534
|
function isCjkLatinAutospace(prevText, nextText, gap, fontSize, hangulLine = false) {
|
|
4521
4535
|
if (!(gap < fontSize * 0.35)) return false;
|
|
4522
4536
|
if (hangulLine) return false;
|
|
4523
|
-
const a = prevText.replace(/(?:<\/?u>|~~)+$/, "").slice(-1), b = _nullishCoalesce(nextText.replace(/^(?:<\/?u>|~~)+/, "")[0], () => ( ""));
|
|
4537
|
+
const a = prevText.replace(/(?:<\/?u>|~~)+$/, "").slice(-1), b = _nullishCoalesce(nextText.replace(/^(?:<\/?u>|~~)+/, "").replace(/^\(/, "")[0], () => ( ""));
|
|
4524
4538
|
const cjk = /[\u3000-\u303f\u3040-\u30ff\u3400-\u9fff\uf900-\ufaff\uff00-\uffef]/, latin = /[A-Za-z0-9]/;
|
|
4525
|
-
|
|
4539
|
+
const cjkOrQuote = /[\u3000-\u303f\u3040-\u30ff\u3400-\u9fff\uf900-\ufaff\uff00-\uffef\u2018-\u201f]/;
|
|
4540
|
+
const bare = _nullishCoalesce(nextText.replace(/^(?:<\/?u>|~~)+/, "")[0], () => ( ""));
|
|
4541
|
+
if (bare === "(" && cjk.test(a) || a === ")" && cjk.test(b)) return true;
|
|
4542
|
+
return cjk.test(a) && latin.test(b) || latin.test(a) && cjk.test(b) || cjkOrQuote.test(a) && cjkOrQuote.test(b) && (cjk.test(a) || cjk.test(b));
|
|
4526
4543
|
}
|
|
4527
4544
|
function filterHiddenText(items, pageWidth, pageHeight, originX = 0, originY = 0) {
|
|
4528
4545
|
let hiddenCount = 0;
|
|
@@ -4580,7 +4597,7 @@ function dominantStyle(items) {
|
|
|
4580
4597
|
let maxCount = 0, dominantSize = 0;
|
|
4581
4598
|
for (const i of items) {
|
|
4582
4599
|
if (i.fontSize <= 0) continue;
|
|
4583
|
-
const count = (freq.get(i.fontSize) || 0) + Math.max(1, _nullishCoalesce(_optionalChain([i, 'access',
|
|
4600
|
+
const count = (freq.get(i.fontSize) || 0) + Math.max(1, _nullishCoalesce(_optionalChain([i, 'access', _140 => _140.text, 'access', _141 => _141.match, 'call', _142 => _142(/[\p{L}\p{N}]/gu), 'optionalAccess', _143 => _143.length]), () => ( 0)));
|
|
4584
4601
|
freq.set(i.fontSize, count);
|
|
4585
4602
|
if (count > maxCount) {
|
|
4586
4603
|
maxCount = count;
|
|
@@ -4588,7 +4605,7 @@ function dominantStyle(items) {
|
|
|
4588
4605
|
}
|
|
4589
4606
|
}
|
|
4590
4607
|
if (dominantSize === 0) return void 0;
|
|
4591
|
-
const fontName = _optionalChain([items, 'access',
|
|
4608
|
+
const fontName = _optionalChain([items, 'access', _144 => _144.find, 'call', _145 => _145((i) => i.fontSize === dominantSize), 'optionalAccess', _146 => _146.fontName]) || void 0;
|
|
4592
4609
|
return fontName ? { fontSize: dominantSize, fontName } : { fontSize: dominantSize };
|
|
4593
4610
|
}
|
|
4594
4611
|
function normalizeItems(rawItems) {
|
|
@@ -4743,7 +4760,7 @@ function splitAroundOverlays(c, overlays) {
|
|
|
4743
4760
|
const ov = overlays.filter((o) => {
|
|
4744
4761
|
for (let at = c.text.indexOf(o.text); at >= 0; at = c.text.indexOf(o.text, at + 1)) {
|
|
4745
4762
|
const prefix = c.text.slice(0, at);
|
|
4746
|
-
const est = c.x + glyphUnits(prefix.replace(/\s+/g, "")) * a0 + (_nullishCoalesce(_optionalChain([prefix, 'access',
|
|
4763
|
+
const est = c.x + glyphUnits(prefix.replace(/\s+/g, "")) * a0 + (_nullishCoalesce(_optionalChain([prefix, 'access', _147 => _147.match, 'call', _148 => _148(/\s+/g), 'optionalAccess', _149 => _149.length]), () => ( 0))) * ws;
|
|
4747
4764
|
if (Math.abs(est - o.x) <= OVERLAY_DUP_EM * fs) return false;
|
|
4748
4765
|
}
|
|
4749
4766
|
return true;
|
|
@@ -4905,7 +4922,7 @@ function trackedSpaces(sorted, med = trackingShift([sorted])) {
|
|
|
4905
4922
|
});
|
|
4906
4923
|
}
|
|
4907
4924
|
function mergeLineSimple(items) {
|
|
4908
|
-
if (items.length <= 1) return _optionalChain([items, 'access',
|
|
4925
|
+
if (items.length <= 1) return _optionalChain([items, 'access', _150 => _150[0], 'optionalAccess', _151 => _151.text]) || "";
|
|
4909
4926
|
const sorted = sortLineByX([...items]);
|
|
4910
4927
|
const tracked = trackedSpaces(sorted);
|
|
4911
4928
|
const isEvenSpaced = detectEvenSpacedItems(sorted);
|
|
@@ -4940,7 +4957,7 @@ function mergeLineSimple(items) {
|
|
|
4940
4957
|
result += sorted[i].text;
|
|
4941
4958
|
continue;
|
|
4942
4959
|
}
|
|
4943
|
-
if (gap > spaceGapThreshold(avgFs) || _optionalChain([tracked, 'optionalAccess',
|
|
4960
|
+
if (gap > spaceGapThreshold(avgFs) || _optionalChain([tracked, 'optionalAccess', _152 => _152[i]])) result += " ";
|
|
4944
4961
|
result += sorted[i].text;
|
|
4945
4962
|
}
|
|
4946
4963
|
return result;
|
|
@@ -4997,7 +5014,7 @@ function isProseTable(table) {
|
|
|
4997
5014
|
if (!(long > 0 && long >= total * 0.5 && longRows >= rows * 0.4)) return false;
|
|
4998
5015
|
for (let c = 0; c < table.cols; c++) {
|
|
4999
5016
|
const filled = table.cells.map((row) => row[c]).filter((cell) => cell && cell.colSpan < table.cols && cell.text.trim()).map((cell) => cell.text.trim());
|
|
5000
|
-
if (filled.length >= 3 && filled.length >= rows * 0.6 && filled.every((text) => text.length <= 30 && (_nullishCoalesce(_optionalChain([text, 'access',
|
|
5017
|
+
if (filled.length >= 3 && filled.length >= rows * 0.6 && filled.every((text) => text.length <= 30 && (_nullishCoalesce(_optionalChain([text, 'access', _153 => _153.match, 'call', _154 => _154(/\p{L}/gu), 'optionalAccess', _155 => _155.length]), () => ( 0))) >= 2)) return false;
|
|
5001
5018
|
}
|
|
5002
5019
|
return true;
|
|
5003
5020
|
}
|
|
@@ -5026,7 +5043,7 @@ var TICK = /^-?[\d,]+(?:\.\d+)?%?$/;
|
|
|
5026
5043
|
var QUANTITY = /^[-−–]?[\d,]*\.?\d+%?$/;
|
|
5027
5044
|
var quantity = (token) => Number(token.replace(/^[−–]/, "-").replace(/[,%]/g, ""));
|
|
5028
5045
|
function isValueAxisColumn(table, c) {
|
|
5029
|
-
const lines = table.cells.flatMap((row) => (_nullishCoalesce(_optionalChain([row, 'access',
|
|
5046
|
+
const lines = table.cells.flatMap((row) => (_nullishCoalesce(_optionalChain([row, 'access', _156 => _156[c], 'optionalAccess', _157 => _157.text]), () => ( ""))).split("\n").map((line) => line.trim().split(/\s+/)));
|
|
5030
5047
|
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));
|
|
5031
5048
|
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)]) {
|
|
5032
5049
|
const run = fallingRun(ticks);
|
|
@@ -5059,7 +5076,7 @@ function isChartTable(table, ocr = false) {
|
|
|
5059
5076
|
if (numeric < texts.length * 0.5) return false;
|
|
5060
5077
|
if (ocr && table.cols >= 3 && table.cells.slice(0, 3).some((row) => row.filter((cell) => /[가-힣]{2}/.test(cell.text)).length >= 2)) return false;
|
|
5061
5078
|
for (let c = 0; c < table.cols; c++) {
|
|
5062
|
-
if (!ocr ? isValueAxisColumn(table, c) : hasValueAxis(table.cells.flatMap((row) => (_nullishCoalesce(_optionalChain([row, 'access',
|
|
5079
|
+
if (!ocr ? isValueAxisColumn(table, c) : hasValueAxis(table.cells.flatMap((row) => (_nullishCoalesce(_optionalChain([row, 'access', _158 => _158[c], 'optionalAccess', _159 => _159.text]), () => ( ""))).split(/\s+/)).filter((t) => TICK.test(t)).map((t) => Number(t.replace(/[,%]/g, ""))))) return true;
|
|
5063
5080
|
}
|
|
5064
5081
|
const values = texts.filter((text) => text.split(/\s+/).every((token) => QUANTITY.test(token))).length;
|
|
5065
5082
|
const cells = table.rows * table.cols;
|
|
@@ -5068,7 +5085,7 @@ function isChartTable(table, ocr = false) {
|
|
|
5068
5085
|
function isProseFragmentTable(table) {
|
|
5069
5086
|
const texts = table.cells.flat().map((cell) => cell.text.trim()).filter(Boolean);
|
|
5070
5087
|
if (texts.length < 4) return false;
|
|
5071
|
-
const hangul = (text) => _nullishCoalesce(_optionalChain([text, 'access',
|
|
5088
|
+
const hangul = (text) => _nullishCoalesce(_optionalChain([text, 'access', _160 => _160.match, 'call', _161 => _161(/[가-힣]/g), 'optionalAccess', _162 => _162.length]), () => ( 0));
|
|
5072
5089
|
if (texts.filter((text) => hangul(text) >= 2).length < texts.length * 0.7) return false;
|
|
5073
5090
|
if (texts.length >= 12 && texts.filter((text) => hangul(text) >= 15 && !text.includes("\n")).length >= texts.length * 0.4) return true;
|
|
5074
5091
|
return texts.filter((text) => /(?:[다요고서는을를에게지며면어아야니까던]|[.,?!])$/.test(text)).length >= texts.length * 0.3;
|
|
@@ -5121,7 +5138,7 @@ function clusterCellLines(items) {
|
|
|
5121
5138
|
}
|
|
5122
5139
|
var WRAP_INDENT_MAX = 3;
|
|
5123
5140
|
function joinClusterCellLines(lines, box, lex) {
|
|
5124
|
-
let out = _nullishCoalesce(_optionalChain([lines, 'access',
|
|
5141
|
+
let out = _nullishCoalesce(_optionalChain([lines, 'access', _163 => _163[0], 'optionalAccess', _164 => _164.text]), () => ( ""));
|
|
5125
5142
|
for (let i = 1; i < lines.length; i++) {
|
|
5126
5143
|
const a = lines[i - 1], b = lines[i];
|
|
5127
5144
|
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) === "";
|
|
@@ -5424,11 +5441,25 @@ function detectCompactStatisticalTables(rows, pageNum) {
|
|
|
5424
5441
|
}
|
|
5425
5442
|
return found;
|
|
5426
5443
|
}
|
|
5444
|
+
function twoColumnCells(row) {
|
|
5445
|
+
const items = [...row.items].sort((a, b) => a.x - b.x);
|
|
5446
|
+
if (items.length <= 2) return items.map((c) => ({ x: c.x, y: c.y, fontSize: c.fontSize, text: c.text }));
|
|
5447
|
+
const out = [];
|
|
5448
|
+
for (const c of items) {
|
|
5449
|
+
const last = out.at(-1), gap = last ? c.x - last.end : Infinity;
|
|
5450
|
+
if (last && gap <= c.fontSize * 1.2) {
|
|
5451
|
+
last.text += (gap > c.fontSize * 0.2 || c.hasSpaceBefore ? " " : "") + c.text;
|
|
5452
|
+
last.end = Math.max(last.end, c.x + c.w);
|
|
5453
|
+
} else out.push({ x: c.x, y: c.y, fontSize: c.fontSize, text: c.text, end: c.x + c.w });
|
|
5454
|
+
}
|
|
5455
|
+
if (out.length === 2 && (out[0].text.length > 20 || out.some((c) => /^\s*[::]|[::]\s*$|\s[::]\s/.test(c.text)))) return [];
|
|
5456
|
+
return out.map(({ end: _end, ...cell }) => cell);
|
|
5457
|
+
}
|
|
5427
5458
|
function detectAlignedTwoColumnTables(rows, pageNum) {
|
|
5428
5459
|
const found = [];
|
|
5429
5460
|
let i = 0;
|
|
5430
5461
|
while (i < rows.length - 2) {
|
|
5431
|
-
const first =
|
|
5462
|
+
const first = twoColumnCells(rows[i]);
|
|
5432
5463
|
if (first.length !== 2 || first.some((c) => !c.text.trim() || c.text.length > 48) || first[1].x - first[0].x < 45 || first[1].x - first[0].x > 260 || /[.!?]$/.test(first[0].text)) {
|
|
5433
5464
|
i++;
|
|
5434
5465
|
continue;
|
|
@@ -5436,23 +5467,28 @@ function detectAlignedTwoColumnTables(rows, pageNum) {
|
|
|
5436
5467
|
const body = [];
|
|
5437
5468
|
let j = i;
|
|
5438
5469
|
for (; j < rows.length; j++) {
|
|
5439
|
-
const cells2 =
|
|
5470
|
+
const cells2 = twoColumnCells(rows[j]);
|
|
5440
5471
|
const previous = body.at(-1);
|
|
5441
|
-
if (
|
|
5442
|
-
|
|
5472
|
+
if (previous && previous.rows.at(-1).y - rows[j].y > Math.max(24, first[0].fontSize * 2.8)) break;
|
|
5473
|
+
if (previous && cells2.length === 1 && Math.abs(cells2[0].x - first[1].x) <= 5 && cells2[0].text.trim()) {
|
|
5474
|
+
previous.rows.push(rows[j]);
|
|
5475
|
+
previous.right.push(cells2[0].text);
|
|
5476
|
+
continue;
|
|
5477
|
+
}
|
|
5478
|
+
if (cells2.length !== 2 || cells2.some((c) => !c.text.trim() || c.text.length > 48) || Math.abs(cells2[0].x - first[0].x) > 5 || Math.abs(cells2[1].x - first[1].x) > 5) break;
|
|
5479
|
+
body.push({ rows: [rows[j]], left: cells2[0].text, right: [cells2[1].text] });
|
|
5443
5480
|
}
|
|
5444
|
-
if (body.length < 3) {
|
|
5481
|
+
if (body.length < 3 || body.filter((b) => !/[\p{L}\p{N}]/u.test(b.right.join(""))).length * 2 >= body.length) {
|
|
5445
5482
|
i++;
|
|
5446
5483
|
continue;
|
|
5447
5484
|
}
|
|
5448
5485
|
const top = rows[i - 1];
|
|
5449
|
-
const title = _optionalChain([top, 'optionalAccess',
|
|
5450
|
-
const tableRows = title ? [title, ...body
|
|
5451
|
-
const cells =
|
|
5452
|
-
|
|
5453
|
-
|
|
5454
|
-
|
|
5455
|
-
});
|
|
5486
|
+
const title = _optionalChain([top, 'optionalAccess', _165 => _165.items, 'access', _166 => _166.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
|
+
const tableRows = [...title ? [title] : [], ...body.flatMap((b) => b.rows)];
|
|
5488
|
+
const cells = [
|
|
5489
|
+
...title ? [[{ text: title.items[0].text, colSpan: 2, rowSpan: 1 }, { text: "", colSpan: 1, rowSpan: 1 }]] : [],
|
|
5490
|
+
...body.map((b) => [{ text: b.left, colSpan: 1, rowSpan: 1 }, { text: b.right.join(" "), colSpan: 1, rowSpan: 1 }])
|
|
5491
|
+
];
|
|
5456
5492
|
const usedItems = new Set(tableRows.flatMap((row) => row.items));
|
|
5457
5493
|
const all = [...usedItems];
|
|
5458
5494
|
const minX = Math.min(...all.map((c) => c.x)), minY = Math.min(...all.map((c) => c.y));
|
|
@@ -5503,12 +5539,12 @@ function isTwoColumnProse(r) {
|
|
|
5503
5539
|
if (t.rows < (ocr ? 6 : 8)) return false;
|
|
5504
5540
|
const dense = [];
|
|
5505
5541
|
for (let c = 0; c < t.cols; c++) {
|
|
5506
|
-
const filled = t.cells.filter((row) => _optionalChain([row, 'access',
|
|
5542
|
+
const filled = t.cells.filter((row) => _optionalChain([row, 'access', _167 => _167[c], 'optionalAccess', _168 => _168.text, 'access', _169 => _169.trim, 'call', _170 => _170()])).length;
|
|
5507
5543
|
if (filled / t.rows >= 0.3) dense.push(c);
|
|
5508
5544
|
}
|
|
5509
5545
|
if (dense.length !== 2) return false;
|
|
5510
5546
|
for (const c of dense) {
|
|
5511
|
-
const lens = t.cells.map((row) => _nullishCoalesce(_optionalChain([row, 'access',
|
|
5547
|
+
const lens = t.cells.map((row) => _nullishCoalesce(_optionalChain([row, 'access', _171 => _171[c], 'optionalAccess', _172 => _172.text, 'access', _173 => _173.replace, 'call', _174 => _174(/\s+/g, ""), 'access', _175 => _175.length]), () => ( 0))).filter((n) => n > 0);
|
|
5512
5548
|
const avg = lens.reduce((s, v) => s + v, 0) / (lens.length || 1);
|
|
5513
5549
|
if (avg < (ocr ? 15 : 12)) return false;
|
|
5514
5550
|
}
|
|
@@ -5970,7 +6006,7 @@ function assignRowItems(items, columns, numCols, headerFace) {
|
|
|
5970
6006
|
const runs = [];
|
|
5971
6007
|
for (const it of sorted) {
|
|
5972
6008
|
const last = runs[runs.length - 1];
|
|
5973
|
-
const prev = _optionalChain([last, 'optionalAccess',
|
|
6009
|
+
const prev = _optionalChain([last, 'optionalAccess', _176 => _176[last.length - 1]]);
|
|
5974
6010
|
if (prev && it.x - (prev.x + prev.w) <= Math.max(0.5, it.fontSize * 0.05) && !it.hasSpaceBefore) last.push(it);
|
|
5975
6011
|
else runs.push([it]);
|
|
5976
6012
|
}
|
|
@@ -6021,7 +6057,7 @@ function assignRowItems(items, columns, numCols, headerFace) {
|
|
|
6021
6057
|
assignedGroups.add(gi);
|
|
6022
6058
|
usedCols.add(ci);
|
|
6023
6059
|
}
|
|
6024
|
-
const colOf = groups.map((g) => _nullishCoalesce(_optionalChain([result, 'access',
|
|
6060
|
+
const colOf = groups.map((g) => _nullishCoalesce(_optionalChain([result, 'access', _177 => _177.find, 'call', _178 => _178((a) => a.items === g), 'optionalAccess', _179 => _179.col]), () => ( -1)));
|
|
6025
6061
|
if (groups.length <= numCols && colOf.some((c, g) => g > 0 && c < colOf[g - 1])) {
|
|
6026
6062
|
const G = groups.length, cost = (g, c2) => Math.abs(groupCenters[g] - colCenters[c2]);
|
|
6027
6063
|
const best = groups.map(() => new Array(numCols).fill(Infinity)), from = groups.map(() => new Array(numCols).fill(-1));
|
|
@@ -6058,7 +6094,7 @@ function assignRowItems(items, columns, numCols, headerFace) {
|
|
|
6058
6094
|
function buildClusterTable(rows, columns, pageNum, lex) {
|
|
6059
6095
|
const numRows = rows.length;
|
|
6060
6096
|
if (numRows < MIN_ROWS || columns.length < MIN_COLS) return null;
|
|
6061
|
-
const headFaces = new Set(_optionalChain([rows, 'access',
|
|
6097
|
+
const headFaces = new Set(_optionalChain([rows, 'access', _180 => _180[0], 'optionalAccess', _181 => _181.items, 'access', _182 => _182.map, 'call', _183 => _183((i) => i.fontName)]));
|
|
6062
6098
|
const headerFace = headFaces.size === 1 && rows.slice(1).every((row) => row.items.every((i) => !headFaces.has(i.fontName))) ? [...headFaces][0] : void 0;
|
|
6063
6099
|
const assigned = rows.map((row, r) => assignRowItems(row.items, columns, columns.length, r === 0 ? headerFace : void 0));
|
|
6064
6100
|
const cuts = supportedOcrColumnCuts(assigned);
|
|
@@ -6129,7 +6165,7 @@ function buildClusterTable(rows, columns, pageNum, lex) {
|
|
|
6129
6165
|
const nonEmptyCols = cells[r].filter((c) => c.text.trim()).length;
|
|
6130
6166
|
if (nonEmptyCols !== 1) continue;
|
|
6131
6167
|
if (cells[r][0].text.trim() !== "") continue;
|
|
6132
|
-
const contentText = _optionalChain([cells, 'access',
|
|
6168
|
+
const contentText = _optionalChain([cells, 'access', _184 => _184[r], 'access', _185 => _185.find, 'call', _186 => _186((c) => c.text.trim()), 'optionalAccess', _187 => _187.text, 'access', _188 => _188.trim, 'call', _189 => _189()]) || "";
|
|
6133
6169
|
if (/^[○●▶\-·]/.test(contentText)) continue;
|
|
6134
6170
|
for (let pr = r - 1; pr >= 0; pr--) {
|
|
6135
6171
|
if (cells[pr].some((c) => c.text.trim())) {
|
|
@@ -6362,7 +6398,7 @@ function stackedTableBands(items) {
|
|
|
6362
6398
|
const caption = (start, end) => lines.slice(start, end).some((line) => /^Table\s+\d+\s*[:.]/i.test(mergeLineSimple(line).trim()));
|
|
6363
6399
|
while (runs.length > 0 && !caption(runs[runs.length - 1].end, lines.length)) runs.pop();
|
|
6364
6400
|
if (runs.length < 2) return null;
|
|
6365
|
-
if (runs.some((run, i) => !caption(run.end, _nullishCoalesce(_optionalChain([runs, 'access',
|
|
6401
|
+
if (runs.some((run, i) => !caption(run.end, _nullishCoalesce(_optionalChain([runs, 'access', _190 => _190[i + 1], 'optionalAccess', _191 => _191.start]), () => ( lines.length))))) return null;
|
|
6366
6402
|
const tables = runs.map((run) => lines.slice(run.start, run.end).flat());
|
|
6367
6403
|
const between = runs.slice(0, -1).map((run, i) => lines.slice(run.end, runs[i + 1].start).flat());
|
|
6368
6404
|
const tail = lines.slice(runs[runs.length - 1].end);
|
|
@@ -6630,7 +6666,7 @@ function splitTrailingColumnRegion(items) {
|
|
|
6630
6666
|
}
|
|
6631
6667
|
function panelBlocks(items, panel, pageNum) {
|
|
6632
6668
|
const lines = groupByY([...items].sort((a, b) => b.y - a.y || a.x - b.x));
|
|
6633
|
-
const faceOf = (line) => _nullishCoalesce(_optionalChain([dominantStyle, 'call',
|
|
6669
|
+
const faceOf = (line) => _nullishCoalesce(_optionalChain([dominantStyle, 'call', _192 => _192(line), 'optionalAccess', _193 => _193.fontName]), () => ( ""));
|
|
6634
6670
|
const runs = [];
|
|
6635
6671
|
for (const line of lines) {
|
|
6636
6672
|
const last = runs[runs.length - 1];
|
|
@@ -6677,7 +6713,7 @@ function chartBandGap(group, gap, charts) {
|
|
|
6677
6713
|
const top = Math.max(...group.map((i) => i.y + i.fontSize)), em = Math.max(...group.map((i) => i.fontSize));
|
|
6678
6714
|
return charts.some((c) => x1 >= c.x1 - 2 && x2 <= c.x2 + 2 && top <= c.y1 + 2 && c.y1 - top <= 2 * em) ? gap : 0;
|
|
6679
6715
|
}
|
|
6680
|
-
function xyCutOrder(items, gapThreshold, depth = 0, wrapped, columnGap = 0) {
|
|
6716
|
+
function xyCutOrder(items, gapThreshold, depth = 0, wrapped, columnGap = 0, lex) {
|
|
6681
6717
|
if (items.length === 0) return [];
|
|
6682
6718
|
const newRegion = wrapped === void 0;
|
|
6683
6719
|
wrapped ??= inheritedWrapBands(items);
|
|
@@ -6685,7 +6721,7 @@ function xyCutOrder(items, gapThreshold, depth = 0, wrapped, columnGap = 0) {
|
|
|
6685
6721
|
if (items.length === 2 && depth < MAX_XYCUT_DEPTH) {
|
|
6686
6722
|
const sortedY2 = [...items].sort((a, b) => b.y - a.y);
|
|
6687
6723
|
if (findHorizontalCut(sortedY2, wrapped).gap >= farGap) {
|
|
6688
|
-
if (newRegion) wrapped = wrappedLineBands(items, wrapped);
|
|
6724
|
+
if (newRegion) wrapped = wrappedLineBands(items, wrapped, lex);
|
|
6689
6725
|
const cut = findHorizontalCut(sortedY2, wrapped);
|
|
6690
6726
|
if (cut.gap >= farGap) return [...leaf([sortedY2[0]], wrapped), ...leaf([sortedY2[1]], wrapped)];
|
|
6691
6727
|
}
|
|
@@ -6696,7 +6732,7 @@ function xyCutOrder(items, gapThreshold, depth = 0, wrapped, columnGap = 0) {
|
|
|
6696
6732
|
if (cross.size > 0 && cross.size <= items.length * CROSS_MAX_MASK_RATIO) {
|
|
6697
6733
|
const rest = items.filter((i) => !cross.has(i));
|
|
6698
6734
|
if (rest.length > 0) {
|
|
6699
|
-
const groups = xyCutOrder(rest, gapThreshold, 1, void 0, columnGap);
|
|
6735
|
+
const groups = xyCutOrder(rest, gapThreshold, 1, void 0, columnGap, lex);
|
|
6700
6736
|
return mergeCrossLayoutGroups(groups, [...cross]);
|
|
6701
6737
|
}
|
|
6702
6738
|
}
|
|
@@ -6705,29 +6741,29 @@ function xyCutOrder(items, gapThreshold, depth = 0, wrapped, columnGap = 0) {
|
|
|
6705
6741
|
const sortedY = [...items].sort((a, b) => b.y - a.y);
|
|
6706
6742
|
let hCut = findHorizontalCut(sortedY, wrapped);
|
|
6707
6743
|
if (newRegion && hCut.gap >= minGap) {
|
|
6708
|
-
wrapped = wrappedLineBands(items, wrapped);
|
|
6744
|
+
wrapped = wrappedLineBands(items, wrapped, lex);
|
|
6709
6745
|
hCut = findHorizontalCut(sortedY, wrapped);
|
|
6710
6746
|
}
|
|
6711
6747
|
const vMinGap = Math.max(minGap, columnGap);
|
|
6712
6748
|
const vCut = findVerticalCutWithOutlierFilter(items, vMinGap);
|
|
6713
6749
|
const hValid = hCut.gap >= minGap;
|
|
6714
|
-
const vValid = (vCut.gap >= vMinGap || vCut.gap >= PROSE_GUTTER_MIN_GAP && isProseGutter(items, vCut.position)) && !splitsSpacedLabel(items, vCut.position);
|
|
6750
|
+
const vValid = (vCut.gap >= vMinGap || vCut.gap >= PROSE_GUTTER_MIN_GAP && isProseGutter(items, vCut.position)) && !splitsSpacedLabel(items, vCut.position) && !splitsLoneRowTail(items, vCut.position);
|
|
6715
6751
|
let useHorizontal;
|
|
6716
6752
|
if (hValid && vValid) useHorizontal = (vCut.gap <= hCut.gap * 1.5 || staggeredSides(items, vCut.position)) && !gapInsideLongerColumn(items, hCut.position, hCut.gap, vCut.position);
|
|
6717
6753
|
else if (hValid) useHorizontal = true;
|
|
6718
6754
|
else if (vValid) useHorizontal = false;
|
|
6719
|
-
else return _nullishCoalesce(splitEdgeSpannedColumns(items, gapThreshold, depth), () => ( leaf(items, wrapped)));
|
|
6755
|
+
else return _nullishCoalesce(splitEdgeSpannedColumns(items, gapThreshold, depth, lex), () => ( leaf(items, wrapped)));
|
|
6720
6756
|
if (useHorizontal) {
|
|
6721
6757
|
const upper = items.filter((i) => i.y > hCut.position);
|
|
6722
6758
|
const lower = items.filter((i) => i.y <= hCut.position);
|
|
6723
6759
|
if (upper.length > 0 && lower.length > 0 && upper.length < items.length) {
|
|
6724
|
-
return [...xyCutOrder(upper, gapThreshold, depth + 1, wrapped, columnGap), ...xyCutOrder(lower, gapThreshold, depth + 1, wrapped, columnGap)];
|
|
6760
|
+
return [...xyCutOrder(upper, gapThreshold, depth + 1, wrapped, columnGap, lex), ...xyCutOrder(lower, gapThreshold, depth + 1, wrapped, columnGap, lex)];
|
|
6725
6761
|
}
|
|
6726
6762
|
} else {
|
|
6727
6763
|
const left = items.filter((i) => i.x + i.w / 2 < vCut.position);
|
|
6728
6764
|
const right = items.filter((i) => i.x + i.w / 2 >= vCut.position);
|
|
6729
6765
|
if (left.length > 0 && right.length > 0 && left.length < items.length) {
|
|
6730
|
-
return [...xyCutOrder(left, gapThreshold, depth + 1, void 0, columnGap), ...xyCutOrder(right, gapThreshold, depth + 1, void 0, columnGap)];
|
|
6766
|
+
return [...xyCutOrder(left, gapThreshold, depth + 1, void 0, columnGap, lex), ...xyCutOrder(right, gapThreshold, depth + 1, void 0, columnGap, lex)];
|
|
6731
6767
|
}
|
|
6732
6768
|
}
|
|
6733
6769
|
return leaf(items, wrapped);
|
|
@@ -6837,7 +6873,7 @@ function validWrapBands(items, bands) {
|
|
|
6837
6873
|
}
|
|
6838
6874
|
function inheritedWrapBands(items) {
|
|
6839
6875
|
const source = XY_WRAP_ITEMS.get(items[0]);
|
|
6840
|
-
const present = _optionalChain([source, 'optionalAccess',
|
|
6876
|
+
const present = _optionalChain([source, 'optionalAccess', _194 => _194.length]) === items.length ? new Set(items) : null;
|
|
6841
6877
|
const sameLeaf = present && source.every((item) => present.has(item));
|
|
6842
6878
|
return sameLeaf ? validWrapBands(items, _nullishCoalesce(XY_WRAP_BANDS.get(items[0]), () => ( []))) : [];
|
|
6843
6879
|
}
|
|
@@ -6866,7 +6902,19 @@ function tocRecordBoundaries(rows) {
|
|
|
6866
6902
|
}
|
|
6867
6903
|
return out;
|
|
6868
6904
|
}
|
|
6869
|
-
function
|
|
6905
|
+
function splitsLoneRowTail(items, x) {
|
|
6906
|
+
const left = groupByY(items.filter((i) => i.x + i.w / 2 < x)), right = groupByY(items.filter((i) => i.x + i.w / 2 >= x));
|
|
6907
|
+
if (right.length !== 1 || left.length < 2) return false;
|
|
6908
|
+
const tail = right[0], box = computeBBox(items, 0), tailBox = computeBBox(tail, 0);
|
|
6909
|
+
const head = left.find((r) => Math.abs(r[0].y - tail[0].y) <= 2);
|
|
6910
|
+
if (!head) return false;
|
|
6911
|
+
const headBox = computeBBox(head, 0), fs = _nullishCoalesce(_optionalChain([dominantStyle, 'call', _195 => _195(tail), 'optionalAccess', _196 => _196.fontSize]), () => ( 10));
|
|
6912
|
+
const gap = tailBox.x - (headBox.x + headBox.width), fills = tailBox.x + tailBox.width >= box.x + box.width - fs;
|
|
6913
|
+
if (gap <= fs * 3 && fills && headBox.width >= box.width / 2) return true;
|
|
6914
|
+
const text = [...head, ...tail].map((i) => i.text).join("");
|
|
6915
|
+
return !/[가-힣]/.test(text) && /[\u3040-\u30ff\u3400-\u9fff]/.test(text) && gap <= fs * 4 && fills && headBox.x <= box.x + fs;
|
|
6916
|
+
}
|
|
6917
|
+
function wrappedLineBands(items, inherited, lex) {
|
|
6870
6918
|
const rows = groupByY(items);
|
|
6871
6919
|
const records = tocRecordBoundaries(rows);
|
|
6872
6920
|
const lines = rows.map((row) => {
|
|
@@ -6876,11 +6924,11 @@ function wrappedLineBands(items, inherited) {
|
|
|
6876
6924
|
left: box.x,
|
|
6877
6925
|
right: box.x + box.width,
|
|
6878
6926
|
y: row.reduce((n, i) => n + i.y, 0) / row.length,
|
|
6879
|
-
fontSize: _nullishCoalesce(_optionalChain([dominantStyle, 'call',
|
|
6927
|
+
fontSize: _nullishCoalesce(_optionalChain([dominantStyle, 'call', _197 => _197(row), 'optionalAccess', _198 => _198.fontSize]), () => ( 0)),
|
|
6880
6928
|
sources: row.map((item) => ({ item, state: { ...item } }))
|
|
6881
6929
|
};
|
|
6882
6930
|
});
|
|
6883
|
-
const joins = bodyLineJoins(lines);
|
|
6931
|
+
const joins = bodyLineJoins(lines, lex);
|
|
6884
6932
|
const fresh = lines.slice(0, -1).flatMap((line, i) => joins[i] === "\n" || records.has(i) || line.text.trim() === lines[i + 1].text.trim() ? [] : [{ top: line.y, bottom: lines[i + 1].y, sources: [...line.sources, ...lines[i + 1].sources] }]);
|
|
6885
6933
|
const freshKeys = new Set(fresh.map((b) => `${b.top}:${b.bottom}`));
|
|
6886
6934
|
return [...inherited.filter((b) => !freshKeys.has(`${b.top}:${b.bottom}`)), ...fresh].sort((a, b) => b.top - a.top);
|
|
@@ -6974,7 +7022,7 @@ function isProseGutter(items, x) {
|
|
|
6974
7022
|
const [l0, l1] = span2(left), [r0, r1] = span2(right);
|
|
6975
7023
|
return Math.min(l1, r1) - Math.max(l0, r0) >= Math.min(l1 - l0, r1 - r0) * 0.5;
|
|
6976
7024
|
}
|
|
6977
|
-
function splitEdgeSpannedColumns(items, gapThreshold, depth) {
|
|
7025
|
+
function splitEdgeSpannedColumns(items, gapThreshold, depth, lex) {
|
|
6978
7026
|
let minX = Infinity, maxX = -Infinity;
|
|
6979
7027
|
for (const i of items) {
|
|
6980
7028
|
minX = Math.min(minX, i.x);
|
|
@@ -6992,8 +7040,8 @@ function splitEdgeSpannedColumns(items, gapThreshold, depth) {
|
|
|
6992
7040
|
const left = rest.filter((i) => i.x + i.w / 2 < cut.position), right = rest.filter((i) => i.x + i.w / 2 >= cut.position);
|
|
6993
7041
|
return [
|
|
6994
7042
|
...above.length ? [above] : [],
|
|
6995
|
-
...xyCutOrder(left, gapThreshold, depth + 1),
|
|
6996
|
-
...xyCutOrder(right, gapThreshold, depth + 1),
|
|
7043
|
+
...xyCutOrder(left, gapThreshold, depth + 1, void 0, 0, lex),
|
|
7044
|
+
...xyCutOrder(right, gapThreshold, depth + 1, void 0, 0, lex),
|
|
6997
7045
|
...below.length ? [below] : []
|
|
6998
7046
|
];
|
|
6999
7047
|
}
|
|
@@ -7012,10 +7060,10 @@ function pushLineParagraphs(out, yLines, pageNum, lex) {
|
|
|
7012
7060
|
const lines = attachDropCaps(yLines).map((items) => ({ items, text: mergeLineSimple(items) })).filter((l) => l.text.trim());
|
|
7013
7061
|
const geo = lines.map((l) => {
|
|
7014
7062
|
const b = computeBBox(l.items, pageNum);
|
|
7015
|
-
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',
|
|
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', _199 => _199(l.items), 'optionalAccess', _200 => _200.fontSize]), () => ( 0)) };
|
|
7016
7064
|
});
|
|
7017
7065
|
const joins = bodyLineJoins(geo, lex);
|
|
7018
|
-
const first = _optionalChain([lines, 'access',
|
|
7066
|
+
const first = _optionalChain([lines, 'access', _201 => _201[0], 'optionalAccess', _202 => _202.items, 'access', _203 => _203[0]]);
|
|
7019
7067
|
const bands = first ? _nullishCoalesce(XY_WRAP_BANDS.get(first), () => ( [])) : [];
|
|
7020
7068
|
const hasBand = (top, bottom) => {
|
|
7021
7069
|
let lo = 0, hi = bands.length;
|
|
@@ -7092,15 +7140,15 @@ function computeMedianFontSizeFromFreq(freq) {
|
|
|
7092
7140
|
function detectHeadings(blocks, medianFontSize) {
|
|
7093
7141
|
for (let bi = 0; bi < blocks.length; bi++) {
|
|
7094
7142
|
const block = blocks[bi];
|
|
7095
|
-
if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access',
|
|
7143
|
+
if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access', _204 => _204.style, 'optionalAccess', _205 => _205.fontSize])) continue;
|
|
7096
7144
|
const text = block.text.trim();
|
|
7097
7145
|
if (text.length === 0 || text.length > 200) continue;
|
|
7098
7146
|
if (/^\d+$/.test(text) && !isChapterNumber(block, blocks[bi + 1], medianFontSize)) continue;
|
|
7099
7147
|
const ratio = block.style.fontSize / medianFontSize;
|
|
7100
7148
|
let level = 0;
|
|
7101
|
-
if (ratio >=
|
|
7102
|
-
else if (ratio >=
|
|
7103
|
-
else if (ratio >=
|
|
7149
|
+
if (ratio >= _chunkOW2XKTQAcjs.HEADING_RATIO_H1) level = 1;
|
|
7150
|
+
else if (ratio >= _chunkOW2XKTQAcjs.HEADING_RATIO_H2) level = 2;
|
|
7151
|
+
else if (ratio >= _chunkOW2XKTQAcjs.HEADING_RATIO_H3) level = 3;
|
|
7104
7152
|
if (level > 0) {
|
|
7105
7153
|
block.type = "heading";
|
|
7106
7154
|
block.level = level;
|
|
@@ -7109,21 +7157,21 @@ function detectHeadings(blocks, medianFontSize) {
|
|
|
7109
7157
|
}
|
|
7110
7158
|
}
|
|
7111
7159
|
function isChapterNumber(block, next, medianFontSize) {
|
|
7112
|
-
const size = _nullishCoalesce(_optionalChain([block, 'access',
|
|
7113
|
-
const nextSize = _nullishCoalesce(_optionalChain([next, 'optionalAccess',
|
|
7114
|
-
const text = _nullishCoalesce(_optionalChain([next, 'optionalAccess',
|
|
7115
|
-
const a = block.bbox, b = _optionalChain([next, 'optionalAccess',
|
|
7116
|
-
return /^\d{1,2}$/.test(_nullishCoalesce(_optionalChain([block, 'access',
|
|
7160
|
+
const size = _nullishCoalesce(_optionalChain([block, 'access', _206 => _206.style, 'optionalAccess', _207 => _207.fontSize]), () => ( 0));
|
|
7161
|
+
const nextSize = _nullishCoalesce(_optionalChain([next, 'optionalAccess', _208 => _208.style, 'optionalAccess', _209 => _209.fontSize]), () => ( 0));
|
|
7162
|
+
const text = _nullishCoalesce(_optionalChain([next, 'optionalAccess', _210 => _210.text, 'optionalAccess', _211 => _211.trim, 'call', _212 => _212()]), () => ( ""));
|
|
7163
|
+
const a = block.bbox, b = _optionalChain([next, 'optionalAccess', _213 => _213.bbox]);
|
|
7164
|
+
return /^\d{1,2}$/.test(_nullishCoalesce(_optionalChain([block, 'access', _214 => _214.text, 'optionalAccess', _215 => _215.trim, 'call', _216 => _216()]), () => ( ""))) && size >= medianFontSize * 2.5 && !!next && (next.type === "paragraph" || next.type === "heading") && next.pageNumber === block.pageNumber && nextSize >= medianFontSize * _chunkOW2XKTQAcjs.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;
|
|
7117
7165
|
}
|
|
7118
7166
|
function mergeStackedHeadingLines(blocks, medianFontSize) {
|
|
7119
7167
|
for (let i = 0; i < blocks.length - 1; ) {
|
|
7120
7168
|
const a = blocks[i], b = blocks[i + 1];
|
|
7121
7169
|
const ab = a.bbox, bb = b.bbox;
|
|
7122
|
-
const af = _nullishCoalesce(_optionalChain([a, 'access',
|
|
7170
|
+
const af = _nullishCoalesce(_optionalChain([a, 'access', _217 => _217.style, 'optionalAccess', _218 => _218.fontSize]), () => ( 0)), bf = _nullishCoalesce(_optionalChain([b, 'access', _219 => _219.style, 'optionalAccess', _220 => _220.fontSize]), () => ( 0));
|
|
7123
7171
|
const gap = ab && bb ? ab.y - (bb.y + bb.height) : Infinity;
|
|
7124
|
-
const centered = ab && bb && _optionalChain([a, 'access',
|
|
7172
|
+
const centered = ab && bb && _optionalChain([a, 'access', _221 => _221.style, 'optionalAccess', _222 => _222.fontName]) === _optionalChain([b, 'access', _223 => _223.style, 'optionalAccess', _224 => _224.fontName]) && Math.abs(ab.x + ab.width / 2 - (bb.x + bb.width / 2)) <= Math.max(5, af * 0.5);
|
|
7125
7173
|
const sameAnchor = ab && bb && Math.abs(ab.x - bb.x) <= 5;
|
|
7126
|
-
const wrapped = sameAnchor && _optionalChain([a, 'access',
|
|
7174
|
+
const wrapped = sameAnchor && _optionalChain([a, 'access', _225 => _225.style, 'optionalAccess', _226 => _226.fontName]) === _optionalChain([b, 'access', _227 => _227.style, 'optionalAccess', _228 => _228.fontName]) && af === bf && ab.width >= bb.width * 0.95 && (_nullishCoalesce(_optionalChain([a, 'access', _229 => _229.text, 'optionalAccess', _230 => _230.trim, 'call', _231 => _231(), 'access', _232 => _232.split, 'call', _233 => _233(/\s+/), 'access', _234 => _234.length]), () => ( 0))) >= 3;
|
|
7127
7175
|
const displayStack = centered && gap <= Math.min(af, bf) * 0.3 && Math.max(af, bf) <= Math.min(af, bf) * 1.45;
|
|
7128
7176
|
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)) {
|
|
7129
7177
|
i++;
|
|
@@ -7152,25 +7200,25 @@ function detectTypographyHeadings(blocks) {
|
|
|
7152
7200
|
if (page.some((block) => block.type === "heading")) continue;
|
|
7153
7201
|
const faceWeight = /* @__PURE__ */ new Map();
|
|
7154
7202
|
for (const block of page) {
|
|
7155
|
-
if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access',
|
|
7203
|
+
if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access', _235 => _235.style, 'optionalAccess', _236 => _236.fontName])) continue;
|
|
7156
7204
|
const faces = FACE_CHARS.get(block);
|
|
7157
7205
|
if (faces) for (const [face, n] of faces) faceWeight.set(face, (_nullishCoalesce(faceWeight.get(face), () => ( 0))) + n);
|
|
7158
7206
|
else faceWeight.set(block.style.fontName, (_nullishCoalesce(faceWeight.get(block.style.fontName), () => ( 0))) + block.text.length);
|
|
7159
7207
|
}
|
|
7160
|
-
const bodyFace = _optionalChain([[...faceWeight], 'access',
|
|
7208
|
+
const bodyFace = _optionalChain([[...faceWeight], 'access', _237 => _237.sort, 'call', _238 => _238((a, b) => b[1] - a[1]), 'access', _239 => _239[0], 'optionalAccess', _240 => _240[0]]);
|
|
7161
7209
|
if (!bodyFace || (_nullishCoalesce(faceWeight.get(bodyFace), () => ( 0))) < 250) continue;
|
|
7162
7210
|
const sizeWeight = /* @__PURE__ */ new Map();
|
|
7163
7211
|
for (const block of page) {
|
|
7164
|
-
if (block.type !== "paragraph" || !_optionalChain([block, 'access',
|
|
7212
|
+
if (block.type !== "paragraph" || !_optionalChain([block, 'access', _241 => _241.style, 'optionalAccess', _242 => _242.fontSize])) continue;
|
|
7165
7213
|
const faces = FACE_CHARS.get(block);
|
|
7166
|
-
const chars = faces ? _nullishCoalesce(faces.get(bodyFace), () => ( 0)) : block.style.fontName === bodyFace ? _nullishCoalesce(_optionalChain([block, 'access',
|
|
7214
|
+
const chars = faces ? _nullishCoalesce(faces.get(bodyFace), () => ( 0)) : block.style.fontName === bodyFace ? _nullishCoalesce(_optionalChain([block, 'access', _243 => _243.text, 'optionalAccess', _244 => _244.length]), () => ( 0)) : 0;
|
|
7167
7215
|
if (chars) sizeWeight.set(block.style.fontSize, (_nullishCoalesce(sizeWeight.get(block.style.fontSize), () => ( 0))) + chars);
|
|
7168
7216
|
}
|
|
7169
|
-
const bodySize = _nullishCoalesce(_optionalChain([[...sizeWeight], 'access',
|
|
7217
|
+
const bodySize = _nullishCoalesce(_optionalChain([[...sizeWeight], 'access', _245 => _245.sort, 'call', _246 => _246((a, b) => b[1] - a[1]), 'access', _247 => _247[0], 'optionalAccess', _248 => _248[0]]), () => ( 0));
|
|
7170
7218
|
for (let i = 0; i < page.length; i++) {
|
|
7171
7219
|
const block = page[i];
|
|
7172
7220
|
const { text, bbox, style } = block;
|
|
7173
|
-
if (block.type !== "paragraph" || !text || !bbox || !_optionalChain([style, 'optionalAccess',
|
|
7221
|
+
if (block.type !== "paragraph" || !text || !bbox || !_optionalChain([style, 'optionalAccess', _249 => _249.fontName]) || !style.fontSize) continue;
|
|
7174
7222
|
const title = text.trim();
|
|
7175
7223
|
const numbered = /^\d+(?:\.\d+)*\.?\s+[A-Z가-힣]/.test(title);
|
|
7176
7224
|
const faces = FACE_CHARS.get(block);
|
|
@@ -7200,16 +7248,16 @@ function detectDocumentStyleHeadings(blocks) {
|
|
|
7200
7248
|
for (const page of byPage.values()) {
|
|
7201
7249
|
const faceChars = /* @__PURE__ */ new Map();
|
|
7202
7250
|
for (const block of page) {
|
|
7203
|
-
if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access',
|
|
7251
|
+
if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access', _250 => _250.style, 'optionalAccess', _251 => _251.fontName])) continue;
|
|
7204
7252
|
faceChars.set(block.style.fontName, (_nullishCoalesce(faceChars.get(block.style.fontName), () => ( 0))) + block.text.length);
|
|
7205
7253
|
}
|
|
7206
|
-
const bodyFace = _optionalChain([[...faceChars], 'access',
|
|
7254
|
+
const bodyFace = _optionalChain([[...faceChars], 'access', _252 => _252.sort, 'call', _253 => _253((a, b) => b[1] - a[1]), 'access', _254 => _254[0], 'optionalAccess', _255 => _255[0]]);
|
|
7207
7255
|
if (!bodyFace || (_nullishCoalesce(faceChars.get(bodyFace), () => ( 0))) < 100) continue;
|
|
7208
|
-
const labels = page.filter((b) => b.type === "paragraph" && b.text && b.bbox && _optionalChain([b, 'access',
|
|
7256
|
+
const labels = page.filter((b) => b.type === "paragraph" && b.text && b.bbox && _optionalChain([b, 'access', _256 => _256.style, 'optionalAccess', _257 => _257.fontName]) && b.style.fontName !== bodyFace && b.text.trim().length >= 3 && b.text.trim().length <= 40);
|
|
7209
7257
|
for (const label of labels) {
|
|
7210
|
-
const peers = labels.filter((b) => _optionalChain([b, 'access',
|
|
7258
|
+
const peers = labels.filter((b) => _optionalChain([b, 'access', _258 => _258.style, 'optionalAccess', _259 => _259.fontName]) === _optionalChain([label, 'access', _260 => _260.style, 'optionalAccess', _261 => _261.fontName]) && Math.abs(b.bbox.y - label.bbox.y) <= 3 && Math.abs(b.bbox.x - label.bbox.x) >= 60);
|
|
7211
7259
|
if (peers.length < 2) continue;
|
|
7212
|
-
const value = page.find((b) => b.type === "paragraph" && b.bbox && _optionalChain([b, 'access',
|
|
7260
|
+
const value = page.find((b) => b.type === "paragraph" && b.bbox && _optionalChain([b, 'access', _262 => _262.style, 'optionalAccess', _263 => _263.fontName]) !== _optionalChain([label, 'access', _264 => _264.style, 'optionalAccess', _265 => _265.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);
|
|
7213
7261
|
if (value) {
|
|
7214
7262
|
label.type = "heading";
|
|
7215
7263
|
label.level = 2;
|
|
@@ -7218,7 +7266,7 @@ function detectDocumentStyleHeadings(blocks) {
|
|
|
7218
7266
|
const first = page.find((b) => b.type !== "image" && b.type !== "separator");
|
|
7219
7267
|
const second = page[page.indexOf(first) + 1];
|
|
7220
7268
|
const third = page[page.indexOf(first) + 2];
|
|
7221
|
-
if (!first || !second || !third || first.type !== "list" && first.type !== "paragraph" || second.type !== "paragraph" || !first.text || !second.text || !first.bbox || !second.bbox || !_optionalChain([first, 'access',
|
|
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', _266 => _266.style, 'optionalAccess', _267 => _267.fontName]) || !_optionalChain([second, 'access', _268 => _268.style, 'optionalAccess', _269 => _269.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', _270 => _270.style, 'optionalAccess', _271 => _271.fontName]) !== bodyFace) continue;
|
|
7222
7270
|
first.type = "heading";
|
|
7223
7271
|
first.level = 1;
|
|
7224
7272
|
first.text = `${first.text.trim()} ${second.text.trim()}`;
|
|
@@ -7242,18 +7290,18 @@ function detectSiblingStyleHeadings(blocks) {
|
|
|
7242
7290
|
for (const page of byPage.values()) {
|
|
7243
7291
|
const bodyChars = /* @__PURE__ */ new Map();
|
|
7244
7292
|
for (const block of page) {
|
|
7245
|
-
if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access',
|
|
7293
|
+
if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access', _272 => _272.style, 'optionalAccess', _273 => _273.fontName])) continue;
|
|
7246
7294
|
const face = block.style.fontName;
|
|
7247
7295
|
bodyChars.set(face, (_nullishCoalesce(bodyChars.get(face), () => ( 0))) + block.text.length);
|
|
7248
7296
|
}
|
|
7249
|
-
const bodyFace = _optionalChain([[...bodyChars], 'access',
|
|
7250
|
-
const anchors = page.filter((b) => b.type === "heading" && b.text && _optionalChain([b, 'access',
|
|
7297
|
+
const bodyFace = _optionalChain([[...bodyChars], 'access', _274 => _274.sort, 'call', _275 => _275((a, b) => b[1] - a[1]), 'access', _276 => _276[0], 'optionalAccess', _277 => _277[0]]);
|
|
7298
|
+
const anchors = page.filter((b) => b.type === "heading" && b.text && _optionalChain([b, 'access', _278 => _278.style, 'optionalAccess', _279 => _279.fontName]) && b.style.fontName !== bodyFace);
|
|
7251
7299
|
for (const anchor of anchors) {
|
|
7252
7300
|
const numbered = /^([A-Z])\.\d+\s+/.exec(anchor.text.trim());
|
|
7253
7301
|
const lettered = /^([A-Z])\s+/.exec(anchor.text.trim());
|
|
7254
|
-
const peers = anchors.filter((b) => _optionalChain([b, 'access',
|
|
7302
|
+
const peers = anchors.filter((b) => _optionalChain([b, 'access', _280 => _280.style, 'optionalAccess', _281 => _281.fontName]) === _optionalChain([anchor, 'access', _282 => _282.style, 'optionalAccess', _283 => _283.fontName]) && Math.abs((_nullishCoalesce(_optionalChain([b, 'access', _284 => _284.style, 'optionalAccess', _285 => _285.fontSize]), () => ( 0))) - (_nullishCoalesce(_optionalChain([anchor, 'access', _286 => _286.style, 'optionalAccess', _287 => _287.fontSize]), () => ( 0)))) < 0.5);
|
|
7255
7303
|
if (peers.length < 2 && !numbered && !lettered) continue;
|
|
7256
|
-
const candidates = page.filter((b) => b.type === "paragraph" && b.text && b.bbox && _optionalChain([b, 'access',
|
|
7304
|
+
const candidates = page.filter((b) => b.type === "paragraph" && b.text && b.bbox && _optionalChain([b, 'access', _288 => _288.style, 'optionalAccess', _289 => _289.fontName]) === _optionalChain([anchor, 'access', _290 => _290.style, 'optionalAccess', _291 => _291.fontName]) && Math.abs((_nullishCoalesce(_optionalChain([b, 'access', _292 => _292.style, 'optionalAccess', _293 => _293.fontSize]), () => ( 0))) - (_nullishCoalesce(_optionalChain([anchor, 'access', _294 => _294.style, 'optionalAccess', _295 => _295.fontSize]), () => ( 0)))) < 0.5 && b.text.trim().length >= 3 && b.text.trim().length <= 80 && b.bbox.height <= (_nullishCoalesce(_optionalChain([b, 'access', _296 => _296.style, 'optionalAccess', _297 => _297.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()));
|
|
7257
7305
|
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));
|
|
7258
7306
|
if (siblings.length < (numbered || lettered ? 1 : 2)) continue;
|
|
7259
7307
|
for (const sibling of siblings) {
|
|
@@ -7272,13 +7320,13 @@ function detectRepeatedPageLabels(blocks) {
|
|
|
7272
7320
|
}
|
|
7273
7321
|
for (const page of byPage.values()) {
|
|
7274
7322
|
const bodyChars = /* @__PURE__ */ new Map();
|
|
7275
|
-
for (const b of page) if (b.type === "paragraph" && b.text && _optionalChain([b, 'access',
|
|
7323
|
+
for (const b of page) if (b.type === "paragraph" && b.text && _optionalChain([b, 'access', _298 => _298.style, 'optionalAccess', _299 => _299.fontName])) {
|
|
7276
7324
|
const faces = FACE_CHARS.get(b);
|
|
7277
7325
|
if (faces) for (const [face, n] of faces) bodyChars.set(face, (_nullishCoalesce(bodyChars.get(face), () => ( 0))) + n);
|
|
7278
7326
|
else bodyChars.set(b.style.fontName, (_nullishCoalesce(bodyChars.get(b.style.fontName), () => ( 0))) + b.text.length);
|
|
7279
7327
|
}
|
|
7280
|
-
const bodyFace = _optionalChain([[...bodyChars], 'access',
|
|
7281
|
-
const candidates = page.filter((b) => b.type === "paragraph" && b.text && b.bbox && _optionalChain([b, 'access',
|
|
7328
|
+
const bodyFace = _optionalChain([[...bodyChars], 'access', _300 => _300.sort, 'call', _301 => _301((a, b) => b[1] - a[1]), 'access', _302 => _302[0], 'optionalAccess', _303 => _303[0]]);
|
|
7329
|
+
const candidates = page.filter((b) => b.type === "paragraph" && b.text && b.bbox && _optionalChain([b, 'access', _304 => _304.style, 'optionalAccess', _305 => _305.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);
|
|
7282
7330
|
const groups = /* @__PURE__ */ new Map();
|
|
7283
7331
|
for (const b of candidates) {
|
|
7284
7332
|
const key = `${b.style.fontName}:${b.style.fontSize}`;
|
|
@@ -7314,19 +7362,19 @@ function detectPageLeadHeadings(blocks) {
|
|
|
7314
7362
|
for (const page of byPage.values()) {
|
|
7315
7363
|
const content = page.filter((b) => b.type !== "image" && b.type !== "separator" && !(b.type === "paragraph" && !b.style));
|
|
7316
7364
|
const [first, second, third] = content;
|
|
7317
|
-
if (!_optionalChain([first, 'optionalAccess',
|
|
7365
|
+
if (!_optionalChain([first, 'optionalAccess', _306 => _306.bbox]) || !first.text || !_optionalChain([first, 'access', _307 => _307.style, 'optionalAccess', _308 => _308.fontSize]) || !second) continue;
|
|
7318
7366
|
const firstText = first.text.trim();
|
|
7319
7367
|
const captionLike = /^(?:Figure|Fig\.?|Table|표|그림)\s*\d/i;
|
|
7320
7368
|
const hasImage = page.some((b) => b.type === "image");
|
|
7321
|
-
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',
|
|
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', _309 => _309.text, 'optionalAccess', _310 => _310.trim, 'call', _311 => _311()]), () => ( ""))) && (_nullishCoalesce(_optionalChain([second, 'access', _312 => _312.text, 'optionalAccess', _313 => _313.length]), () => ( 0))) >= 100 && second.bbox && first.bbox.y - (second.bbox.y + second.bbox.height) >= first.style.fontSize);
|
|
7322
7370
|
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);
|
|
7323
|
-
const firstIsSection = first.type === "list" && /^\d+\.\s+[A-Z][A-Z\s]{12,}$/.test(firstText) && second.type === "paragraph" && (_nullishCoalesce(_optionalChain([second, 'access',
|
|
7371
|
+
const firstIsSection = first.type === "list" && /^\d+\.\s+[A-Z][A-Z\s]{12,}$/.test(firstText) && second.type === "paragraph" && (_nullishCoalesce(_optionalChain([second, 'access', _314 => _314.text, 'optionalAccess', _315 => _315.length]), () => ( 0))) >= 100;
|
|
7324
7372
|
if (firstIsTitle || firstAboveProse || firstIsSection) {
|
|
7325
7373
|
first.type = "heading";
|
|
7326
7374
|
first.level = 1;
|
|
7327
7375
|
}
|
|
7328
|
-
if (first.type !== "heading" || captionLike.test(firstText) || second.type !== "paragraph" || !second.text || !second.bbox || !_optionalChain([second, 'access',
|
|
7329
|
-
const distinctFace = _optionalChain([third, 'access',
|
|
7376
|
+
if (first.type !== "heading" || captionLike.test(firstText) || second.type !== "paragraph" || !second.text || !second.bbox || !_optionalChain([second, 'access', _316 => _316.style, 'optionalAccess', _317 => _317.fontName]) || !second.style.fontSize || !_optionalChain([third, 'optionalAccess', _318 => _318.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;
|
|
7377
|
+
const distinctFace = _optionalChain([third, 'access', _319 => _319.style, 'optionalAccess', _320 => _320.fontName]) !== second.style.fontName;
|
|
7330
7378
|
const namedContents = /^Table of Contents$/i.test(second.text.trim());
|
|
7331
7379
|
if (distinctFace && third.text.length >= 60 || namedContents) {
|
|
7332
7380
|
second.type = "heading";
|
|
@@ -7337,24 +7385,24 @@ function detectPageLeadHeadings(blocks) {
|
|
|
7337
7385
|
function refineDocumentStyleHeadings(blocks) {
|
|
7338
7386
|
const faceChars = /* @__PURE__ */ new Map();
|
|
7339
7387
|
for (const block of blocks) {
|
|
7340
|
-
if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access',
|
|
7388
|
+
if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access', _321 => _321.style, 'optionalAccess', _322 => _322.fontName])) continue;
|
|
7341
7389
|
faceChars.set(block.style.fontName, (_nullishCoalesce(faceChars.get(block.style.fontName), () => ( 0))) + block.text.length);
|
|
7342
7390
|
}
|
|
7343
7391
|
const [bodyFace, bodyChars] = _nullishCoalesce([...faceChars].sort((a, b) => b[1] - a[1])[0], () => ( []));
|
|
7344
7392
|
if (!bodyFace || !bodyChars || bodyChars < 300) return;
|
|
7345
7393
|
for (let i = 0; i < blocks.length; i++) {
|
|
7346
7394
|
const block = blocks[i];
|
|
7347
|
-
const text = _nullishCoalesce(_optionalChain([block, 'access',
|
|
7395
|
+
const text = _nullishCoalesce(_optionalChain([block, 'access', _323 => _323.text, 'optionalAccess', _324 => _324.trim, 'call', _325 => _325()]), () => ( ""));
|
|
7348
7396
|
if (block.type === "heading" && /(?:https?:\/\/|www\.|^arxiv:|^doi:)/i.test(text)) {
|
|
7349
7397
|
block.type = "paragraph";
|
|
7350
7398
|
block.level = void 0;
|
|
7351
7399
|
continue;
|
|
7352
7400
|
}
|
|
7353
7401
|
const box = block.bbox, style = block.style;
|
|
7354
|
-
if (block.type !== "paragraph" || !box || !_optionalChain([style, 'optionalAccess',
|
|
7402
|
+
if (block.type !== "paragraph" || !box || !_optionalChain([style, 'optionalAccess', _326 => _326.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;
|
|
7355
7403
|
const previous = blocks[i - 1], next = blocks[i + 1];
|
|
7356
|
-
const pb = _optionalChain([previous, 'optionalAccess',
|
|
7357
|
-
if (!pb || !nb || previous.pageNumber !== block.pageNumber || next.pageNumber !== block.pageNumber || previous.type !== "paragraph" && previous.type !== "heading" || next.type !== "paragraph" || _optionalChain([next, 'access',
|
|
7404
|
+
const pb = _optionalChain([previous, 'optionalAccess', _327 => _327.bbox]), nb = _optionalChain([next, 'optionalAccess', _328 => _328.bbox]);
|
|
7405
|
+
if (!pb || !nb || previous.pageNumber !== block.pageNumber || next.pageNumber !== block.pageNumber || previous.type !== "paragraph" && previous.type !== "heading" || next.type !== "paragraph" || _optionalChain([next, 'access', _329 => _329.style, 'optionalAccess', _330 => _330.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;
|
|
7358
7406
|
block.type = "heading";
|
|
7359
7407
|
block.level = 2;
|
|
7360
7408
|
}
|
|
@@ -7404,7 +7452,7 @@ function detectMarkerHeadings(blocks) {
|
|
|
7404
7452
|
block.level = 4;
|
|
7405
7453
|
continue;
|
|
7406
7454
|
}
|
|
7407
|
-
if (/^[가-힣]{2,6}$/.test(text) && _optionalChain([block, 'access',
|
|
7455
|
+
if (/^[가-힣]{2,6}$/.test(text) && _optionalChain([block, 'access', _331 => _331.style, 'optionalAccess', _332 => _332.fontSize])) {
|
|
7408
7456
|
const prev = blocks[i - 1];
|
|
7409
7457
|
const next = blocks[i + 1];
|
|
7410
7458
|
const prevIsStructural = !prev || prev.type === "table" || prev.type === "heading" || prev.type === "separator";
|
|
@@ -7445,7 +7493,7 @@ function detectTableCaptions(blocks) {
|
|
|
7445
7493
|
block.table.caption = blocks[i - 1].text.trim();
|
|
7446
7494
|
blocks.splice(i - 1, 1);
|
|
7447
7495
|
i--;
|
|
7448
|
-
} else if (isCaptionCandidate(blocks[i + 1], block) && _optionalChain([blocks, 'access',
|
|
7496
|
+
} else if (isCaptionCandidate(blocks[i + 1], block) && _optionalChain([blocks, 'access', _333 => _333[i + 2], 'optionalAccess', _334 => _334.type]) !== "table") {
|
|
7449
7497
|
const cap = blocks[i + 1].bbox, tbl = block.bbox;
|
|
7450
7498
|
block.table.caption = blocks[i + 1].text.trim();
|
|
7451
7499
|
if (cap && tbl && cap.y + cap.height <= tbl.y + 1) block.table.captionBelow = true;
|
|
@@ -7530,7 +7578,7 @@ function detectKoreanListBlocks(blocks) {
|
|
|
7530
7578
|
}
|
|
7531
7579
|
const listType = label.family === "arabicDot" ? "ordered" : "unordered";
|
|
7532
7580
|
const listBlock = { ...b, type: "list", listType };
|
|
7533
|
-
const pb = _optionalChain([lastTopLevelList, 'optionalAccess',
|
|
7581
|
+
const pb = _optionalChain([lastTopLevelList, 'optionalAccess', _335 => _335.bbox]), cb = b.bbox;
|
|
7534
7582
|
const notIndented = depth > 0 && !!pb && !!cb && pb.page === cb.page && cb.x >= pb.x + pb.width && cb.y >= pb.y + pb.height;
|
|
7535
7583
|
if (notIndented) familyStack = [label.family];
|
|
7536
7584
|
if (depth === 0 || notIndented) {
|
|
@@ -7688,7 +7736,7 @@ function removeHeaderFooterBlocks(blocks, pageHeights, warnings, notes, tables =
|
|
|
7688
7736
|
const b = blocks[bi];
|
|
7689
7737
|
const cellTexts = b.type === "table" && b.table ? b.table.cells.flat().map((c) => c.text.trim()).filter(Boolean) : [];
|
|
7690
7738
|
const headBox = cellTexts.length <= 4 && !!b.bbox && b.bbox.height <= (_nullishCoalesce(pageHeights.get(b.bbox.page), () => ( Infinity))) * 0.05;
|
|
7691
|
-
const text = !tables ? _optionalChain([b, 'access',
|
|
7739
|
+
const text = !tables ? _optionalChain([b, 'access', _336 => _336.text, 'optionalAccess', _337 => _337.trim, 'call', _338 => _338()]) : cellTexts.length ? (headBox ? [...cellTexts].sort() : cellTexts).join(" | ") : void 0;
|
|
7692
7740
|
if (!b.bbox || !b.pageNumber || !text) continue;
|
|
7693
7741
|
const ph = pageHeights.get(b.bbox.page) || pageHeights.get(b.pageNumber);
|
|
7694
7742
|
if (!ph) continue;
|
|
@@ -7721,7 +7769,7 @@ function removeHeaderFooterBlocks(blocks, pageHeights, warnings, notes, tables =
|
|
|
7721
7769
|
for (const [p, count] of patternCount) {
|
|
7722
7770
|
const pages = [..._nullishCoalesce(patternPages.get(p), () => ( []))];
|
|
7723
7771
|
const span2 = pages.length ? Math.max(...pages) - Math.min(...pages) + 1 : 0;
|
|
7724
|
-
const varying = !tables && (_nullishCoalesce(_optionalChain([patternNumbers, 'access',
|
|
7772
|
+
const varying = !tables && (_nullishCoalesce(_optionalChain([patternNumbers, 'access', _339 => _339.get, 'call', _340 => _340(p), 'optionalAccess', _341 => _341.size]), () => ( 0))) > 1;
|
|
7725
7773
|
const occ = _nullishCoalesce(patternOcc.get(p), () => ( []));
|
|
7726
7774
|
const dense = pages.length >= span2 * 0.4;
|
|
7727
7775
|
const loose = looseVaryingNumber(occ, entries === topEntries) && (entries === bottomEntries || dense || tracksPages(occ));
|
|
@@ -7733,8 +7781,8 @@ function removeHeaderFooterBlocks(blocks, pageHeights, warnings, notes, tables =
|
|
|
7733
7781
|
for (const e of entries) {
|
|
7734
7782
|
const norm = e.text.replace(/\d+/g, "#");
|
|
7735
7783
|
if (!repeatedPatterns.has(norm)) continue;
|
|
7736
|
-
const noteMark = _optionalChain([e, 'access',
|
|
7737
|
-
if (noteMark && _optionalChain([notes, 'optionalAccess',
|
|
7784
|
+
const noteMark = _optionalChain([e, 'access', _342 => _342.text, 'access', _343 => _343.match, 'call', _344 => _344(/^\d{1,3}\)/), 'optionalAccess', _345 => _345[0]]);
|
|
7785
|
+
if (noteMark && _optionalChain([notes, 'optionalAccess', _346 => _346.get, 'call', _347 => _347(e.page), 'optionalAccess', _348 => _348.marks, 'access', _349 => _349.some, 'call', _350 => _350((m) => m.mark === noteMark)])) continue;
|
|
7738
7786
|
const cand = blocks[e.blockIdx];
|
|
7739
7787
|
const cb = cand.bbox;
|
|
7740
7788
|
const tableNote = /^(?:주\s*(?:\d+\s*[).:]|[::])|(?:자료|출처)\s*[::]|\*\s+\S)/.test(e.text.replace(/ \| /g, " ")) && blocks.some((o) => {
|
|
@@ -7748,7 +7796,7 @@ function removeHeaderFooterBlocks(blocks, pageHeights, warnings, notes, tables =
|
|
|
7748
7796
|
if (bi === e.blockIdx) continue;
|
|
7749
7797
|
const o = blocks[bi];
|
|
7750
7798
|
if (!o.bbox || o.bbox.page !== cb.page) continue;
|
|
7751
|
-
const oNorm = _optionalChain([o, 'access',
|
|
7799
|
+
const oNorm = _optionalChain([o, 'access', _351 => _351.text, 'optionalAccess', _352 => _352.trim, 'call', _353 => _353(), 'access', _354 => _354.replace, 'call', _355 => _355(/\d+/g, "#")]);
|
|
7752
7800
|
if (oNorm && repeatedPatterns.has(oNorm)) continue;
|
|
7753
7801
|
const overlap2 = Math.min(cb.y + cb.height, o.bbox.y + o.bbox.height) - Math.max(cb.y, o.bbox.y);
|
|
7754
7802
|
if (overlap2 >= cb.height * 0.5) {
|
|
@@ -7876,7 +7924,7 @@ function recordRowRules(table, cells, bbox, hs) {
|
|
|
7876
7924
|
function markImageCell(cell) {
|
|
7877
7925
|
IMAGE_CELLS.add(cell);
|
|
7878
7926
|
}
|
|
7879
|
-
var emptyCell = (cell) => !cell || !_optionalChain([cell, 'access',
|
|
7927
|
+
var emptyCell = (cell) => !cell || !_optionalChain([cell, 'access', _356 => _356.text, 'optionalAccess', _357 => _357.trim, 'call', _358 => _358()]) && !_optionalChain([cell, 'access', _359 => _359.blocks, 'optionalAccess', _360 => _360.length]) && !IMAGE_CELLS.has(cell);
|
|
7880
7928
|
function trimTable(table) {
|
|
7881
7929
|
let cols = table.cols;
|
|
7882
7930
|
while (cols > 0 && table.cells.every((row) => emptyCell(row[cols - 1]))) cols--;
|
|
@@ -7892,7 +7940,7 @@ function trimTable(table) {
|
|
|
7892
7940
|
function trimTrailingEmptyTableCols(blocks) {
|
|
7893
7941
|
for (const b of blocks) {
|
|
7894
7942
|
if (b.type !== "table" || !b.table) continue;
|
|
7895
|
-
for (const row of b.table.cells) for (const cell of row) if (_optionalChain([cell, 'access',
|
|
7943
|
+
for (const row of b.table.cells) for (const cell of row) if (_optionalChain([cell, 'access', _361 => _361.blocks, 'optionalAccess', _362 => _362.length])) trimTrailingEmptyTableCols(cell.blocks);
|
|
7896
7944
|
trimTable(b.table);
|
|
7897
7945
|
}
|
|
7898
7946
|
}
|
|
@@ -7912,7 +7960,7 @@ function mergeSliverColumns(grid, colXs, maxWidth) {
|
|
|
7912
7960
|
}
|
|
7913
7961
|
const ok = owner.every((row) => {
|
|
7914
7962
|
const o = row[c];
|
|
7915
|
-
return !!o && (o.colSpan > 1 || !o.text.trim() && !_optionalChain([o, 'access',
|
|
7963
|
+
return !!o && (o.colSpan > 1 || !o.text.trim() && !_optionalChain([o, 'access', _363 => _363.blocks, 'optionalAccess', _364 => _364.length]));
|
|
7916
7964
|
});
|
|
7917
7965
|
if (!ok) continue;
|
|
7918
7966
|
const spanning = /* @__PURE__ */ new Set();
|
|
@@ -7939,7 +7987,7 @@ var multiply = (m, t) => [
|
|
|
7939
7987
|
m[1] * t[4] + m[3] * t[5] + m[5]
|
|
7940
7988
|
];
|
|
7941
7989
|
function hollowCircle(image) {
|
|
7942
|
-
if (!_optionalChain([image, 'optionalAccess',
|
|
7990
|
+
if (!_optionalChain([image, 'optionalAccess', _365 => _365.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;
|
|
7943
7991
|
const stride = image.kind === _pdfmjs.ImageKind.RGB_24BPP ? 3 : image.kind === _pdfmjs.ImageKind.RGBA_32BPP ? 4 : 0;
|
|
7944
7992
|
const { width, height, data } = image;
|
|
7945
7993
|
if (!stride || data.length < width * height * stride) return false;
|
|
@@ -8004,9 +8052,9 @@ function smallVisibleImagePaints(fnArray, argsArray) {
|
|
|
8004
8052
|
const op = fnArray[i], args = argsArray[i];
|
|
8005
8053
|
if (op === _pdfmjs.OPS.save || op === _pdfmjs.OPS.paintFormXObjectBegin) {
|
|
8006
8054
|
stack.push({ ctm, alpha, clip, unknownClip });
|
|
8007
|
-
const matrix = op === _pdfmjs.OPS.paintFormXObjectBegin ? _optionalChain([args, 'optionalAccess',
|
|
8055
|
+
const matrix = op === _pdfmjs.OPS.paintFormXObjectBegin ? _optionalChain([args, 'optionalAccess', _366 => _366[0]]) : void 0;
|
|
8008
8056
|
if (Array.isArray(matrix) && matrix.length >= 6) ctm = multiply(ctm, matrix);
|
|
8009
|
-
const bounds = op === _pdfmjs.OPS.paintFormXObjectBegin ? _optionalChain([args, 'optionalAccess',
|
|
8057
|
+
const bounds = op === _pdfmjs.OPS.paintFormXObjectBegin ? _optionalChain([args, 'optionalAccess', _367 => _367[1]]) : void 0;
|
|
8010
8058
|
if (Array.isArray(bounds) && bounds.length === 4) {
|
|
8011
8059
|
const box = rectangle(bounds[0], bounds[1], bounds[2] - bounds[0], bounds[3] - bounds[1]);
|
|
8012
8060
|
if (box && ctm[1] === 0 && ctm[2] === 0) intersectClip(box);
|
|
@@ -8014,17 +8062,17 @@ function smallVisibleImagePaints(fnArray, argsArray) {
|
|
|
8014
8062
|
}
|
|
8015
8063
|
} else if (op === _pdfmjs.OPS.restore || op === _pdfmjs.OPS.paintFormXObjectEnd) {
|
|
8016
8064
|
const state = stack.pop();
|
|
8017
|
-
ctm = _nullishCoalesce(_optionalChain([state, 'optionalAccess',
|
|
8018
|
-
alpha = _nullishCoalesce(_optionalChain([state, 'optionalAccess',
|
|
8019
|
-
clip = _nullishCoalesce(_optionalChain([state, 'optionalAccess',
|
|
8020
|
-
unknownClip = _nullishCoalesce(_optionalChain([state, 'optionalAccess',
|
|
8065
|
+
ctm = _nullishCoalesce(_optionalChain([state, 'optionalAccess', _368 => _368.ctm]), () => ( [1, 0, 0, 1, 0, 0]));
|
|
8066
|
+
alpha = _nullishCoalesce(_optionalChain([state, 'optionalAccess', _369 => _369.alpha]), () => ( 1));
|
|
8067
|
+
clip = _nullishCoalesce(_optionalChain([state, 'optionalAccess', _370 => _370.clip]), () => ( null));
|
|
8068
|
+
unknownClip = _nullishCoalesce(_optionalChain([state, 'optionalAccess', _371 => _371.unknownClip]), () => ( false));
|
|
8021
8069
|
} else if (op === _pdfmjs.OPS.setGState) {
|
|
8022
|
-
for (const [key, value] of _nullishCoalesce(_optionalChain([args, 'optionalAccess',
|
|
8070
|
+
for (const [key, value] of _nullishCoalesce(_optionalChain([args, 'optionalAccess', _372 => _372[0]]), () => ( []))) {
|
|
8023
8071
|
if (key === "ca") alpha = typeof value === "number" ? value : 0;
|
|
8024
8072
|
}
|
|
8025
8073
|
} else if (op === _pdfmjs.OPS.constructPath) {
|
|
8026
8074
|
const [operations, coordinates] = args;
|
|
8027
|
-
pathRect = pathRect === void 0 && _optionalChain([operations, 'optionalAccess',
|
|
8075
|
+
pathRect = pathRect === void 0 && _optionalChain([operations, 'optionalAccess', _373 => _373.length]) === 1 && operations[0] === _pdfmjs.OPS.rectangle && _optionalChain([coordinates, 'optionalAccess', _374 => _374.length]) >= 4 && ctm[1] === 0 && ctm[2] === 0 ? rectangle(coordinates[0], coordinates[1], coordinates[2], coordinates[3]) : null;
|
|
8028
8076
|
} else if (op === _pdfmjs.OPS.clip || op === _pdfmjs.OPS.eoClip) pendingClip = true;
|
|
8029
8077
|
else if ([
|
|
8030
8078
|
_pdfmjs.OPS.endPath,
|
|
@@ -8044,7 +8092,7 @@ function smallVisibleImagePaints(fnArray, argsArray) {
|
|
|
8044
8092
|
pendingClip = false;
|
|
8045
8093
|
pathRect = void 0;
|
|
8046
8094
|
} else if (op === _pdfmjs.OPS.transform && Array.isArray(args) && args.length >= 6) ctm = multiply(ctm, args);
|
|
8047
|
-
else if (op === _pdfmjs.OPS.paintImageXObject && typeof _optionalChain([args, 'optionalAccess',
|
|
8095
|
+
else if (op === _pdfmjs.OPS.paintImageXObject && typeof _optionalChain([args, 'optionalAccess', _375 => _375[0]]) === "string") {
|
|
8048
8096
|
if (typeof args[1] !== "number" || typeof args[2] !== "number" || args[1] < 16 || args[1] > 128 || args[2] < 16 || args[2] > 128) continue;
|
|
8049
8097
|
const box = extractImageRegions([_pdfmjs.OPS.transform, _pdfmjs.OPS.paintImageXObject], [ctm, args])[0];
|
|
8050
8098
|
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;
|
|
@@ -8063,14 +8111,14 @@ async function restoreImageBullets(items, page, fnArray, argsArray, shapes = /*
|
|
|
8063
8111
|
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];
|
|
8064
8112
|
if (!line || /^[○●•◦□■∙]/.test(line.text.trim()) || !/\p{L}/u.test(line.text)) continue;
|
|
8065
8113
|
const row = items.filter((item) => Math.abs(item.y - line.y) <= 2 && item.x >= line.x);
|
|
8066
|
-
if (row.reduce((n, item) => n + (_nullishCoalesce(_optionalChain([item, 'access',
|
|
8114
|
+
if (row.reduce((n, item) => n + (_nullishCoalesce(_optionalChain([item, 'access', _376 => _376.text, 'access', _377 => _377.match, 'call', _378 => _378(/\p{L}/gu), 'optionalAccess', _379 => _379.length]), () => ( 0))), 0) < 12 || items.some((item) => item !== line && Math.abs(item.y - line.y) <= 2 && item.x < line.x)) continue;
|
|
8067
8115
|
candidates.push({ id, x: box.x1, width, line });
|
|
8068
8116
|
}
|
|
8069
8117
|
let restored = 0;
|
|
8070
8118
|
const used = /* @__PURE__ */ new Set();
|
|
8071
8119
|
for (const candidate of candidates) {
|
|
8072
8120
|
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);
|
|
8073
|
-
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',
|
|
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', _380 => _380.text, 'access', _381 => _381.match, 'call', _382 => _382(/\p{L}/gu), 'optionalAccess', _383 => _383.length]), () => ( 0))) >= 12).sort((a, b) => b.y - a.y);
|
|
8074
8122
|
const numberedList = numbered.some((item, index) => index > 0 && item.text.trim().charCodeAt(0) === numbered[index - 1].text.trim().charCodeAt(0) + 1);
|
|
8075
8123
|
if (!same.length && !numberedList || used.has(candidate.line)) continue;
|
|
8076
8124
|
if (!shapes.has(candidate.id)) shapes.set(candidate.id, hollowCircle(await resolveImagePixels(page, candidate.id)));
|
|
@@ -8136,7 +8184,7 @@ function groupFlowBoxUnits(blocks, grids, hs, vs, images) {
|
|
|
8136
8184
|
return units;
|
|
8137
8185
|
}
|
|
8138
8186
|
function arrowDirection(image) {
|
|
8139
|
-
if (!_optionalChain([image, 'optionalAccess',
|
|
8187
|
+
if (!_optionalChain([image, 'optionalAccess', _384 => _384.data]) || image.width < 16 || image.width > 128 || image.height < 16 || image.height > 128) return 0;
|
|
8140
8188
|
const { width, height, data } = image;
|
|
8141
8189
|
const stride = image.kind === _pdfmjs.ImageKind.RGB_24BPP ? 3 : image.kind === _pdfmjs.ImageKind.RGBA_32BPP ? 4 : 0;
|
|
8142
8190
|
if (!stride || data.length < width * height * stride) return 0;
|
|
@@ -8204,7 +8252,7 @@ function isSideTabTable(box, table, others, pageWidth, pageHeight) {
|
|
|
8204
8252
|
function removeSideTabs(blocks, pageWidths) {
|
|
8205
8253
|
const edges = /* @__PURE__ */ new Map();
|
|
8206
8254
|
for (const b of blocks) {
|
|
8207
|
-
if (!b.bbox || b.pageNumber === void 0 || [..._nullishCoalesce(_optionalChain([b, 'access',
|
|
8255
|
+
if (!b.bbox || b.pageNumber === void 0 || [..._nullishCoalesce(_optionalChain([b, 'access', _385 => _385.text, 'optionalAccess', _386 => _386.trim, 'call', _387 => _387()]), () => ( ""))].length <= MAX_CHARS) continue;
|
|
8208
8256
|
const e = _nullishCoalesce(edges.get(b.pageNumber), () => ( { lefts: [], rights: [] }));
|
|
8209
8257
|
e.lefts.push(b.bbox.x);
|
|
8210
8258
|
e.rights.push(b.bbox.x + b.bbox.width);
|
|
@@ -8220,7 +8268,7 @@ function removeSideTabs(blocks, pageWidths) {
|
|
|
8220
8268
|
const fallback = all.length ? { left: q(all.map((e) => e.left), 0.5), right: q(all.map((e) => e.right), 0.5) } : void 0;
|
|
8221
8269
|
const key = (b) => {
|
|
8222
8270
|
const w = b.pageNumber !== void 0 ? pageWidths.get(b.pageNumber) : void 0;
|
|
8223
|
-
const text = _optionalChain([b, 'access',
|
|
8271
|
+
const text = _optionalChain([b, 'access', _388 => _388.text, 'optionalAccess', _389 => _389.trim, 'call', _390 => _390()]);
|
|
8224
8272
|
const area = _nullishCoalesce((b.pageNumber !== void 0 ? body.get(b.pageNumber) : void 0), () => ( fallback));
|
|
8225
8273
|
if (b.type === "table") {
|
|
8226
8274
|
if (!w || !b.bbox || !b.table || !SIDE_TAB_TABLES.has(b.table)) return null;
|
|
@@ -8886,16 +8934,16 @@ function isProseSpread(items) {
|
|
|
8886
8934
|
for (let i = 1; i < sorted.length; i++) {
|
|
8887
8935
|
gaps.push(sorted[i].x - (sorted[i - 1].x + sorted[i - 1].w));
|
|
8888
8936
|
}
|
|
8889
|
-
const maxGap =
|
|
8937
|
+
const maxGap = _chunkLFTO5QAPcjs.safeMax.call(void 0, gaps);
|
|
8890
8938
|
const avgLen = items.reduce((s, i) => s + i.text.length, 0) / items.length;
|
|
8891
8939
|
if (items.length >= 4 && maxGap < 40 && avgLen < 5) return true;
|
|
8892
|
-
const minGap =
|
|
8940
|
+
const minGap = _chunkLFTO5QAPcjs.safeMin.call(void 0, gaps);
|
|
8893
8941
|
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)));
|
|
8894
8942
|
}
|
|
8895
8943
|
function detectColumns(yLines) {
|
|
8896
8944
|
const allItems = yLines.flat();
|
|
8897
8945
|
if (allItems.length === 0) return null;
|
|
8898
|
-
const pageWidth =
|
|
8946
|
+
const pageWidth = _chunkLFTO5QAPcjs.safeMax.call(void 0, allItems.map((i) => i.x + i.w)) - _chunkLFTO5QAPcjs.safeMin.call(void 0, allItems.map((i) => i.x));
|
|
8899
8947
|
if (pageWidth < 100) return null;
|
|
8900
8948
|
let bigoLineIdx = -1;
|
|
8901
8949
|
for (let i = 0; i < yLines.length; i++) {
|
|
@@ -9120,7 +9168,7 @@ var UNDER_BOX_PAIR_MAX_EM = 2.2;
|
|
|
9120
9168
|
var UNDER_BOX_PAIR_OVERLAP = 0.8;
|
|
9121
9169
|
function markUnderlineItems(items, horizontals, verticals, nonRules) {
|
|
9122
9170
|
const underlines = [];
|
|
9123
|
-
if (_optionalChain([nonRules, 'optionalAccess',
|
|
9171
|
+
if (_optionalChain([nonRules, 'optionalAccess', _391 => _391.size])) horizontals = horizontals.filter((line) => !nonRules.has(line));
|
|
9124
9172
|
if (items.length === 0 || horizontals.length === 0) return underlines;
|
|
9125
9173
|
const tightOwners = /* @__PURE__ */ new Map();
|
|
9126
9174
|
const tightlyOwned = (line) => {
|
|
@@ -9226,7 +9274,7 @@ function hasBoxTopPair(line, maxH, horizontals, cellItems) {
|
|
|
9226
9274
|
if (ow <= 0) continue;
|
|
9227
9275
|
const overlap2 = Math.min(line.x2, o.x2) - Math.max(line.x1, o.x1);
|
|
9228
9276
|
if (overlap2 / Math.max(w, ow) < UNDER_BOX_PAIR_OVERLAP) continue;
|
|
9229
|
-
const covered = _nullishCoalesce(_optionalChain([cellItems, 'optionalAccess',
|
|
9277
|
+
const covered = _nullishCoalesce(_optionalChain([cellItems, 'optionalAccess', _392 => _392.reduce, 'call', _393 => _393((sum, item) => {
|
|
9230
9278
|
const below = item.y - o.y1;
|
|
9231
9279
|
if (below < 0.5 || below > 3 || !item.text.trim()) return sum;
|
|
9232
9280
|
return sum + Math.max(0, Math.min(o.x2, item.x + item.w) - Math.max(o.x1, item.x));
|
|
@@ -9293,13 +9341,13 @@ function partTex(group) {
|
|
|
9293
9341
|
const base = Math.min(...g.filter((i) => i.fontSize >= size * SCRIPT_SIZE_RATIO).map((i) => i.y));
|
|
9294
9342
|
let s = "", run = "";
|
|
9295
9343
|
const flush = () => {
|
|
9296
|
-
if (run) s +=
|
|
9344
|
+
if (run) s += _chunkOW2XKTQAcjs.toTex.call(void 0, run);
|
|
9297
9345
|
run = "";
|
|
9298
9346
|
};
|
|
9299
9347
|
g.forEach((it, k) => {
|
|
9300
9348
|
if (it.fontSize < size * SCRIPT_SIZE_RATIO && it.y - base >= size * SCRIPT_RISE_EM) {
|
|
9301
9349
|
flush();
|
|
9302
|
-
s += `^{${
|
|
9350
|
+
s += `^{${_chunkOW2XKTQAcjs.toTex.call(void 0, it.text)}}`;
|
|
9303
9351
|
return;
|
|
9304
9352
|
}
|
|
9305
9353
|
if (k && it.x - (g[k - 1].x + g[k - 1].w) > spaceGapThreshold(it.fontSize)) run += " ";
|
|
@@ -9472,12 +9520,12 @@ function rebuildUnitLine(items, grid) {
|
|
|
9472
9520
|
function prependUnitRow(cells, cols, line, usedItems) {
|
|
9473
9521
|
const text = cleanCellText(line.map((item) => item.text).join(""));
|
|
9474
9522
|
cells.unshift(Array.from({ length: cols }, (_, c) => ({ text: c === 0 ? text : "", colSpan: c === 0 ? cols : 1, rowSpan: 1 })));
|
|
9475
|
-
for (const cell of cells[0])
|
|
9523
|
+
for (const cell of cells[0]) _chunkOW2XKTQAcjs.CELL_EDGES.set(cell, NO_EDGES);
|
|
9476
9524
|
for (const item of line) usedItems.add(item);
|
|
9477
9525
|
}
|
|
9478
9526
|
function attachUnitRow(items, grid, cells, cols, usedItems) {
|
|
9479
9527
|
const all = cells.flat();
|
|
9480
|
-
if (all.filter((c) => c.text.trim()).length * 2 < all.length || UNIT.test(_nullishCoalesce(_optionalChain([cells, 'access',
|
|
9528
|
+
if (all.filter((c) => c.text.trim()).length * 2 < all.length || UNIT.test(_nullishCoalesce(_optionalChain([cells, 'access', _394 => _394[0], 'optionalAccess', _395 => _395[0], 'optionalAccess', _396 => _396.text]), () => ( "")))) return false;
|
|
9481
9529
|
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);
|
|
9482
9530
|
let nearest = Infinity;
|
|
9483
9531
|
for (const it of above) nearest = Math.min(nearest, it.y);
|
|
@@ -9512,7 +9560,7 @@ function closeShadedTableEdges(clipGrids, horizontals, verticals, fillRects) {
|
|
|
9512
9560
|
let hs = horizontals, vs = verticals;
|
|
9513
9561
|
const restored = [];
|
|
9514
9562
|
for (const grid of clipGrids) {
|
|
9515
|
-
if (grid.clipParent || grid.rowYs.length !== 2 || grid.colXs.length < 3 || !_optionalChain([grid, 'access',
|
|
9563
|
+
if (grid.clipParent || grid.rowYs.length !== 2 || grid.colXs.length < 3 || !_optionalChain([grid, 'access', _397 => _397.cells, 'optionalAccess', _398 => _398.length]) || grid.cells.some((c) => c.filler || c.rowSpan !== 1 || c.colSpan !== 1)) continue;
|
|
9516
9564
|
const { x1, x2, y1: mid, y2: top } = grid.bbox;
|
|
9517
9565
|
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;
|
|
9518
9566
|
const topRule = hs.find((h) => near2(h.y1, top) && near2(h.x1, x1) && near2(h.x2, x2));
|
|
@@ -9976,7 +10024,7 @@ function takeFrameSpanningText(items, cutX, pageNum, lex) {
|
|
|
9976
10024
|
const rows = groupByY([...items].sort((a, b) => b.y - a.y || a.x - b.x)).map((line) => {
|
|
9977
10025
|
const runs = [];
|
|
9978
10026
|
for (const item of [...line].sort((a, b) => a.x - b.x)) {
|
|
9979
|
-
const run = runs[runs.length - 1], prev = _optionalChain([run, 'optionalAccess',
|
|
10027
|
+
const run = runs[runs.length - 1], prev = _optionalChain([run, 'optionalAccess', _399 => _399[run.length - 1]]);
|
|
9980
10028
|
if (prev && item.x - (prev.x + prev.w) <= Math.max(prev.fontSize, item.fontSize) * 0.6) run.push(item);
|
|
9981
10029
|
else runs.push([item]);
|
|
9982
10030
|
}
|
|
@@ -10020,7 +10068,7 @@ function groupFrameParagraphUnits(units, frames) {
|
|
|
10020
10068
|
for (const unit of units) for (const block of unit) source.set(block, unit);
|
|
10021
10069
|
const members = /* @__PURE__ */ new Map(), emitted = /* @__PURE__ */ new Set();
|
|
10022
10070
|
for (const frame of frames) {
|
|
10023
|
-
if (frame.length < 2 || frame.some((block) => block.type !== "paragraph" || _optionalChain([source, 'access',
|
|
10071
|
+
if (frame.length < 2 || frame.some((block) => block.type !== "paragraph" || _optionalChain([source, 'access', _400 => _400.get, 'call', _401 => _401(block), 'optionalAccess', _402 => _402.length]) !== 1)) continue;
|
|
10024
10072
|
for (const block of frame) members.set(block, frame);
|
|
10025
10073
|
}
|
|
10026
10074
|
const out = [];
|
|
@@ -10033,7 +10081,7 @@ function groupFrameParagraphUnits(units, frames) {
|
|
|
10033
10081
|
}
|
|
10034
10082
|
}
|
|
10035
10083
|
for (const unit of out) {
|
|
10036
|
-
if (unit.length < 2 || _optionalChain([FRAME_READING_UNITS, 'access',
|
|
10084
|
+
if (unit.length < 2 || _optionalChain([FRAME_READING_UNITS, 'access', _403 => _403.get, 'call', _404 => _404(unit[0]), 'optionalAccess', _405 => _405.blocks]) === unit) continue;
|
|
10037
10085
|
const bs = unit.map((b) => b.bbox).filter((b) => !!b);
|
|
10038
10086
|
if (bs.length !== unit.length) continue;
|
|
10039
10087
|
const x = Math.min(...bs.map((b) => b.x)), y = Math.min(...bs.map((b) => b.y));
|
|
@@ -10050,14 +10098,14 @@ function groupFrameParagraphUnits(units, frames) {
|
|
|
10050
10098
|
function recordFrameTitle(table, source, pageNum) {
|
|
10051
10099
|
if (!CLIP_TABLES.has(table) || table.rows !== 1 || table.cols !== 3 || source.length < 2) return;
|
|
10052
10100
|
const cells = table.cells[0];
|
|
10053
|
-
if (cells.length !== 3 || cells.some((c) => c.colSpan !== 1 || c.rowSpan !== 1 || _optionalChain([c, 'access',
|
|
10101
|
+
if (cells.length !== 3 || cells.some((c) => c.colSpan !== 1 || c.rowSpan !== 1 || _optionalChain([c, 'access', _406 => _406.blocks, 'optionalAccess', _407 => _407.length]) || c.text.includes("\n"))) return;
|
|
10054
10102
|
const [label, spacer, title] = cells;
|
|
10055
10103
|
if (!/^(?:붙임|별첨|첨부|부록)\s*\d{1,3}$/.test(label.text.trim()) || spacer.text.trim() || !title.text.trim()) return;
|
|
10056
10104
|
if (cells.some((c) => {
|
|
10057
|
-
const e =
|
|
10105
|
+
const e = _chunkOW2XKTQAcjs.CELL_EDGES.get(c);
|
|
10058
10106
|
return !e || e.t || e.b || e.l || e.r;
|
|
10059
10107
|
})) return;
|
|
10060
|
-
const xs = TABLE_COLXS.get(table), style = dominantStyle(source), fs = _nullishCoalesce(_optionalChain([style, 'optionalAccess',
|
|
10108
|
+
const xs = TABLE_COLXS.get(table), style = dominantStyle(source), fs = _nullishCoalesce(_optionalChain([style, 'optionalAccess', _408 => _408.fontSize]), () => ( 0));
|
|
10061
10109
|
if (!xs || xs.length !== 4 || fs <= 0) return;
|
|
10062
10110
|
const width = xs[3] - xs[0], gap = xs[2] - xs[1];
|
|
10063
10111
|
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;
|
|
@@ -10121,7 +10169,7 @@ function extendNestedShadedHeaders(clipGrids, lineGrids, horizontals, verticals,
|
|
|
10121
10169
|
const extended = [];
|
|
10122
10170
|
for (let i = 0; i < clipGrids.length; i++) {
|
|
10123
10171
|
const c = clipGrids[i], parent = c.clipParent;
|
|
10124
|
-
if (!parent || c.rowYs.length !== 2 || c.colXs.length < 3 || !_optionalChain([c, 'access',
|
|
10172
|
+
if (!parent || c.rowYs.length !== 2 || c.colXs.length < 3 || !_optionalChain([c, 'access', _409 => _409.cells, 'optionalAccess', _410 => _410.length]) || c.cells.some((cell) => cell.filler || cell.rowSpan !== 1 || cell.colSpan !== 1)) continue;
|
|
10125
10173
|
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;
|
|
10126
10174
|
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;
|
|
10127
10175
|
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)));
|
|
@@ -10144,7 +10192,7 @@ function attachSideTabBlocks(tab, body, pageNum) {
|
|
|
10144
10192
|
bbox: computeBBox(items, pageNum),
|
|
10145
10193
|
style: dominantStyle(items)
|
|
10146
10194
|
});
|
|
10147
|
-
const prefix = ordered.filter((g) => !_optionalChain([caps, 'optionalAccess',
|
|
10195
|
+
const prefix = ordered.filter((g) => !_optionalChain([caps, 'optionalAccess', _411 => _411.has, 'call', _412 => _412(g)])).map((g) => ({
|
|
10148
10196
|
type: "paragraph",
|
|
10149
10197
|
text: g.text.trim(),
|
|
10150
10198
|
pageNumber: pageNum,
|
|
@@ -10153,7 +10201,7 @@ function attachSideTabBlocks(tab, body, pageNum) {
|
|
|
10153
10201
|
}));
|
|
10154
10202
|
const groups = /* @__PURE__ */ new Map();
|
|
10155
10203
|
for (const g of ordered) {
|
|
10156
|
-
const cap = _optionalChain([caps, 'optionalAccess',
|
|
10204
|
+
const cap = _optionalChain([caps, 'optionalAccess', _413 => _413.get, 'call', _414 => _414(g)]);
|
|
10157
10205
|
if (cap) groups.set(cap, [..._nullishCoalesce(groups.get(cap), () => ( [])), g]);
|
|
10158
10206
|
}
|
|
10159
10207
|
for (const [cap, glyphs] of groups) {
|
|
@@ -10185,7 +10233,7 @@ function extractPageBlocksWithLines(items, pageNum, opList, pageWidth, pageHeigh
|
|
|
10185
10233
|
let prev = null;
|
|
10186
10234
|
for (const line of streamLines(items)) {
|
|
10187
10235
|
lex.addLine(mergeLineSimple(line));
|
|
10188
|
-
const fs = _nullishCoalesce(_optionalChain([dominantStyle, 'call',
|
|
10236
|
+
const fs = _nullishCoalesce(_optionalChain([dominantStyle, 'call', _415 => _415(line), 'optionalAccess', _416 => _416.fontSize]), () => ( 0));
|
|
10189
10237
|
const left = Math.min(...line.map((i) => i.x)), right = Math.max(...line.map((i) => i.x + i.w));
|
|
10190
10238
|
const y = line.reduce((n, i) => n + i.y, 0) / line.length;
|
|
10191
10239
|
const wide = fs > 0 && right - left >= 12 * fs;
|
|
@@ -10199,7 +10247,7 @@ function extractPageBlocksWithLines(items, pageNum, opList, pageWidth, pageHeigh
|
|
|
10199
10247
|
const filled = fillBlanks(items, horizontals, verticals);
|
|
10200
10248
|
items = filled.items;
|
|
10201
10249
|
horizontals = filled.horizontals;
|
|
10202
|
-
const prevPage = _optionalChain([carry, 'optionalAccess',
|
|
10250
|
+
const prevPage = _optionalChain([carry, 'optionalAccess', _417 => _417.page]) === pageNum - 1 ? carry.clip : void 0;
|
|
10203
10251
|
const images = extractImageRegions(opList.fnArray, opList.argsArray);
|
|
10204
10252
|
const clipRects = images.length ? withoutImageOnlyClips(extracted.clipRects, images) : extracted.clipRects;
|
|
10205
10253
|
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 };
|
|
@@ -10497,7 +10545,7 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
|
|
|
10497
10545
|
const nested = pendingNested.length ? takePendingNested(pendingNested, cell.bbox, !!grid.cells) : [];
|
|
10498
10546
|
const lone = nested.length === 1 && !cellItems.length ? nested[0] : null;
|
|
10499
10547
|
const cw = cell.bbox.x2 - cell.bbox.x1;
|
|
10500
|
-
if (_optionalChain([lone, 'optionalAccess',
|
|
10548
|
+
if (_optionalChain([lone, 'optionalAccess', _418 => _418.table]) && lone.bbox && lone.table.rows === 1 && lone.table.cols === 1 && CLIP_TABLES.has(lone.table) && !_optionalChain([lone, 'access', _419 => _419.table, 'access', _420 => _420.cells, 'access', _421 => _421[0], 'access', _422 => _422[0], 'access', _423 => _423.blocks, 'optionalAccess', _424 => _424.some, 'call', _425 => _425((b2) => b2.type === "table")]) && lone.bbox.width >= cw * 0.9 && /^[^\n]{1,30}$/.test(lone.table.cells[0][0].text.trim())) {
|
|
10501
10549
|
irGrid[cell.row][cell.col] = { text: lone.table.cells[0][0].text, colSpan: cell.colSpan, rowSpan: cell.rowSpan };
|
|
10502
10550
|
takeClipCellEdges(cell, irGrid[cell.row][cell.col]);
|
|
10503
10551
|
continue;
|
|
@@ -10547,10 +10595,10 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
|
|
|
10547
10595
|
const ls = irGrid.slice(1).flat().flatMap((c) => c.text.split("\n")).map((t) => t.trim()).filter(Boolean);
|
|
10548
10596
|
const numericLine = (t) => {
|
|
10549
10597
|
const cs = t.replace(/\s+/g, "");
|
|
10550
|
-
return cs.length > 0 && (_nullishCoalesce(_optionalChain([cs, 'access',
|
|
10598
|
+
return cs.length > 0 && (_nullishCoalesce(_optionalChain([cs, 'access', _426 => _426.match, 'call', _427 => _427(/[\d.,%()+\-−–—△▲▽▼]/g), 'optionalAccess', _428 => _428.length]), () => ( 0))) >= cs.length * 0.85;
|
|
10551
10599
|
};
|
|
10552
10600
|
const labelValueLine = (t) => {
|
|
10553
|
-
const hangul = _nullishCoalesce(_optionalChain([t, 'access',
|
|
10601
|
+
const hangul = _nullishCoalesce(_optionalChain([t, 'access', _429 => _429.match, 'call', _430 => _430(/[가-힣]/g), 'optionalAccess', _431 => _431.length]), () => ( 0));
|
|
10554
10602
|
return hangul > 0 && hangul <= 6 && /\d,\d{3}/.test(t) && numericLine(t.replace(/[가-힣()]/g, ""));
|
|
10555
10603
|
};
|
|
10556
10604
|
const bulletLine = (t) => /^\s*[○◦•□■▪]/.test(t) || /^\s*-\s*[^\d\s.,−-]/.test(t) && t.replace(/\s+/g, "").length > 7;
|
|
@@ -10560,14 +10608,14 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
|
|
|
10560
10608
|
const share = ls.filter((t) => numericLine(t) || lvLines.has(t)).length / ls.length;
|
|
10561
10609
|
if (share >= 0.5) return true;
|
|
10562
10610
|
const colShares = Array.from({ length: numCols }, (_, c) => {
|
|
10563
|
-
const cl = irGrid.slice(1).flatMap((row) => (_nullishCoalesce(_optionalChain([row, 'access',
|
|
10611
|
+
const cl = irGrid.slice(1).flatMap((row) => (_nullishCoalesce(_optionalChain([row, 'access', _432 => _432[c], 'optionalAccess', _433 => _433.text]), () => ( ""))).split("\n")).map((t) => t.trim()).filter(Boolean);
|
|
10564
10612
|
return cl.length ? cl.filter(numericLine).length / cl.length : null;
|
|
10565
10613
|
}).filter((v) => v !== null);
|
|
10566
10614
|
return share >= 0.35 && colShares.some((v) => v >= 0.8) && colShares.every((v) => v >= 0.8 || v <= 0.2);
|
|
10567
10615
|
})();
|
|
10568
10616
|
const layoutProse = irGrid.some((row) => row.some((c) => c.colSpan >= numCols - 1 && c.text.length > 60));
|
|
10569
10617
|
const maxRows = numericBody ? layoutProse ? OCR_NUMERIC_MAX_ROWS_FRAMED : OCR_NUMERIC_MAX_ROWS : 5;
|
|
10570
|
-
const proseLine = (t) => (_nullishCoalesce(_optionalChain([t, 'access',
|
|
10618
|
+
const proseLine = (t) => (_nullishCoalesce(_optionalChain([t, 'access', _434 => _434.match, 'call', _435 => _435(/[가-힣]/g), 'optionalAccess', _436 => _436.length]), () => ( 0))) > 6 && !/^[-−]?[\d,.]+$/.test(t.replace(/\s+/g, ""));
|
|
10571
10619
|
const proseCols = numRows === 2 ? (_nullishCoalesce(irGrid[1], () => ( []))).filter((c) => {
|
|
10572
10620
|
const ls = c.text.split("\n").map((t) => t.trim()).filter(Boolean);
|
|
10573
10621
|
return ls.length >= 3 && ls.filter(proseLine).length >= ls.length * 0.6;
|
|
@@ -10588,8 +10636,8 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
|
|
|
10588
10636
|
finalGrid = rebuilt.map((row, i) => {
|
|
10589
10637
|
const o = kept.get(i);
|
|
10590
10638
|
return row.map((rawText, c) => {
|
|
10591
|
-
const src = o === void 0 ? void 0 : _optionalChain([irGrid, 'access',
|
|
10592
|
-
return { text: cleanCellText(rawText), colSpan: _nullishCoalesce(_optionalChain([src, 'optionalAccess',
|
|
10639
|
+
const src = o === void 0 ? void 0 : _optionalChain([irGrid, 'access', _437 => _437[o], 'optionalAccess', _438 => _438[c]]);
|
|
10640
|
+
return { text: cleanCellText(rawText), colSpan: _nullishCoalesce(_optionalChain([src, 'optionalAccess', _439 => _439.colSpan]), () => ( 1)), rowSpan: src ? spanRows(o, src.rowSpan) : 1 };
|
|
10593
10641
|
});
|
|
10594
10642
|
});
|
|
10595
10643
|
finalRows = finalGrid.length;
|
|
@@ -10609,14 +10657,14 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
|
|
|
10609
10657
|
if (!assignedItems.has(textItems[ti]) && !inExpanded(textItems[ti])) usedItems.delete(owners[ti]);
|
|
10610
10658
|
}
|
|
10611
10659
|
}
|
|
10612
|
-
if (unitLine.length > 0 && rebuiltUsed && !/^\s*\(\s*단위\s*[::]/.test(_nullishCoalesce(_optionalChain([finalGrid, 'access',
|
|
10660
|
+
if (unitLine.length > 0 && rebuiltUsed && !/^\s*\(\s*단위\s*[::]/.test(_nullishCoalesce(_optionalChain([finalGrid, 'access', _440 => _440[0], 'optionalAccess', _441 => _441[0], 'optionalAccess', _442 => _442.text]), () => ( "")))) {
|
|
10613
10661
|
prependUnitRow(finalGrid, numCols, unitLine, usedItems);
|
|
10614
10662
|
finalRows++;
|
|
10615
10663
|
}
|
|
10616
10664
|
if (!rebuiltUsed && attachUnitRow(items, grid, finalGrid, numCols, usedItems)) finalRows++;
|
|
10617
10665
|
let semanticOneColumn = false;
|
|
10618
10666
|
if (!grid.cells && !nestedAttached && numCols === 1 && numGridRows >= 2) {
|
|
10619
|
-
const populatedRows = finalGrid.filter((row) => _optionalChain([row, 'access',
|
|
10667
|
+
const populatedRows = finalGrid.filter((row) => _optionalChain([row, 'access', _443 => _443[0], 'optionalAccess', _444 => _444.text, 'access', _445 => _445.trim, 'call', _446 => _446()]));
|
|
10620
10668
|
if (populatedRows.length >= 4) {
|
|
10621
10669
|
const fontSizes = tableItems.map((item) => item.fontSize).filter((size) => size > 0).sort((a, b) => a - b);
|
|
10622
10670
|
const medianFont = _nullishCoalesce(fontSizes[Math.floor(fontSizes.length / 2)], () => ( 0));
|
|
@@ -10714,7 +10762,7 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
|
|
|
10714
10762
|
height: grid.bbox.y2 - grid.bbox.y1
|
|
10715
10763
|
};
|
|
10716
10764
|
if (numRows === 1 && numCols === 1 && gridW < pageWidth * 0.35) {
|
|
10717
|
-
const prose = _nullishCoalesce(_optionalChain([finalGrid, 'access',
|
|
10765
|
+
const prose = _nullishCoalesce(_optionalChain([finalGrid, 'access', _447 => _447[0], 'optionalAccess', _448 => _448[0], 'optionalAccess', _449 => _449.text]), () => ( ""));
|
|
10718
10766
|
const besideLines = (side) => new Set(side.map((it) => Math.round(it.y / 3))).size;
|
|
10719
10767
|
const rightLines = items.filter((it) => it.x >= grid.bbox.x2 + 3 && it.y >= grid.bbox.y1 && it.y <= grid.bbox.y2);
|
|
10720
10768
|
const leftLines = items.filter((it) => it.x + it.w <= grid.bbox.x1 - 3 && it.y >= grid.bbox.y1 && it.y <= grid.bbox.y2);
|
|
@@ -10733,8 +10781,8 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
|
|
|
10733
10781
|
}
|
|
10734
10782
|
}
|
|
10735
10783
|
if (!grid.cells && !nestedAttached && shouldDemoteTable(irTable)) {
|
|
10736
|
-
const paragraphs = numRows === 1 && numCols === 1 ? _optionalChain([irTable, 'access',
|
|
10737
|
-
if (_optionalChain([paragraphs, 'optionalAccess',
|
|
10784
|
+
const paragraphs = numRows === 1 && numCols === 1 ? _optionalChain([irTable, 'access', _450 => _450.cells, 'access', _451 => _451[0], 'optionalAccess', _452 => _452[0], 'optionalAccess', _453 => _453.blocks]) : void 0;
|
|
10785
|
+
if (_optionalChain([paragraphs, 'optionalAccess', _454 => _454.length])) {
|
|
10738
10786
|
blocks.push(...paragraphs);
|
|
10739
10787
|
frameParagraphUnits.push(paragraphs);
|
|
10740
10788
|
recordFrameReadingUnit(paragraphs, tableBbox);
|
|
@@ -10781,7 +10829,7 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
|
|
|
10781
10829
|
const clusterResults = (proseColumns ? [] : detectClusterTables(clusterItems, pageNum, void 0, lex)).filter((cr) => {
|
|
10782
10830
|
const b = cr.bbox;
|
|
10783
10831
|
const overlapX = (x) => Math.min(x.x + x.width, b.x + b.width) - Math.max(x.x, b.x);
|
|
10784
|
-
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',
|
|
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', _455 => _455.text, 'optionalAccess', _456 => _456.match, 'call', _457 => _457(/\p{L}/gu), 'optionalAccess', _458 => _458.length]), () => ( 0))) >= 10 && overlapX(x.bbox) >= 0.8 * b.width : x.type === "table" && !ocrPage && _optionalChain([x, 'access', _459 => _459.table, 'optionalAccess', _460 => _460.cols]) === cr.table.cols && overlapX(x.bbox) >= 0.5 * Math.min(x.bbox.width, b.width)));
|
|
10785
10833
|
});
|
|
10786
10834
|
if (clusterResults.length > 0) {
|
|
10787
10835
|
const ciToIdx = /* @__PURE__ */ new Map();
|
|
@@ -10818,13 +10866,13 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
|
|
|
10818
10866
|
groupSizes.push(1);
|
|
10819
10867
|
}
|
|
10820
10868
|
const allY = remaining.map((i) => i.y);
|
|
10821
|
-
const pageH =
|
|
10869
|
+
const pageH = _chunkLFTO5QAPcjs.safeMax.call(void 0, allY) - _chunkLFTO5QAPcjs.safeMin.call(void 0, allY);
|
|
10822
10870
|
const gapThreshold = Math.max(15, pageH * 0.03);
|
|
10823
10871
|
const sides = frameColumnTextBands(remaining, spanning, gx);
|
|
10824
10872
|
const textBlocks = [];
|
|
10825
10873
|
for (const side of sides) {
|
|
10826
10874
|
if (side.length === 0) continue;
|
|
10827
|
-
for (const group of xyCutOrder(side, gapThreshold)) {
|
|
10875
|
+
for (const group of xyCutOrder(side, gapThreshold, 0, void 0, 0, lex)) {
|
|
10828
10876
|
if (group.length === 0) continue;
|
|
10829
10877
|
const groupBlocks = extractPageBlocksFallback(group, pageNum, false, true, lex, [], chartBandGap(group, gapThreshold, charts));
|
|
10830
10878
|
for (const b of groupBlocks) textBlocks.push(b);
|
|
@@ -10834,9 +10882,9 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
|
|
|
10834
10882
|
finalTextBlocks.push(...detectListBlocks(textBlocks));
|
|
10835
10883
|
} else {
|
|
10836
10884
|
const allY = remaining.map((i) => i.y);
|
|
10837
|
-
const pageH =
|
|
10885
|
+
const pageH = _chunkLFTO5QAPcjs.safeMax.call(void 0, allY) - _chunkLFTO5QAPcjs.safeMin.call(void 0, allY);
|
|
10838
10886
|
const gapThreshold = Math.max(15, pageH * 0.03);
|
|
10839
|
-
const groups = xyCutOrder(remaining, gapThreshold);
|
|
10887
|
+
const groups = xyCutOrder(remaining, gapThreshold, 0, void 0, 0, lex);
|
|
10840
10888
|
const textBlocks = [];
|
|
10841
10889
|
for (const group of groups) {
|
|
10842
10890
|
if (group.length === 0) continue;
|
|
@@ -11196,9 +11244,9 @@ function extractPageBlocksFallback(items, pageNum, fullPage = false, detectTable
|
|
|
11196
11244
|
blocks.push(...columnTextToBlocks(tableText, pageNum, bbox, dominantStyle(items)));
|
|
11197
11245
|
} else {
|
|
11198
11246
|
const allY = items.map((i) => i.y);
|
|
11199
|
-
const pageHeight =
|
|
11247
|
+
const pageHeight = _chunkLFTO5QAPcjs.safeMax.call(void 0, allY) - _chunkLFTO5QAPcjs.safeMin.call(void 0, allY);
|
|
11200
11248
|
const gapThreshold = Math.max(15, pageHeight * 0.03);
|
|
11201
|
-
const orderedGroups = proseCutX !== null ? splitTwoColumnProse(items, proseCutX) : xyCutOrder(items, gapThreshold, 0, void 0, minGap);
|
|
11249
|
+
const orderedGroups = proseCutX !== null ? splitTwoColumnProse(items, proseCutX) : xyCutOrder(items, gapThreshold, 0, void 0, minGap, lex);
|
|
11202
11250
|
for (const group of orderedGroups) {
|
|
11203
11251
|
if (group.length === 0) continue;
|
|
11204
11252
|
const yLines = mergeSuperscriptLines(groupByY(group));
|
|
@@ -11253,19 +11301,19 @@ function mergeOcrImageRegions(blocks, page, regions, ocrBlocks) {
|
|
|
11253
11301
|
const overlapH = Math.max(0, Math.min(b.y + b.height, region.y2) - Math.max(b.y, region.y1));
|
|
11254
11302
|
return overlapW * overlapH >= b.width * b.height * 0.8;
|
|
11255
11303
|
});
|
|
11256
|
-
const labels = candidates.filter((b) => b.type === "paragraph" && b.bbox.height <= 24 && (_nullishCoalesce(_optionalChain([b, 'access',
|
|
11304
|
+
const labels = candidates.filter((b) => b.type === "paragraph" && b.bbox.height <= 24 && (_nullishCoalesce(_optionalChain([b, 'access', _461 => _461.text, 'optionalAccess', _462 => _462.match, 'call', _463 => _463(/[\p{L}\p{N}]/gu), 'optionalAccess', _464 => _464.length]), () => ( 0))) >= 2);
|
|
11257
11305
|
const axisFragments = rotatedAxisFragments(candidates);
|
|
11258
11306
|
const accepted = candidates.filter((b) => {
|
|
11259
|
-
if (b.type === "paragraph") return (_nullishCoalesce(_optionalChain([b, 'access',
|
|
11307
|
+
if (b.type === "paragraph") return (_nullishCoalesce(_optionalChain([b, 'access', _465 => _465.text, 'optionalAccess', _466 => _466.match, 'call', _467 => _467(/[\p{L}\p{N}]/gu), 'optionalAccess', _468 => _468.length]), () => ( 0))) >= 2 || !axisFragments.has(b) && (supportedDiagramLabel(b, labels, region) || axisTick(b, candidates));
|
|
11260
11308
|
const t = b.table;
|
|
11261
11309
|
if (b.type !== "table" || !t || UNRULED_REGION_TABLES.has(b)) return false;
|
|
11262
11310
|
const lone = t.cells.filter((row) => row.filter((c) => c.text.trim()).length === 1 && row.some((c) => c.colSpan === t.cols)).length;
|
|
11263
11311
|
if (t.rows >= 2 && lone * 2 >= t.rows) return false;
|
|
11264
11312
|
if (t.rows === 1 && t.cols === 1) {
|
|
11265
|
-
const text = _nullishCoalesce(_optionalChain([t, 'access',
|
|
11266
|
-
return (_nullishCoalesce(_optionalChain([text, 'access',
|
|
11313
|
+
const text = _nullishCoalesce(_optionalChain([t, 'access', _469 => _469.cells, 'access', _470 => _470[0], 'optionalAccess', _471 => _471[0], 'optionalAccess', _472 => _472.text]), () => ( ""));
|
|
11314
|
+
return (_nullishCoalesce(_optionalChain([text, 'access', _473 => _473.match, 'call', _474 => _474(/\n/g), 'optionalAccess', _475 => _475.length]), () => ( 0))) >= 5 && (_nullishCoalesce(_optionalChain([text, 'access', _476 => _476.match, 'call', _477 => _477(/\d/g), 'optionalAccess', _478 => _478.length]), () => ( 0))) >= text.length * 0.25;
|
|
11267
11315
|
}
|
|
11268
|
-
const headerLabels = _nullishCoalesce(_optionalChain([t, 'access',
|
|
11316
|
+
const headerLabels = _nullishCoalesce(_optionalChain([t, 'access', _479 => _479.cells, 'access', _480 => _480[0], 'optionalAccess', _481 => _481.filter, 'call', _482 => _482((c) => c.text.replace(/[^A-Za-z가-힣]/g, "").length >= 2), 'access', _483 => _483.length]), () => ( 0));
|
|
11269
11317
|
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);
|
|
11270
11318
|
});
|
|
11271
11319
|
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, () => ( "")))) : []);
|
|
@@ -11282,14 +11330,14 @@ function mergeOcrImageRegions(blocks, page, regions, ocrBlocks) {
|
|
|
11282
11330
|
for (const block of selected) {
|
|
11283
11331
|
if (seen2.has(block)) continue;
|
|
11284
11332
|
const frame = FRAME_READING_UNITS.get(block);
|
|
11285
|
-
const source = _optionalChain([frame, 'optionalAccess',
|
|
11333
|
+
const source = _optionalChain([frame, 'optionalAccess', _484 => _484.blocks, 'access', _485 => _485.every, 'call', _486 => _486((member) => selectedSet.has(member))]) ? frame.blocks : [block];
|
|
11286
11334
|
source.forEach((member) => seen2.add(member));
|
|
11287
11335
|
const available = source.filter((member) => !hasOriginal(member));
|
|
11288
11336
|
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 }));
|
|
11289
11337
|
for (const unit of units) {
|
|
11290
11338
|
const b = unit.bbox;
|
|
11291
11339
|
const index = blocks.findIndex((existing) => {
|
|
11292
|
-
const e = _nullishCoalesce(_optionalChain([FRAME_READING_UNITS, 'access',
|
|
11340
|
+
const e = _nullishCoalesce(_optionalChain([FRAME_READING_UNITS, 'access', _487 => _487.get, 'call', _488 => _488(existing), 'optionalAccess', _489 => _489.bbox]), () => ( existing.bbox));
|
|
11293
11341
|
if (existing.pageNumber !== page || !e) return false;
|
|
11294
11342
|
const beside = e.y < region.y2 && e.y + e.height > region.y1 && e.x >= region.x2 - 1;
|
|
11295
11343
|
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;
|
|
@@ -11307,16 +11355,16 @@ function mergeOcrImageRegions(blocks, page, regions, ocrBlocks) {
|
|
|
11307
11355
|
}
|
|
11308
11356
|
function axisTick(block, candidates) {
|
|
11309
11357
|
const b = block.bbox;
|
|
11310
|
-
if (!/^\d$/u.test(_nullishCoalesce(_optionalChain([block, 'access',
|
|
11311
|
-
const numeric = candidates.filter((o) => o !== block && o.type === "paragraph" && o.bbox && /^[\d\s.,%+−-]+$/u.test(_nullishCoalesce(_optionalChain([o, 'access',
|
|
11358
|
+
if (!/^\d$/u.test(_nullishCoalesce(_optionalChain([block, 'access', _490 => _490.text, 'optionalAccess', _491 => _491.trim, 'call', _492 => _492()]), () => ( "")))) return false;
|
|
11359
|
+
const numeric = candidates.filter((o) => o !== block && o.type === "paragraph" && o.bbox && /^[\d\s.,%+−-]+$/u.test(_nullishCoalesce(_optionalChain([o, 'access', _493 => _493.text, 'optionalAccess', _494 => _494.trim, 'call', _495 => _495()]), () => ( ""))) && /\d/u.test(_nullishCoalesce(o.text, () => ( ""))) && Math.max(o.bbox.height, b.height) <= Math.min(o.bbox.height, b.height) * 2);
|
|
11312
11360
|
const cy = b.y + b.height / 2, right = b.x + b.width;
|
|
11313
11361
|
const row = numeric.filter((o) => Math.abs(o.bbox.y + o.bbox.height / 2 - cy) <= Math.min(o.bbox.height, b.height) * 0.35);
|
|
11314
11362
|
const column = numeric.filter((o) => Math.abs(o.bbox.x + o.bbox.width - right) <= Math.max(o.bbox.height, b.height) * 0.5);
|
|
11315
11363
|
return row.length >= 2 || column.length >= 2;
|
|
11316
11364
|
}
|
|
11317
11365
|
function supportedDiagramLabel(block, labels, region) {
|
|
11318
|
-
const b = block.bbox, text = _nullishCoalesce(_optionalChain([block, 'access',
|
|
11319
|
-
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',
|
|
11366
|
+
const b = block.bbox, text = _nullishCoalesce(_optionalChain([block, 'access', _496 => _496.text, 'optionalAccess', _497 => _497.trim, 'call', _498 => _498()]), () => ( ""));
|
|
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', _499 => _499.text, 'optionalAccess', _500 => _500.match, 'call', _501 => _501(/\p{N}/gu), 'optionalAccess', _502 => _502.length]), () => ( 0))) >= 2).length < 2) return false;
|
|
11320
11368
|
let above = false, below = false;
|
|
11321
11369
|
for (const label of labels) {
|
|
11322
11370
|
const a = label.bbox, em = Math.max(b.height, a.height);
|
|
@@ -11331,7 +11379,7 @@ function rotatedAxisFragments(candidates) {
|
|
|
11331
11379
|
const paragraphs = candidates.filter((b) => b.type === "paragraph" && b.bbox.height <= 24);
|
|
11332
11380
|
const axes = [];
|
|
11333
11381
|
for (const block of paragraphs) {
|
|
11334
|
-
const b = block.bbox, text = _nullishCoalesce(_optionalChain([block, 'access',
|
|
11382
|
+
const b = block.bbox, text = _nullishCoalesce(_optionalChain([block, 'access', _503 => _503.text, 'optionalAccess', _504 => _504.trim, 'call', _505 => _505()]), () => ( ""));
|
|
11335
11383
|
if (!/^[\d\s.,%+−-]+$/u.test(text) || !/\d/u.test(text) || b.width > b.height * 6) continue;
|
|
11336
11384
|
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);
|
|
11337
11385
|
if (axis) axis.push(block);
|
|
@@ -11348,8 +11396,8 @@ function rotatedAxisFragments(candidates) {
|
|
|
11348
11396
|
const em = Math.max(...axis.map((a) => a.bbox.height)), right = axis[0].bbox.x + axis[0].bbox.width;
|
|
11349
11397
|
if (top - bottom < em * 6) continue;
|
|
11350
11398
|
const left = paragraphs.filter((block) => {
|
|
11351
|
-
const b = block.bbox, text = _nullishCoalesce(_optionalChain([block, 'access',
|
|
11352
|
-
return /\p{Script=Latin}/u.test(text) && (_nullishCoalesce(_optionalChain([text, 'access',
|
|
11399
|
+
const b = block.bbox, text = _nullishCoalesce(_optionalChain([block, 'access', _506 => _506.text, 'optionalAccess', _507 => _507.trim, 'call', _508 => _508()]), () => ( ""));
|
|
11400
|
+
return /\p{Script=Latin}/u.test(text) && (_nullishCoalesce(_optionalChain([text, 'access', _509 => _509.match, 'call', _510 => _510(/[\p{L}\p{N}]/gu), 'optionalAccess', _511 => _511.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;
|
|
11353
11401
|
});
|
|
11354
11402
|
const stack = left.filter((a) => left.some((b) => {
|
|
11355
11403
|
if (a === b || !aligned(a, b)) return false;
|
|
@@ -11359,7 +11407,7 @@ function rotatedAxisFragments(candidates) {
|
|
|
11359
11407
|
if (stack.length < 2) continue;
|
|
11360
11408
|
for (const block of paragraphs) {
|
|
11361
11409
|
const b = block.bbox;
|
|
11362
|
-
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',
|
|
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', _512 => _512.text, 'optionalAccess', _513 => _513.trim, 'call', _514 => _514()]), () => ( ""))) && stack.some((s) => aligned(s, block))) fragments.add(block);
|
|
11363
11411
|
}
|
|
11364
11412
|
}
|
|
11365
11413
|
return fragments;
|
|
@@ -11466,4 +11514,4 @@ function rowParagraphs(block) {
|
|
|
11466
11514
|
|
|
11467
11515
|
|
|
11468
11516
|
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;
|
|
11469
|
-
//# sourceMappingURL=chunk-
|
|
11517
|
+
//# sourceMappingURL=chunk-H2VOH7X3.cjs.map
|