kordoc 4.24.71 → 4.24.73
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/{-F7GLIIGT.js → -CNXSUEGZ.js} +21 -21
- package/dist/{chunk-YPRIJDH6.js → chunk-2JA4FJJM.js} +2 -2
- package/dist/{chunk-M27VBFO6.js → chunk-32NWTEPA.js} +26 -6
- package/dist/chunk-32NWTEPA.js.map +1 -0
- package/dist/{chunk-SMEBVDM2.js → chunk-376JPHHC.js} +5 -5
- package/dist/{chunk-OW2XKTQA.cjs → chunk-5MBQW3KP.cjs} +8 -8
- package/dist/{chunk-OW2XKTQA.cjs.map → chunk-5MBQW3KP.cjs.map} +1 -1
- package/dist/{chunk-TYGZ6O2A.js → chunk-64QDDZO3.js} +11 -11
- package/dist/{chunk-RWU3Y5YK.js → chunk-A6YD5KUQ.js} +18 -16
- package/dist/chunk-A6YD5KUQ.js.map +1 -0
- package/dist/{chunk-OUHMNF2A.js → chunk-AAXWKG3C.js} +2 -2
- package/dist/{chunk-BHYBZSOC.js → chunk-ABNK5QI2.js} +2 -2
- package/dist/{chunk-KLUI4SAZ.js → chunk-AUGOG3KY.js} +2 -2
- package/dist/{chunk-O7PJFEOC.js → chunk-B5F7B5NL.js} +2 -2
- package/dist/{chunk-7KVDHXP2.js → chunk-BK55EX56.js} +4 -4
- package/dist/{chunk-T7MHZIFG.js → chunk-BUB3O7LS.js} +27 -7
- package/dist/chunk-BUB3O7LS.js.map +1 -0
- package/dist/{chunk-KGCJNPAI.js → chunk-BX23BOYN.js} +5 -5
- package/dist/{chunk-2CPEW6WC.js → chunk-CBGH37CU.js} +3 -3
- package/dist/{chunk-AUHQRRKM.js → chunk-CGOCVSWC.js} +3 -3
- package/dist/{chunk-MHXPW72E.js → chunk-E3G3JTXW.js} +2 -2
- package/dist/{chunk-NPBNJCXZ.js → chunk-G7QVY67O.js} +2 -2
- package/dist/{chunk-LFTO5QAP.cjs → chunk-HMHIF6QF.cjs} +2 -2
- package/dist/{chunk-LFTO5QAP.cjs.map → chunk-HMHIF6QF.cjs.map} +1 -1
- package/dist/{chunk-5WWGC5SG.js → chunk-IV6UP7MO.js} +2 -2
- package/dist/{chunk-HIYRMYAS.js → chunk-JDGPQVTX.js} +2 -2
- package/dist/{chunk-GRCIFCGC.js → chunk-JY4YMR6F.js} +2 -2
- package/dist/{chunk-2VBRCIPI.js → chunk-LMHDQWQM.js} +2 -2
- package/dist/{chunk-YISBYF7X.cjs → chunk-LUQH3SUU.cjs} +58 -58
- package/dist/{chunk-YISBYF7X.cjs.map → chunk-LUQH3SUU.cjs.map} +1 -1
- package/dist/{chunk-LNWURZ2Z.js → chunk-M4QZCXT4.js} +7 -7
- package/dist/{chunk-SK5AOGYK.cjs → chunk-MDDQRVA4.cjs} +104 -104
- package/dist/{chunk-SK5AOGYK.cjs.map → chunk-MDDQRVA4.cjs.map} +1 -1
- package/dist/{chunk-GFAWIBHG.js → chunk-MHLTXTP2.js} +10 -10
- package/dist/{chunk-IMT5TVVM.js → chunk-NQL7NCSE.js} +2 -2
- package/dist/{chunk-YTP7FPA5.cjs → chunk-O4TKUBCF.cjs} +3 -3
- package/dist/{chunk-YTP7FPA5.cjs.map → chunk-O4TKUBCF.cjs.map} +1 -1
- package/dist/{chunk-H2VOH7X3.cjs → chunk-OOD35TZR.cjs} +203 -183
- package/dist/chunk-OOD35TZR.cjs.map +1 -0
- package/dist/{chunk-2OF2YWIZ.js → chunk-P4FHTYVX.js} +2 -2
- package/dist/{chunk-BNP3WXTB.cjs → chunk-QLUFTCAE.cjs} +3 -3
- package/dist/{chunk-BNP3WXTB.cjs.map → chunk-QLUFTCAE.cjs.map} +1 -1
- package/dist/{chunk-WMA4GJHC.js → chunk-RJ26GRDB.js} +5 -5
- package/dist/{chunk-YJ2YVG6N.cjs → chunk-ROYGVYLL.cjs} +88 -88
- package/dist/{chunk-YJ2YVG6N.cjs.map → chunk-ROYGVYLL.cjs.map} +1 -1
- package/dist/{chunk-QK5KCWLE.js → chunk-S366ICXS.js} +2 -2
- package/dist/{chunk-EZNUMAAJ.js → chunk-S6K222FM.js} +2 -2
- package/dist/{chunk-ZPJZXTEG.js → chunk-TTIJTR5Z.js} +6 -6
- package/dist/{chunk-D4UFBXMT.js → chunk-UMVL776E.js} +2 -2
- package/dist/{chunk-YTDHH362.js → chunk-VMM5PVOA.js} +2 -2
- package/dist/{chunk-OJK4FLS5.js → chunk-VSWGRKTF.js} +3 -3
- package/dist/{chunk-6ZA4V4QS.js → chunk-X4HNVXJI.js} +2 -2
- package/dist/{chunk-RUUUGCXS.js → chunk-XSDVY4S6.js} +6 -6
- package/dist/{chunk-DSCT67WF.js → chunk-YLC25Z64.js} +3 -3
- package/dist/{chunk-UJQRIX4L.js → chunk-ZH322FQG.js} +2 -2
- package/dist/chunks-7XYOWREB.js +11 -0
- package/dist/cli.js +45 -45
- package/dist/{formula-3PJYUQMG.js → formula-7Q6CKLK2.js} +36 -6
- package/dist/formula-7Q6CKLK2.js.map +1 -0
- package/dist/{formula-RTPZD2IM.cjs → formula-AORKEC66.cjs} +41 -11
- package/dist/formula-AORKEC66.cjs.map +1 -0
- package/dist/{formula-UJF4RZ6W.js → formula-IP2SLKUY.js} +35 -5
- package/dist/formula-IP2SLKUY.js.map +1 -0
- package/dist/generator-BPEAWT2P.cjs +12 -0
- package/dist/{generator-INMUN6KB.cjs.map → generator-BPEAWT2P.cjs.map} +1 -1
- package/dist/generator-NLWOHWUW.js +18 -0
- package/dist/generator-VBJWJI3E.js +11 -0
- package/dist/{hancom-P3SUQXM4.js → hancom-DVWCKSEN.js} +2 -2
- package/dist/{hancom-MVPEYI4X.cjs → hancom-J2SWJYM6.cjs} +5 -5
- package/dist/{hancom-MVPEYI4X.cjs.map → hancom-J2SWJYM6.cjs.map} +1 -1
- package/dist/{hancom-RYIZHWJ5.js → hancom-P34JL3HX.js} +2 -2
- package/dist/{image-ocr-ZS4EMQN3.cjs → image-ocr-3CJ4KVOT.cjs} +28 -28
- package/dist/{image-ocr-ZS4EMQN3.cjs.map → image-ocr-3CJ4KVOT.cjs.map} +1 -1
- package/dist/{image-ocr-ZXLHPQI2.js → image-ocr-5RBEPJPK.js} +7 -7
- package/dist/{image-ocr-GL5YVCNU.js → image-ocr-7EOTOS42.js} +10 -10
- package/dist/index.cjs +1118 -1116
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +12 -10
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +36 -36
- package/dist/memo-ARHG3OC5.js +17 -0
- package/dist/{model-bundle-VCUAKBF3.js → model-bundle-7YL3PW4N.js} +5 -5
- package/dist/{models-UACAGYBI.js → models-ZXDUWX64.js} +5 -5
- package/dist/{parse-worker-v2-LJB4QXGF.js → parse-worker-v2-SGBIWVYJ.js} +22 -22
- package/dist/{parser-T4HAQ3QW.cjs → parser-6M4IIKSU.cjs} +166 -166
- package/dist/{parser-T4HAQ3QW.cjs.map → parser-6M4IIKSU.cjs.map} +1 -1
- package/dist/{parser-5GZUD22P.js → parser-HZANYZZA.js} +12 -12
- package/dist/{parser-HCZD4DUO.js → parser-RYPZ245J.js} +9 -9
- package/dist/pdf-ocr-26AWXUHX.cjs +43 -0
- package/dist/{pdf-ocr-H4DKZSOB.cjs.map → pdf-ocr-26AWXUHX.cjs.map} +1 -1
- package/dist/{pdf-ocr-JXVGK5MR.js → pdf-ocr-J5BIUOOQ.js} +6 -6
- package/dist/{pdf-ocr-YCMC2VL4.js → pdf-ocr-VMB4NOXR.js} +9 -9
- package/dist/{profile-io-MVTEOXAU.js → profile-io-F6WUV5PU.js} +3 -3
- package/dist/{rasterize-VWT3C3RW.js → rasterize-AFUYHCSP.js} +3 -3
- package/dist/{redact-doc-SU3JDC6F.js → redact-doc-UKYOAVBS.js} +21 -21
- package/dist/{render-D5N4FKWB.js → render-VRZS47LX.js} +12 -12
- package/dist/{rewrite-fallback-QXTWSPGY.js → rewrite-fallback-PNSM4XRC.js} +13 -13
- package/dist/seal-CJOUVTMN.js +16 -0
- package/dist/{setup-TXNJYX6P.js → setup-VV6ERJGY.js} +3 -3
- package/dist/to-hwpx-3OWX37Q4.cjs +16 -0
- package/dist/{to-hwpx-KZTTH7EY.cjs.map → to-hwpx-3OWX37Q4.cjs.map} +1 -1
- package/dist/{to-hwpx-Z7NHUMUD.js → to-hwpx-WBMWA54L.js} +7 -7
- package/dist/{to-hwpx-YHGVFTBO.js → to-hwpx-YYMXNCCW.js} +4 -4
- package/dist/visual-YY2BPPCJ.js +38 -0
- package/dist/{watch-EI5QYDT2.js → watch-BTAIN7LZ.js} +22 -22
- package/package.json +1 -1
- package/dist/chunk-H2VOH7X3.cjs.map +0 -1
- package/dist/chunk-M27VBFO6.js.map +0 -1
- package/dist/chunk-RWU3Y5YK.js.map +0 -1
- package/dist/chunk-T7MHZIFG.js.map +0 -1
- package/dist/chunks-JAD5Z5YY.js +0 -11
- package/dist/formula-3PJYUQMG.js.map +0 -1
- package/dist/formula-RTPZD2IM.cjs.map +0 -1
- package/dist/formula-UJF4RZ6W.js.map +0 -1
- package/dist/generator-EB2436BE.js +0 -18
- package/dist/generator-INMUN6KB.cjs +0 -12
- package/dist/generator-K5KMPSLC.js +0 -11
- package/dist/memo-JNMSGIO7.js +0 -17
- package/dist/pdf-ocr-H4DKZSOB.cjs +0 -43
- package/dist/seal-Q3BD6CRB.js +0 -16
- package/dist/to-hwpx-KZTTH7EY.cjs +0 -16
- package/dist/visual-LNHFYJDL.js +0 -38
- /package/dist/{-F7GLIIGT.js.map → -CNXSUEGZ.js.map} +0 -0
- /package/dist/{chunk-YPRIJDH6.js.map → chunk-2JA4FJJM.js.map} +0 -0
- /package/dist/{chunk-SMEBVDM2.js.map → chunk-376JPHHC.js.map} +0 -0
- /package/dist/{chunk-TYGZ6O2A.js.map → chunk-64QDDZO3.js.map} +0 -0
- /package/dist/{chunk-OUHMNF2A.js.map → chunk-AAXWKG3C.js.map} +0 -0
- /package/dist/{chunk-BHYBZSOC.js.map → chunk-ABNK5QI2.js.map} +0 -0
- /package/dist/{chunk-KLUI4SAZ.js.map → chunk-AUGOG3KY.js.map} +0 -0
- /package/dist/{chunk-O7PJFEOC.js.map → chunk-B5F7B5NL.js.map} +0 -0
- /package/dist/{chunk-7KVDHXP2.js.map → chunk-BK55EX56.js.map} +0 -0
- /package/dist/{chunk-KGCJNPAI.js.map → chunk-BX23BOYN.js.map} +0 -0
- /package/dist/{chunk-2CPEW6WC.js.map → chunk-CBGH37CU.js.map} +0 -0
- /package/dist/{chunk-AUHQRRKM.js.map → chunk-CGOCVSWC.js.map} +0 -0
- /package/dist/{chunk-MHXPW72E.js.map → chunk-E3G3JTXW.js.map} +0 -0
- /package/dist/{chunk-NPBNJCXZ.js.map → chunk-G7QVY67O.js.map} +0 -0
- /package/dist/{chunk-5WWGC5SG.js.map → chunk-IV6UP7MO.js.map} +0 -0
- /package/dist/{chunk-HIYRMYAS.js.map → chunk-JDGPQVTX.js.map} +0 -0
- /package/dist/{chunk-GRCIFCGC.js.map → chunk-JY4YMR6F.js.map} +0 -0
- /package/dist/{chunk-2VBRCIPI.js.map → chunk-LMHDQWQM.js.map} +0 -0
- /package/dist/{chunk-LNWURZ2Z.js.map → chunk-M4QZCXT4.js.map} +0 -0
- /package/dist/{chunk-GFAWIBHG.js.map → chunk-MHLTXTP2.js.map} +0 -0
- /package/dist/{chunk-IMT5TVVM.js.map → chunk-NQL7NCSE.js.map} +0 -0
- /package/dist/{chunk-2OF2YWIZ.js.map → chunk-P4FHTYVX.js.map} +0 -0
- /package/dist/{chunk-WMA4GJHC.js.map → chunk-RJ26GRDB.js.map} +0 -0
- /package/dist/{chunk-QK5KCWLE.js.map → chunk-S366ICXS.js.map} +0 -0
- /package/dist/{chunk-EZNUMAAJ.js.map → chunk-S6K222FM.js.map} +0 -0
- /package/dist/{chunk-ZPJZXTEG.js.map → chunk-TTIJTR5Z.js.map} +0 -0
- /package/dist/{chunk-D4UFBXMT.js.map → chunk-UMVL776E.js.map} +0 -0
- /package/dist/{chunk-YTDHH362.js.map → chunk-VMM5PVOA.js.map} +0 -0
- /package/dist/{chunk-OJK4FLS5.js.map → chunk-VSWGRKTF.js.map} +0 -0
- /package/dist/{chunk-6ZA4V4QS.js.map → chunk-X4HNVXJI.js.map} +0 -0
- /package/dist/{chunk-RUUUGCXS.js.map → chunk-XSDVY4S6.js.map} +0 -0
- /package/dist/{chunk-DSCT67WF.js.map → chunk-YLC25Z64.js.map} +0 -0
- /package/dist/{chunk-UJQRIX4L.js.map → chunk-ZH322FQG.js.map} +0 -0
- /package/dist/{chunks-JAD5Z5YY.js.map → chunks-7XYOWREB.js.map} +0 -0
- /package/dist/{generator-EB2436BE.js.map → generator-NLWOHWUW.js.map} +0 -0
- /package/dist/{generator-K5KMPSLC.js.map → generator-VBJWJI3E.js.map} +0 -0
- /package/dist/{hancom-P3SUQXM4.js.map → hancom-DVWCKSEN.js.map} +0 -0
- /package/dist/{hancom-RYIZHWJ5.js.map → hancom-P34JL3HX.js.map} +0 -0
- /package/dist/{image-ocr-ZXLHPQI2.js.map → image-ocr-5RBEPJPK.js.map} +0 -0
- /package/dist/{image-ocr-GL5YVCNU.js.map → image-ocr-7EOTOS42.js.map} +0 -0
- /package/dist/{memo-JNMSGIO7.js.map → memo-ARHG3OC5.js.map} +0 -0
- /package/dist/{model-bundle-VCUAKBF3.js.map → model-bundle-7YL3PW4N.js.map} +0 -0
- /package/dist/{models-UACAGYBI.js.map → models-ZXDUWX64.js.map} +0 -0
- /package/dist/{parse-worker-v2-LJB4QXGF.js.map → parse-worker-v2-SGBIWVYJ.js.map} +0 -0
- /package/dist/{parser-5GZUD22P.js.map → parser-HZANYZZA.js.map} +0 -0
- /package/dist/{parser-HCZD4DUO.js.map → parser-RYPZ245J.js.map} +0 -0
- /package/dist/{pdf-ocr-JXVGK5MR.js.map → pdf-ocr-J5BIUOOQ.js.map} +0 -0
- /package/dist/{pdf-ocr-YCMC2VL4.js.map → pdf-ocr-VMB4NOXR.js.map} +0 -0
- /package/dist/{profile-io-MVTEOXAU.js.map → profile-io-F6WUV5PU.js.map} +0 -0
- /package/dist/{rasterize-VWT3C3RW.js.map → rasterize-AFUYHCSP.js.map} +0 -0
- /package/dist/{redact-doc-SU3JDC6F.js.map → redact-doc-UKYOAVBS.js.map} +0 -0
- /package/dist/{render-D5N4FKWB.js.map → render-VRZS47LX.js.map} +0 -0
- /package/dist/{rewrite-fallback-QXTWSPGY.js.map → rewrite-fallback-PNSM4XRC.js.map} +0 -0
- /package/dist/{seal-Q3BD6CRB.js.map → seal-CJOUVTMN.js.map} +0 -0
- /package/dist/{setup-TXNJYX6P.js.map → setup-VV6ERJGY.js.map} +0 -0
- /package/dist/{to-hwpx-YHGVFTBO.js.map → to-hwpx-WBMWA54L.js.map} +0 -0
- /package/dist/{to-hwpx-Z7NHUMUD.js.map → to-hwpx-YYMXNCCW.js.map} +0 -0
- /package/dist/{visual-LNHFYJDL.js.map → visual-YY2BPPCJ.js.map} +0 -0
- /package/dist/{watch-EI5QYDT2.js.map → watch-BTAIN7LZ.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 _chunkO4TKUBCFcjs = require('./chunk-O4TKUBCF.cjs');
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
@@ -9,11 +9,11 @@ var _chunkYTP7FPA5cjs = require('./chunk-YTP7FPA5.cjs');
|
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _chunk5MBQW3KPcjs = require('./chunk-5MBQW3KP.cjs');
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
|
|
16
|
-
var
|
|
16
|
+
var _chunkHMHIF6QFcjs = require('./chunk-HMHIF6QF.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 _chunkO4TKUBCFcjs.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 _chunkO4TKUBCFcjs.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) _chunk5MBQW3KPcjs.CELL_EDGES.set(to, e);
|
|
3418
3418
|
}
|
|
3419
3419
|
function hasOpenCellSeam(a, b) {
|
|
3420
|
-
const u =
|
|
3420
|
+
const u = _chunk5MBQW3KPcjs.CELL_EDGES.get(a), d = _chunk5MBQW3KPcjs.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 = _chunk5MBQW3KPcjs.CELL_EDGES.get(a), d = _chunk5MBQW3KPcjs.CELL_EDGES.get(b);
|
|
3425
3425
|
if (!u || !d) return;
|
|
3426
|
-
|
|
3426
|
+
_chunk5MBQW3KPcjs.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 _chunk5MBQW3KPcjs.tidyScriptTags.call(void 0, out);
|
|
3612
3612
|
}
|
|
3613
3613
|
|
|
3614
3614
|
// src/pdf/line-wrap.ts
|
|
@@ -3624,7 +3624,7 @@ var bump2 = (m, k1, k2) => {
|
|
|
3624
3624
|
if (!inner) m.set(k1, inner = /* @__PURE__ */ new Map());
|
|
3625
3625
|
bump(inner, k2);
|
|
3626
3626
|
};
|
|
3627
|
-
var WrapLexicon = (_class = class {constructor() { _class.prototype.__init.call(this);_class.prototype.__init2.call(this);_class.prototype.__init3.call(this);_class.prototype.__init4.call(this);_class.prototype.__init5.call(this);_class.prototype.__init6.call(this);_class.prototype.__init7.call(this);_class.prototype.__init8.call(this);_class.prototype.__init9.call(this);_class.prototype.__init10.call(this); }
|
|
3627
|
+
var WrapLexicon = (_class = class {constructor() { _class.prototype.__init.call(this);_class.prototype.__init2.call(this);_class.prototype.__init3.call(this);_class.prototype.__init4.call(this);_class.prototype.__init5.call(this);_class.prototype.__init6.call(this);_class.prototype.__init7.call(this);_class.prototype.__init8.call(this);_class.prototype.__init9.call(this);_class.prototype.__init10.call(this);_class.prototype.__init11.call(this); }
|
|
3628
3628
|
__init() {this.joined1 = /* @__PURE__ */ new Map()}
|
|
3629
3629
|
__init2() {this.joined2 = /* @__PURE__ */ new Map()}
|
|
3630
3630
|
__init3() {this.spaced1 = /* @__PURE__ */ new Map()}
|
|
@@ -3642,6 +3642,8 @@ var WrapLexicon = (_class = class {constructor() { _class.prototype.__init.call(
|
|
|
3642
3642
|
__init9() {this.cites = /* @__PURE__ */ new Map()}
|
|
3643
3643
|
/** 쪽 줄 흐름에서 넓은 줄 사이 기준선 간격(글자 크기별) — 줄 둘뿐인 묶음은 묶음 안에 견줄 간격이 없어 넓은 줄 간격 본문을 문단 경계로 봤다 */
|
|
3644
3644
|
__init10() {this.pitches = []}
|
|
3645
|
+
/** 줄 안 한글 바로 뒤 여는 괄호 — 붙여 쓴 "주택(아파트)" 수와 띄운 "주택 (아파트)" 수 */
|
|
3646
|
+
__init11() {this.parens = { joined: 0, spaced: 0 }}
|
|
3645
3647
|
/** 줄 흐름의 이웃한 넓은 두 줄(같은 글자 크기) 사이 간격 하나를 더한다 */
|
|
3646
3648
|
addPitch(fontSize, pitch) {
|
|
3647
3649
|
if (fontSize > 0 && pitch > 0 && pitch < 4 * fontSize) this.pitches.push({ fs: fontSize, pitch });
|
|
@@ -3654,6 +3656,8 @@ var WrapLexicon = (_class = class {constructor() { _class.prototype.__init.call(
|
|
|
3654
3656
|
/** 줄 글 한 줄을 증거로 더한다 — 탭(큰 갭)으로 나뉜 조각은 다른 칸·단이라 조각 사이는 어절 경계 증거로 쓰지 않는다 */
|
|
3655
3657
|
addLine(text) {
|
|
3656
3658
|
for (const seg of text.replace(MARKUP, "").split(" ")) {
|
|
3659
|
+
this.parens.joined += _nullishCoalesce(_optionalChain([seg, 'access', _59 => _59.match, 'call', _60 => _60(/[가-힣]\(/g), 'optionalAccess', _61 => _61.length]), () => ( 0));
|
|
3660
|
+
this.parens.spaced += _nullishCoalesce(_optionalChain([seg, 'access', _62 => _62.match, 'call', _63 => _63(/[가-힣] \(/g), 'optionalAccess', _64 => _64.length]), () => ( 0));
|
|
3657
3661
|
for (const m of seg.matchAll(CITE_LINK)) {
|
|
3658
3662
|
const c = _nullishCoalesce(this.cites.get(m[1]), () => ( { joined: 0, spaced: 0 }));
|
|
3659
3663
|
if (m[2]) c.spaced++;
|
|
@@ -3665,12 +3669,12 @@ var WrapLexicon = (_class = class {constructor() { _class.prototype.__init.call(
|
|
|
3665
3669
|
const t = toks[i], n = t.length;
|
|
3666
3670
|
if (i > 0 && i < toks.length - 1) {
|
|
3667
3671
|
bump(this.words, t);
|
|
3668
|
-
const run = _nullishCoalesce(_optionalChain([t, 'access',
|
|
3672
|
+
const run = _nullishCoalesce(_optionalChain([t, 'access', _65 => _65.match, 'call', _66 => _66(/^[가-힣]+/), 'optionalAccess', _67 => _67[0]]), () => ( ""));
|
|
3669
3673
|
for (let j = 2; j <= Math.min(run.length, 6); j++) this.heads.add(run.slice(0, j));
|
|
3670
3674
|
}
|
|
3671
3675
|
if (i + 1 < toks.length) {
|
|
3672
3676
|
this.pairs.add(t + " " + toks[i + 1]);
|
|
3673
|
-
const tail = _optionalChain([t, 'access',
|
|
3677
|
+
const tail = _optionalChain([t, 'access', _68 => _68.match, 'call', _69 => _69(/[가-힣]+$/), 'optionalAccess', _70 => _70[0]]);
|
|
3674
3678
|
if (tail) this.spacedHeads.add(tail + " " + toks[i + 1].charAt(0));
|
|
3675
3679
|
}
|
|
3676
3680
|
for (let a = 0; a + 1 < n; a++) {
|
|
@@ -3691,6 +3695,13 @@ var WrapLexicon = (_class = class {constructor() { _class.prototype.__init.call(
|
|
|
3691
3695
|
const c = this.cites.get(unit);
|
|
3692
3696
|
return !c || c.joined === c.spaced ? null : c.joined > c.spaced;
|
|
3693
3697
|
}
|
|
3698
|
+
/** 한글 뒤 여는 괄호로 꺾인 줄을 붙일까 — 문서 줄 안에서 붙여 쓴 쪽이 셋 넘고 띄운 쪽의 네 배 넘으면 true, 거꾸로면 false, 그 밖 null */
|
|
3699
|
+
parenJoins() {
|
|
3700
|
+
const { joined, spaced } = this.parens;
|
|
3701
|
+
if (joined >= 3 && joined >= 4 * spaced) return true;
|
|
3702
|
+
if (spaced >= 3 && spaced >= 4 * joined) return false;
|
|
3703
|
+
return null;
|
|
3704
|
+
}
|
|
3694
3705
|
/** 문서 줄 안에서 홀로 선 어절로 나온 적 있나 */
|
|
3695
3706
|
isWord(word) {
|
|
3696
3707
|
return (_nullishCoalesce(this.words.get(word), () => ( 0))) > 0;
|
|
@@ -3699,6 +3710,10 @@ var WrapLexicon = (_class = class {constructor() { _class.prototype.__init.call(
|
|
|
3699
3710
|
joinedWord(left, right) {
|
|
3700
3711
|
return this.isWord(left + right) && !this.pairs.has(left + " " + right);
|
|
3701
3712
|
}
|
|
3713
|
+
/** 두 어절을 줄 안에서 띄어 쓴 이웃으로 쓴 적 있나 */
|
|
3714
|
+
spacedPair(left, right) {
|
|
3715
|
+
return this.pairs.has(left + " " + right);
|
|
3716
|
+
}
|
|
3702
3717
|
/** 줄 안 어절이 이 한글로 시작한 적 있나 */
|
|
3703
3718
|
startsWord(head) {
|
|
3704
3719
|
return this.heads.has(head);
|
|
@@ -3712,14 +3727,14 @@ var WrapLexicon = (_class = class {constructor() { _class.prototype.__init.call(
|
|
|
3712
3727
|
const n = left.length;
|
|
3713
3728
|
if (n < 2 || right.length < 2) return null;
|
|
3714
3729
|
const k1 = pairKey(left.charCodeAt(n - 2), left.charCodeAt(n - 1)), k2 = pairKey(right.charCodeAt(0), right.charCodeAt(1));
|
|
3715
|
-
return decideCounts(_nullishCoalesce(_optionalChain([this, 'access',
|
|
3730
|
+
return decideCounts(_nullishCoalesce(_optionalChain([this, 'access', _71 => _71.joined2, 'access', _72 => _72.get, 'call', _73 => _73(k1), 'optionalAccess', _74 => _74.get, 'call', _75 => _75(k2)]), () => ( 0)), _nullishCoalesce(_optionalChain([this, 'access', _76 => _76.spaced2, 'access', _77 => _77.get, 'call', _78 => _78(k1), 'optionalAccess', _79 => _79.get, 'call', _80 => _80(k2)]), () => ( 0)));
|
|
3716
3731
|
}
|
|
3717
3732
|
/** 꺾인 자리 증거: "" 붙음 · " " 띄움 · null 모름 (두 글자 증거가 갈리거나 없으면 한 글자) */
|
|
3718
3733
|
evidence(left, right) {
|
|
3719
3734
|
const n = left.length;
|
|
3720
3735
|
if (n >= 2 && right.length >= 2) {
|
|
3721
3736
|
const k1 = pairKey(left.charCodeAt(n - 2), left.charCodeAt(n - 1)), k2 = pairKey(right.charCodeAt(0), right.charCodeAt(1));
|
|
3722
|
-
const v = decideCounts(_nullishCoalesce(_optionalChain([this, 'access',
|
|
3737
|
+
const v = decideCounts(_nullishCoalesce(_optionalChain([this, 'access', _81 => _81.joined2, 'access', _82 => _82.get, 'call', _83 => _83(k1), 'optionalAccess', _84 => _84.get, 'call', _85 => _85(k2)]), () => ( 0)), _nullishCoalesce(_optionalChain([this, 'access', _86 => _86.spaced2, 'access', _87 => _87.get, 'call', _88 => _88(k1), 'optionalAccess', _89 => _89.get, 'call', _90 => _90(k2)]), () => ( 0)));
|
|
3723
3738
|
if (v !== null) return v;
|
|
3724
3739
|
}
|
|
3725
3740
|
if (n && right.length) {
|
|
@@ -3736,9 +3751,9 @@ var hasBatchim = (c) => {
|
|
|
3736
3751
|
};
|
|
3737
3752
|
var CJK = /[\u3000-\u303F\u3040-\u30FF\u3400-\u4DBF\u4E00-\u9FFF\uF900-\uFAFF\uFF00-\uFFEF]/;
|
|
3738
3753
|
var unspacedCjkBoundary = (prev, next) => CJK.test(prev.trimEnd().slice(-1)) && CJK.test(next.trimStart().charAt(0)) && !/[가-힣ㄱ-ㅎㅏ-ㅣ]/.test(prev + next);
|
|
3739
|
-
var CLOSE_TAIL = /[’”」』)\]
|
|
3754
|
+
var CLOSE_TAIL = /[’”」』)\]〉》>*]+$/;
|
|
3740
3755
|
var TAIL = "[.,)\u300D\u300F\u2019\u201D]*";
|
|
3741
|
-
var PARTICLE = new RegExp(`^(?:\uB2E4\\.|\uC758|\uC5D0|\uC5D0\uC11C|\uC5D0\uB294|\uC5D0\uAC8C|\uC5D0\uB3C4|\uC5D0\uC11C\uB294|\uAE4C\uC9C0|\uBD80\uD130|\uCC98\uB7FC|\uB9C8\uB2E4|\uB9CC|\uB3C4|\uB4E4|\uB4E4\uC774|\uB4E4\uC758|\uB4E4\uC740|\uB4E4\uC744|\uB4E4\uC5D0\uAC8C|\uC11C\uB294|\uC11C\uB3C4|\uB77C\uACE0|\uB77C\uBA70|\uC740|\uB294|\uC744|\uB97C|\uC73C\uB85C|\uB85C|\uC73C\uB85C\uC11C|\uB85C\uC11C|\uC73C\uB85C\uC368|\uB85C\uC368|\uC5D0\uC11C\uB3C4|\uC5D0\uC11C\uC758|\uC5D0\uC11C\uB9CC|\uC5D0\uC11C\uBD80\uD130|\uC5D0\uB9CC|\uC5D0\uC758|\uC5D0\uAC8C\uB294|\uC5D0\uAC8C\uB3C4|\uAED8\uC11C|\uAED8\uC11C\uB294|\uAED8\uC11C\uB3C4|\uC73C\uB85C\uB294|\uB85C\uB294|\uC73C\uB85C\uB3C4|\uB85C\uB3C4|\uC73C\uB85C\uBD80\uD130|\uB85C\uBD80\uD130|\uBD80\uD130\uB294|\uAE4C\uC9C0\uB294|\uAE4C\uC9C0\uB3C4|\uBCF4\uB2E4\uB3C4|\uB77C\uB3C4|\uC774\uB77C\uB3C4|\uAE4C\uC9C0\uC640|\uAE4C\uC9C0\uC758|\uC5D0\uC11C\uC640|\uC73C\uB85C\uC758|\uB85C\uC758|\uB4E4\uACFC|\uB4E4\uACFC\uC758|\uB4E4\uB85C|\uB4E4\uB3C4|\uB4E4\uC5D0|\uB4E4\uC5D0\uC11C|\uB4E4\uB9CC|\uC774\uB2E4|\uC774\uBA70|\uC774\uB098|\uC774\uB77C\uB294|\uC774\uB77C\uACE0|\uC774\uB77C\uBA70|\uC778\uB370|\uC774\uBBC0\uB85C|\uC774\uC9C0\uB9CC|\uC774\uBA74\uC11C)${TAIL}$`);
|
|
3756
|
+
var PARTICLE = new RegExp(`^(?:\uB2E4\\.|\uC758|\uC5D0|\uC5D0\uC11C|\uC5D0\uB294|\uC5D0\uAC8C|\uC5D0\uB3C4|\uC5D0\uC11C\uB294|\uAE4C\uC9C0|\uBD80\uD130|\uCC98\uB7FC|\uB9C8\uB2E4|\uB9CC|\uB3C4|\uB4E4|\uB4E4\uC774|\uB4E4\uC758|\uB4E4\uC740|\uB4E4\uC744|\uB4E4\uC5D0\uAC8C|\uC11C\uB294|\uC11C\uB3C4|\uB77C\uACE0|\uB77C\uBA70|\uC740|\uB294|\uC744|\uB97C|\uC73C\uB85C|\uB85C|\uC73C\uB85C\uC11C|\uB85C\uC11C|\uC73C\uB85C\uC368|\uB85C\uC368|\uC5D0\uC11C\uB3C4|\uC5D0\uC11C\uC758|\uC5D0\uC11C\uB9CC|\uC5D0\uC11C\uBD80\uD130|\uC5D0\uB9CC|\uC5D0\uC758|\uC5D0\uAC8C\uB294|\uC5D0\uAC8C\uB3C4|\uAED8\uC11C|\uAED8\uC11C\uB294|\uAED8\uC11C\uB3C4|\uC73C\uB85C\uB294|\uB85C\uB294|\uC73C\uB85C\uB3C4|\uB85C\uB3C4|\uC73C\uB85C\uBD80\uD130|\uB85C\uBD80\uD130|\uBD80\uD130\uB294|\uAE4C\uC9C0\uB294|\uAE4C\uC9C0\uB3C4|\uBCF4\uB2E4\uB3C4|\uB77C\uB3C4|\uC774\uB77C\uB3C4|\uAE4C\uC9C0\uC640|\uAE4C\uC9C0\uC758|\uC5D0\uC11C\uC640|\uC73C\uB85C\uC758|\uB85C\uC758|\uB4E4\uACFC|\uB4E4\uACFC\uC758|\uB4E4\uB85C|\uB4E4\uB3C4|\uB4E4\uC5D0|\uB4E4\uC5D0\uC11C|\uB4E4\uB9CC|\uC774\uB2E4|\uC774\uBA70|\uC774\uB098|\uC774\uB77C\uB294|\uC774\uB77C\uACE0|\uC774\uB77C\uBA70|\uC774\uB77C\uBA74\uC11C|\uB77C\uBA74\uC11C|\uC778\uB370|\uC774\uBBC0\uB85C|\uC774\uC9C0\uB9CC|\uC774\uBA74\uC11C)${TAIL}$`);
|
|
3742
3757
|
var PARTICLE_AFTER_CONS = new RegExp(`^(?:\uC774|\uACFC|\uACFC\uC758|\uC774\uACE0|\uC778|\uC778\uC9C0|\uC784|\uC784\uC744|\uC784\uC5D0\uB3C4|\uC774\uC5B4\uC57C)${TAIL}$`);
|
|
3743
3758
|
var PARTICLE_AFTER_VOWEL = new RegExp(`^(?:\uAC00|\uC640|\uC640\uC758|\uB77C\uB294)${TAIL}$`);
|
|
3744
3759
|
var ENDING = new RegExp(`^(?:\uC5B4\uC57C|\uC544\uC57C|\uC5EC\uC57C|\uBBC0\uB85C|\uC73C\uBBC0\uB85C|\uC9C0\uB9CC|\uBA74\uC11C|\uC73C\uBA74\uC11C|\uC73C\uBA70|\uAC70\uB098|\uB354\uB77C\uB3C4|\uB4E0\uC9C0|\uC5C8\uB2E4|\uC558\uB2E4|\uC600\uB2E4|\uC5C8\uC73C\uBA70|\uC558\uC73C\uBA70|\uC600\uC73C\uBA70|\uC5C8\uACE0|\uC558\uACE0|\uC600\uACE0|\uC600\uB358|\uC84C\uB2E4|\uC84C\uC73C\uBA70|\uC84C\uACE0|\uC84C\uB358|\uB294\uB370|\uACA0\uB2E4|\uACA0\uACE0|\uACA0\uC73C\uBA70|\uC2B5\uB2C8\uB2E4|\uB2C8\uB2E4|\uB2C8\uAE4C)${TAIL}$`);
|
|
@@ -3800,17 +3815,22 @@ function wrapJoiner(prevText, nextText, lex, heads = true) {
|
|
|
3800
3815
|
if (particleContinues(left, right)) return "";
|
|
3801
3816
|
if (endsAsWord(left)) return " ";
|
|
3802
3817
|
if (/[A-Za-z]-$/.test(left) && /^[A-Za-z]/.test(right) && !/[가-힣]/.test(prev + next)) {
|
|
3803
|
-
return _optionalChain([lex, 'optionalAccess',
|
|
3818
|
+
return _optionalChain([lex, 'optionalAccess', _91 => _91.joinedWord, 'call', _92 => _92(left, right.replace(/[.,;:!?)]*$/, ""))]) ? "" : " ";
|
|
3804
3819
|
}
|
|
3805
|
-
if (/[
|
|
3820
|
+
if (/[·ㆍ‧・․-]/.test(a) && !/[·ㆍ‧・․…]{2}$/.test(prev) && /[가-힣A-Za-z0-9]/.test(b)) return "";
|
|
3821
|
+
if (heads && /[가-힣A-Za-z0-9]/.test(a) && /^[·ㆍ‧・․-][가-힣A-Za-z0-9]/.test(next)) return "";
|
|
3806
3822
|
if (/[A-Za-z]/.test(a) && /[A-Za-z]/.test(b) || /\d/.test(a) && /\d/.test(b)) return " ";
|
|
3807
3823
|
if (/(?:^|[^가-힣])제$/.test(left) && /^\d+(?:조|항|호|목|장|절|편|관)/.test(right)) return "";
|
|
3808
3824
|
const cite = left.match(/제\d+(조|항|호)(?:의\d+)?$/);
|
|
3809
3825
|
if (cite && /^제\d+(?:항|호|목)/.test(right)) {
|
|
3810
|
-
const joins = _optionalChain([lex, 'optionalAccess',
|
|
3826
|
+
const joins = _optionalChain([lex, 'optionalAccess', _93 => _93.citationJoins, 'call', _94 => _94(cite[1])]);
|
|
3827
|
+
if (joins != null) return joins ? "" : " ";
|
|
3828
|
+
}
|
|
3829
|
+
if (heads && b === "(" && /[가-힣]$/.test(left) && !endsAsWord(left) && !/(?:함|음|됨|임|다)$/.test(left) && !/^\([^()]*\)\s*$/.test(next) && !/^\([^()]*\s[^()]*\)\s/.test(next) && !_optionalChain([lex, 'optionalAccess', _95 => _95.spacedPair, 'call', _96 => _96(left, right)])) {
|
|
3830
|
+
const joins = _optionalChain([lex, 'optionalAccess', _97 => _97.parenJoins, 'call', _98 => _98()]);
|
|
3811
3831
|
if (joins != null) return joins ? "" : " ";
|
|
3812
3832
|
}
|
|
3813
|
-
const ev = _optionalChain([lex, 'optionalAccess',
|
|
3833
|
+
const ev = _optionalChain([lex, 'optionalAccess', _99 => _99.evidence, 'call', _100 => _100(left, right)]);
|
|
3814
3834
|
if (ev != null) return ev;
|
|
3815
3835
|
if (lex && /[가-힣A-Za-z0-9]$/.test(left) && /^[가-힣A-Za-z0-9]/.test(right) && lex.joinedWord(left, right.replace(/[.,)」』’”;:]+$/, ""))) return "";
|
|
3816
3836
|
if (/\d$/.test(left) && COUNTER.test(right)) return "";
|
|
@@ -3818,7 +3838,7 @@ function wrapJoiner(prevText, nextText, lex, heads = true) {
|
|
|
3818
3838
|
const r1 = right.replace(/[.,)」』’”]+$/, "");
|
|
3819
3839
|
if (lex && /[가-힣]$/.test(left) && /^[가-힣]$/.test(r1) && !STANDALONE_SYLLABLE.test(r1) && !lex.isWord(r1) && !lex.isWord(right)) return "";
|
|
3820
3840
|
if (lex && heads) {
|
|
3821
|
-
const tail = _optionalChain([left, 'access',
|
|
3841
|
+
const tail = _optionalChain([left, 'access', _101 => _101.match, 'call', _102 => _102(/[가-힣]+$/), 'optionalAccess', _103 => _103[0]]), run = _optionalChain([right, 'access', _104 => _104.match, 'call', _105 => _105(/^[가-힣]+/), 'optionalAccess', _106 => _106[0]]);
|
|
3822
3842
|
if (tail && run && !STANDALONE_SYLLABLE.test(tail) && lex.startsWord(tail + run.slice(0, 2)) && !lex.spacedHead(tail, run[0])) return "";
|
|
3823
3843
|
if (/[가-힣]{2}$/.test(left) && /^\([^()\s]*\)/.test(right) && !endsAsWord(left) && !/(?:함|음|됨|임|다)$/.test(left) && !BARE_UNIT_PAREN.test(right) && !/^\(\d/.test(right)) return "";
|
|
3824
3844
|
}
|
|
@@ -3855,14 +3875,14 @@ function joinPageBreakWraps(blocks, lex) {
|
|
|
3855
3875
|
const last = a.bbox && PARA_LAST_LINE.get(a.bbox), fs = last ? last.fontSize : 0;
|
|
3856
3876
|
const hang = !/[가-힣]/.test(a.text) && CJK.test(a.text.replace(MARKUP, "").trimEnd().slice(-1)) ? fs : 0;
|
|
3857
3877
|
if (!last || fs <= 0 || (_nullishCoalesce(pageRight.get(a.pageNumber), () => ( Infinity))) - last.right >= BODY_FULL_TOL * fs + hang) continue;
|
|
3858
|
-
if (last.width < BODY_MIN_WIDTH_EM * fs || Math.abs((_nullishCoalesce(_optionalChain([b, 'access',
|
|
3878
|
+
if (last.width < BODY_MIN_WIDTH_EM * fs || Math.abs((_nullishCoalesce(_optionalChain([b, 'access', _107 => _107.style, 'optionalAccess', _108 => _108.fontSize]), () => ( 0))) - fs) > 0.15 * fs) continue;
|
|
3859
3879
|
const bt = b.text.replace(MARKUP, "");
|
|
3860
3880
|
if (startsNewItem(a.text, b.text) || PAGE_REF_TAIL.test(a.text) || PAGE_ITEM_HEAD.test(bt)) continue;
|
|
3861
3881
|
if (PAGE_HEAD_MARK.test(bt) && !(/^[\u25a0-\u25ff]/.test(bt) && a.text.includes(bt[0]))) continue;
|
|
3862
3882
|
const firstLeft = b.bbox && PARA_FIRST_LEFT.get(b.bbox);
|
|
3863
3883
|
const indented = firstLeft === void 0 || firstLeft - (_nullishCoalesce(pageLeft.get(b.pageNumber), () => ( firstLeft))) >= 0.3 * fs;
|
|
3864
3884
|
if (indented && SENTENCE_END.test(a.text.replace(MARKUP, "").trimEnd())) continue;
|
|
3865
|
-
if (Math.round(_nullishCoalesce(_optionalChain([b, 'access',
|
|
3885
|
+
if (Math.round(_nullishCoalesce(_optionalChain([b, 'access', _109 => _109.style, 'optionalAccess', _110 => _110.fontSize]), () => ( 0))) !== Math.round(fs) && titleLike(b.text)) continue;
|
|
3866
3886
|
if (/\t/.test(a.text.slice(a.text.lastIndexOf("\n") + 1).replace(/^\S{1,8}\t/, "")) && titleLike(bt.trim().split("\n")[0])) continue;
|
|
3867
3887
|
const joined = wrapJoiner(a.text, b.text, lex);
|
|
3868
3888
|
const head = a.text, joiner = joined === "" && last.spaceAfter ? " " : joined;
|
|
@@ -3878,9 +3898,9 @@ function joinPageBreakWraps(blocks, lex) {
|
|
|
3878
3898
|
}
|
|
3879
3899
|
function footnoteBetween(a, f, b) {
|
|
3880
3900
|
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',
|
|
3901
|
+
const afs = _nullishCoalesce(_optionalChain([a, 'access', _111 => _111.style, 'optionalAccess', _112 => _112.fontSize]), () => ( 0)), ffs = _nullishCoalesce(_optionalChain([f, 'access', _113 => _113.style, 'optionalAccess', _114 => _114.fontSize]), () => ( 0));
|
|
3882
3902
|
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',
|
|
3903
|
+
const at = _nullishCoalesce(_optionalChain([a, 'access', _115 => _115.text, 'optionalAccess', _116 => _116.replace, 'call', _117 => _117(MARKUP, ""), 'access', _118 => _118.trimEnd, 'call', _119 => _119()]), () => ( ""));
|
|
3884
3904
|
if (/[가-힣]/.test(at) || SENTENCE_END.test(at)) return false;
|
|
3885
3905
|
return /^(?:\d{1,2}\)?\s|\*|※)/.test(f.text.replace(MARKUP, "").trimStart());
|
|
3886
3906
|
}
|
|
@@ -3920,7 +3940,7 @@ function bodyLineJoins(lines, lex) {
|
|
|
3920
3940
|
for (const l of lines) if (!HANGING.test(l.text) && l.right > inner) inner = l.right;
|
|
3921
3941
|
const full = (l) => right - l.right < BODY_FULL_TOL * l.fontSize || right - inner <= 1.2 * l.fontSize && inner - l.right < BODY_FULL_TOL * l.fontSize;
|
|
3922
3942
|
const nextWordNoRoom = (a, b) => {
|
|
3923
|
-
const w = _optionalChain([b, 'access',
|
|
3943
|
+
const w = _optionalChain([b, 'access', _120 => _120.text, 'access', _121 => _121.trim, 'call', _122 => _122(), 'access', _123 => _123.match, 'call', _124 => _124(/^\S+/), 'optionalAccess', _125 => _125[0]]);
|
|
3924
3944
|
const n = [...b.text.trim()].length;
|
|
3925
3945
|
if (!w || n === 0) return false;
|
|
3926
3946
|
const em = (b.right - b.left) / n;
|
|
@@ -3946,7 +3966,7 @@ function bodyLineJoins(lines, lex) {
|
|
|
3946
3966
|
const a = lines[i], b = lines[i + 1];
|
|
3947
3967
|
const fs = a.fontSize;
|
|
3948
3968
|
const own = i === i1 ? p2 : p1;
|
|
3949
|
-
const others = Number.isFinite(own) ? own : _nullishCoalesce(_optionalChain([lex, 'optionalAccess',
|
|
3969
|
+
const others = Number.isFinite(own) ? own : _nullishCoalesce(_optionalChain([lex, 'optionalAccess', _126 => _126.bodyPitch, 'call', _127 => _127(fs)]), () => ( Infinity));
|
|
3950
3970
|
const maxPitch = Number.isFinite(others) ? Math.min(BODY_MAX_PITCH_ABS_EM * fs, Math.max(BODY_MAX_PITCH_EM * fs, others * BODY_PITCH_REL)) : BODY_MAX_PITCH_EM * fs;
|
|
3951
3971
|
const wordWrap = ragged && !full(a) && nextWordNoRoom(a, b) && !MULTI_LEVEL_NUMBER.test(b.text.trimStart());
|
|
3952
3972
|
const wraps = fs > 0 && (full(a) || wordWrap) && a.right - a.left >= BODY_MIN_WIDTH_EM * fs && a.y - b.y > 0 && (a.y - b.y < maxPitch || indentedCjkFirstLine(a, b, fs)) && Math.abs(b.fontSize - fs) <= 0.15 * fs && !startsNewItem(a.text, b.text) && !(SENTENCE_END.test(a.text.trimEnd()) && MULTI_LEVEL_NUMBER.test(b.text.trimStart()));
|
|
@@ -4123,7 +4143,7 @@ function cellTextToString(items, wrap) {
|
|
|
4123
4143
|
const merged = mergeSuperscriptRows(lines).map((line) => sortLineByX(line));
|
|
4124
4144
|
const textLines = merged.map((s) => {
|
|
4125
4145
|
if (s.length === 1) return s[0].text;
|
|
4126
|
-
if (s.length === 2 && /^[가-힣]$/.test(s[0].text) && /^[가-힣]$/.test(s[1].text) && !!_optionalChain([wrap, 'optionalAccess',
|
|
4146
|
+
if (s.length === 2 && /^[가-힣]$/.test(s[0].text) && /^[가-힣]$/.test(s[1].text) && !!_optionalChain([wrap, 'optionalAccess', _128 => _128.lex]) && (wrap.lex.isWord(s[0].text + s[1].text) || wrap.lex.evidence(s[0].text, s[1].text) === "" || REGION_LABELS.has(s[0].text + s[1].text)) && s[1].x - (s[0].x + s[0].w) >= Math.max(s[0].fontSize, s[1].fontSize) * 1.5 && s[1].x + s[1].w - s[0].x >= wrap.box.x2 - wrap.box.x1 - Math.max(s[0].fontSize, s[1].fontSize) * 2) return s[0].text + s[1].text;
|
|
4127
4147
|
const evenSpaced = detectEvenSpacedItems(s, true);
|
|
4128
4148
|
const tracked = trackedSpaces(s);
|
|
4129
4149
|
const hangulLine = s.some((it) => /[가-힣]/.test(it.text));
|
|
@@ -4139,7 +4159,7 @@ function cellTextToString(items, wrap) {
|
|
|
4139
4159
|
result += s[j].text;
|
|
4140
4160
|
} else if (s[j].hasSpaceBefore && exactGap(s[j - 1], s[j], gap) >= avgFs * 0.05) {
|
|
4141
4161
|
result += " " + s[j].text;
|
|
4142
|
-
} else if (gap > spaceGapThreshold(avgFs) || _optionalChain([tracked, 'optionalAccess',
|
|
4162
|
+
} else if (gap > spaceGapThreshold(avgFs) || _optionalChain([tracked, 'optionalAccess', _129 => _129[j]])) {
|
|
4143
4163
|
result += " " + s[j].text;
|
|
4144
4164
|
} else {
|
|
4145
4165
|
result += s[j].text;
|
|
@@ -4266,12 +4286,12 @@ function markEvenRun(items, visible, result, start, end) {
|
|
|
4266
4286
|
}
|
|
4267
4287
|
function mergeCellTextLines(textLines, wrap) {
|
|
4268
4288
|
if (textLines.length <= 1) return textLines[0] || "";
|
|
4269
|
-
const numberWrapped = (k) => !!_optionalChain([wrap, 'optionalAccess',
|
|
4289
|
+
const numberWrapped = (k) => !!_optionalChain([wrap, 'optionalAccess', _130 => _130.wraps, 'access', _131 => _131[k]]) && (_nullishCoalesce(_optionalChain([wrap, 'access', _132 => _132.wide, 'optionalAccess', _133 => _133[k]]), () => ( true)));
|
|
4270
4290
|
const merged = [textLines[0]];
|
|
4271
4291
|
for (let i = 1; i < textLines.length; i++) {
|
|
4272
4292
|
const prev = merged[merged.length - 1];
|
|
4273
4293
|
const curr = textLines[i];
|
|
4274
|
-
if (wrap ? wrap.wraps[i - 1] && !_optionalChain([wrap, 'access',
|
|
4294
|
+
if (wrap ? wrap.wraps[i - 1] && !_optionalChain([wrap, 'access', _134 => _134.spaced, 'optionalAccess', _135 => _135[i - 1]]) && !startsNewItem(prev, curr) && wrapJoiner(prev, curr, wrap.lex, false) === "" : /[가-힣]$/.test(prev) && /^[가-힣]+$/.test(curr) && curr.length <= 8 && !curr.includes(" ")) {
|
|
4275
4295
|
merged[merged.length - 1] = prev + curr;
|
|
4276
4296
|
} else if (curr.trim().length <= 3 && /^[)\]%}]/.test(curr.trim())) {
|
|
4277
4297
|
merged[merged.length - 1] = prev + curr.trim();
|
|
@@ -4411,34 +4431,34 @@ function normalizeUndersegmentedTable(originalCells, colXs, items, rowYs, kept,
|
|
|
4411
4431
|
if (numRows > maxRows || numCols < MIN_UNDERSEGMENTED_COLUMNS) return null;
|
|
4412
4432
|
if (items.length === 0) return null;
|
|
4413
4433
|
if (numRows >= 3) {
|
|
4414
|
-
if (_optionalChain([rowYs, 'optionalAccess',
|
|
4434
|
+
if (_optionalChain([rowYs, 'optionalAccess', _136 => _136.length]) !== numRows + 1) return null;
|
|
4415
4435
|
const rebuilt2 = [];
|
|
4416
4436
|
let expanded = 0;
|
|
4417
4437
|
const ocr = items.every((it) => it.fontName === "ocr");
|
|
4418
4438
|
for (let r = 0; r < numRows; r++) {
|
|
4419
4439
|
const row = originalCells[r].map((cell) => cell.text);
|
|
4420
4440
|
if (r === 0 || numRows === 3 && r === 1) {
|
|
4421
|
-
_optionalChain([kept, 'optionalAccess',
|
|
4441
|
+
_optionalChain([kept, 'optionalAccess', _137 => _137.set, 'call', _138 => _138(rebuilt2.length, r)]);
|
|
4422
4442
|
rebuilt2.push(row);
|
|
4423
4443
|
continue;
|
|
4424
4444
|
}
|
|
4425
4445
|
const span2 = Math.min(numRows - r, Math.max(1, ...originalCells[r].map((cell) => _nullishCoalesce(cell.rowSpan, () => ( 1)))));
|
|
4426
4446
|
const filled = originalCells[r].filter((cell) => cell.text.trim());
|
|
4427
4447
|
const spanning = filled.filter((cell) => (_nullishCoalesce(cell.rowSpan, () => ( 1))) >= span2);
|
|
4428
|
-
const loose = ocr && filled.length >= MIN_UNDERSEGMENTED_COLUMNS && spanning.length * 2 > filled.length && originalCells.slice(r + 1, r + span2).every((cells) => cells.every((cell, c) => !cell.text.trim() || (_nullishCoalesce(_optionalChain([originalCells, 'access',
|
|
4448
|
+
const loose = ocr && filled.length >= MIN_UNDERSEGMENTED_COLUMNS && spanning.length * 2 > filled.length && originalCells.slice(r + 1, r + span2).every((cells) => cells.every((cell, c) => !cell.text.trim() || (_nullishCoalesce(_optionalChain([originalCells, 'access', _139 => _139[r], 'access', _140 => _140[c], 'optionalAccess', _141 => _141.rowSpan]), () => ( 1))) === 1));
|
|
4429
4449
|
const band = span2 > 1 && (loose || originalCells.slice(r + 1, r + span2).every((cells) => cells.every((cell) => !cell.text.trim()))) ? span2 : 1;
|
|
4430
4450
|
const rowItems = items.filter((item) => itemCenterY(item) <= rowYs[r] + 1 && itemCenterY(item) >= rowYs[r + band] - 1);
|
|
4431
4451
|
const body = normalizeUndersegmentedTable([originalCells[r]], colXs, rowItems, void 0, void 0, void 0, band > 1 ? 2 : MIN_ALIGNED_LINES);
|
|
4432
4452
|
if (body) {
|
|
4433
4453
|
originalCells[r].forEach((cell, c) => {
|
|
4434
4454
|
const cols = Array.from({ length: Math.max(1, _nullishCoalesce(cell.colSpan, () => ( 1))) }, (_, k) => c + k);
|
|
4435
|
-
if (cell.text.trim() && body.every((cells) => cols.every((k) => !_optionalChain([cells, 'access',
|
|
4455
|
+
if (cell.text.trim() && body.every((cells) => cols.every((k) => !_optionalChain([cells, 'access', _142 => _142[k], 'optionalAccess', _143 => _143.trim, 'call', _144 => _144()])))) body[0][c] = cell.text;
|
|
4436
4456
|
});
|
|
4437
4457
|
rebuilt2.push(...body);
|
|
4438
4458
|
expanded++;
|
|
4439
4459
|
r += band - 1;
|
|
4440
4460
|
} else {
|
|
4441
|
-
_optionalChain([kept, 'optionalAccess',
|
|
4461
|
+
_optionalChain([kept, 'optionalAccess', _145 => _145.set, 'call', _146 => _146(rebuilt2.length, r)]);
|
|
4442
4462
|
rebuilt2.push(row);
|
|
4443
4463
|
}
|
|
4444
4464
|
}
|
|
@@ -4522,7 +4542,7 @@ function sortLineByX(items) {
|
|
|
4522
4542
|
e++;
|
|
4523
4543
|
}
|
|
4524
4544
|
const run = items.slice(s, e), seqs = run.map((i) => i.seq);
|
|
4525
|
-
const ok = !wide ? !run.some((i) => _optionalChain([i, 'access',
|
|
4545
|
+
const ok = !wide ? !run.some((i) => _optionalChain([i, 'access', _147 => _147.text, 'optionalAccess', _148 => _148.startsWith, 'call', _149 => _149("$")])) : Math.max(...seqs) - Math.min(...seqs) <= 2 * (e - s - 1) && run.every((i) => Math.abs((_nullishCoalesce(i.fontSize, () => ( 0))) - (_nullishCoalesce(run[0].fontSize, () => ( 0)))) <= 0.5);
|
|
4526
4546
|
if (e - s > 1 && seqs.every((q) => q !== void 0) && ok) {
|
|
4527
4547
|
run.sort((a, b) => a.seq - b.seq);
|
|
4528
4548
|
for (let k = 0; k < run.length; k++) items[s + k] = run[k];
|
|
@@ -4597,7 +4617,7 @@ function dominantStyle(items) {
|
|
|
4597
4617
|
let maxCount = 0, dominantSize = 0;
|
|
4598
4618
|
for (const i of items) {
|
|
4599
4619
|
if (i.fontSize <= 0) continue;
|
|
4600
|
-
const count = (freq.get(i.fontSize) || 0) + Math.max(1, _nullishCoalesce(_optionalChain([i, 'access',
|
|
4620
|
+
const count = (freq.get(i.fontSize) || 0) + Math.max(1, _nullishCoalesce(_optionalChain([i, 'access', _150 => _150.text, 'access', _151 => _151.match, 'call', _152 => _152(/[\p{L}\p{N}]/gu), 'optionalAccess', _153 => _153.length]), () => ( 0)));
|
|
4601
4621
|
freq.set(i.fontSize, count);
|
|
4602
4622
|
if (count > maxCount) {
|
|
4603
4623
|
maxCount = count;
|
|
@@ -4605,7 +4625,7 @@ function dominantStyle(items) {
|
|
|
4605
4625
|
}
|
|
4606
4626
|
}
|
|
4607
4627
|
if (dominantSize === 0) return void 0;
|
|
4608
|
-
const fontName = _optionalChain([items, 'access',
|
|
4628
|
+
const fontName = _optionalChain([items, 'access', _154 => _154.find, 'call', _155 => _155((i) => i.fontSize === dominantSize), 'optionalAccess', _156 => _156.fontName]) || void 0;
|
|
4609
4629
|
return fontName ? { fontSize: dominantSize, fontName } : { fontSize: dominantSize };
|
|
4610
4630
|
}
|
|
4611
4631
|
function normalizeItems(rawItems) {
|
|
@@ -4760,7 +4780,7 @@ function splitAroundOverlays(c, overlays) {
|
|
|
4760
4780
|
const ov = overlays.filter((o) => {
|
|
4761
4781
|
for (let at = c.text.indexOf(o.text); at >= 0; at = c.text.indexOf(o.text, at + 1)) {
|
|
4762
4782
|
const prefix = c.text.slice(0, at);
|
|
4763
|
-
const est = c.x + glyphUnits(prefix.replace(/\s+/g, "")) * a0 + (_nullishCoalesce(_optionalChain([prefix, 'access',
|
|
4783
|
+
const est = c.x + glyphUnits(prefix.replace(/\s+/g, "")) * a0 + (_nullishCoalesce(_optionalChain([prefix, 'access', _157 => _157.match, 'call', _158 => _158(/\s+/g), 'optionalAccess', _159 => _159.length]), () => ( 0))) * ws;
|
|
4764
4784
|
if (Math.abs(est - o.x) <= OVERLAY_DUP_EM * fs) return false;
|
|
4765
4785
|
}
|
|
4766
4786
|
return true;
|
|
@@ -4922,7 +4942,7 @@ function trackedSpaces(sorted, med = trackingShift([sorted])) {
|
|
|
4922
4942
|
});
|
|
4923
4943
|
}
|
|
4924
4944
|
function mergeLineSimple(items) {
|
|
4925
|
-
if (items.length <= 1) return _optionalChain([items, 'access',
|
|
4945
|
+
if (items.length <= 1) return _optionalChain([items, 'access', _160 => _160[0], 'optionalAccess', _161 => _161.text]) || "";
|
|
4926
4946
|
const sorted = sortLineByX([...items]);
|
|
4927
4947
|
const tracked = trackedSpaces(sorted);
|
|
4928
4948
|
const isEvenSpaced = detectEvenSpacedItems(sorted);
|
|
@@ -4957,7 +4977,7 @@ function mergeLineSimple(items) {
|
|
|
4957
4977
|
result += sorted[i].text;
|
|
4958
4978
|
continue;
|
|
4959
4979
|
}
|
|
4960
|
-
if (gap > spaceGapThreshold(avgFs) || _optionalChain([tracked, 'optionalAccess',
|
|
4980
|
+
if (gap > spaceGapThreshold(avgFs) || _optionalChain([tracked, 'optionalAccess', _162 => _162[i]])) result += " ";
|
|
4961
4981
|
result += sorted[i].text;
|
|
4962
4982
|
}
|
|
4963
4983
|
return result;
|
|
@@ -5014,7 +5034,7 @@ function isProseTable(table) {
|
|
|
5014
5034
|
if (!(long > 0 && long >= total * 0.5 && longRows >= rows * 0.4)) return false;
|
|
5015
5035
|
for (let c = 0; c < table.cols; c++) {
|
|
5016
5036
|
const filled = table.cells.map((row) => row[c]).filter((cell) => cell && cell.colSpan < table.cols && cell.text.trim()).map((cell) => cell.text.trim());
|
|
5017
|
-
if (filled.length >= 3 && filled.length >= rows * 0.6 && filled.every((text) => text.length <= 30 && (_nullishCoalesce(_optionalChain([text, 'access',
|
|
5037
|
+
if (filled.length >= 3 && filled.length >= rows * 0.6 && filled.every((text) => text.length <= 30 && (_nullishCoalesce(_optionalChain([text, 'access', _163 => _163.match, 'call', _164 => _164(/\p{L}/gu), 'optionalAccess', _165 => _165.length]), () => ( 0))) >= 2)) return false;
|
|
5018
5038
|
}
|
|
5019
5039
|
return true;
|
|
5020
5040
|
}
|
|
@@ -5043,7 +5063,7 @@ var TICK = /^-?[\d,]+(?:\.\d+)?%?$/;
|
|
|
5043
5063
|
var QUANTITY = /^[-−–]?[\d,]*\.?\d+%?$/;
|
|
5044
5064
|
var quantity = (token) => Number(token.replace(/^[−–]/, "-").replace(/[,%]/g, ""));
|
|
5045
5065
|
function isValueAxisColumn(table, c) {
|
|
5046
|
-
const lines = table.cells.flatMap((row) => (_nullishCoalesce(_optionalChain([row, 'access',
|
|
5066
|
+
const lines = table.cells.flatMap((row) => (_nullishCoalesce(_optionalChain([row, 'access', _166 => _166[c], 'optionalAccess', _167 => _167.text]), () => ( ""))).split("\n").map((line) => line.trim().split(/\s+/)));
|
|
5047
5067
|
const others = table.cells.flatMap((row) => row.filter((_, k) => k !== c).map((cell) => cell.text.trim().split(/\s+/))).filter((tokens) => tokens.every((token) => QUANTITY.test(token))).flat().map(quantity).filter((v) => !(Number.isInteger(v) && v >= 1900 && v <= 2100));
|
|
5048
5068
|
for (const ticks of [lines.flat().filter((t) => TICK.test(t)).map(quantity), lines.map((tokens) => tokens[0]).filter((t) => TICK.test(t)).map(quantity)]) {
|
|
5049
5069
|
const run = fallingRun(ticks);
|
|
@@ -5076,7 +5096,7 @@ function isChartTable(table, ocr = false) {
|
|
|
5076
5096
|
if (numeric < texts.length * 0.5) return false;
|
|
5077
5097
|
if (ocr && table.cols >= 3 && table.cells.slice(0, 3).some((row) => row.filter((cell) => /[가-힣]{2}/.test(cell.text)).length >= 2)) return false;
|
|
5078
5098
|
for (let c = 0; c < table.cols; c++) {
|
|
5079
|
-
if (!ocr ? isValueAxisColumn(table, c) : hasValueAxis(table.cells.flatMap((row) => (_nullishCoalesce(_optionalChain([row, 'access',
|
|
5099
|
+
if (!ocr ? isValueAxisColumn(table, c) : hasValueAxis(table.cells.flatMap((row) => (_nullishCoalesce(_optionalChain([row, 'access', _168 => _168[c], 'optionalAccess', _169 => _169.text]), () => ( ""))).split(/\s+/)).filter((t) => TICK.test(t)).map((t) => Number(t.replace(/[,%]/g, ""))))) return true;
|
|
5080
5100
|
}
|
|
5081
5101
|
const values = texts.filter((text) => text.split(/\s+/).every((token) => QUANTITY.test(token))).length;
|
|
5082
5102
|
const cells = table.rows * table.cols;
|
|
@@ -5085,7 +5105,7 @@ function isChartTable(table, ocr = false) {
|
|
|
5085
5105
|
function isProseFragmentTable(table) {
|
|
5086
5106
|
const texts = table.cells.flat().map((cell) => cell.text.trim()).filter(Boolean);
|
|
5087
5107
|
if (texts.length < 4) return false;
|
|
5088
|
-
const hangul = (text) => _nullishCoalesce(_optionalChain([text, 'access',
|
|
5108
|
+
const hangul = (text) => _nullishCoalesce(_optionalChain([text, 'access', _170 => _170.match, 'call', _171 => _171(/[가-힣]/g), 'optionalAccess', _172 => _172.length]), () => ( 0));
|
|
5089
5109
|
if (texts.filter((text) => hangul(text) >= 2).length < texts.length * 0.7) return false;
|
|
5090
5110
|
if (texts.length >= 12 && texts.filter((text) => hangul(text) >= 15 && !text.includes("\n")).length >= texts.length * 0.4) return true;
|
|
5091
5111
|
return texts.filter((text) => /(?:[다요고서는을를에게지며면어아야니까던]|[.,?!])$/.test(text)).length >= texts.length * 0.3;
|
|
@@ -5138,7 +5158,7 @@ function clusterCellLines(items) {
|
|
|
5138
5158
|
}
|
|
5139
5159
|
var WRAP_INDENT_MAX = 3;
|
|
5140
5160
|
function joinClusterCellLines(lines, box, lex) {
|
|
5141
|
-
let out = _nullishCoalesce(_optionalChain([lines, 'access',
|
|
5161
|
+
let out = _nullishCoalesce(_optionalChain([lines, 'access', _173 => _173[0], 'optionalAccess', _174 => _174.text]), () => ( ""));
|
|
5142
5162
|
for (let i = 1; i < lines.length; i++) {
|
|
5143
5163
|
const a = lines[i - 1], b = lines[i];
|
|
5144
5164
|
const join2 = !a.spaceAfter && cellLineWraps(box, box.x1, a.right, a.fontSize, b.firstCharW) && a.left - box.x1 <= WRAP_INDENT_MAX * a.fontSize && b.left - box.x1 <= WRAP_INDENT_MAX * b.fontSize && /<\/u>$/.test(a.text) === /^<u>/.test(b.text) && !startsNewItem(out, b.text) && wrapJoiner(out, b.text, lex, false) === "";
|
|
@@ -5483,7 +5503,7 @@ function detectAlignedTwoColumnTables(rows, pageNum) {
|
|
|
5483
5503
|
continue;
|
|
5484
5504
|
}
|
|
5485
5505
|
const top = rows[i - 1];
|
|
5486
|
-
const title = _optionalChain([top, 'optionalAccess',
|
|
5506
|
+
const title = _optionalChain([top, 'optionalAccess', _175 => _175.items, 'access', _176 => _176.length]) === 1 && Math.abs(top.items[0].x - first[0].x) <= 5 && top.items[0].text.length <= 65 && top.y - first[0].y <= Math.max(24, first[0].fontSize * 2.8) ? top : void 0;
|
|
5487
5507
|
const tableRows = [...title ? [title] : [], ...body.flatMap((b) => b.rows)];
|
|
5488
5508
|
const cells = [
|
|
5489
5509
|
...title ? [[{ text: title.items[0].text, colSpan: 2, rowSpan: 1 }, { text: "", colSpan: 1, rowSpan: 1 }]] : [],
|
|
@@ -5539,12 +5559,12 @@ function isTwoColumnProse(r) {
|
|
|
5539
5559
|
if (t.rows < (ocr ? 6 : 8)) return false;
|
|
5540
5560
|
const dense = [];
|
|
5541
5561
|
for (let c = 0; c < t.cols; c++) {
|
|
5542
|
-
const filled = t.cells.filter((row) => _optionalChain([row, 'access',
|
|
5562
|
+
const filled = t.cells.filter((row) => _optionalChain([row, 'access', _177 => _177[c], 'optionalAccess', _178 => _178.text, 'access', _179 => _179.trim, 'call', _180 => _180()])).length;
|
|
5543
5563
|
if (filled / t.rows >= 0.3) dense.push(c);
|
|
5544
5564
|
}
|
|
5545
5565
|
if (dense.length !== 2) return false;
|
|
5546
5566
|
for (const c of dense) {
|
|
5547
|
-
const lens = t.cells.map((row) => _nullishCoalesce(_optionalChain([row, 'access',
|
|
5567
|
+
const lens = t.cells.map((row) => _nullishCoalesce(_optionalChain([row, 'access', _181 => _181[c], 'optionalAccess', _182 => _182.text, 'access', _183 => _183.replace, 'call', _184 => _184(/\s+/g, ""), 'access', _185 => _185.length]), () => ( 0))).filter((n) => n > 0);
|
|
5548
5568
|
const avg = lens.reduce((s, v) => s + v, 0) / (lens.length || 1);
|
|
5549
5569
|
if (avg < (ocr ? 15 : 12)) return false;
|
|
5550
5570
|
}
|
|
@@ -6006,7 +6026,7 @@ function assignRowItems(items, columns, numCols, headerFace) {
|
|
|
6006
6026
|
const runs = [];
|
|
6007
6027
|
for (const it of sorted) {
|
|
6008
6028
|
const last = runs[runs.length - 1];
|
|
6009
|
-
const prev = _optionalChain([last, 'optionalAccess',
|
|
6029
|
+
const prev = _optionalChain([last, 'optionalAccess', _186 => _186[last.length - 1]]);
|
|
6010
6030
|
if (prev && it.x - (prev.x + prev.w) <= Math.max(0.5, it.fontSize * 0.05) && !it.hasSpaceBefore) last.push(it);
|
|
6011
6031
|
else runs.push([it]);
|
|
6012
6032
|
}
|
|
@@ -6057,7 +6077,7 @@ function assignRowItems(items, columns, numCols, headerFace) {
|
|
|
6057
6077
|
assignedGroups.add(gi);
|
|
6058
6078
|
usedCols.add(ci);
|
|
6059
6079
|
}
|
|
6060
|
-
const colOf = groups.map((g) => _nullishCoalesce(_optionalChain([result, 'access',
|
|
6080
|
+
const colOf = groups.map((g) => _nullishCoalesce(_optionalChain([result, 'access', _187 => _187.find, 'call', _188 => _188((a) => a.items === g), 'optionalAccess', _189 => _189.col]), () => ( -1)));
|
|
6061
6081
|
if (groups.length <= numCols && colOf.some((c, g) => g > 0 && c < colOf[g - 1])) {
|
|
6062
6082
|
const G = groups.length, cost = (g, c2) => Math.abs(groupCenters[g] - colCenters[c2]);
|
|
6063
6083
|
const best = groups.map(() => new Array(numCols).fill(Infinity)), from = groups.map(() => new Array(numCols).fill(-1));
|
|
@@ -6094,7 +6114,7 @@ function assignRowItems(items, columns, numCols, headerFace) {
|
|
|
6094
6114
|
function buildClusterTable(rows, columns, pageNum, lex) {
|
|
6095
6115
|
const numRows = rows.length;
|
|
6096
6116
|
if (numRows < MIN_ROWS || columns.length < MIN_COLS) return null;
|
|
6097
|
-
const headFaces = new Set(_optionalChain([rows, 'access',
|
|
6117
|
+
const headFaces = new Set(_optionalChain([rows, 'access', _190 => _190[0], 'optionalAccess', _191 => _191.items, 'access', _192 => _192.map, 'call', _193 => _193((i) => i.fontName)]));
|
|
6098
6118
|
const headerFace = headFaces.size === 1 && rows.slice(1).every((row) => row.items.every((i) => !headFaces.has(i.fontName))) ? [...headFaces][0] : void 0;
|
|
6099
6119
|
const assigned = rows.map((row, r) => assignRowItems(row.items, columns, columns.length, r === 0 ? headerFace : void 0));
|
|
6100
6120
|
const cuts = supportedOcrColumnCuts(assigned);
|
|
@@ -6165,7 +6185,7 @@ function buildClusterTable(rows, columns, pageNum, lex) {
|
|
|
6165
6185
|
const nonEmptyCols = cells[r].filter((c) => c.text.trim()).length;
|
|
6166
6186
|
if (nonEmptyCols !== 1) continue;
|
|
6167
6187
|
if (cells[r][0].text.trim() !== "") continue;
|
|
6168
|
-
const contentText = _optionalChain([cells, 'access',
|
|
6188
|
+
const contentText = _optionalChain([cells, 'access', _194 => _194[r], 'access', _195 => _195.find, 'call', _196 => _196((c) => c.text.trim()), 'optionalAccess', _197 => _197.text, 'access', _198 => _198.trim, 'call', _199 => _199()]) || "";
|
|
6169
6189
|
if (/^[○●▶\-·]/.test(contentText)) continue;
|
|
6170
6190
|
for (let pr = r - 1; pr >= 0; pr--) {
|
|
6171
6191
|
if (cells[pr].some((c) => c.text.trim())) {
|
|
@@ -6398,7 +6418,7 @@ function stackedTableBands(items) {
|
|
|
6398
6418
|
const caption = (start, end) => lines.slice(start, end).some((line) => /^Table\s+\d+\s*[:.]/i.test(mergeLineSimple(line).trim()));
|
|
6399
6419
|
while (runs.length > 0 && !caption(runs[runs.length - 1].end, lines.length)) runs.pop();
|
|
6400
6420
|
if (runs.length < 2) return null;
|
|
6401
|
-
if (runs.some((run, i) => !caption(run.end, _nullishCoalesce(_optionalChain([runs, 'access',
|
|
6421
|
+
if (runs.some((run, i) => !caption(run.end, _nullishCoalesce(_optionalChain([runs, 'access', _200 => _200[i + 1], 'optionalAccess', _201 => _201.start]), () => ( lines.length))))) return null;
|
|
6402
6422
|
const tables = runs.map((run) => lines.slice(run.start, run.end).flat());
|
|
6403
6423
|
const between = runs.slice(0, -1).map((run, i) => lines.slice(run.end, runs[i + 1].start).flat());
|
|
6404
6424
|
const tail = lines.slice(runs[runs.length - 1].end);
|
|
@@ -6666,7 +6686,7 @@ function splitTrailingColumnRegion(items) {
|
|
|
6666
6686
|
}
|
|
6667
6687
|
function panelBlocks(items, panel, pageNum) {
|
|
6668
6688
|
const lines = groupByY([...items].sort((a, b) => b.y - a.y || a.x - b.x));
|
|
6669
|
-
const faceOf = (line) => _nullishCoalesce(_optionalChain([dominantStyle, 'call',
|
|
6689
|
+
const faceOf = (line) => _nullishCoalesce(_optionalChain([dominantStyle, 'call', _202 => _202(line), 'optionalAccess', _203 => _203.fontName]), () => ( ""));
|
|
6670
6690
|
const runs = [];
|
|
6671
6691
|
for (const line of lines) {
|
|
6672
6692
|
const last = runs[runs.length - 1];
|
|
@@ -6873,7 +6893,7 @@ function validWrapBands(items, bands) {
|
|
|
6873
6893
|
}
|
|
6874
6894
|
function inheritedWrapBands(items) {
|
|
6875
6895
|
const source = XY_WRAP_ITEMS.get(items[0]);
|
|
6876
|
-
const present = _optionalChain([source, 'optionalAccess',
|
|
6896
|
+
const present = _optionalChain([source, 'optionalAccess', _204 => _204.length]) === items.length ? new Set(items) : null;
|
|
6877
6897
|
const sameLeaf = present && source.every((item) => present.has(item));
|
|
6878
6898
|
return sameLeaf ? validWrapBands(items, _nullishCoalesce(XY_WRAP_BANDS.get(items[0]), () => ( []))) : [];
|
|
6879
6899
|
}
|
|
@@ -6908,7 +6928,7 @@ function splitsLoneRowTail(items, x) {
|
|
|
6908
6928
|
const tail = right[0], box = computeBBox(items, 0), tailBox = computeBBox(tail, 0);
|
|
6909
6929
|
const head = left.find((r) => Math.abs(r[0].y - tail[0].y) <= 2);
|
|
6910
6930
|
if (!head) return false;
|
|
6911
|
-
const headBox = computeBBox(head, 0), fs = _nullishCoalesce(_optionalChain([dominantStyle, 'call',
|
|
6931
|
+
const headBox = computeBBox(head, 0), fs = _nullishCoalesce(_optionalChain([dominantStyle, 'call', _205 => _205(tail), 'optionalAccess', _206 => _206.fontSize]), () => ( 10));
|
|
6912
6932
|
const gap = tailBox.x - (headBox.x + headBox.width), fills = tailBox.x + tailBox.width >= box.x + box.width - fs;
|
|
6913
6933
|
if (gap <= fs * 3 && fills && headBox.width >= box.width / 2) return true;
|
|
6914
6934
|
const text = [...head, ...tail].map((i) => i.text).join("");
|
|
@@ -6924,7 +6944,7 @@ function wrappedLineBands(items, inherited, lex) {
|
|
|
6924
6944
|
left: box.x,
|
|
6925
6945
|
right: box.x + box.width,
|
|
6926
6946
|
y: row.reduce((n, i) => n + i.y, 0) / row.length,
|
|
6927
|
-
fontSize: _nullishCoalesce(_optionalChain([dominantStyle, 'call',
|
|
6947
|
+
fontSize: _nullishCoalesce(_optionalChain([dominantStyle, 'call', _207 => _207(row), 'optionalAccess', _208 => _208.fontSize]), () => ( 0)),
|
|
6928
6948
|
sources: row.map((item) => ({ item, state: { ...item } }))
|
|
6929
6949
|
};
|
|
6930
6950
|
});
|
|
@@ -7060,10 +7080,10 @@ function pushLineParagraphs(out, yLines, pageNum, lex) {
|
|
|
7060
7080
|
const lines = attachDropCaps(yLines).map((items) => ({ items, text: mergeLineSimple(items) })).filter((l) => l.text.trim());
|
|
7061
7081
|
const geo = lines.map((l) => {
|
|
7062
7082
|
const b = computeBBox(l.items, pageNum);
|
|
7063
|
-
return { text: l.text, left: b.x, right: b.x + b.width, y: l.items.reduce((s, i) => s + i.y, 0) / l.items.length, fontSize: _nullishCoalesce(_optionalChain([dominantStyle, 'call',
|
|
7083
|
+
return { text: l.text, left: b.x, right: b.x + b.width, y: l.items.reduce((s, i) => s + i.y, 0) / l.items.length, fontSize: _nullishCoalesce(_optionalChain([dominantStyle, 'call', _209 => _209(l.items), 'optionalAccess', _210 => _210.fontSize]), () => ( 0)) };
|
|
7064
7084
|
});
|
|
7065
7085
|
const joins = bodyLineJoins(geo, lex);
|
|
7066
|
-
const first = _optionalChain([lines, 'access',
|
|
7086
|
+
const first = _optionalChain([lines, 'access', _211 => _211[0], 'optionalAccess', _212 => _212.items, 'access', _213 => _213[0]]);
|
|
7067
7087
|
const bands = first ? _nullishCoalesce(XY_WRAP_BANDS.get(first), () => ( [])) : [];
|
|
7068
7088
|
const hasBand = (top, bottom) => {
|
|
7069
7089
|
let lo = 0, hi = bands.length;
|
|
@@ -7140,15 +7160,15 @@ function computeMedianFontSizeFromFreq(freq) {
|
|
|
7140
7160
|
function detectHeadings(blocks, medianFontSize) {
|
|
7141
7161
|
for (let bi = 0; bi < blocks.length; bi++) {
|
|
7142
7162
|
const block = blocks[bi];
|
|
7143
|
-
if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access',
|
|
7163
|
+
if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access', _214 => _214.style, 'optionalAccess', _215 => _215.fontSize])) continue;
|
|
7144
7164
|
const text = block.text.trim();
|
|
7145
7165
|
if (text.length === 0 || text.length > 200) continue;
|
|
7146
7166
|
if (/^\d+$/.test(text) && !isChapterNumber(block, blocks[bi + 1], medianFontSize)) continue;
|
|
7147
7167
|
const ratio = block.style.fontSize / medianFontSize;
|
|
7148
7168
|
let level = 0;
|
|
7149
|
-
if (ratio >=
|
|
7150
|
-
else if (ratio >=
|
|
7151
|
-
else if (ratio >=
|
|
7169
|
+
if (ratio >= _chunk5MBQW3KPcjs.HEADING_RATIO_H1) level = 1;
|
|
7170
|
+
else if (ratio >= _chunk5MBQW3KPcjs.HEADING_RATIO_H2) level = 2;
|
|
7171
|
+
else if (ratio >= _chunk5MBQW3KPcjs.HEADING_RATIO_H3) level = 3;
|
|
7152
7172
|
if (level > 0) {
|
|
7153
7173
|
block.type = "heading";
|
|
7154
7174
|
block.level = level;
|
|
@@ -7157,21 +7177,21 @@ function detectHeadings(blocks, medianFontSize) {
|
|
|
7157
7177
|
}
|
|
7158
7178
|
}
|
|
7159
7179
|
function isChapterNumber(block, next, medianFontSize) {
|
|
7160
|
-
const size = _nullishCoalesce(_optionalChain([block, 'access',
|
|
7161
|
-
const nextSize = _nullishCoalesce(_optionalChain([next, 'optionalAccess',
|
|
7162
|
-
const text = _nullishCoalesce(_optionalChain([next, 'optionalAccess',
|
|
7163
|
-
const a = block.bbox, b = _optionalChain([next, 'optionalAccess',
|
|
7164
|
-
return /^\d{1,2}$/.test(_nullishCoalesce(_optionalChain([block, 'access',
|
|
7180
|
+
const size = _nullishCoalesce(_optionalChain([block, 'access', _216 => _216.style, 'optionalAccess', _217 => _217.fontSize]), () => ( 0));
|
|
7181
|
+
const nextSize = _nullishCoalesce(_optionalChain([next, 'optionalAccess', _218 => _218.style, 'optionalAccess', _219 => _219.fontSize]), () => ( 0));
|
|
7182
|
+
const text = _nullishCoalesce(_optionalChain([next, 'optionalAccess', _220 => _220.text, 'optionalAccess', _221 => _221.trim, 'call', _222 => _222()]), () => ( ""));
|
|
7183
|
+
const a = block.bbox, b = _optionalChain([next, 'optionalAccess', _223 => _223.bbox]);
|
|
7184
|
+
return /^\d{1,2}$/.test(_nullishCoalesce(_optionalChain([block, 'access', _224 => _224.text, 'optionalAccess', _225 => _225.trim, 'call', _226 => _226()]), () => ( ""))) && size >= medianFontSize * 2.5 && !!next && (next.type === "paragraph" || next.type === "heading") && next.pageNumber === block.pageNumber && nextSize >= medianFontSize * _chunk5MBQW3KPcjs.HEADING_RATIO_H1 && text.length > 0 && text.length <= 80 && !/^[\d\s.]+$/.test(text) && !!a && !!b && a.y > b.y && a.y - (b.y + b.height) <= size * 2;
|
|
7165
7185
|
}
|
|
7166
7186
|
function mergeStackedHeadingLines(blocks, medianFontSize) {
|
|
7167
7187
|
for (let i = 0; i < blocks.length - 1; ) {
|
|
7168
7188
|
const a = blocks[i], b = blocks[i + 1];
|
|
7169
7189
|
const ab = a.bbox, bb = b.bbox;
|
|
7170
|
-
const af = _nullishCoalesce(_optionalChain([a, 'access',
|
|
7190
|
+
const af = _nullishCoalesce(_optionalChain([a, 'access', _227 => _227.style, 'optionalAccess', _228 => _228.fontSize]), () => ( 0)), bf = _nullishCoalesce(_optionalChain([b, 'access', _229 => _229.style, 'optionalAccess', _230 => _230.fontSize]), () => ( 0));
|
|
7171
7191
|
const gap = ab && bb ? ab.y - (bb.y + bb.height) : Infinity;
|
|
7172
|
-
const centered = ab && bb && _optionalChain([a, 'access',
|
|
7192
|
+
const centered = ab && bb && _optionalChain([a, 'access', _231 => _231.style, 'optionalAccess', _232 => _232.fontName]) === _optionalChain([b, 'access', _233 => _233.style, 'optionalAccess', _234 => _234.fontName]) && Math.abs(ab.x + ab.width / 2 - (bb.x + bb.width / 2)) <= Math.max(5, af * 0.5);
|
|
7173
7193
|
const sameAnchor = ab && bb && Math.abs(ab.x - bb.x) <= 5;
|
|
7174
|
-
const wrapped = sameAnchor && _optionalChain([a, 'access',
|
|
7194
|
+
const wrapped = sameAnchor && _optionalChain([a, 'access', _235 => _235.style, 'optionalAccess', _236 => _236.fontName]) === _optionalChain([b, 'access', _237 => _237.style, 'optionalAccess', _238 => _238.fontName]) && af === bf && ab.width >= bb.width * 0.95 && (_nullishCoalesce(_optionalChain([a, 'access', _239 => _239.text, 'optionalAccess', _240 => _240.trim, 'call', _241 => _241(), 'access', _242 => _242.split, 'call', _243 => _243(/\s+/), 'access', _244 => _244.length]), () => ( 0))) >= 3;
|
|
7175
7195
|
const displayStack = centered && gap <= Math.min(af, bf) * 0.3 && Math.max(af, bf) <= Math.min(af, bf) * 1.45;
|
|
7176
7196
|
if (a.type !== "heading" || b.type !== "heading" || !a.text || !b.text || /^\d+$/.test(a.text.trim()) || !ab || !bb || ab.page !== bb.page || !(sameAnchor && af >= medianFontSize * 2 && bf >= medianFontSize * 2) && !wrapped && !(centered && af >= medianFontSize * 1.25 && bf >= medianFontSize * 1.25) || Math.abs(af - bf) > Math.max(af, bf) * 0.15 && !displayStack || gap < -2 || gap > Math.max(af, bf) * 0.45 || a.text.length > (centered ? 120 : 50) || b.text.length > (centered ? 120 : 50)) {
|
|
7177
7197
|
i++;
|
|
@@ -7200,25 +7220,25 @@ function detectTypographyHeadings(blocks) {
|
|
|
7200
7220
|
if (page.some((block) => block.type === "heading")) continue;
|
|
7201
7221
|
const faceWeight = /* @__PURE__ */ new Map();
|
|
7202
7222
|
for (const block of page) {
|
|
7203
|
-
if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access',
|
|
7223
|
+
if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access', _245 => _245.style, 'optionalAccess', _246 => _246.fontName])) continue;
|
|
7204
7224
|
const faces = FACE_CHARS.get(block);
|
|
7205
7225
|
if (faces) for (const [face, n] of faces) faceWeight.set(face, (_nullishCoalesce(faceWeight.get(face), () => ( 0))) + n);
|
|
7206
7226
|
else faceWeight.set(block.style.fontName, (_nullishCoalesce(faceWeight.get(block.style.fontName), () => ( 0))) + block.text.length);
|
|
7207
7227
|
}
|
|
7208
|
-
const bodyFace = _optionalChain([[...faceWeight], 'access',
|
|
7228
|
+
const bodyFace = _optionalChain([[...faceWeight], 'access', _247 => _247.sort, 'call', _248 => _248((a, b) => b[1] - a[1]), 'access', _249 => _249[0], 'optionalAccess', _250 => _250[0]]);
|
|
7209
7229
|
if (!bodyFace || (_nullishCoalesce(faceWeight.get(bodyFace), () => ( 0))) < 250) continue;
|
|
7210
7230
|
const sizeWeight = /* @__PURE__ */ new Map();
|
|
7211
7231
|
for (const block of page) {
|
|
7212
|
-
if (block.type !== "paragraph" || !_optionalChain([block, 'access',
|
|
7232
|
+
if (block.type !== "paragraph" || !_optionalChain([block, 'access', _251 => _251.style, 'optionalAccess', _252 => _252.fontSize])) continue;
|
|
7213
7233
|
const faces = FACE_CHARS.get(block);
|
|
7214
|
-
const chars = faces ? _nullishCoalesce(faces.get(bodyFace), () => ( 0)) : block.style.fontName === bodyFace ? _nullishCoalesce(_optionalChain([block, 'access',
|
|
7234
|
+
const chars = faces ? _nullishCoalesce(faces.get(bodyFace), () => ( 0)) : block.style.fontName === bodyFace ? _nullishCoalesce(_optionalChain([block, 'access', _253 => _253.text, 'optionalAccess', _254 => _254.length]), () => ( 0)) : 0;
|
|
7215
7235
|
if (chars) sizeWeight.set(block.style.fontSize, (_nullishCoalesce(sizeWeight.get(block.style.fontSize), () => ( 0))) + chars);
|
|
7216
7236
|
}
|
|
7217
|
-
const bodySize = _nullishCoalesce(_optionalChain([[...sizeWeight], 'access',
|
|
7237
|
+
const bodySize = _nullishCoalesce(_optionalChain([[...sizeWeight], 'access', _255 => _255.sort, 'call', _256 => _256((a, b) => b[1] - a[1]), 'access', _257 => _257[0], 'optionalAccess', _258 => _258[0]]), () => ( 0));
|
|
7218
7238
|
for (let i = 0; i < page.length; i++) {
|
|
7219
7239
|
const block = page[i];
|
|
7220
7240
|
const { text, bbox, style } = block;
|
|
7221
|
-
if (block.type !== "paragraph" || !text || !bbox || !_optionalChain([style, 'optionalAccess',
|
|
7241
|
+
if (block.type !== "paragraph" || !text || !bbox || !_optionalChain([style, 'optionalAccess', _259 => _259.fontName]) || !style.fontSize) continue;
|
|
7222
7242
|
const title = text.trim();
|
|
7223
7243
|
const numbered = /^\d+(?:\.\d+)*\.?\s+[A-Z가-힣]/.test(title);
|
|
7224
7244
|
const faces = FACE_CHARS.get(block);
|
|
@@ -7248,16 +7268,16 @@ function detectDocumentStyleHeadings(blocks) {
|
|
|
7248
7268
|
for (const page of byPage.values()) {
|
|
7249
7269
|
const faceChars = /* @__PURE__ */ new Map();
|
|
7250
7270
|
for (const block of page) {
|
|
7251
|
-
if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access',
|
|
7271
|
+
if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access', _260 => _260.style, 'optionalAccess', _261 => _261.fontName])) continue;
|
|
7252
7272
|
faceChars.set(block.style.fontName, (_nullishCoalesce(faceChars.get(block.style.fontName), () => ( 0))) + block.text.length);
|
|
7253
7273
|
}
|
|
7254
|
-
const bodyFace = _optionalChain([[...faceChars], 'access',
|
|
7274
|
+
const bodyFace = _optionalChain([[...faceChars], 'access', _262 => _262.sort, 'call', _263 => _263((a, b) => b[1] - a[1]), 'access', _264 => _264[0], 'optionalAccess', _265 => _265[0]]);
|
|
7255
7275
|
if (!bodyFace || (_nullishCoalesce(faceChars.get(bodyFace), () => ( 0))) < 100) continue;
|
|
7256
|
-
const labels = page.filter((b) => b.type === "paragraph" && b.text && b.bbox && _optionalChain([b, 'access',
|
|
7276
|
+
const labels = page.filter((b) => b.type === "paragraph" && b.text && b.bbox && _optionalChain([b, 'access', _266 => _266.style, 'optionalAccess', _267 => _267.fontName]) && b.style.fontName !== bodyFace && b.text.trim().length >= 3 && b.text.trim().length <= 40);
|
|
7257
7277
|
for (const label of labels) {
|
|
7258
|
-
const peers = labels.filter((b) => _optionalChain([b, 'access',
|
|
7278
|
+
const peers = labels.filter((b) => _optionalChain([b, 'access', _268 => _268.style, 'optionalAccess', _269 => _269.fontName]) === _optionalChain([label, 'access', _270 => _270.style, 'optionalAccess', _271 => _271.fontName]) && Math.abs(b.bbox.y - label.bbox.y) <= 3 && Math.abs(b.bbox.x - label.bbox.x) >= 60);
|
|
7259
7279
|
if (peers.length < 2) continue;
|
|
7260
|
-
const value = page.find((b) => b.type === "paragraph" && b.bbox && _optionalChain([b, 'access',
|
|
7280
|
+
const value = page.find((b) => b.type === "paragraph" && b.bbox && _optionalChain([b, 'access', _272 => _272.style, 'optionalAccess', _273 => _273.fontName]) !== _optionalChain([label, 'access', _274 => _274.style, 'optionalAccess', _275 => _275.fontName]) && b.bbox.x >= label.bbox.x - 5 && b.bbox.x <= label.bbox.x + 20 && b.bbox.y < label.bbox.y && label.bbox.y - (b.bbox.y + b.bbox.height) <= 60);
|
|
7261
7281
|
if (value) {
|
|
7262
7282
|
label.type = "heading";
|
|
7263
7283
|
label.level = 2;
|
|
@@ -7266,7 +7286,7 @@ function detectDocumentStyleHeadings(blocks) {
|
|
|
7266
7286
|
const first = page.find((b) => b.type !== "image" && b.type !== "separator");
|
|
7267
7287
|
const second = page[page.indexOf(first) + 1];
|
|
7268
7288
|
const third = page[page.indexOf(first) + 2];
|
|
7269
|
-
if (!first || !second || !third || first.type !== "list" && first.type !== "paragraph" || second.type !== "paragraph" || !first.text || !second.text || !first.bbox || !second.bbox || !_optionalChain([first, 'access',
|
|
7289
|
+
if (!first || !second || !third || first.type !== "list" && first.type !== "paragraph" || second.type !== "paragraph" || !first.text || !second.text || !first.bbox || !second.bbox || !_optionalChain([first, 'access', _276 => _276.style, 'optionalAccess', _277 => _277.fontName]) || !_optionalChain([second, 'access', _278 => _278.style, 'optionalAccess', _279 => _279.fontName]) || !/^\d+(?:\.\d+)*\.\s+/.test(first.text.trim()) || first.style.fontName === bodyFace || second.style.fontName === bodyFace || first.text.length + second.text.length > 140 || Math.abs(first.bbox.x - second.bbox.x) > 30 || first.bbox.y - (second.bbox.y + second.bbox.height) > (_nullishCoalesce(first.style.fontSize, () => ( 0))) * 1.5 || _optionalChain([third, 'access', _280 => _280.style, 'optionalAccess', _281 => _281.fontName]) !== bodyFace) continue;
|
|
7270
7290
|
first.type = "heading";
|
|
7271
7291
|
first.level = 1;
|
|
7272
7292
|
first.text = `${first.text.trim()} ${second.text.trim()}`;
|
|
@@ -7290,18 +7310,18 @@ function detectSiblingStyleHeadings(blocks) {
|
|
|
7290
7310
|
for (const page of byPage.values()) {
|
|
7291
7311
|
const bodyChars = /* @__PURE__ */ new Map();
|
|
7292
7312
|
for (const block of page) {
|
|
7293
|
-
if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access',
|
|
7313
|
+
if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access', _282 => _282.style, 'optionalAccess', _283 => _283.fontName])) continue;
|
|
7294
7314
|
const face = block.style.fontName;
|
|
7295
7315
|
bodyChars.set(face, (_nullishCoalesce(bodyChars.get(face), () => ( 0))) + block.text.length);
|
|
7296
7316
|
}
|
|
7297
|
-
const bodyFace = _optionalChain([[...bodyChars], 'access',
|
|
7298
|
-
const anchors = page.filter((b) => b.type === "heading" && b.text && _optionalChain([b, 'access',
|
|
7317
|
+
const bodyFace = _optionalChain([[...bodyChars], 'access', _284 => _284.sort, 'call', _285 => _285((a, b) => b[1] - a[1]), 'access', _286 => _286[0], 'optionalAccess', _287 => _287[0]]);
|
|
7318
|
+
const anchors = page.filter((b) => b.type === "heading" && b.text && _optionalChain([b, 'access', _288 => _288.style, 'optionalAccess', _289 => _289.fontName]) && b.style.fontName !== bodyFace);
|
|
7299
7319
|
for (const anchor of anchors) {
|
|
7300
7320
|
const numbered = /^([A-Z])\.\d+\s+/.exec(anchor.text.trim());
|
|
7301
7321
|
const lettered = /^([A-Z])\s+/.exec(anchor.text.trim());
|
|
7302
|
-
const peers = anchors.filter((b) => _optionalChain([b, 'access',
|
|
7322
|
+
const peers = anchors.filter((b) => _optionalChain([b, 'access', _290 => _290.style, 'optionalAccess', _291 => _291.fontName]) === _optionalChain([anchor, 'access', _292 => _292.style, 'optionalAccess', _293 => _293.fontName]) && Math.abs((_nullishCoalesce(_optionalChain([b, 'access', _294 => _294.style, 'optionalAccess', _295 => _295.fontSize]), () => ( 0))) - (_nullishCoalesce(_optionalChain([anchor, 'access', _296 => _296.style, 'optionalAccess', _297 => _297.fontSize]), () => ( 0)))) < 0.5);
|
|
7303
7323
|
if (peers.length < 2 && !numbered && !lettered) continue;
|
|
7304
|
-
const candidates = page.filter((b) => b.type === "paragraph" && b.text && b.bbox && _optionalChain([b, 'access',
|
|
7324
|
+
const candidates = page.filter((b) => b.type === "paragraph" && b.text && b.bbox && _optionalChain([b, 'access', _298 => _298.style, 'optionalAccess', _299 => _299.fontName]) === _optionalChain([anchor, 'access', _300 => _300.style, 'optionalAccess', _301 => _301.fontName]) && Math.abs((_nullishCoalesce(_optionalChain([b, 'access', _302 => _302.style, 'optionalAccess', _303 => _303.fontSize]), () => ( 0))) - (_nullishCoalesce(_optionalChain([anchor, 'access', _304 => _304.style, 'optionalAccess', _305 => _305.fontSize]), () => ( 0)))) < 0.5 && b.text.trim().length >= 3 && b.text.trim().length <= 80 && b.bbox.height <= (_nullishCoalesce(_optionalChain([b, 'access', _306 => _306.style, 'optionalAccess', _307 => _307.fontSize]), () => ( 0))) * 1.6 && /^[A-Z]/.test(b.text.trim()) && !/[.!?:;,]$/.test(b.text.trim()) && !/^(?:Table|Figure|Fig\.?|Appendix)\s+\d/i.test(b.text.trim()));
|
|
7305
7325
|
const siblings = candidates.filter((b) => numbered ? new RegExp(`^${numbered[1]}\\.\\d+\\s+`).test(b.text.trim()) : lettered ? /^[A-Z]\s+/.test(b.text.trim()) && Math.abs(anchor.bbox.x - b.bbox.x) < 8 : peers.some((h) => h.bbox && Math.abs(h.bbox.x - b.bbox.x) < 8));
|
|
7306
7326
|
if (siblings.length < (numbered || lettered ? 1 : 2)) continue;
|
|
7307
7327
|
for (const sibling of siblings) {
|
|
@@ -7320,13 +7340,13 @@ function detectRepeatedPageLabels(blocks) {
|
|
|
7320
7340
|
}
|
|
7321
7341
|
for (const page of byPage.values()) {
|
|
7322
7342
|
const bodyChars = /* @__PURE__ */ new Map();
|
|
7323
|
-
for (const b of page) if (b.type === "paragraph" && b.text && _optionalChain([b, 'access',
|
|
7343
|
+
for (const b of page) if (b.type === "paragraph" && b.text && _optionalChain([b, 'access', _308 => _308.style, 'optionalAccess', _309 => _309.fontName])) {
|
|
7324
7344
|
const faces = FACE_CHARS.get(b);
|
|
7325
7345
|
if (faces) for (const [face, n] of faces) bodyChars.set(face, (_nullishCoalesce(bodyChars.get(face), () => ( 0))) + n);
|
|
7326
7346
|
else bodyChars.set(b.style.fontName, (_nullishCoalesce(bodyChars.get(b.style.fontName), () => ( 0))) + b.text.length);
|
|
7327
7347
|
}
|
|
7328
|
-
const bodyFace = _optionalChain([[...bodyChars], 'access',
|
|
7329
|
-
const candidates = page.filter((b) => b.type === "paragraph" && b.text && b.bbox && _optionalChain([b, 'access',
|
|
7348
|
+
const bodyFace = _optionalChain([[...bodyChars], 'access', _310 => _310.sort, 'call', _311 => _311((a, b) => b[1] - a[1]), 'access', _312 => _312[0], 'optionalAccess', _313 => _313[0]]);
|
|
7349
|
+
const candidates = page.filter((b) => b.type === "paragraph" && b.text && b.bbox && _optionalChain([b, 'access', _314 => _314.style, 'optionalAccess', _315 => _315.fontName]) && b.style.fontName !== bodyFace && b.bbox.height <= (_nullishCoalesce(b.style.fontSize, () => ( 0))) * 1.6 && b.text.trim().length >= 5 && b.text.trim().length <= 80);
|
|
7330
7350
|
const groups = /* @__PURE__ */ new Map();
|
|
7331
7351
|
for (const b of candidates) {
|
|
7332
7352
|
const key = `${b.style.fontName}:${b.style.fontSize}`;
|
|
@@ -7362,19 +7382,19 @@ function detectPageLeadHeadings(blocks) {
|
|
|
7362
7382
|
for (const page of byPage.values()) {
|
|
7363
7383
|
const content = page.filter((b) => b.type !== "image" && b.type !== "separator" && !(b.type === "paragraph" && !b.style));
|
|
7364
7384
|
const [first, second, third] = content;
|
|
7365
|
-
if (!_optionalChain([first, 'optionalAccess',
|
|
7385
|
+
if (!_optionalChain([first, 'optionalAccess', _316 => _316.bbox]) || !first.text || !_optionalChain([first, 'access', _317 => _317.style, 'optionalAccess', _318 => _318.fontSize]) || !second) continue;
|
|
7366
7386
|
const firstText = first.text.trim();
|
|
7367
7387
|
const captionLike = /^(?:Figure|Fig\.?|Table|표|그림)\s*\d/i;
|
|
7368
7388
|
const hasImage = page.some((b) => b.type === "image");
|
|
7369
|
-
const firstIsTitle = first.type === "paragraph" && firstText.length >= 5 && firstText.length <= 80 && first.bbox.height <= first.style.fontSize * 1.6 && (/^(?:CONTENTS|Table of Contents)$/i.test(firstText) || hasImage && /^[A-Z]/.test(firstText) && !captionLike.test(firstText) && second.type === "paragraph" && /^[A-Z]/.test(_nullishCoalesce(_optionalChain([second, 'access',
|
|
7389
|
+
const firstIsTitle = first.type === "paragraph" && firstText.length >= 5 && firstText.length <= 80 && first.bbox.height <= first.style.fontSize * 1.6 && (/^(?:CONTENTS|Table of Contents)$/i.test(firstText) || hasImage && /^[A-Z]/.test(firstText) && !captionLike.test(firstText) && second.type === "paragraph" && /^[A-Z]/.test(_nullishCoalesce(_optionalChain([second, 'access', _319 => _319.text, 'optionalAccess', _320 => _320.trim, 'call', _321 => _321()]), () => ( ""))) && (_nullishCoalesce(_optionalChain([second, 'access', _322 => _322.text, 'optionalAccess', _323 => _323.length]), () => ( 0))) >= 100 && second.bbox && first.bbox.y - (second.bbox.y + second.bbox.height) >= first.style.fontSize);
|
|
7370
7390
|
const firstAboveProse = first.type === "paragraph" && firstText.length >= 5 && firstText.length <= 80 && first.bbox.height <= first.style.fontSize * 2 && second.type === "paragraph" && second.bbox && second.bbox.height >= first.style.fontSize * 4 && Math.abs(first.bbox.x - second.bbox.x) <= first.style.fontSize * 2 && first.bbox.y - (second.bbox.y + second.bbox.height) >= first.style.fontSize * 2 && !captionLike.test(firstText) && !/^(?:doi:|https?:|www\.)/i.test(firstText);
|
|
7371
|
-
const firstIsSection = first.type === "list" && /^\d+\.\s+[A-Z][A-Z\s]{12,}$/.test(firstText) && second.type === "paragraph" && (_nullishCoalesce(_optionalChain([second, 'access',
|
|
7391
|
+
const firstIsSection = first.type === "list" && /^\d+\.\s+[A-Z][A-Z\s]{12,}$/.test(firstText) && second.type === "paragraph" && (_nullishCoalesce(_optionalChain([second, 'access', _324 => _324.text, 'optionalAccess', _325 => _325.length]), () => ( 0))) >= 100;
|
|
7372
7392
|
if (firstIsTitle || firstAboveProse || firstIsSection) {
|
|
7373
7393
|
first.type = "heading";
|
|
7374
7394
|
first.level = 1;
|
|
7375
7395
|
}
|
|
7376
|
-
if (first.type !== "heading" || captionLike.test(firstText) || second.type !== "paragraph" || !second.text || !second.bbox || !_optionalChain([second, 'access',
|
|
7377
|
-
const distinctFace = _optionalChain([third, 'access',
|
|
7396
|
+
if (first.type !== "heading" || captionLike.test(firstText) || second.type !== "paragraph" || !second.text || !second.bbox || !_optionalChain([second, 'access', _326 => _326.style, 'optionalAccess', _327 => _327.fontName]) || !second.style.fontSize || !_optionalChain([third, 'optionalAccess', _328 => _328.text]) || !third.bbox || second.text.trim().length < 5 || second.text.trim().length > 80 || captionLike.test(second.text.trim()) || /^(?:doi:|https?:)/i.test(second.text.trim()) || second.bbox.height > second.style.fontSize * 1.6 || Math.abs(second.bbox.x - third.bbox.x) > 30) continue;
|
|
7397
|
+
const distinctFace = _optionalChain([third, 'access', _329 => _329.style, 'optionalAccess', _330 => _330.fontName]) !== second.style.fontName;
|
|
7378
7398
|
const namedContents = /^Table of Contents$/i.test(second.text.trim());
|
|
7379
7399
|
if (distinctFace && third.text.length >= 60 || namedContents) {
|
|
7380
7400
|
second.type = "heading";
|
|
@@ -7385,24 +7405,24 @@ function detectPageLeadHeadings(blocks) {
|
|
|
7385
7405
|
function refineDocumentStyleHeadings(blocks) {
|
|
7386
7406
|
const faceChars = /* @__PURE__ */ new Map();
|
|
7387
7407
|
for (const block of blocks) {
|
|
7388
|
-
if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access',
|
|
7408
|
+
if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access', _331 => _331.style, 'optionalAccess', _332 => _332.fontName])) continue;
|
|
7389
7409
|
faceChars.set(block.style.fontName, (_nullishCoalesce(faceChars.get(block.style.fontName), () => ( 0))) + block.text.length);
|
|
7390
7410
|
}
|
|
7391
7411
|
const [bodyFace, bodyChars] = _nullishCoalesce([...faceChars].sort((a, b) => b[1] - a[1])[0], () => ( []));
|
|
7392
7412
|
if (!bodyFace || !bodyChars || bodyChars < 300) return;
|
|
7393
7413
|
for (let i = 0; i < blocks.length; i++) {
|
|
7394
7414
|
const block = blocks[i];
|
|
7395
|
-
const text = _nullishCoalesce(_optionalChain([block, 'access',
|
|
7415
|
+
const text = _nullishCoalesce(_optionalChain([block, 'access', _333 => _333.text, 'optionalAccess', _334 => _334.trim, 'call', _335 => _335()]), () => ( ""));
|
|
7396
7416
|
if (block.type === "heading" && /(?:https?:\/\/|www\.|^arxiv:|^doi:)/i.test(text)) {
|
|
7397
7417
|
block.type = "paragraph";
|
|
7398
7418
|
block.level = void 0;
|
|
7399
7419
|
continue;
|
|
7400
7420
|
}
|
|
7401
7421
|
const box = block.bbox, style = block.style;
|
|
7402
|
-
if (block.type !== "paragraph" || !box || !_optionalChain([style, 'optionalAccess',
|
|
7422
|
+
if (block.type !== "paragraph" || !box || !_optionalChain([style, 'optionalAccess', _336 => _336.fontName]) || !style.fontSize || style.fontName === bodyFace || (_nullishCoalesce(faceChars.get(style.fontName), () => ( 0))) > bodyChars * 0.25 || text.length < 3 || text.length > 70 || text.includes("\n") || box.height > style.fontSize * 1.6 || /^(?:table|figure|fig\.?|source|doi:|arxiv:|https?:|www\.|[•●○▪▫⮚*∗†])/i.test(text) || /(?:https?:\/\/|www\.|@|[=¼≪þ])/i.test(text) || /^definition\s+\d+[.:]?\s+.*\b(?:is|are|means)\b/i.test(text) || /^[\d\s.,:%+\-–]+$/.test(text)) continue;
|
|
7403
7423
|
const previous = blocks[i - 1], next = blocks[i + 1];
|
|
7404
|
-
const pb = _optionalChain([previous, 'optionalAccess',
|
|
7405
|
-
if (!pb || !nb || previous.pageNumber !== block.pageNumber || next.pageNumber !== block.pageNumber || previous.type !== "paragraph" && previous.type !== "heading" || next.type !== "paragraph" || _optionalChain([next, 'access',
|
|
7424
|
+
const pb = _optionalChain([previous, 'optionalAccess', _337 => _337.bbox]), nb = _optionalChain([next, 'optionalAccess', _338 => _338.bbox]);
|
|
7425
|
+
if (!pb || !nb || previous.pageNumber !== block.pageNumber || next.pageNumber !== block.pageNumber || previous.type !== "paragraph" && previous.type !== "heading" || next.type !== "paragraph" || _optionalChain([next, 'access', _339 => _339.style, 'optionalAccess', _340 => _340.fontName]) !== bodyFace || !next.text || next.text.length < 40 || style.fontSize < (_nullishCoalesce(next.style.fontSize, () => ( 0))) * 0.95 || pb.y - (box.y + box.height) < style.fontSize * 0.5 || box.y - (nb.y + nb.height) < 0 || box.y - (nb.y + nb.height) > style.fontSize * 2 || box.x + box.width / 2 < nb.x - 10 || box.x + box.width / 2 > nb.x + nb.width + 10) continue;
|
|
7406
7426
|
block.type = "heading";
|
|
7407
7427
|
block.level = 2;
|
|
7408
7428
|
}
|
|
@@ -7452,7 +7472,7 @@ function detectMarkerHeadings(blocks) {
|
|
|
7452
7472
|
block.level = 4;
|
|
7453
7473
|
continue;
|
|
7454
7474
|
}
|
|
7455
|
-
if (/^[가-힣]{2,6}$/.test(text) && _optionalChain([block, 'access',
|
|
7475
|
+
if (/^[가-힣]{2,6}$/.test(text) && _optionalChain([block, 'access', _341 => _341.style, 'optionalAccess', _342 => _342.fontSize])) {
|
|
7456
7476
|
const prev = blocks[i - 1];
|
|
7457
7477
|
const next = blocks[i + 1];
|
|
7458
7478
|
const prevIsStructural = !prev || prev.type === "table" || prev.type === "heading" || prev.type === "separator";
|
|
@@ -7493,7 +7513,7 @@ function detectTableCaptions(blocks) {
|
|
|
7493
7513
|
block.table.caption = blocks[i - 1].text.trim();
|
|
7494
7514
|
blocks.splice(i - 1, 1);
|
|
7495
7515
|
i--;
|
|
7496
|
-
} else if (isCaptionCandidate(blocks[i + 1], block) && _optionalChain([blocks, 'access',
|
|
7516
|
+
} else if (isCaptionCandidate(blocks[i + 1], block) && _optionalChain([blocks, 'access', _343 => _343[i + 2], 'optionalAccess', _344 => _344.type]) !== "table") {
|
|
7497
7517
|
const cap = blocks[i + 1].bbox, tbl = block.bbox;
|
|
7498
7518
|
block.table.caption = blocks[i + 1].text.trim();
|
|
7499
7519
|
if (cap && tbl && cap.y + cap.height <= tbl.y + 1) block.table.captionBelow = true;
|
|
@@ -7578,7 +7598,7 @@ function detectKoreanListBlocks(blocks) {
|
|
|
7578
7598
|
}
|
|
7579
7599
|
const listType = label.family === "arabicDot" ? "ordered" : "unordered";
|
|
7580
7600
|
const listBlock = { ...b, type: "list", listType };
|
|
7581
|
-
const pb = _optionalChain([lastTopLevelList, 'optionalAccess',
|
|
7601
|
+
const pb = _optionalChain([lastTopLevelList, 'optionalAccess', _345 => _345.bbox]), cb = b.bbox;
|
|
7582
7602
|
const notIndented = depth > 0 && !!pb && !!cb && pb.page === cb.page && cb.x >= pb.x + pb.width && cb.y >= pb.y + pb.height;
|
|
7583
7603
|
if (notIndented) familyStack = [label.family];
|
|
7584
7604
|
if (depth === 0 || notIndented) {
|
|
@@ -7736,7 +7756,7 @@ function removeHeaderFooterBlocks(blocks, pageHeights, warnings, notes, tables =
|
|
|
7736
7756
|
const b = blocks[bi];
|
|
7737
7757
|
const cellTexts = b.type === "table" && b.table ? b.table.cells.flat().map((c) => c.text.trim()).filter(Boolean) : [];
|
|
7738
7758
|
const headBox = cellTexts.length <= 4 && !!b.bbox && b.bbox.height <= (_nullishCoalesce(pageHeights.get(b.bbox.page), () => ( Infinity))) * 0.05;
|
|
7739
|
-
const text = !tables ? _optionalChain([b, 'access',
|
|
7759
|
+
const text = !tables ? _optionalChain([b, 'access', _346 => _346.text, 'optionalAccess', _347 => _347.trim, 'call', _348 => _348()]) : cellTexts.length ? (headBox ? [...cellTexts].sort() : cellTexts).join(" | ") : void 0;
|
|
7740
7760
|
if (!b.bbox || !b.pageNumber || !text) continue;
|
|
7741
7761
|
const ph = pageHeights.get(b.bbox.page) || pageHeights.get(b.pageNumber);
|
|
7742
7762
|
if (!ph) continue;
|
|
@@ -7769,7 +7789,7 @@ function removeHeaderFooterBlocks(blocks, pageHeights, warnings, notes, tables =
|
|
|
7769
7789
|
for (const [p, count] of patternCount) {
|
|
7770
7790
|
const pages = [..._nullishCoalesce(patternPages.get(p), () => ( []))];
|
|
7771
7791
|
const span2 = pages.length ? Math.max(...pages) - Math.min(...pages) + 1 : 0;
|
|
7772
|
-
const varying = !tables && (_nullishCoalesce(_optionalChain([patternNumbers, 'access',
|
|
7792
|
+
const varying = !tables && (_nullishCoalesce(_optionalChain([patternNumbers, 'access', _349 => _349.get, 'call', _350 => _350(p), 'optionalAccess', _351 => _351.size]), () => ( 0))) > 1;
|
|
7773
7793
|
const occ = _nullishCoalesce(patternOcc.get(p), () => ( []));
|
|
7774
7794
|
const dense = pages.length >= span2 * 0.4;
|
|
7775
7795
|
const loose = looseVaryingNumber(occ, entries === topEntries) && (entries === bottomEntries || dense || tracksPages(occ));
|
|
@@ -7781,8 +7801,8 @@ function removeHeaderFooterBlocks(blocks, pageHeights, warnings, notes, tables =
|
|
|
7781
7801
|
for (const e of entries) {
|
|
7782
7802
|
const norm = e.text.replace(/\d+/g, "#");
|
|
7783
7803
|
if (!repeatedPatterns.has(norm)) continue;
|
|
7784
|
-
const noteMark = _optionalChain([e, 'access',
|
|
7785
|
-
if (noteMark && _optionalChain([notes, 'optionalAccess',
|
|
7804
|
+
const noteMark = _optionalChain([e, 'access', _352 => _352.text, 'access', _353 => _353.match, 'call', _354 => _354(/^\d{1,3}\)/), 'optionalAccess', _355 => _355[0]]);
|
|
7805
|
+
if (noteMark && _optionalChain([notes, 'optionalAccess', _356 => _356.get, 'call', _357 => _357(e.page), 'optionalAccess', _358 => _358.marks, 'access', _359 => _359.some, 'call', _360 => _360((m) => m.mark === noteMark)])) continue;
|
|
7786
7806
|
const cand = blocks[e.blockIdx];
|
|
7787
7807
|
const cb = cand.bbox;
|
|
7788
7808
|
const tableNote = /^(?:주\s*(?:\d+\s*[).:]|[::])|(?:자료|출처)\s*[::]|\*\s+\S)/.test(e.text.replace(/ \| /g, " ")) && blocks.some((o) => {
|
|
@@ -7796,7 +7816,7 @@ function removeHeaderFooterBlocks(blocks, pageHeights, warnings, notes, tables =
|
|
|
7796
7816
|
if (bi === e.blockIdx) continue;
|
|
7797
7817
|
const o = blocks[bi];
|
|
7798
7818
|
if (!o.bbox || o.bbox.page !== cb.page) continue;
|
|
7799
|
-
const oNorm = _optionalChain([o, 'access',
|
|
7819
|
+
const oNorm = _optionalChain([o, 'access', _361 => _361.text, 'optionalAccess', _362 => _362.trim, 'call', _363 => _363(), 'access', _364 => _364.replace, 'call', _365 => _365(/\d+/g, "#")]);
|
|
7800
7820
|
if (oNorm && repeatedPatterns.has(oNorm)) continue;
|
|
7801
7821
|
const overlap2 = Math.min(cb.y + cb.height, o.bbox.y + o.bbox.height) - Math.max(cb.y, o.bbox.y);
|
|
7802
7822
|
if (overlap2 >= cb.height * 0.5) {
|
|
@@ -7924,7 +7944,7 @@ function recordRowRules(table, cells, bbox, hs) {
|
|
|
7924
7944
|
function markImageCell(cell) {
|
|
7925
7945
|
IMAGE_CELLS.add(cell);
|
|
7926
7946
|
}
|
|
7927
|
-
var emptyCell = (cell) => !cell || !_optionalChain([cell, 'access',
|
|
7947
|
+
var emptyCell = (cell) => !cell || !_optionalChain([cell, 'access', _366 => _366.text, 'optionalAccess', _367 => _367.trim, 'call', _368 => _368()]) && !_optionalChain([cell, 'access', _369 => _369.blocks, 'optionalAccess', _370 => _370.length]) && !IMAGE_CELLS.has(cell);
|
|
7928
7948
|
function trimTable(table) {
|
|
7929
7949
|
let cols = table.cols;
|
|
7930
7950
|
while (cols > 0 && table.cells.every((row) => emptyCell(row[cols - 1]))) cols--;
|
|
@@ -7940,7 +7960,7 @@ function trimTable(table) {
|
|
|
7940
7960
|
function trimTrailingEmptyTableCols(blocks) {
|
|
7941
7961
|
for (const b of blocks) {
|
|
7942
7962
|
if (b.type !== "table" || !b.table) continue;
|
|
7943
|
-
for (const row of b.table.cells) for (const cell of row) if (_optionalChain([cell, 'access',
|
|
7963
|
+
for (const row of b.table.cells) for (const cell of row) if (_optionalChain([cell, 'access', _371 => _371.blocks, 'optionalAccess', _372 => _372.length])) trimTrailingEmptyTableCols(cell.blocks);
|
|
7944
7964
|
trimTable(b.table);
|
|
7945
7965
|
}
|
|
7946
7966
|
}
|
|
@@ -7960,7 +7980,7 @@ function mergeSliverColumns(grid, colXs, maxWidth) {
|
|
|
7960
7980
|
}
|
|
7961
7981
|
const ok = owner.every((row) => {
|
|
7962
7982
|
const o = row[c];
|
|
7963
|
-
return !!o && (o.colSpan > 1 || !o.text.trim() && !_optionalChain([o, 'access',
|
|
7983
|
+
return !!o && (o.colSpan > 1 || !o.text.trim() && !_optionalChain([o, 'access', _373 => _373.blocks, 'optionalAccess', _374 => _374.length]));
|
|
7964
7984
|
});
|
|
7965
7985
|
if (!ok) continue;
|
|
7966
7986
|
const spanning = /* @__PURE__ */ new Set();
|
|
@@ -7987,7 +8007,7 @@ var multiply = (m, t) => [
|
|
|
7987
8007
|
m[1] * t[4] + m[3] * t[5] + m[5]
|
|
7988
8008
|
];
|
|
7989
8009
|
function hollowCircle(image) {
|
|
7990
|
-
if (!_optionalChain([image, 'optionalAccess',
|
|
8010
|
+
if (!_optionalChain([image, 'optionalAccess', _375 => _375.data]) || image.width < 16 || image.width > 128 || image.height < 16 || image.height > 128 || Math.abs(image.width - image.height) > Math.min(image.width, image.height) * 0.1) return false;
|
|
7991
8011
|
const stride = image.kind === _pdfmjs.ImageKind.RGB_24BPP ? 3 : image.kind === _pdfmjs.ImageKind.RGBA_32BPP ? 4 : 0;
|
|
7992
8012
|
const { width, height, data } = image;
|
|
7993
8013
|
if (!stride || data.length < width * height * stride) return false;
|
|
@@ -8052,9 +8072,9 @@ function smallVisibleImagePaints(fnArray, argsArray) {
|
|
|
8052
8072
|
const op = fnArray[i], args = argsArray[i];
|
|
8053
8073
|
if (op === _pdfmjs.OPS.save || op === _pdfmjs.OPS.paintFormXObjectBegin) {
|
|
8054
8074
|
stack.push({ ctm, alpha, clip, unknownClip });
|
|
8055
|
-
const matrix = op === _pdfmjs.OPS.paintFormXObjectBegin ? _optionalChain([args, 'optionalAccess',
|
|
8075
|
+
const matrix = op === _pdfmjs.OPS.paintFormXObjectBegin ? _optionalChain([args, 'optionalAccess', _376 => _376[0]]) : void 0;
|
|
8056
8076
|
if (Array.isArray(matrix) && matrix.length >= 6) ctm = multiply(ctm, matrix);
|
|
8057
|
-
const bounds = op === _pdfmjs.OPS.paintFormXObjectBegin ? _optionalChain([args, 'optionalAccess',
|
|
8077
|
+
const bounds = op === _pdfmjs.OPS.paintFormXObjectBegin ? _optionalChain([args, 'optionalAccess', _377 => _377[1]]) : void 0;
|
|
8058
8078
|
if (Array.isArray(bounds) && bounds.length === 4) {
|
|
8059
8079
|
const box = rectangle(bounds[0], bounds[1], bounds[2] - bounds[0], bounds[3] - bounds[1]);
|
|
8060
8080
|
if (box && ctm[1] === 0 && ctm[2] === 0) intersectClip(box);
|
|
@@ -8062,17 +8082,17 @@ function smallVisibleImagePaints(fnArray, argsArray) {
|
|
|
8062
8082
|
}
|
|
8063
8083
|
} else if (op === _pdfmjs.OPS.restore || op === _pdfmjs.OPS.paintFormXObjectEnd) {
|
|
8064
8084
|
const state = stack.pop();
|
|
8065
|
-
ctm = _nullishCoalesce(_optionalChain([state, 'optionalAccess',
|
|
8066
|
-
alpha = _nullishCoalesce(_optionalChain([state, 'optionalAccess',
|
|
8067
|
-
clip = _nullishCoalesce(_optionalChain([state, 'optionalAccess',
|
|
8068
|
-
unknownClip = _nullishCoalesce(_optionalChain([state, 'optionalAccess',
|
|
8085
|
+
ctm = _nullishCoalesce(_optionalChain([state, 'optionalAccess', _378 => _378.ctm]), () => ( [1, 0, 0, 1, 0, 0]));
|
|
8086
|
+
alpha = _nullishCoalesce(_optionalChain([state, 'optionalAccess', _379 => _379.alpha]), () => ( 1));
|
|
8087
|
+
clip = _nullishCoalesce(_optionalChain([state, 'optionalAccess', _380 => _380.clip]), () => ( null));
|
|
8088
|
+
unknownClip = _nullishCoalesce(_optionalChain([state, 'optionalAccess', _381 => _381.unknownClip]), () => ( false));
|
|
8069
8089
|
} else if (op === _pdfmjs.OPS.setGState) {
|
|
8070
|
-
for (const [key, value] of _nullishCoalesce(_optionalChain([args, 'optionalAccess',
|
|
8090
|
+
for (const [key, value] of _nullishCoalesce(_optionalChain([args, 'optionalAccess', _382 => _382[0]]), () => ( []))) {
|
|
8071
8091
|
if (key === "ca") alpha = typeof value === "number" ? value : 0;
|
|
8072
8092
|
}
|
|
8073
8093
|
} else if (op === _pdfmjs.OPS.constructPath) {
|
|
8074
8094
|
const [operations, coordinates] = args;
|
|
8075
|
-
pathRect = pathRect === void 0 && _optionalChain([operations, 'optionalAccess',
|
|
8095
|
+
pathRect = pathRect === void 0 && _optionalChain([operations, 'optionalAccess', _383 => _383.length]) === 1 && operations[0] === _pdfmjs.OPS.rectangle && _optionalChain([coordinates, 'optionalAccess', _384 => _384.length]) >= 4 && ctm[1] === 0 && ctm[2] === 0 ? rectangle(coordinates[0], coordinates[1], coordinates[2], coordinates[3]) : null;
|
|
8076
8096
|
} else if (op === _pdfmjs.OPS.clip || op === _pdfmjs.OPS.eoClip) pendingClip = true;
|
|
8077
8097
|
else if ([
|
|
8078
8098
|
_pdfmjs.OPS.endPath,
|
|
@@ -8092,7 +8112,7 @@ function smallVisibleImagePaints(fnArray, argsArray) {
|
|
|
8092
8112
|
pendingClip = false;
|
|
8093
8113
|
pathRect = void 0;
|
|
8094
8114
|
} else if (op === _pdfmjs.OPS.transform && Array.isArray(args) && args.length >= 6) ctm = multiply(ctm, args);
|
|
8095
|
-
else if (op === _pdfmjs.OPS.paintImageXObject && typeof _optionalChain([args, 'optionalAccess',
|
|
8115
|
+
else if (op === _pdfmjs.OPS.paintImageXObject && typeof _optionalChain([args, 'optionalAccess', _385 => _385[0]]) === "string") {
|
|
8096
8116
|
if (typeof args[1] !== "number" || typeof args[2] !== "number" || args[1] < 16 || args[1] > 128 || args[2] < 16 || args[2] > 128) continue;
|
|
8097
8117
|
const box = extractImageRegions([_pdfmjs.OPS.transform, _pdfmjs.OPS.paintImageXObject], [ctm, args])[0];
|
|
8098
8118
|
if (!box || ctm[1] !== 0 || ctm[2] !== 0 || alpha < 0.99 || unknownClip || clip && (box.x1 + (box.x2 - box.x1) * 0.03 < clip.x1 || box.y1 + (box.y2 - box.y1) * 0.03 < clip.y1 || box.x2 - (box.x2 - box.x1) * 0.03 > clip.x2 || box.y2 - (box.y2 - box.y1) * 0.03 > clip.y2)) continue;
|
|
@@ -8111,14 +8131,14 @@ async function restoreImageBullets(items, page, fnArray, argsArray, shapes = /*
|
|
|
8111
8131
|
const line = items.filter((item) => !item.isHidden && item.fontSize > 0 && item.x >= box.x2 && item.x - box.x2 <= item.fontSize * 0.7 && Math.abs(item.y + item.h / 2 - (box.y1 + box.y2) / 2) <= item.fontSize * 0.4 && height >= item.fontSize * 0.5 && height <= item.fontSize * 1.2).sort((a, b) => a.x - b.x)[0];
|
|
8112
8132
|
if (!line || /^[○●•◦□■∙]/.test(line.text.trim()) || !/\p{L}/u.test(line.text)) continue;
|
|
8113
8133
|
const row = items.filter((item) => Math.abs(item.y - line.y) <= 2 && item.x >= line.x);
|
|
8114
|
-
if (row.reduce((n, item) => n + (_nullishCoalesce(_optionalChain([item, 'access',
|
|
8134
|
+
if (row.reduce((n, item) => n + (_nullishCoalesce(_optionalChain([item, 'access', _386 => _386.text, 'access', _387 => _387.match, 'call', _388 => _388(/\p{L}/gu), 'optionalAccess', _389 => _389.length]), () => ( 0))), 0) < 12 || items.some((item) => item !== line && Math.abs(item.y - line.y) <= 2 && item.x < line.x)) continue;
|
|
8115
8135
|
candidates.push({ id, x: box.x1, width, line });
|
|
8116
8136
|
}
|
|
8117
8137
|
let restored = 0;
|
|
8118
8138
|
const used = /* @__PURE__ */ new Set();
|
|
8119
8139
|
for (const candidate of candidates) {
|
|
8120
8140
|
const same = candidates.filter((other) => other.id === candidate.id && other.line !== candidate.line && Math.abs(other.line.x - candidate.line.x) <= 1 && Math.abs(other.x - candidate.x) <= 1 && Math.abs(other.width - candidate.width) <= 1 && other.line.fontSize === candidate.line.fontSize && Math.abs(other.line.y - candidate.line.y) >= candidate.line.fontSize * 2);
|
|
8121
|
-
const numbered = items.filter((item) => !item.isHidden && /^[①-⑮]\s*/.test(item.text.trim()) && item.fontName === candidate.line.fontName && item.fontSize === candidate.line.fontSize && Math.abs(item.x - candidate.x) <= 1 && (_nullishCoalesce(_optionalChain([item, 'access',
|
|
8141
|
+
const numbered = items.filter((item) => !item.isHidden && /^[①-⑮]\s*/.test(item.text.trim()) && item.fontName === candidate.line.fontName && item.fontSize === candidate.line.fontSize && Math.abs(item.x - candidate.x) <= 1 && (_nullishCoalesce(_optionalChain([item, 'access', _390 => _390.text, 'access', _391 => _391.match, 'call', _392 => _392(/\p{L}/gu), 'optionalAccess', _393 => _393.length]), () => ( 0))) >= 12).sort((a, b) => b.y - a.y);
|
|
8122
8142
|
const numberedList = numbered.some((item, index) => index > 0 && item.text.trim().charCodeAt(0) === numbered[index - 1].text.trim().charCodeAt(0) + 1);
|
|
8123
8143
|
if (!same.length && !numberedList || used.has(candidate.line)) continue;
|
|
8124
8144
|
if (!shapes.has(candidate.id)) shapes.set(candidate.id, hollowCircle(await resolveImagePixels(page, candidate.id)));
|
|
@@ -8184,7 +8204,7 @@ function groupFlowBoxUnits(blocks, grids, hs, vs, images) {
|
|
|
8184
8204
|
return units;
|
|
8185
8205
|
}
|
|
8186
8206
|
function arrowDirection(image) {
|
|
8187
|
-
if (!_optionalChain([image, 'optionalAccess',
|
|
8207
|
+
if (!_optionalChain([image, 'optionalAccess', _394 => _394.data]) || image.width < 16 || image.width > 128 || image.height < 16 || image.height > 128) return 0;
|
|
8188
8208
|
const { width, height, data } = image;
|
|
8189
8209
|
const stride = image.kind === _pdfmjs.ImageKind.RGB_24BPP ? 3 : image.kind === _pdfmjs.ImageKind.RGBA_32BPP ? 4 : 0;
|
|
8190
8210
|
if (!stride || data.length < width * height * stride) return 0;
|
|
@@ -8252,7 +8272,7 @@ function isSideTabTable(box, table, others, pageWidth, pageHeight) {
|
|
|
8252
8272
|
function removeSideTabs(blocks, pageWidths) {
|
|
8253
8273
|
const edges = /* @__PURE__ */ new Map();
|
|
8254
8274
|
for (const b of blocks) {
|
|
8255
|
-
if (!b.bbox || b.pageNumber === void 0 || [..._nullishCoalesce(_optionalChain([b, 'access',
|
|
8275
|
+
if (!b.bbox || b.pageNumber === void 0 || [..._nullishCoalesce(_optionalChain([b, 'access', _395 => _395.text, 'optionalAccess', _396 => _396.trim, 'call', _397 => _397()]), () => ( ""))].length <= MAX_CHARS) continue;
|
|
8256
8276
|
const e = _nullishCoalesce(edges.get(b.pageNumber), () => ( { lefts: [], rights: [] }));
|
|
8257
8277
|
e.lefts.push(b.bbox.x);
|
|
8258
8278
|
e.rights.push(b.bbox.x + b.bbox.width);
|
|
@@ -8268,7 +8288,7 @@ function removeSideTabs(blocks, pageWidths) {
|
|
|
8268
8288
|
const fallback = all.length ? { left: q(all.map((e) => e.left), 0.5), right: q(all.map((e) => e.right), 0.5) } : void 0;
|
|
8269
8289
|
const key = (b) => {
|
|
8270
8290
|
const w = b.pageNumber !== void 0 ? pageWidths.get(b.pageNumber) : void 0;
|
|
8271
|
-
const text = _optionalChain([b, 'access',
|
|
8291
|
+
const text = _optionalChain([b, 'access', _398 => _398.text, 'optionalAccess', _399 => _399.trim, 'call', _400 => _400()]);
|
|
8272
8292
|
const area = _nullishCoalesce((b.pageNumber !== void 0 ? body.get(b.pageNumber) : void 0), () => ( fallback));
|
|
8273
8293
|
if (b.type === "table") {
|
|
8274
8294
|
if (!w || !b.bbox || !b.table || !SIDE_TAB_TABLES.has(b.table)) return null;
|
|
@@ -8934,16 +8954,16 @@ function isProseSpread(items) {
|
|
|
8934
8954
|
for (let i = 1; i < sorted.length; i++) {
|
|
8935
8955
|
gaps.push(sorted[i].x - (sorted[i - 1].x + sorted[i - 1].w));
|
|
8936
8956
|
}
|
|
8937
|
-
const maxGap =
|
|
8957
|
+
const maxGap = _chunkHMHIF6QFcjs.safeMax.call(void 0, gaps);
|
|
8938
8958
|
const avgLen = items.reduce((s, i) => s + i.text.length, 0) / items.length;
|
|
8939
8959
|
if (items.length >= 4 && maxGap < 40 && avgLen < 5) return true;
|
|
8940
|
-
const minGap =
|
|
8960
|
+
const minGap = _chunkHMHIF6QFcjs.safeMin.call(void 0, gaps);
|
|
8941
8961
|
return minGap > 0 && maxGap - minGap <= Math.max(2, maxGap * 0.15) && (items.filter((i) => /^\P{L}*\p{Ll}/u.test(i.text)).length * 2 >= items.length || items.some((i) => /\p{L}[,.;:]["”’)]?$/u.test(i.text)));
|
|
8942
8962
|
}
|
|
8943
8963
|
function detectColumns(yLines) {
|
|
8944
8964
|
const allItems = yLines.flat();
|
|
8945
8965
|
if (allItems.length === 0) return null;
|
|
8946
|
-
const pageWidth =
|
|
8966
|
+
const pageWidth = _chunkHMHIF6QFcjs.safeMax.call(void 0, allItems.map((i) => i.x + i.w)) - _chunkHMHIF6QFcjs.safeMin.call(void 0, allItems.map((i) => i.x));
|
|
8947
8967
|
if (pageWidth < 100) return null;
|
|
8948
8968
|
let bigoLineIdx = -1;
|
|
8949
8969
|
for (let i = 0; i < yLines.length; i++) {
|
|
@@ -9168,7 +9188,7 @@ var UNDER_BOX_PAIR_MAX_EM = 2.2;
|
|
|
9168
9188
|
var UNDER_BOX_PAIR_OVERLAP = 0.8;
|
|
9169
9189
|
function markUnderlineItems(items, horizontals, verticals, nonRules) {
|
|
9170
9190
|
const underlines = [];
|
|
9171
|
-
if (_optionalChain([nonRules, 'optionalAccess',
|
|
9191
|
+
if (_optionalChain([nonRules, 'optionalAccess', _401 => _401.size])) horizontals = horizontals.filter((line) => !nonRules.has(line));
|
|
9172
9192
|
if (items.length === 0 || horizontals.length === 0) return underlines;
|
|
9173
9193
|
const tightOwners = /* @__PURE__ */ new Map();
|
|
9174
9194
|
const tightlyOwned = (line) => {
|
|
@@ -9274,7 +9294,7 @@ function hasBoxTopPair(line, maxH, horizontals, cellItems) {
|
|
|
9274
9294
|
if (ow <= 0) continue;
|
|
9275
9295
|
const overlap2 = Math.min(line.x2, o.x2) - Math.max(line.x1, o.x1);
|
|
9276
9296
|
if (overlap2 / Math.max(w, ow) < UNDER_BOX_PAIR_OVERLAP) continue;
|
|
9277
|
-
const covered = _nullishCoalesce(_optionalChain([cellItems, 'optionalAccess',
|
|
9297
|
+
const covered = _nullishCoalesce(_optionalChain([cellItems, 'optionalAccess', _402 => _402.reduce, 'call', _403 => _403((sum, item) => {
|
|
9278
9298
|
const below = item.y - o.y1;
|
|
9279
9299
|
if (below < 0.5 || below > 3 || !item.text.trim()) return sum;
|
|
9280
9300
|
return sum + Math.max(0, Math.min(o.x2, item.x + item.w) - Math.max(o.x1, item.x));
|
|
@@ -9341,13 +9361,13 @@ function partTex(group) {
|
|
|
9341
9361
|
const base = Math.min(...g.filter((i) => i.fontSize >= size * SCRIPT_SIZE_RATIO).map((i) => i.y));
|
|
9342
9362
|
let s = "", run = "";
|
|
9343
9363
|
const flush = () => {
|
|
9344
|
-
if (run) s +=
|
|
9364
|
+
if (run) s += _chunk5MBQW3KPcjs.toTex.call(void 0, run);
|
|
9345
9365
|
run = "";
|
|
9346
9366
|
};
|
|
9347
9367
|
g.forEach((it, k) => {
|
|
9348
9368
|
if (it.fontSize < size * SCRIPT_SIZE_RATIO && it.y - base >= size * SCRIPT_RISE_EM) {
|
|
9349
9369
|
flush();
|
|
9350
|
-
s += `^{${
|
|
9370
|
+
s += `^{${_chunk5MBQW3KPcjs.toTex.call(void 0, it.text)}}`;
|
|
9351
9371
|
return;
|
|
9352
9372
|
}
|
|
9353
9373
|
if (k && it.x - (g[k - 1].x + g[k - 1].w) > spaceGapThreshold(it.fontSize)) run += " ";
|
|
@@ -9520,12 +9540,12 @@ function rebuildUnitLine(items, grid) {
|
|
|
9520
9540
|
function prependUnitRow(cells, cols, line, usedItems) {
|
|
9521
9541
|
const text = cleanCellText(line.map((item) => item.text).join(""));
|
|
9522
9542
|
cells.unshift(Array.from({ length: cols }, (_, c) => ({ text: c === 0 ? text : "", colSpan: c === 0 ? cols : 1, rowSpan: 1 })));
|
|
9523
|
-
for (const cell of cells[0])
|
|
9543
|
+
for (const cell of cells[0]) _chunk5MBQW3KPcjs.CELL_EDGES.set(cell, NO_EDGES);
|
|
9524
9544
|
for (const item of line) usedItems.add(item);
|
|
9525
9545
|
}
|
|
9526
9546
|
function attachUnitRow(items, grid, cells, cols, usedItems) {
|
|
9527
9547
|
const all = cells.flat();
|
|
9528
|
-
if (all.filter((c) => c.text.trim()).length * 2 < all.length || UNIT.test(_nullishCoalesce(_optionalChain([cells, 'access',
|
|
9548
|
+
if (all.filter((c) => c.text.trim()).length * 2 < all.length || UNIT.test(_nullishCoalesce(_optionalChain([cells, 'access', _404 => _404[0], 'optionalAccess', _405 => _405[0], 'optionalAccess', _406 => _406.text]), () => ( "")))) return false;
|
|
9529
9549
|
const above = items.filter((it) => !usedItems.has(it) && it.y >= grid.bbox.y2 && it.y - grid.bbox.y2 <= 8 && it.x >= grid.bbox.x1 - 3 && it.x + it.w <= grid.bbox.x2 + 3);
|
|
9530
9550
|
let nearest = Infinity;
|
|
9531
9551
|
for (const it of above) nearest = Math.min(nearest, it.y);
|
|
@@ -9560,7 +9580,7 @@ function closeShadedTableEdges(clipGrids, horizontals, verticals, fillRects) {
|
|
|
9560
9580
|
let hs = horizontals, vs = verticals;
|
|
9561
9581
|
const restored = [];
|
|
9562
9582
|
for (const grid of clipGrids) {
|
|
9563
|
-
if (grid.clipParent || grid.rowYs.length !== 2 || grid.colXs.length < 3 || !_optionalChain([grid, 'access',
|
|
9583
|
+
if (grid.clipParent || grid.rowYs.length !== 2 || grid.colXs.length < 3 || !_optionalChain([grid, 'access', _407 => _407.cells, 'optionalAccess', _408 => _408.length]) || grid.cells.some((c) => c.filler || c.rowSpan !== 1 || c.colSpan !== 1)) continue;
|
|
9564
9584
|
const { x1, x2, y1: mid, y2: top } = grid.bbox;
|
|
9565
9585
|
if (!grid.cells.every((c) => fillRects.some((f) => near2(f.x1, c.bbox.x1) && near2(f.x2, c.bbox.x2) && near2(f.y1, c.bbox.y1) && near2(f.y2, c.bbox.y2)))) continue;
|
|
9566
9586
|
const topRule = hs.find((h) => near2(h.y1, top) && near2(h.x1, x1) && near2(h.x2, x2));
|
|
@@ -10024,7 +10044,7 @@ function takeFrameSpanningText(items, cutX, pageNum, lex) {
|
|
|
10024
10044
|
const rows = groupByY([...items].sort((a, b) => b.y - a.y || a.x - b.x)).map((line) => {
|
|
10025
10045
|
const runs = [];
|
|
10026
10046
|
for (const item of [...line].sort((a, b) => a.x - b.x)) {
|
|
10027
|
-
const run = runs[runs.length - 1], prev = _optionalChain([run, 'optionalAccess',
|
|
10047
|
+
const run = runs[runs.length - 1], prev = _optionalChain([run, 'optionalAccess', _409 => _409[run.length - 1]]);
|
|
10028
10048
|
if (prev && item.x - (prev.x + prev.w) <= Math.max(prev.fontSize, item.fontSize) * 0.6) run.push(item);
|
|
10029
10049
|
else runs.push([item]);
|
|
10030
10050
|
}
|
|
@@ -10068,7 +10088,7 @@ function groupFrameParagraphUnits(units, frames) {
|
|
|
10068
10088
|
for (const unit of units) for (const block of unit) source.set(block, unit);
|
|
10069
10089
|
const members = /* @__PURE__ */ new Map(), emitted = /* @__PURE__ */ new Set();
|
|
10070
10090
|
for (const frame of frames) {
|
|
10071
|
-
if (frame.length < 2 || frame.some((block) => block.type !== "paragraph" || _optionalChain([source, 'access',
|
|
10091
|
+
if (frame.length < 2 || frame.some((block) => block.type !== "paragraph" || _optionalChain([source, 'access', _410 => _410.get, 'call', _411 => _411(block), 'optionalAccess', _412 => _412.length]) !== 1)) continue;
|
|
10072
10092
|
for (const block of frame) members.set(block, frame);
|
|
10073
10093
|
}
|
|
10074
10094
|
const out = [];
|
|
@@ -10081,7 +10101,7 @@ function groupFrameParagraphUnits(units, frames) {
|
|
|
10081
10101
|
}
|
|
10082
10102
|
}
|
|
10083
10103
|
for (const unit of out) {
|
|
10084
|
-
if (unit.length < 2 || _optionalChain([FRAME_READING_UNITS, 'access',
|
|
10104
|
+
if (unit.length < 2 || _optionalChain([FRAME_READING_UNITS, 'access', _413 => _413.get, 'call', _414 => _414(unit[0]), 'optionalAccess', _415 => _415.blocks]) === unit) continue;
|
|
10085
10105
|
const bs = unit.map((b) => b.bbox).filter((b) => !!b);
|
|
10086
10106
|
if (bs.length !== unit.length) continue;
|
|
10087
10107
|
const x = Math.min(...bs.map((b) => b.x)), y = Math.min(...bs.map((b) => b.y));
|
|
@@ -10098,14 +10118,14 @@ function groupFrameParagraphUnits(units, frames) {
|
|
|
10098
10118
|
function recordFrameTitle(table, source, pageNum) {
|
|
10099
10119
|
if (!CLIP_TABLES.has(table) || table.rows !== 1 || table.cols !== 3 || source.length < 2) return;
|
|
10100
10120
|
const cells = table.cells[0];
|
|
10101
|
-
if (cells.length !== 3 || cells.some((c) => c.colSpan !== 1 || c.rowSpan !== 1 || _optionalChain([c, 'access',
|
|
10121
|
+
if (cells.length !== 3 || cells.some((c) => c.colSpan !== 1 || c.rowSpan !== 1 || _optionalChain([c, 'access', _416 => _416.blocks, 'optionalAccess', _417 => _417.length]) || c.text.includes("\n"))) return;
|
|
10102
10122
|
const [label, spacer, title] = cells;
|
|
10103
10123
|
if (!/^(?:붙임|별첨|첨부|부록)\s*\d{1,3}$/.test(label.text.trim()) || spacer.text.trim() || !title.text.trim()) return;
|
|
10104
10124
|
if (cells.some((c) => {
|
|
10105
|
-
const e =
|
|
10125
|
+
const e = _chunk5MBQW3KPcjs.CELL_EDGES.get(c);
|
|
10106
10126
|
return !e || e.t || e.b || e.l || e.r;
|
|
10107
10127
|
})) return;
|
|
10108
|
-
const xs = TABLE_COLXS.get(table), style = dominantStyle(source), fs = _nullishCoalesce(_optionalChain([style, 'optionalAccess',
|
|
10128
|
+
const xs = TABLE_COLXS.get(table), style = dominantStyle(source), fs = _nullishCoalesce(_optionalChain([style, 'optionalAccess', _418 => _418.fontSize]), () => ( 0));
|
|
10109
10129
|
if (!xs || xs.length !== 4 || fs <= 0) return;
|
|
10110
10130
|
const width = xs[3] - xs[0], gap = xs[2] - xs[1];
|
|
10111
10131
|
if (width < fs * 12 || gap <= 0 || gap > fs * 1.5 || xs[1] - xs[0] > width * 0.25 || xs[3] - xs[2] < width * 0.6) return;
|
|
@@ -10169,7 +10189,7 @@ function extendNestedShadedHeaders(clipGrids, lineGrids, horizontals, verticals,
|
|
|
10169
10189
|
const extended = [];
|
|
10170
10190
|
for (let i = 0; i < clipGrids.length; i++) {
|
|
10171
10191
|
const c = clipGrids[i], parent = c.clipParent;
|
|
10172
|
-
if (!parent || c.rowYs.length !== 2 || c.colXs.length < 3 || !_optionalChain([c, 'access',
|
|
10192
|
+
if (!parent || c.rowYs.length !== 2 || c.colXs.length < 3 || !_optionalChain([c, 'access', _419 => _419.cells, 'optionalAccess', _420 => _420.length]) || c.cells.some((cell) => cell.filler || cell.rowSpan !== 1 || cell.colSpan !== 1)) continue;
|
|
10173
10193
|
if (!clipGrids.some((g) => g.rowYs.length === 2 && g.colXs.length === 2 && near2(g.bbox.x1, parent.x1) && near2(g.bbox.x2, parent.x2) && near2(g.bbox.y1, parent.y1) && near2(g.bbox.y2, parent.y2))) continue;
|
|
10174
10194
|
if (!c.cells.every((cell) => fills.some((f) => near2(f.x1, cell.bbox.x1) && near2(f.x2, cell.bbox.x2) && near2(f.y1, cell.bbox.y1) && near2(f.y2, cell.bbox.y2)))) continue;
|
|
10175
10195
|
const host = lineGrids.find((l) => l.rowYs.length > 2 && l.colXs.length === c.colXs.length && c.colXs.every((x, k) => near2(x, l.colXs[k])) && c.rowYs.every((y, k) => near2(y, l.rowYs[k])) && contains4(parent, l.bbox) && l.rowYs.every((y) => horizontals.some((h) => near2(h.y1, y) && near2(h.x1, l.bbox.x1) && near2(h.x2, l.bbox.x2))) && l.colXs.every((x) => verticals.some((v) => near2(v.x1, x) && v.y1 <= l.bbox.y1 + 1.5 && v.y2 >= l.bbox.y2 - 1.5)) && !clipGrids.some((o) => o !== c && !contains4(o.bbox, l.bbox) && Math.min(o.bbox.x2, l.bbox.x2) > Math.max(o.bbox.x1, l.bbox.x1) && Math.min(o.bbox.y2, l.bbox.y2) > Math.max(o.bbox.y1, l.bbox.y1)));
|
|
@@ -10192,7 +10212,7 @@ function attachSideTabBlocks(tab, body, pageNum) {
|
|
|
10192
10212
|
bbox: computeBBox(items, pageNum),
|
|
10193
10213
|
style: dominantStyle(items)
|
|
10194
10214
|
});
|
|
10195
|
-
const prefix = ordered.filter((g) => !_optionalChain([caps, 'optionalAccess',
|
|
10215
|
+
const prefix = ordered.filter((g) => !_optionalChain([caps, 'optionalAccess', _421 => _421.has, 'call', _422 => _422(g)])).map((g) => ({
|
|
10196
10216
|
type: "paragraph",
|
|
10197
10217
|
text: g.text.trim(),
|
|
10198
10218
|
pageNumber: pageNum,
|
|
@@ -10201,7 +10221,7 @@ function attachSideTabBlocks(tab, body, pageNum) {
|
|
|
10201
10221
|
}));
|
|
10202
10222
|
const groups = /* @__PURE__ */ new Map();
|
|
10203
10223
|
for (const g of ordered) {
|
|
10204
|
-
const cap = _optionalChain([caps, 'optionalAccess',
|
|
10224
|
+
const cap = _optionalChain([caps, 'optionalAccess', _423 => _423.get, 'call', _424 => _424(g)]);
|
|
10205
10225
|
if (cap) groups.set(cap, [..._nullishCoalesce(groups.get(cap), () => ( [])), g]);
|
|
10206
10226
|
}
|
|
10207
10227
|
for (const [cap, glyphs] of groups) {
|
|
@@ -10233,7 +10253,7 @@ function extractPageBlocksWithLines(items, pageNum, opList, pageWidth, pageHeigh
|
|
|
10233
10253
|
let prev = null;
|
|
10234
10254
|
for (const line of streamLines(items)) {
|
|
10235
10255
|
lex.addLine(mergeLineSimple(line));
|
|
10236
|
-
const fs = _nullishCoalesce(_optionalChain([dominantStyle, 'call',
|
|
10256
|
+
const fs = _nullishCoalesce(_optionalChain([dominantStyle, 'call', _425 => _425(line), 'optionalAccess', _426 => _426.fontSize]), () => ( 0));
|
|
10237
10257
|
const left = Math.min(...line.map((i) => i.x)), right = Math.max(...line.map((i) => i.x + i.w));
|
|
10238
10258
|
const y = line.reduce((n, i) => n + i.y, 0) / line.length;
|
|
10239
10259
|
const wide = fs > 0 && right - left >= 12 * fs;
|
|
@@ -10247,7 +10267,7 @@ function extractPageBlocksWithLines(items, pageNum, opList, pageWidth, pageHeigh
|
|
|
10247
10267
|
const filled = fillBlanks(items, horizontals, verticals);
|
|
10248
10268
|
items = filled.items;
|
|
10249
10269
|
horizontals = filled.horizontals;
|
|
10250
|
-
const prevPage = _optionalChain([carry, 'optionalAccess',
|
|
10270
|
+
const prevPage = _optionalChain([carry, 'optionalAccess', _427 => _427.page]) === pageNum - 1 ? carry.clip : void 0;
|
|
10251
10271
|
const images = extractImageRegions(opList.fnArray, opList.argsArray);
|
|
10252
10272
|
const clipRects = images.length ? withoutImageOnlyClips(extracted.clipRects, images) : extracted.clipRects;
|
|
10253
10273
|
const clipResult = detectTables ? buildClipCellGrids(clipRects, horizontals, verticals, pageWidth, pageHeight, items.map((it) => ({ x: it.x + it.w / 2, y: it.y + it.h / 2 })), extracted.fillRects, prevPage) : { grids: [], containers: [], page: void 0 };
|
|
@@ -10545,7 +10565,7 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
|
|
|
10545
10565
|
const nested = pendingNested.length ? takePendingNested(pendingNested, cell.bbox, !!grid.cells) : [];
|
|
10546
10566
|
const lone = nested.length === 1 && !cellItems.length ? nested[0] : null;
|
|
10547
10567
|
const cw = cell.bbox.x2 - cell.bbox.x1;
|
|
10548
|
-
if (_optionalChain([lone, 'optionalAccess',
|
|
10568
|
+
if (_optionalChain([lone, 'optionalAccess', _428 => _428.table]) && lone.bbox && lone.table.rows === 1 && lone.table.cols === 1 && CLIP_TABLES.has(lone.table) && !_optionalChain([lone, 'access', _429 => _429.table, 'access', _430 => _430.cells, 'access', _431 => _431[0], 'access', _432 => _432[0], 'access', _433 => _433.blocks, 'optionalAccess', _434 => _434.some, 'call', _435 => _435((b2) => b2.type === "table")]) && lone.bbox.width >= cw * 0.9 && /^[^\n]{1,30}$/.test(lone.table.cells[0][0].text.trim())) {
|
|
10549
10569
|
irGrid[cell.row][cell.col] = { text: lone.table.cells[0][0].text, colSpan: cell.colSpan, rowSpan: cell.rowSpan };
|
|
10550
10570
|
takeClipCellEdges(cell, irGrid[cell.row][cell.col]);
|
|
10551
10571
|
continue;
|
|
@@ -10595,10 +10615,10 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
|
|
|
10595
10615
|
const ls = irGrid.slice(1).flat().flatMap((c) => c.text.split("\n")).map((t) => t.trim()).filter(Boolean);
|
|
10596
10616
|
const numericLine = (t) => {
|
|
10597
10617
|
const cs = t.replace(/\s+/g, "");
|
|
10598
|
-
return cs.length > 0 && (_nullishCoalesce(_optionalChain([cs, 'access',
|
|
10618
|
+
return cs.length > 0 && (_nullishCoalesce(_optionalChain([cs, 'access', _436 => _436.match, 'call', _437 => _437(/[\d.,%()+\-−–—△▲▽▼]/g), 'optionalAccess', _438 => _438.length]), () => ( 0))) >= cs.length * 0.85;
|
|
10599
10619
|
};
|
|
10600
10620
|
const labelValueLine = (t) => {
|
|
10601
|
-
const hangul = _nullishCoalesce(_optionalChain([t, 'access',
|
|
10621
|
+
const hangul = _nullishCoalesce(_optionalChain([t, 'access', _439 => _439.match, 'call', _440 => _440(/[가-힣]/g), 'optionalAccess', _441 => _441.length]), () => ( 0));
|
|
10602
10622
|
return hangul > 0 && hangul <= 6 && /\d,\d{3}/.test(t) && numericLine(t.replace(/[가-힣()]/g, ""));
|
|
10603
10623
|
};
|
|
10604
10624
|
const bulletLine = (t) => /^\s*[○◦•□■▪]/.test(t) || /^\s*-\s*[^\d\s.,−-]/.test(t) && t.replace(/\s+/g, "").length > 7;
|
|
@@ -10608,14 +10628,14 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
|
|
|
10608
10628
|
const share = ls.filter((t) => numericLine(t) || lvLines.has(t)).length / ls.length;
|
|
10609
10629
|
if (share >= 0.5) return true;
|
|
10610
10630
|
const colShares = Array.from({ length: numCols }, (_, c) => {
|
|
10611
|
-
const cl = irGrid.slice(1).flatMap((row) => (_nullishCoalesce(_optionalChain([row, 'access',
|
|
10631
|
+
const cl = irGrid.slice(1).flatMap((row) => (_nullishCoalesce(_optionalChain([row, 'access', _442 => _442[c], 'optionalAccess', _443 => _443.text]), () => ( ""))).split("\n")).map((t) => t.trim()).filter(Boolean);
|
|
10612
10632
|
return cl.length ? cl.filter(numericLine).length / cl.length : null;
|
|
10613
10633
|
}).filter((v) => v !== null);
|
|
10614
10634
|
return share >= 0.35 && colShares.some((v) => v >= 0.8) && colShares.every((v) => v >= 0.8 || v <= 0.2);
|
|
10615
10635
|
})();
|
|
10616
10636
|
const layoutProse = irGrid.some((row) => row.some((c) => c.colSpan >= numCols - 1 && c.text.length > 60));
|
|
10617
10637
|
const maxRows = numericBody ? layoutProse ? OCR_NUMERIC_MAX_ROWS_FRAMED : OCR_NUMERIC_MAX_ROWS : 5;
|
|
10618
|
-
const proseLine = (t) => (_nullishCoalesce(_optionalChain([t, 'access',
|
|
10638
|
+
const proseLine = (t) => (_nullishCoalesce(_optionalChain([t, 'access', _444 => _444.match, 'call', _445 => _445(/[가-힣]/g), 'optionalAccess', _446 => _446.length]), () => ( 0))) > 6 && !/^[-−]?[\d,.]+$/.test(t.replace(/\s+/g, ""));
|
|
10619
10639
|
const proseCols = numRows === 2 ? (_nullishCoalesce(irGrid[1], () => ( []))).filter((c) => {
|
|
10620
10640
|
const ls = c.text.split("\n").map((t) => t.trim()).filter(Boolean);
|
|
10621
10641
|
return ls.length >= 3 && ls.filter(proseLine).length >= ls.length * 0.6;
|
|
@@ -10636,8 +10656,8 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
|
|
|
10636
10656
|
finalGrid = rebuilt.map((row, i) => {
|
|
10637
10657
|
const o = kept.get(i);
|
|
10638
10658
|
return row.map((rawText, c) => {
|
|
10639
|
-
const src = o === void 0 ? void 0 : _optionalChain([irGrid, 'access',
|
|
10640
|
-
return { text: cleanCellText(rawText), colSpan: _nullishCoalesce(_optionalChain([src, 'optionalAccess',
|
|
10659
|
+
const src = o === void 0 ? void 0 : _optionalChain([irGrid, 'access', _447 => _447[o], 'optionalAccess', _448 => _448[c]]);
|
|
10660
|
+
return { text: cleanCellText(rawText), colSpan: _nullishCoalesce(_optionalChain([src, 'optionalAccess', _449 => _449.colSpan]), () => ( 1)), rowSpan: src ? spanRows(o, src.rowSpan) : 1 };
|
|
10641
10661
|
});
|
|
10642
10662
|
});
|
|
10643
10663
|
finalRows = finalGrid.length;
|
|
@@ -10657,14 +10677,14 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
|
|
|
10657
10677
|
if (!assignedItems.has(textItems[ti]) && !inExpanded(textItems[ti])) usedItems.delete(owners[ti]);
|
|
10658
10678
|
}
|
|
10659
10679
|
}
|
|
10660
|
-
if (unitLine.length > 0 && rebuiltUsed && !/^\s*\(\s*단위\s*[::]/.test(_nullishCoalesce(_optionalChain([finalGrid, 'access',
|
|
10680
|
+
if (unitLine.length > 0 && rebuiltUsed && !/^\s*\(\s*단위\s*[::]/.test(_nullishCoalesce(_optionalChain([finalGrid, 'access', _450 => _450[0], 'optionalAccess', _451 => _451[0], 'optionalAccess', _452 => _452.text]), () => ( "")))) {
|
|
10661
10681
|
prependUnitRow(finalGrid, numCols, unitLine, usedItems);
|
|
10662
10682
|
finalRows++;
|
|
10663
10683
|
}
|
|
10664
10684
|
if (!rebuiltUsed && attachUnitRow(items, grid, finalGrid, numCols, usedItems)) finalRows++;
|
|
10665
10685
|
let semanticOneColumn = false;
|
|
10666
10686
|
if (!grid.cells && !nestedAttached && numCols === 1 && numGridRows >= 2) {
|
|
10667
|
-
const populatedRows = finalGrid.filter((row) => _optionalChain([row, 'access',
|
|
10687
|
+
const populatedRows = finalGrid.filter((row) => _optionalChain([row, 'access', _453 => _453[0], 'optionalAccess', _454 => _454.text, 'access', _455 => _455.trim, 'call', _456 => _456()]));
|
|
10668
10688
|
if (populatedRows.length >= 4) {
|
|
10669
10689
|
const fontSizes = tableItems.map((item) => item.fontSize).filter((size) => size > 0).sort((a, b) => a - b);
|
|
10670
10690
|
const medianFont = _nullishCoalesce(fontSizes[Math.floor(fontSizes.length / 2)], () => ( 0));
|
|
@@ -10762,7 +10782,7 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
|
|
|
10762
10782
|
height: grid.bbox.y2 - grid.bbox.y1
|
|
10763
10783
|
};
|
|
10764
10784
|
if (numRows === 1 && numCols === 1 && gridW < pageWidth * 0.35) {
|
|
10765
|
-
const prose = _nullishCoalesce(_optionalChain([finalGrid, 'access',
|
|
10785
|
+
const prose = _nullishCoalesce(_optionalChain([finalGrid, 'access', _457 => _457[0], 'optionalAccess', _458 => _458[0], 'optionalAccess', _459 => _459.text]), () => ( ""));
|
|
10766
10786
|
const besideLines = (side) => new Set(side.map((it) => Math.round(it.y / 3))).size;
|
|
10767
10787
|
const rightLines = items.filter((it) => it.x >= grid.bbox.x2 + 3 && it.y >= grid.bbox.y1 && it.y <= grid.bbox.y2);
|
|
10768
10788
|
const leftLines = items.filter((it) => it.x + it.w <= grid.bbox.x1 - 3 && it.y >= grid.bbox.y1 && it.y <= grid.bbox.y2);
|
|
@@ -10781,8 +10801,8 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
|
|
|
10781
10801
|
}
|
|
10782
10802
|
}
|
|
10783
10803
|
if (!grid.cells && !nestedAttached && shouldDemoteTable(irTable)) {
|
|
10784
|
-
const paragraphs = numRows === 1 && numCols === 1 ? _optionalChain([irTable, 'access',
|
|
10785
|
-
if (_optionalChain([paragraphs, 'optionalAccess',
|
|
10804
|
+
const paragraphs = numRows === 1 && numCols === 1 ? _optionalChain([irTable, 'access', _460 => _460.cells, 'access', _461 => _461[0], 'optionalAccess', _462 => _462[0], 'optionalAccess', _463 => _463.blocks]) : void 0;
|
|
10805
|
+
if (_optionalChain([paragraphs, 'optionalAccess', _464 => _464.length])) {
|
|
10786
10806
|
blocks.push(...paragraphs);
|
|
10787
10807
|
frameParagraphUnits.push(paragraphs);
|
|
10788
10808
|
recordFrameReadingUnit(paragraphs, tableBbox);
|
|
@@ -10829,7 +10849,7 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
|
|
|
10829
10849
|
const clusterResults = (proseColumns ? [] : detectClusterTables(clusterItems, pageNum, void 0, lex)).filter((cr) => {
|
|
10830
10850
|
const b = cr.bbox;
|
|
10831
10851
|
const overlapX = (x) => Math.min(x.x + x.width, b.x + b.width) - Math.max(x.x, b.x);
|
|
10832
|
-
return !blocks.some((x) => x.bbox && x.bbox.y >= b.y - 2 && x.bbox.y + x.bbox.height <= b.y + b.height + 2 && (x.type === "paragraph" ? (_nullishCoalesce(_optionalChain([x, 'access',
|
|
10852
|
+
return !blocks.some((x) => x.bbox && x.bbox.y >= b.y - 2 && x.bbox.y + x.bbox.height <= b.y + b.height + 2 && (x.type === "paragraph" ? (_nullishCoalesce(_optionalChain([x, 'access', _465 => _465.text, 'optionalAccess', _466 => _466.match, 'call', _467 => _467(/\p{L}/gu), 'optionalAccess', _468 => _468.length]), () => ( 0))) >= 10 && overlapX(x.bbox) >= 0.8 * b.width : x.type === "table" && !ocrPage && _optionalChain([x, 'access', _469 => _469.table, 'optionalAccess', _470 => _470.cols]) === cr.table.cols && overlapX(x.bbox) >= 0.5 * Math.min(x.bbox.width, b.width)));
|
|
10833
10853
|
});
|
|
10834
10854
|
if (clusterResults.length > 0) {
|
|
10835
10855
|
const ciToIdx = /* @__PURE__ */ new Map();
|
|
@@ -10866,7 +10886,7 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
|
|
|
10866
10886
|
groupSizes.push(1);
|
|
10867
10887
|
}
|
|
10868
10888
|
const allY = remaining.map((i) => i.y);
|
|
10869
|
-
const pageH =
|
|
10889
|
+
const pageH = _chunkHMHIF6QFcjs.safeMax.call(void 0, allY) - _chunkHMHIF6QFcjs.safeMin.call(void 0, allY);
|
|
10870
10890
|
const gapThreshold = Math.max(15, pageH * 0.03);
|
|
10871
10891
|
const sides = frameColumnTextBands(remaining, spanning, gx);
|
|
10872
10892
|
const textBlocks = [];
|
|
@@ -10882,7 +10902,7 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
|
|
|
10882
10902
|
finalTextBlocks.push(...detectListBlocks(textBlocks));
|
|
10883
10903
|
} else {
|
|
10884
10904
|
const allY = remaining.map((i) => i.y);
|
|
10885
|
-
const pageH =
|
|
10905
|
+
const pageH = _chunkHMHIF6QFcjs.safeMax.call(void 0, allY) - _chunkHMHIF6QFcjs.safeMin.call(void 0, allY);
|
|
10886
10906
|
const gapThreshold = Math.max(15, pageH * 0.03);
|
|
10887
10907
|
const groups = xyCutOrder(remaining, gapThreshold, 0, void 0, 0, lex);
|
|
10888
10908
|
const textBlocks = [];
|
|
@@ -11244,7 +11264,7 @@ function extractPageBlocksFallback(items, pageNum, fullPage = false, detectTable
|
|
|
11244
11264
|
blocks.push(...columnTextToBlocks(tableText, pageNum, bbox, dominantStyle(items)));
|
|
11245
11265
|
} else {
|
|
11246
11266
|
const allY = items.map((i) => i.y);
|
|
11247
|
-
const pageHeight =
|
|
11267
|
+
const pageHeight = _chunkHMHIF6QFcjs.safeMax.call(void 0, allY) - _chunkHMHIF6QFcjs.safeMin.call(void 0, allY);
|
|
11248
11268
|
const gapThreshold = Math.max(15, pageHeight * 0.03);
|
|
11249
11269
|
const orderedGroups = proseCutX !== null ? splitTwoColumnProse(items, proseCutX) : xyCutOrder(items, gapThreshold, 0, void 0, minGap, lex);
|
|
11250
11270
|
for (const group of orderedGroups) {
|
|
@@ -11301,19 +11321,19 @@ function mergeOcrImageRegions(blocks, page, regions, ocrBlocks) {
|
|
|
11301
11321
|
const overlapH = Math.max(0, Math.min(b.y + b.height, region.y2) - Math.max(b.y, region.y1));
|
|
11302
11322
|
return overlapW * overlapH >= b.width * b.height * 0.8;
|
|
11303
11323
|
});
|
|
11304
|
-
const labels = candidates.filter((b) => b.type === "paragraph" && b.bbox.height <= 24 && (_nullishCoalesce(_optionalChain([b, 'access',
|
|
11324
|
+
const labels = candidates.filter((b) => b.type === "paragraph" && b.bbox.height <= 24 && (_nullishCoalesce(_optionalChain([b, 'access', _471 => _471.text, 'optionalAccess', _472 => _472.match, 'call', _473 => _473(/[\p{L}\p{N}]/gu), 'optionalAccess', _474 => _474.length]), () => ( 0))) >= 2);
|
|
11305
11325
|
const axisFragments = rotatedAxisFragments(candidates);
|
|
11306
11326
|
const accepted = candidates.filter((b) => {
|
|
11307
|
-
if (b.type === "paragraph") return (_nullishCoalesce(_optionalChain([b, 'access',
|
|
11327
|
+
if (b.type === "paragraph") return (_nullishCoalesce(_optionalChain([b, 'access', _475 => _475.text, 'optionalAccess', _476 => _476.match, 'call', _477 => _477(/[\p{L}\p{N}]/gu), 'optionalAccess', _478 => _478.length]), () => ( 0))) >= 2 || !axisFragments.has(b) && (supportedDiagramLabel(b, labels, region) || axisTick(b, candidates));
|
|
11308
11328
|
const t = b.table;
|
|
11309
11329
|
if (b.type !== "table" || !t || UNRULED_REGION_TABLES.has(b)) return false;
|
|
11310
11330
|
const lone = t.cells.filter((row) => row.filter((c) => c.text.trim()).length === 1 && row.some((c) => c.colSpan === t.cols)).length;
|
|
11311
11331
|
if (t.rows >= 2 && lone * 2 >= t.rows) return false;
|
|
11312
11332
|
if (t.rows === 1 && t.cols === 1) {
|
|
11313
|
-
const text = _nullishCoalesce(_optionalChain([t, 'access',
|
|
11314
|
-
return (_nullishCoalesce(_optionalChain([text, 'access',
|
|
11333
|
+
const text = _nullishCoalesce(_optionalChain([t, 'access', _479 => _479.cells, 'access', _480 => _480[0], 'optionalAccess', _481 => _481[0], 'optionalAccess', _482 => _482.text]), () => ( ""));
|
|
11334
|
+
return (_nullishCoalesce(_optionalChain([text, 'access', _483 => _483.match, 'call', _484 => _484(/\n/g), 'optionalAccess', _485 => _485.length]), () => ( 0))) >= 5 && (_nullishCoalesce(_optionalChain([text, 'access', _486 => _486.match, 'call', _487 => _487(/\d/g), 'optionalAccess', _488 => _488.length]), () => ( 0))) >= text.length * 0.25;
|
|
11315
11335
|
}
|
|
11316
|
-
const headerLabels = _nullishCoalesce(_optionalChain([t, 'access',
|
|
11336
|
+
const headerLabels = _nullishCoalesce(_optionalChain([t, 'access', _489 => _489.cells, 'access', _490 => _490[0], 'optionalAccess', _491 => _491.filter, 'call', _492 => _492((c) => c.text.replace(/[^A-Za-z가-힣]/g, "").length >= 2), 'access', _493 => _493.length]), () => ( 0));
|
|
11317
11337
|
return t.rows >= 2 && t.cols >= 2 && headerLabels >= t.cols * 0.75 && t.cells.slice(1).some((row) => row.filter((c) => c.text.trim()).length >= 2);
|
|
11318
11338
|
});
|
|
11319
11339
|
const selected = candidates.flatMap((b) => accepted.includes(b) ? [b] : b.type === "table" && b.table ? rowParagraphs(b).filter((p) => /[\p{L}\p{N}]{2}/u.test(_nullishCoalesce(p.text, () => ( "")))) : []);
|
|
@@ -11330,14 +11350,14 @@ function mergeOcrImageRegions(blocks, page, regions, ocrBlocks) {
|
|
|
11330
11350
|
for (const block of selected) {
|
|
11331
11351
|
if (seen2.has(block)) continue;
|
|
11332
11352
|
const frame = FRAME_READING_UNITS.get(block);
|
|
11333
|
-
const source = _optionalChain([frame, 'optionalAccess',
|
|
11353
|
+
const source = _optionalChain([frame, 'optionalAccess', _494 => _494.blocks, 'access', _495 => _495.every, 'call', _496 => _496((member) => selectedSet.has(member))]) ? frame.blocks : [block];
|
|
11334
11354
|
source.forEach((member) => seen2.add(member));
|
|
11335
11355
|
const available = source.filter((member) => !hasOriginal(member));
|
|
11336
11356
|
const units = frame && available.length === source.length && source === frame.blocks ? [{ blocks: available, bbox: frame.bbox, atomic: true }] : available.map((member) => ({ blocks: [member], bbox: member.bbox, atomic: false }));
|
|
11337
11357
|
for (const unit of units) {
|
|
11338
11358
|
const b = unit.bbox;
|
|
11339
11359
|
const index = blocks.findIndex((existing) => {
|
|
11340
|
-
const e = _nullishCoalesce(_optionalChain([FRAME_READING_UNITS, 'access',
|
|
11360
|
+
const e = _nullishCoalesce(_optionalChain([FRAME_READING_UNITS, 'access', _497 => _497.get, 'call', _498 => _498(existing), 'optionalAccess', _499 => _499.bbox]), () => ( existing.bbox));
|
|
11341
11361
|
if (existing.pageNumber !== page || !e) return false;
|
|
11342
11362
|
const beside = e.y < region.y2 && e.y + e.height > region.y1 && e.x >= region.x2 - 1;
|
|
11343
11363
|
if (placedHere.has(existing) && Math.abs(e.y + e.height / 2 - b.y - b.height / 2) <= Math.min(e.height, b.height) * 0.25) return e.x > b.x;
|
|
@@ -11355,16 +11375,16 @@ function mergeOcrImageRegions(blocks, page, regions, ocrBlocks) {
|
|
|
11355
11375
|
}
|
|
11356
11376
|
function axisTick(block, candidates) {
|
|
11357
11377
|
const b = block.bbox;
|
|
11358
|
-
if (!/^\d$/u.test(_nullishCoalesce(_optionalChain([block, 'access',
|
|
11359
|
-
const numeric = candidates.filter((o) => o !== block && o.type === "paragraph" && o.bbox && /^[\d\s.,%+−-]+$/u.test(_nullishCoalesce(_optionalChain([o, 'access',
|
|
11378
|
+
if (!/^\d$/u.test(_nullishCoalesce(_optionalChain([block, 'access', _500 => _500.text, 'optionalAccess', _501 => _501.trim, 'call', _502 => _502()]), () => ( "")))) return false;
|
|
11379
|
+
const numeric = candidates.filter((o) => o !== block && o.type === "paragraph" && o.bbox && /^[\d\s.,%+−-]+$/u.test(_nullishCoalesce(_optionalChain([o, 'access', _503 => _503.text, 'optionalAccess', _504 => _504.trim, 'call', _505 => _505()]), () => ( ""))) && /\d/u.test(_nullishCoalesce(o.text, () => ( ""))) && Math.max(o.bbox.height, b.height) <= Math.min(o.bbox.height, b.height) * 2);
|
|
11360
11380
|
const cy = b.y + b.height / 2, right = b.x + b.width;
|
|
11361
11381
|
const row = numeric.filter((o) => Math.abs(o.bbox.y + o.bbox.height / 2 - cy) <= Math.min(o.bbox.height, b.height) * 0.35);
|
|
11362
11382
|
const column = numeric.filter((o) => Math.abs(o.bbox.x + o.bbox.width - right) <= Math.max(o.bbox.height, b.height) * 0.5);
|
|
11363
11383
|
return row.length >= 2 || column.length >= 2;
|
|
11364
11384
|
}
|
|
11365
11385
|
function supportedDiagramLabel(block, labels, region) {
|
|
11366
|
-
const b = block.bbox, text = _nullishCoalesce(_optionalChain([block, 'access',
|
|
11367
|
-
if (!b || !/^[\p{L}\p{N}]$/u.test(text) || b.height < 4 || b.width < 1 || b.width > b.height * 2 || b.x < region.x1 || b.y < region.y1 || b.x + b.width > region.x2 || b.y + b.height > region.y2 || b.width * b.height > (region.x2 - region.x1) * (region.y2 - region.y1) * 5e-3 || labels.length < 3 || !labels.some((l) => /\p{L}{3}/u.test(_nullishCoalesce(l.text, () => ( "")))) || labels.filter((l) => !/\p{L}/u.test(_nullishCoalesce(l.text, () => ( ""))) && (_nullishCoalesce(_optionalChain([l, 'access',
|
|
11386
|
+
const b = block.bbox, text = _nullishCoalesce(_optionalChain([block, 'access', _506 => _506.text, 'optionalAccess', _507 => _507.trim, 'call', _508 => _508()]), () => ( ""));
|
|
11387
|
+
if (!b || !/^[\p{L}\p{N}]$/u.test(text) || b.height < 4 || b.width < 1 || b.width > b.height * 2 || b.x < region.x1 || b.y < region.y1 || b.x + b.width > region.x2 || b.y + b.height > region.y2 || b.width * b.height > (region.x2 - region.x1) * (region.y2 - region.y1) * 5e-3 || labels.length < 3 || !labels.some((l) => /\p{L}{3}/u.test(_nullishCoalesce(l.text, () => ( "")))) || labels.filter((l) => !/\p{L}/u.test(_nullishCoalesce(l.text, () => ( ""))) && (_nullishCoalesce(_optionalChain([l, 'access', _509 => _509.text, 'optionalAccess', _510 => _510.match, 'call', _511 => _511(/\p{N}/gu), 'optionalAccess', _512 => _512.length]), () => ( 0))) >= 2).length < 2) return false;
|
|
11368
11388
|
let above = false, below = false;
|
|
11369
11389
|
for (const label of labels) {
|
|
11370
11390
|
const a = label.bbox, em = Math.max(b.height, a.height);
|
|
@@ -11379,7 +11399,7 @@ function rotatedAxisFragments(candidates) {
|
|
|
11379
11399
|
const paragraphs = candidates.filter((b) => b.type === "paragraph" && b.bbox.height <= 24);
|
|
11380
11400
|
const axes = [];
|
|
11381
11401
|
for (const block of paragraphs) {
|
|
11382
|
-
const b = block.bbox, text = _nullishCoalesce(_optionalChain([block, 'access',
|
|
11402
|
+
const b = block.bbox, text = _nullishCoalesce(_optionalChain([block, 'access', _513 => _513.text, 'optionalAccess', _514 => _514.trim, 'call', _515 => _515()]), () => ( ""));
|
|
11383
11403
|
if (!/^[\d\s.,%+−-]+$/u.test(text) || !/\d/u.test(text) || b.width > b.height * 6) continue;
|
|
11384
11404
|
const axis = axes.find((a) => Math.abs(a[0].bbox.x + a[0].bbox.width - b.x - b.width) <= Math.max(a[0].bbox.height, b.height) * 0.5);
|
|
11385
11405
|
if (axis) axis.push(block);
|
|
@@ -11396,8 +11416,8 @@ function rotatedAxisFragments(candidates) {
|
|
|
11396
11416
|
const em = Math.max(...axis.map((a) => a.bbox.height)), right = axis[0].bbox.x + axis[0].bbox.width;
|
|
11397
11417
|
if (top - bottom < em * 6) continue;
|
|
11398
11418
|
const left = paragraphs.filter((block) => {
|
|
11399
|
-
const b = block.bbox, text = _nullishCoalesce(_optionalChain([block, 'access',
|
|
11400
|
-
return /\p{Script=Latin}/u.test(text) && (_nullishCoalesce(_optionalChain([text, 'access',
|
|
11419
|
+
const b = block.bbox, text = _nullishCoalesce(_optionalChain([block, 'access', _516 => _516.text, 'optionalAccess', _517 => _517.trim, 'call', _518 => _518()]), () => ( ""));
|
|
11420
|
+
return /\p{Script=Latin}/u.test(text) && (_nullishCoalesce(_optionalChain([text, 'access', _519 => _519.match, 'call', _520 => _520(/[\p{L}\p{N}]/gu), 'optionalAccess', _521 => _521.length]), () => ( 0))) <= 3 && b.width <= b.height * 3 && b.x + b.width >= right - em * 6 && b.x + b.width <= right - Math.max(em, b.height) && b.y >= bottom && b.y + b.height <= top;
|
|
11401
11421
|
});
|
|
11402
11422
|
const stack = left.filter((a) => left.some((b) => {
|
|
11403
11423
|
if (a === b || !aligned(a, b)) return false;
|
|
@@ -11407,7 +11427,7 @@ function rotatedAxisFragments(candidates) {
|
|
|
11407
11427
|
if (stack.length < 2) continue;
|
|
11408
11428
|
for (const block of paragraphs) {
|
|
11409
11429
|
const b = block.bbox;
|
|
11410
|
-
if (b.y >= bottom && b.y + b.height <= top && b.x + b.width >= right - em * 6 && b.x + b.width <= right - Math.max(em, b.height) && /^[\p{L}\p{N}]$/u.test(_nullishCoalesce(_optionalChain([block, 'access',
|
|
11430
|
+
if (b.y >= bottom && b.y + b.height <= top && b.x + b.width >= right - em * 6 && b.x + b.width <= right - Math.max(em, b.height) && /^[\p{L}\p{N}]$/u.test(_nullishCoalesce(_optionalChain([block, 'access', _522 => _522.text, 'optionalAccess', _523 => _523.trim, 'call', _524 => _524()]), () => ( ""))) && stack.some((s) => aligned(s, block))) fragments.add(block);
|
|
11411
11431
|
}
|
|
11412
11432
|
}
|
|
11413
11433
|
return fragments;
|
|
@@ -11514,4 +11534,4 @@ function rowParagraphs(block) {
|
|
|
11514
11534
|
|
|
11515
11535
|
|
|
11516
11536
|
exports.DEFAULT_OCR_MODELS = DEFAULT_OCR_MODELS; exports.resolveOcrModels = resolveOcrModels; exports.handwritingFallbackModels = handwritingFallbackModels; exports.ocrSelectionKey = ocrSelectionKey; exports.ocrSourcePath = ocrSourcePath; exports.ensureOcrModelsFor = ensureOcrModelsFor; exports.ocrModelsCached = ocrModelsCached; exports.parseCharacterDict = parseCharacterDict; exports.grayCrop = grayCrop; exports.inkStats = inkStats; exports.splitRowBands = splitRowBands; exports.leadingTriangle = leadingTriangle; exports.arrowGlyph = arrowGlyph; exports.leaderRuns = leaderRuns; exports.inkBounds = inkBounds; exports.bracketFeatures = bracketFeatures; exports.slantedPair = slantedPair; exports.romanStems = romanStems; exports.circledAt = circledAt; exports.ringBoxes = ringBoxes; exports.quoteHead = quoteHead; exports.edgeTrim = edgeTrim; exports.tallInkCount = tallInkCount; exports.gapGlyphs = gapGlyphs; exports.ringBullet = ringBullet; exports.dashRatio = dashRatio; exports.leadingRing = leadingRing; exports.discAt = discAt; exports.serifOne = serifOne; exports.starRun = starRun; exports.bracketShape = bracketShape; exports.leadingBullet = leadingBullet; exports.stackedGlyphBands = stackedGlyphBands; exports.rememberOcrTextGaps = rememberOcrTextGaps; exports.copyOcrTextGaps = copyOcrTextGaps; exports.findOcrTextGaps = findOcrTextGaps; exports.extractLines = extractLines; exports.extractImageRegions = extractImageRegions; exports.NO_EDGES = NO_EDGES; exports.hasOpenCellSeam = hasOpenCellSeam; exports.joinCellEdges = joinCellEdges; exports.filterHiddenText = filterHiddenText; exports.collapseEvenSpacing = collapseEvenSpacing; exports.computeBBox = computeBBox; exports.dominantStyle = dominantStyle; exports.normalizeItems = normalizeItems; exports.groupByY = groupByY; exports.mergeLineSimple = mergeLineSimple; exports.WrapLexicon = WrapLexicon; exports.startsNewItem = startsNewItem; exports.wrapJoiner = wrapJoiner; exports.joinPageBreakWraps = joinPageBreakWraps; exports.splitPageBreakWraps = splitPageBreakWraps; exports.latinSoftWrap = latinSoftWrap; exports.TOC_BLOCKS = TOC_BLOCKS; exports.computeMedianFontSizeFromFreq = computeMedianFontSizeFromFreq; exports.detectHeadings = detectHeadings; exports.mergeStackedHeadingLines = mergeStackedHeadingLines; exports.detectTypographyHeadings = detectTypographyHeadings; exports.detectDocumentStyleHeadings = detectDocumentStyleHeadings; exports.detectSiblingStyleHeadings = detectSiblingStyleHeadings; exports.detectRepeatedPageLabels = detectRepeatedPageLabels; exports.detectPageLeadHeadings = detectPageLeadHeadings; exports.refineDocumentStyleHeadings = refineDocumentStyleHeadings; exports.detectMarkerHeadings = detectMarkerHeadings; exports.detectTableCaptions = detectTableCaptions; exports.detectKoreanListBlocks = detectKoreanListBlocks; exports.removeHeaderFooterBlocks = removeHeaderFooterBlocks; exports.runningLinePatterns = runningLinePatterns; exports.stripAbsorbedRunningLines = stripAbsorbedRunningLines; exports.CLIP_TABLES = CLIP_TABLES; exports.FRAME_TITLE_BLOCKS = FRAME_TITLE_BLOCKS; exports.TABLE_COLXS = TABLE_COLXS; exports.TABLE_ROWYS = TABLE_ROWYS; exports.TABLE_TAIL = TABLE_TAIL; exports.PART_COLXS = PART_COLXS; exports.EMPTY_PARTS = EMPTY_PARTS; exports.IMAGE_CELLS = IMAGE_CELLS; exports.FILLER_CELLS = FILLER_CELLS; exports.CONT_PARTS = CONT_PARTS; exports.CELL_LINES = CELL_LINES; exports.ROW_RULES = ROW_RULES; exports.trimTrailingEmptyTableCols = trimTrailingEmptyTableCols; exports.restoreImageBullets = restoreImageBullets; exports.detectRightArrowRegions = detectRightArrowRegions; exports.removeSideTabs = removeSideTabs; exports.extractPageBlocksWithLines = extractPageBlocksWithLines; exports.UNRULED_REGION_TABLES = UNRULED_REGION_TABLES; exports.mergeOcrImageRegions = mergeOcrImageRegions;
|
|
11517
|
-
//# sourceMappingURL=chunk-
|
|
11537
|
+
//# sourceMappingURL=chunk-OOD35TZR.cjs.map
|