kordoc 4.24.37 → 4.24.39
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/{-HX3RWDQF.js → -7VE547IT.js} +60 -60
- package/dist/{chunk-4MWGWS3B.js → chunk-2XXTL4S4.js} +2 -2
- package/dist/{chunk-J26TNCL7.js → chunk-346W5O2J.js} +2 -2
- package/dist/{chunk-LM7LYH54.js → chunk-3MHRL3OO.js} +2 -2
- package/dist/{chunk-TQBNSAAS.js → chunk-4FWLCWNU.js} +2 -2
- package/dist/{chunk-6QK6ZQTF.js → chunk-7AYP2XO6.js} +3 -3
- package/dist/{chunk-YNIZLSM4.js → chunk-7BQWFZJO.js} +8 -8
- package/dist/{chunk-OTB6UOIB.js → chunk-7ZRUR4TZ.js} +2 -2
- package/dist/{chunk-IWCWO3GP.js → chunk-BWBR5GWQ.js} +2 -2
- package/dist/{chunk-P3SZJJRK.js → chunk-COH7WXBK.js} +7 -7
- package/dist/{chunk-524MGRNW.js → chunk-CS76UPUC.js} +125 -21
- package/dist/chunk-CS76UPUC.js.map +1 -0
- package/dist/{chunk-LWSMZJLR.js → chunk-F2JYJ2SP.js} +2 -2
- package/dist/{chunk-MTSWWXSB.js → chunk-FRMJTW3C.js} +2 -2
- package/dist/{chunk-JRVZBYQ2.js → chunk-FZMZUX7B.js} +130 -21
- package/dist/chunk-FZMZUX7B.js.map +1 -0
- package/dist/{chunk-J42O5KBX.js → chunk-GXED6LJX.js} +2 -2
- package/dist/{chunk-E527FG6I.cjs → chunk-IM5SIGUN.cjs} +3 -3
- package/dist/{chunk-E527FG6I.cjs.map → chunk-IM5SIGUN.cjs.map} +1 -1
- package/dist/{chunk-RR2FKPFN.js → chunk-IZWZ3RQC.js} +2 -2
- package/dist/{chunk-RR2FKPFN.js.map → chunk-IZWZ3RQC.js.map} +1 -1
- package/dist/{chunk-BT5RPLV4.js → chunk-L23XOAKF.js} +19 -19
- package/dist/{chunk-WZUTLJP2.cjs → chunk-LE3733C2.cjs} +212 -108
- package/dist/chunk-LE3733C2.cjs.map +1 -0
- package/dist/{chunk-2LDFUVVF.js → chunk-LOJYJISM.js} +16 -7
- package/dist/chunk-LOJYJISM.js.map +1 -0
- package/dist/{chunk-KGX4TLBX.cjs → chunk-LU7X6LLW.cjs} +3 -3
- package/dist/{chunk-KGX4TLBX.cjs.map → chunk-LU7X6LLW.cjs.map} +1 -1
- package/dist/{chunk-DRDW5ULI.js → chunk-M2ZRTYQ5.js} +14 -14
- package/dist/{chunk-QWYIYVIZ.cjs → chunk-MANE7HAZ.cjs} +2 -2
- package/dist/{chunk-QWYIYVIZ.cjs.map → chunk-MANE7HAZ.cjs.map} +1 -1
- package/dist/{chunk-XCMDIXWE.js → chunk-NL5OTD2E.js} +32 -32
- package/dist/{chunk-ONCXLQV4.js → chunk-NQJL3664.js} +3 -3
- package/dist/{chunk-KFJKRST5.js → chunk-PFHMNNW7.js} +126 -17
- package/dist/chunk-PFHMNNW7.js.map +1 -0
- package/dist/{chunk-OHLJEWS6.js → chunk-PHVAJBHM.js} +2 -2
- package/dist/{chunk-7GN7O3K2.js → chunk-PQIIYKNL.js} +51 -51
- package/dist/{chunk-T7K3CLXM.js → chunk-QDPYTJ4Y.js} +2 -2
- package/dist/{chunk-7MGZWDO4.js → chunk-QDQPAC4L.js} +2 -2
- package/dist/{chunk-7MGZWDO4.js.map → chunk-QDQPAC4L.js.map} +1 -1
- package/dist/{chunk-LG4SU2D4.cjs → chunk-RJNHXCMP.cjs} +69 -60
- package/dist/chunk-RJNHXCMP.cjs.map +1 -0
- package/dist/{chunk-33BKUIIC.js → chunk-RPAEXGWZ.js} +2 -2
- package/dist/{chunk-VRCXXZHT.js → chunk-SFLHCRO6.js} +2 -2
- package/dist/{chunk-GCFG67SF.js → chunk-U5OV6D66.js} +50 -50
- package/dist/{chunk-RBCDHT55.cjs → chunk-UKTRLJII.cjs} +98 -98
- package/dist/{chunk-RBCDHT55.cjs.map → chunk-UKTRLJII.cjs.map} +1 -1
- package/dist/{chunk-BYOAA442.js → chunk-V2RIY72D.js} +2 -2
- package/dist/{chunk-EJKCEP3Q.cjs → chunk-V3IMDOZE.cjs} +6 -6
- package/dist/{chunk-EJKCEP3Q.cjs.map → chunk-V3IMDOZE.cjs.map} +1 -1
- package/dist/{chunk-4OWD6WRS.js → chunk-WPIG3KUV.js} +121 -17
- package/dist/chunk-WPIG3KUV.js.map +1 -0
- package/dist/{chunk-6XOJ6CEK.js → chunk-WVER4OWF.js} +3 -3
- package/dist/{chunk-IOABX3GR.cjs → chunk-XYVTCXAG.cjs} +265 -156
- package/dist/chunk-XYVTCXAG.cjs.map +1 -0
- package/dist/{chunk-6SVVVZLV.js → chunk-Y5O4DS56.js} +2 -2
- package/dist/{chunk-UMQADPM5.js → chunk-YXKU6UJD.js} +2 -2
- package/dist/{chunk-B2VRTOQZ.js → chunk-ZDMLZRS4.js} +18 -9
- package/dist/chunk-ZDMLZRS4.js.map +1 -0
- package/dist/{chunk-64MVXWS5.js → chunk-ZVAX6E63.js} +2 -2
- package/dist/chunks-WTYZ4KG2.js +11 -0
- package/dist/cli.js +61 -60
- package/dist/cli.js.map +1 -1
- package/dist/{formula-DLZUYM6F.js → formula-MMLDES2Z.js} +20 -17
- package/dist/{formula-DLZUYM6F.js.map → formula-MMLDES2Z.js.map} +1 -1
- package/dist/{formula-2MQWKUKR.js → formula-PFSZZNPP.js} +19 -16
- package/dist/{formula-2MQWKUKR.js.map → formula-PFSZZNPP.js.map} +1 -1
- package/dist/{formula-T2YY77JT.cjs → formula-UI2UR74M.cjs} +25 -22
- package/dist/formula-UI2UR74M.cjs.map +1 -0
- package/dist/generator-C3SCP3ZG.js +10 -0
- package/dist/generator-CHBOCLYX.cjs +11 -0
- package/dist/{generator-YBWCA6B5.cjs.map → generator-CHBOCLYX.cjs.map} +1 -1
- package/dist/generator-RTSNDZJB.js +17 -0
- package/dist/hancom-3V3USCW5.js +84 -0
- package/dist/hancom-3V3USCW5.js.map +1 -0
- package/dist/hancom-GV5TTF5H.cjs +85 -0
- package/dist/hancom-GV5TTF5H.cjs.map +1 -0
- package/dist/hancom-XO52GNC3.js +85 -0
- package/dist/hancom-XO52GNC3.js.map +1 -0
- package/dist/image-ocr-2WKCFABH.cjs +211 -0
- package/dist/image-ocr-2WKCFABH.cjs.map +1 -0
- package/dist/{image-ocr-3NF3QJM7.js → image-ocr-R2ASFKHX.js} +99 -15
- package/dist/image-ocr-R2ASFKHX.js.map +1 -0
- package/dist/{image-ocr-XRKFK7AA.js → image-ocr-SU4RPHBF.js} +94 -10
- package/dist/image-ocr-SU4RPHBF.js.map +1 -0
- package/dist/index.cjs +1110 -1110
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.js +70 -70
- package/dist/mcp.js +57 -56
- package/dist/mcp.js.map +1 -1
- package/dist/memo-U4RZJRU2.js +17 -0
- package/dist/{model-bundle-MO5I26AO.js → model-bundle-JMSH2F4A.js} +5 -5
- package/dist/{models-IIP4GZ57.js → models-D5SATVOZ.js} +5 -5
- package/dist/{parse-worker-v2-GWOL3TTO.js → parse-worker-v2-WIIZQFRX.js} +28 -28
- package/dist/{parser-UCLUVQPA.js → parser-KCY43TBS.js} +16 -16
- package/dist/{parser-R6UJQ6CV.cjs → parser-MFBTEGJA.cjs} +162 -162
- package/dist/{parser-R6UJQ6CV.cjs.map → parser-MFBTEGJA.cjs.map} +1 -1
- package/dist/{parser-DJQFM6VE.js → parser-SBJKV5GS.js} +16 -16
- package/dist/{pdf-ocr-EWXGN4JB.js → pdf-ocr-I6GNQEFS.js} +8 -6
- package/dist/pdf-ocr-L2O4SQUK.cjs +40 -0
- package/dist/pdf-ocr-L2O4SQUK.cjs.map +1 -0
- package/dist/{pdf-ocr-7PSNKQOI.js → pdf-ocr-UU5PSZ7Z.js} +12 -10
- package/dist/{profile-io-NUU3VKNW.js → profile-io-HZK4ZZ2O.js} +3 -3
- package/dist/{rasterize-RARCMBJ3.js → rasterize-VNP4ULXM.js} +3 -3
- package/dist/{redact-doc-JKGDXGNJ.js → redact-doc-SPHSBCPN.js} +37 -37
- package/dist/{render-SGLKO3PG.js → render-CKTTIDU2.js} +14 -14
- package/dist/{rewrite-fallback-7YZXSR5K.js → rewrite-fallback-H2KMJV6G.js} +21 -21
- package/dist/seal-MSY5G3UR.js +16 -0
- package/dist/{setup-5IYW4FZ7.js → setup-GJVOXJN7.js} +3 -3
- package/dist/{to-hwpx-QMANIAWY.js → to-hwpx-5UIBNW3D.js} +9 -9
- package/dist/to-hwpx-6BQNMA6P.cjs +16 -0
- package/dist/{to-hwpx-DEBHREDM.cjs.map → to-hwpx-6BQNMA6P.cjs.map} +1 -1
- package/dist/{to-hwpx-4PM6XV2L.js → to-hwpx-JJHDCYER.js} +4 -4
- package/dist/visual-Q6PIMKSA.js +37 -0
- package/dist/{watch-YZS76EOS.js → watch-YZZES36Q.js} +27 -27
- package/package.json +1 -1
- package/dist/chunk-2LDFUVVF.js.map +0 -1
- package/dist/chunk-4OWD6WRS.js.map +0 -1
- package/dist/chunk-524MGRNW.js.map +0 -1
- package/dist/chunk-B2VRTOQZ.js.map +0 -1
- package/dist/chunk-IOABX3GR.cjs.map +0 -1
- package/dist/chunk-JRVZBYQ2.js.map +0 -1
- package/dist/chunk-KFJKRST5.js.map +0 -1
- package/dist/chunk-LG4SU2D4.cjs.map +0 -1
- package/dist/chunk-WZUTLJP2.cjs.map +0 -1
- package/dist/chunks-NRA4GFK2.js +0 -11
- package/dist/formula-T2YY77JT.cjs.map +0 -1
- package/dist/generator-2WFWLJFG.js +0 -10
- package/dist/generator-5NWKWLOO.js +0 -17
- package/dist/generator-YBWCA6B5.cjs +0 -11
- package/dist/image-ocr-3NF3QJM7.js.map +0 -1
- package/dist/image-ocr-N7UKGSRY.cjs +0 -127
- package/dist/image-ocr-N7UKGSRY.cjs.map +0 -1
- package/dist/image-ocr-XRKFK7AA.js.map +0 -1
- package/dist/memo-XJ4NBV4J.js +0 -17
- package/dist/pdf-ocr-HECUBUMU.cjs +0 -38
- package/dist/pdf-ocr-HECUBUMU.cjs.map +0 -1
- package/dist/seal-LSS7WY6Z.js +0 -16
- package/dist/to-hwpx-DEBHREDM.cjs +0 -16
- package/dist/visual-QXYBJJ5D.js +0 -37
- /package/dist/{-HX3RWDQF.js.map → -7VE547IT.js.map} +0 -0
- /package/dist/{chunk-4MWGWS3B.js.map → chunk-2XXTL4S4.js.map} +0 -0
- /package/dist/{chunk-J26TNCL7.js.map → chunk-346W5O2J.js.map} +0 -0
- /package/dist/{chunk-LM7LYH54.js.map → chunk-3MHRL3OO.js.map} +0 -0
- /package/dist/{chunk-TQBNSAAS.js.map → chunk-4FWLCWNU.js.map} +0 -0
- /package/dist/{chunk-6QK6ZQTF.js.map → chunk-7AYP2XO6.js.map} +0 -0
- /package/dist/{chunk-YNIZLSM4.js.map → chunk-7BQWFZJO.js.map} +0 -0
- /package/dist/{chunk-OTB6UOIB.js.map → chunk-7ZRUR4TZ.js.map} +0 -0
- /package/dist/{chunk-IWCWO3GP.js.map → chunk-BWBR5GWQ.js.map} +0 -0
- /package/dist/{chunk-P3SZJJRK.js.map → chunk-COH7WXBK.js.map} +0 -0
- /package/dist/{chunk-LWSMZJLR.js.map → chunk-F2JYJ2SP.js.map} +0 -0
- /package/dist/{chunk-MTSWWXSB.js.map → chunk-FRMJTW3C.js.map} +0 -0
- /package/dist/{chunk-J42O5KBX.js.map → chunk-GXED6LJX.js.map} +0 -0
- /package/dist/{chunk-BT5RPLV4.js.map → chunk-L23XOAKF.js.map} +0 -0
- /package/dist/{chunk-DRDW5ULI.js.map → chunk-M2ZRTYQ5.js.map} +0 -0
- /package/dist/{chunk-XCMDIXWE.js.map → chunk-NL5OTD2E.js.map} +0 -0
- /package/dist/{chunk-ONCXLQV4.js.map → chunk-NQJL3664.js.map} +0 -0
- /package/dist/{chunk-OHLJEWS6.js.map → chunk-PHVAJBHM.js.map} +0 -0
- /package/dist/{chunk-7GN7O3K2.js.map → chunk-PQIIYKNL.js.map} +0 -0
- /package/dist/{chunk-T7K3CLXM.js.map → chunk-QDPYTJ4Y.js.map} +0 -0
- /package/dist/{chunk-33BKUIIC.js.map → chunk-RPAEXGWZ.js.map} +0 -0
- /package/dist/{chunk-VRCXXZHT.js.map → chunk-SFLHCRO6.js.map} +0 -0
- /package/dist/{chunk-GCFG67SF.js.map → chunk-U5OV6D66.js.map} +0 -0
- /package/dist/{chunk-BYOAA442.js.map → chunk-V2RIY72D.js.map} +0 -0
- /package/dist/{chunk-6XOJ6CEK.js.map → chunk-WVER4OWF.js.map} +0 -0
- /package/dist/{chunk-6SVVVZLV.js.map → chunk-Y5O4DS56.js.map} +0 -0
- /package/dist/{chunk-UMQADPM5.js.map → chunk-YXKU6UJD.js.map} +0 -0
- /package/dist/{chunk-64MVXWS5.js.map → chunk-ZVAX6E63.js.map} +0 -0
- /package/dist/{chunks-NRA4GFK2.js.map → chunks-WTYZ4KG2.js.map} +0 -0
- /package/dist/{generator-2WFWLJFG.js.map → generator-C3SCP3ZG.js.map} +0 -0
- /package/dist/{generator-5NWKWLOO.js.map → generator-RTSNDZJB.js.map} +0 -0
- /package/dist/{memo-XJ4NBV4J.js.map → memo-U4RZJRU2.js.map} +0 -0
- /package/dist/{model-bundle-MO5I26AO.js.map → model-bundle-JMSH2F4A.js.map} +0 -0
- /package/dist/{models-IIP4GZ57.js.map → models-D5SATVOZ.js.map} +0 -0
- /package/dist/{parse-worker-v2-GWOL3TTO.js.map → parse-worker-v2-WIIZQFRX.js.map} +0 -0
- /package/dist/{parser-UCLUVQPA.js.map → parser-KCY43TBS.js.map} +0 -0
- /package/dist/{parser-DJQFM6VE.js.map → parser-SBJKV5GS.js.map} +0 -0
- /package/dist/{pdf-ocr-7PSNKQOI.js.map → pdf-ocr-I6GNQEFS.js.map} +0 -0
- /package/dist/{pdf-ocr-EWXGN4JB.js.map → pdf-ocr-UU5PSZ7Z.js.map} +0 -0
- /package/dist/{profile-io-NUU3VKNW.js.map → profile-io-HZK4ZZ2O.js.map} +0 -0
- /package/dist/{rasterize-RARCMBJ3.js.map → rasterize-VNP4ULXM.js.map} +0 -0
- /package/dist/{redact-doc-JKGDXGNJ.js.map → redact-doc-SPHSBCPN.js.map} +0 -0
- /package/dist/{render-SGLKO3PG.js.map → render-CKTTIDU2.js.map} +0 -0
- /package/dist/{rewrite-fallback-7YZXSR5K.js.map → rewrite-fallback-H2KMJV6G.js.map} +0 -0
- /package/dist/{seal-LSS7WY6Z.js.map → seal-MSY5G3UR.js.map} +0 -0
- /package/dist/{setup-5IYW4FZ7.js.map → setup-GJVOXJN7.js.map} +0 -0
- /package/dist/{to-hwpx-4PM6XV2L.js.map → to-hwpx-5UIBNW3D.js.map} +0 -0
- /package/dist/{to-hwpx-QMANIAWY.js.map → to-hwpx-JJHDCYER.js.map} +0 -0
- /package/dist/{visual-QXYBJJ5D.js.map → visual-Q6PIMKSA.js.map} +0 -0
- /package/dist/{watch-YZS76EOS.js.map → watch-YZZES36Q.js.map} +0 -0
|
@@ -1,19 +1,19 @@
|
|
|
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 _chunkIM5SIGUNcjs = require('./chunk-IM5SIGUN.cjs');
|
|
4
5
|
|
|
5
6
|
|
|
6
7
|
|
|
7
8
|
|
|
8
|
-
var _chunkEJKCEP3Qcjs = require('./chunk-EJKCEP3Q.cjs');
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _chunkV3IMDOZEcjs = require('./chunk-V3IMDOZE.cjs');
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
|
|
16
|
-
var
|
|
16
|
+
var _chunkMANE7HAZcjs = require('./chunk-MANE7HAZ.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 _chunkIM5SIGUNcjs.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 _chunkIM5SIGUNcjs.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);
|
|
@@ -3201,16 +3201,16 @@ function recordOpenEndCellEdges(grid, cells, horizontals) {
|
|
|
3201
3201
|
}
|
|
3202
3202
|
function takeClipCellEdges(from, to) {
|
|
3203
3203
|
const e = CLIP_CELL_EDGES.get(from);
|
|
3204
|
-
if (e)
|
|
3204
|
+
if (e) _chunkV3IMDOZEcjs.CELL_EDGES.set(to, e);
|
|
3205
3205
|
}
|
|
3206
3206
|
function hasOpenCellSeam(a, b) {
|
|
3207
|
-
const u =
|
|
3207
|
+
const u = _chunkV3IMDOZEcjs.CELL_EDGES.get(a), d = _chunkV3IMDOZEcjs.CELL_EDGES.get(b);
|
|
3208
3208
|
return !!u && !!d && u.t && !u.b && !d.t && d.b && u.l && u.r && d.l && d.r;
|
|
3209
3209
|
}
|
|
3210
3210
|
function joinCellEdges(a, b) {
|
|
3211
|
-
const u =
|
|
3211
|
+
const u = _chunkV3IMDOZEcjs.CELL_EDGES.get(a), d = _chunkV3IMDOZEcjs.CELL_EDGES.get(b);
|
|
3212
3212
|
if (!u || !d) return;
|
|
3213
|
-
|
|
3213
|
+
_chunkV3IMDOZEcjs.CELL_EDGES.set(a, { t: u.t, b: d.b, l: u.l || d.l, r: u.r || d.r });
|
|
3214
3214
|
}
|
|
3215
3215
|
|
|
3216
3216
|
// src/pdf/cell-extract.ts
|
|
@@ -3386,7 +3386,7 @@ function tagScripts(text, lines) {
|
|
|
3386
3386
|
const [s, e, kind] = marks[m];
|
|
3387
3387
|
out = out.slice(0, s) + `<${kind}>` + out.slice(s, e) + `</${kind}>` + out.slice(e);
|
|
3388
3388
|
}
|
|
3389
|
-
return
|
|
3389
|
+
return _chunkV3IMDOZEcjs.tidyScriptTags.call(void 0, out);
|
|
3390
3390
|
}
|
|
3391
3391
|
|
|
3392
3392
|
// src/pdf/line-wrap.ts
|
|
@@ -4090,12 +4090,12 @@ function groupItemsToVisualLines(items) {
|
|
|
4090
4090
|
var MIN_ALIGNED_COLUMNS = 3;
|
|
4091
4091
|
var MIN_ALIGNED_LINES = 3;
|
|
4092
4092
|
var ALIGNED_LINE_TOL = 0.5;
|
|
4093
|
-
function alignedSubRows(itemsByCol) {
|
|
4093
|
+
function alignedSubRows(itemsByCol, minLines = MIN_ALIGNED_LINES) {
|
|
4094
4094
|
const byCol = itemsByCol.map(groupItemsToVisualLines);
|
|
4095
4095
|
const cols = byCol.filter((lines) => lines.length);
|
|
4096
4096
|
if (cols.length < MIN_ALIGNED_COLUMNS) return null;
|
|
4097
4097
|
const k = cols[0].length;
|
|
4098
|
-
if (k <
|
|
4098
|
+
if (k < minLines || cols.some((lines) => lines.length !== k)) return null;
|
|
4099
4099
|
const cy = (line) => line.reduce((s, it) => s + itemCenterY(it), 0) / line.length;
|
|
4100
4100
|
for (let i = 0; i < k; i++) {
|
|
4101
4101
|
const ys = cols.map((lines) => cy(lines[i]));
|
|
@@ -4104,7 +4104,7 @@ function alignedSubRows(itemsByCol) {
|
|
|
4104
4104
|
}
|
|
4105
4105
|
return Array.from({ length: k }, (_, i) => byCol.map((lines) => lines.length ? cellTextToString(lines[i]) : ""));
|
|
4106
4106
|
}
|
|
4107
|
-
function normalizeUndersegmentedTable(originalCells, colXs, items, rowYs, kept, maxRows = MAX_UNDERSEGMENTED_ROWS) {
|
|
4107
|
+
function normalizeUndersegmentedTable(originalCells, colXs, items, rowYs, kept, maxRows = MAX_UNDERSEGMENTED_ROWS, minAlignedLines = MIN_ALIGNED_LINES) {
|
|
4108
4108
|
const numRows = originalCells.length;
|
|
4109
4109
|
const numCols = colXs.length - 1;
|
|
4110
4110
|
if (numRows > maxRows || numCols < MIN_UNDERSEGMENTED_COLUMNS) return null;
|
|
@@ -4120,11 +4120,14 @@ function normalizeUndersegmentedTable(originalCells, colXs, items, rowYs, kept,
|
|
|
4120
4120
|
rebuilt2.push(row);
|
|
4121
4121
|
continue;
|
|
4122
4122
|
}
|
|
4123
|
-
const
|
|
4124
|
-
const
|
|
4123
|
+
const span2 = Math.min(numRows - r, Math.max(1, ...originalCells[r].map((cell) => _nullishCoalesce(cell.rowSpan, () => ( 1)))));
|
|
4124
|
+
const band = span2 > 1 && originalCells.slice(r + 1, r + span2).every((cells) => cells.every((cell) => !cell.text.trim())) ? span2 : 1;
|
|
4125
|
+
const rowItems = items.filter((item) => itemCenterY(item) <= rowYs[r] + 1 && itemCenterY(item) >= rowYs[r + band] - 1);
|
|
4126
|
+
const body = normalizeUndersegmentedTable([originalCells[r]], colXs, rowItems, void 0, void 0, void 0, band > 1 ? 2 : MIN_ALIGNED_LINES);
|
|
4125
4127
|
if (body) {
|
|
4126
4128
|
rebuilt2.push(...body);
|
|
4127
4129
|
expanded++;
|
|
4130
|
+
r += band - 1;
|
|
4128
4131
|
} else {
|
|
4129
4132
|
_optionalChain([kept, 'optionalAccess', _116 => _116.set, 'call', _117 => _117(rebuilt2.length, r)]);
|
|
4130
4133
|
rebuilt2.push(row);
|
|
@@ -4141,7 +4144,7 @@ function normalizeUndersegmentedTable(originalCells, colXs, items, rowYs, kept,
|
|
|
4141
4144
|
for (const colItems of itemsByCol) {
|
|
4142
4145
|
if (groupItemsToVisualLines(colItems).length >= MIN_UNDERSEGMENTED_TEXT_LINES) denseColumns++;
|
|
4143
4146
|
}
|
|
4144
|
-
if (denseColumns < 2) return numRows === 1 ? alignedSubRows(itemsByCol) : null;
|
|
4147
|
+
if (denseColumns < 2) return numRows === 1 ? alignedSubRows(itemsByCol, minAlignedLines) : null;
|
|
4145
4148
|
const allLines = groupItemsToVisualLines(items.filter((i) => i.text.trim()));
|
|
4146
4149
|
const bands = [];
|
|
4147
4150
|
for (const line of allLines) {
|
|
@@ -4751,7 +4754,7 @@ function isChartTable(table, ocr = false) {
|
|
|
4751
4754
|
if (table.rows < 3 || texts.length === 0) return false;
|
|
4752
4755
|
const numeric = texts.filter((text) => NUMERIC_CELL.test(text)).length;
|
|
4753
4756
|
if (numeric < texts.length * 0.5) return false;
|
|
4754
|
-
if (ocr && table.cols >= 3 &&
|
|
4757
|
+
if (ocr && table.cols >= 3 && table.cells.slice(0, 3).some((row) => row.filter((cell) => /[가-힣]{2}/.test(cell.text)).length >= 2)) return false;
|
|
4755
4758
|
for (let c = 0; c < table.cols; c++) {
|
|
4756
4759
|
if (!ocr ? isValueAxisColumn(table, c) : hasValueAxis(table.cells.flatMap((row) => (_nullishCoalesce(_optionalChain([row, 'access', _139 => _139[c], 'optionalAccess', _140 => _140.text]), () => ( ""))).split(/\s+/)).filter((t) => TICK.test(t)).map((t) => Number(t.replace(/[,%]/g, ""))))) return true;
|
|
4757
4760
|
}
|
|
@@ -4759,6 +4762,12 @@ function isChartTable(table, ocr = false) {
|
|
|
4759
4762
|
const cells = table.rows * table.cols;
|
|
4760
4763
|
return cells - texts.length >= cells * 0.55 && values >= texts.length * 0.8 && (ocr || !hasAlignedRows(table));
|
|
4761
4764
|
}
|
|
4765
|
+
function isProseFragmentTable(table) {
|
|
4766
|
+
const texts = table.cells.flat().map((cell) => cell.text.trim()).filter(Boolean);
|
|
4767
|
+
if (texts.length < 4) return false;
|
|
4768
|
+
if (texts.filter((text) => (_nullishCoalesce(_optionalChain([text, 'access', _141 => _141.match, 'call', _142 => _142(/[가-힣]/g), 'optionalAccess', _143 => _143.length]), () => ( 0))) >= 2).length < texts.length * 0.7) return false;
|
|
4769
|
+
return texts.filter((text) => /(?:[다요고서는을를에게지며면어아야니까던]|[.,?!])$/.test(text)).length >= texts.length * 0.3;
|
|
4770
|
+
}
|
|
4762
4771
|
function isFormulaTable(table) {
|
|
4763
4772
|
const texts = table.cells.flat().map((cell) => cell.text.trim()).filter(Boolean);
|
|
4764
4773
|
if (texts.length < 3 || table.rows > 8 || !texts.some((text) => /=/.test(text))) return false;
|
|
@@ -4807,7 +4816,7 @@ function clusterCellLines(items) {
|
|
|
4807
4816
|
}
|
|
4808
4817
|
var WRAP_INDENT_MAX = 3;
|
|
4809
4818
|
function joinClusterCellLines(lines, box, lex) {
|
|
4810
|
-
let out = _nullishCoalesce(_optionalChain([lines, 'access',
|
|
4819
|
+
let out = _nullishCoalesce(_optionalChain([lines, 'access', _144 => _144[0], 'optionalAccess', _145 => _145.text]), () => ( ""));
|
|
4811
4820
|
for (let i = 1; i < lines.length; i++) {
|
|
4812
4821
|
const a = lines[i - 1], b = lines[i];
|
|
4813
4822
|
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) === "";
|
|
@@ -4934,8 +4943,23 @@ function detectClusterTables(items, pageNum, rejected, lex) {
|
|
|
4934
4943
|
}
|
|
4935
4944
|
}
|
|
4936
4945
|
return results.filter((r) => {
|
|
4937
|
-
const
|
|
4946
|
+
const twoColumns = isTwoColumnProse(r);
|
|
4947
|
+
const prose = twoColumns || isProseTable(r.table) || [...r.usedItems].every((it) => it.fontName === "ocr") && isProseFragmentTable(r.table);
|
|
4938
4948
|
if (prose && rejected) rejected.prose++;
|
|
4949
|
+
if (twoColumns && rejected && [...r.usedItems].every((it) => it.fontName === "ocr")) {
|
|
4950
|
+
const used = [...r.usedItems].sort((a, b) => a.x - b.x);
|
|
4951
|
+
const total = used.reduce((n, it) => n + it.text.length, 0);
|
|
4952
|
+
let reach = used[0].x + used[0].w, chars = used[0].text.length, best = 0;
|
|
4953
|
+
for (const it of used.slice(1)) {
|
|
4954
|
+
const gap = it.x - reach, share = chars / total;
|
|
4955
|
+
if (gap >= 8 && gap > best && share >= 0.25 && share <= 0.75) {
|
|
4956
|
+
best = gap;
|
|
4957
|
+
rejected.cutX = (it.x + reach) / 2;
|
|
4958
|
+
}
|
|
4959
|
+
reach = Math.max(reach, it.x + it.w);
|
|
4960
|
+
chars += it.text.length;
|
|
4961
|
+
}
|
|
4962
|
+
}
|
|
4939
4963
|
return !prose;
|
|
4940
4964
|
});
|
|
4941
4965
|
}
|
|
@@ -5079,7 +5103,7 @@ function detectAlignedTwoColumnTables(rows, pageNum) {
|
|
|
5079
5103
|
continue;
|
|
5080
5104
|
}
|
|
5081
5105
|
const top = rows[i - 1];
|
|
5082
|
-
const title = _optionalChain([top, 'optionalAccess',
|
|
5106
|
+
const title = _optionalChain([top, 'optionalAccess', _146 => _146.items, 'access', _147 => _147.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;
|
|
5083
5107
|
const tableRows = title ? [title, ...body] : body;
|
|
5084
5108
|
const cells = tableRows.map((row, idx) => {
|
|
5085
5109
|
if (title && idx === 0) return [{ text: row.items[0].text, colSpan: 2, rowSpan: 1 }, { text: "", colSpan: 1, rowSpan: 1 }];
|
|
@@ -5132,19 +5156,20 @@ function detectSparseTwoColumnTables(rows, pageNum) {
|
|
|
5132
5156
|
}
|
|
5133
5157
|
function isTwoColumnProse(r) {
|
|
5134
5158
|
const t = r.table;
|
|
5135
|
-
|
|
5159
|
+
const ocr = [...r.usedItems].every((it) => it.fontName === "ocr");
|
|
5160
|
+
if (t.rows < (ocr ? 6 : 8)) return false;
|
|
5136
5161
|
const dense = [];
|
|
5137
5162
|
for (let c = 0; c < t.cols; c++) {
|
|
5138
|
-
const filled = t.cells.filter((row) => _optionalChain([row, 'access',
|
|
5163
|
+
const filled = t.cells.filter((row) => _optionalChain([row, 'access', _148 => _148[c], 'optionalAccess', _149 => _149.text, 'access', _150 => _150.trim, 'call', _151 => _151()])).length;
|
|
5139
5164
|
if (filled / t.rows >= 0.3) dense.push(c);
|
|
5140
5165
|
}
|
|
5141
5166
|
if (dense.length !== 2) return false;
|
|
5142
5167
|
for (const c of dense) {
|
|
5143
|
-
const lens = t.cells.map((row) => _nullishCoalesce(_optionalChain([row, 'access',
|
|
5168
|
+
const lens = t.cells.map((row) => _nullishCoalesce(_optionalChain([row, 'access', _152 => _152[c], 'optionalAccess', _153 => _153.text, 'access', _154 => _154.replace, 'call', _155 => _155(/\s+/g, ""), 'access', _156 => _156.length]), () => ( 0))).filter((n) => n > 0);
|
|
5144
5169
|
const avg = lens.reduce((s, v) => s + v, 0) / (lens.length || 1);
|
|
5145
|
-
if (avg < 12) return false;
|
|
5170
|
+
if (avg < (ocr ? 15 : 12)) return false;
|
|
5146
5171
|
}
|
|
5147
|
-
return findTwoColumnProseCutX([...r.usedItems]) !== null;
|
|
5172
|
+
return ocr || findTwoColumnProseCutX([...r.usedItems]) !== null;
|
|
5148
5173
|
}
|
|
5149
5174
|
function findTwoColumnProseCutX(items) {
|
|
5150
5175
|
const lines = groupByBaseline(items);
|
|
@@ -5602,7 +5627,7 @@ function assignRowItems(items, columns, numCols, headerFace) {
|
|
|
5602
5627
|
const runs = [];
|
|
5603
5628
|
for (const it of sorted) {
|
|
5604
5629
|
const last = runs[runs.length - 1];
|
|
5605
|
-
const prev = _optionalChain([last, 'optionalAccess',
|
|
5630
|
+
const prev = _optionalChain([last, 'optionalAccess', _157 => _157[last.length - 1]]);
|
|
5606
5631
|
if (prev && it.x - (prev.x + prev.w) <= Math.max(0.5, it.fontSize * 0.05) && !it.hasSpaceBefore) last.push(it);
|
|
5607
5632
|
else runs.push([it]);
|
|
5608
5633
|
}
|
|
@@ -5653,7 +5678,7 @@ function assignRowItems(items, columns, numCols, headerFace) {
|
|
|
5653
5678
|
assignedGroups.add(gi);
|
|
5654
5679
|
usedCols.add(ci);
|
|
5655
5680
|
}
|
|
5656
|
-
const colOf = groups.map((g) => _nullishCoalesce(_optionalChain([result, 'access',
|
|
5681
|
+
const colOf = groups.map((g) => _nullishCoalesce(_optionalChain([result, 'access', _158 => _158.find, 'call', _159 => _159((a) => a.items === g), 'optionalAccess', _160 => _160.col]), () => ( -1)));
|
|
5657
5682
|
if (groups.length <= numCols && colOf.some((c, g) => g > 0 && c < colOf[g - 1])) {
|
|
5658
5683
|
const G = groups.length, cost = (g, c2) => Math.abs(groupCenters[g] - colCenters[c2]);
|
|
5659
5684
|
const best = groups.map(() => new Array(numCols).fill(Infinity)), from = groups.map(() => new Array(numCols).fill(-1));
|
|
@@ -5690,7 +5715,7 @@ function assignRowItems(items, columns, numCols, headerFace) {
|
|
|
5690
5715
|
function buildClusterTable(rows, columns, pageNum, lex) {
|
|
5691
5716
|
const numRows = rows.length;
|
|
5692
5717
|
if (numRows < MIN_ROWS || columns.length < MIN_COLS) return null;
|
|
5693
|
-
const headFaces = new Set(_optionalChain([rows, 'access',
|
|
5718
|
+
const headFaces = new Set(_optionalChain([rows, 'access', _161 => _161[0], 'optionalAccess', _162 => _162.items, 'access', _163 => _163.map, 'call', _164 => _164((i) => i.fontName)]));
|
|
5694
5719
|
const headerFace = headFaces.size === 1 && rows.slice(1).every((row) => row.items.every((i) => !headFaces.has(i.fontName))) ? [...headFaces][0] : void 0;
|
|
5695
5720
|
const assigned = rows.map((row, r) => assignRowItems(row.items, columns, columns.length, r === 0 ? headerFace : void 0));
|
|
5696
5721
|
const cuts = supportedOcrColumnCuts(assigned);
|
|
@@ -5761,7 +5786,7 @@ function buildClusterTable(rows, columns, pageNum, lex) {
|
|
|
5761
5786
|
const nonEmptyCols = cells[r].filter((c) => c.text.trim()).length;
|
|
5762
5787
|
if (nonEmptyCols !== 1) continue;
|
|
5763
5788
|
if (cells[r][0].text.trim() !== "") continue;
|
|
5764
|
-
const contentText = _optionalChain([cells, 'access',
|
|
5789
|
+
const contentText = _optionalChain([cells, 'access', _165 => _165[r], 'access', _166 => _166.find, 'call', _167 => _167((c) => c.text.trim()), 'optionalAccess', _168 => _168.text, 'access', _169 => _169.trim, 'call', _170 => _170()]) || "";
|
|
5765
5790
|
if (/^[○●▶\-·]/.test(contentText)) continue;
|
|
5766
5791
|
for (let pr = r - 1; pr >= 0; pr--) {
|
|
5767
5792
|
if (cells[pr].some((c) => c.text.trim())) {
|
|
@@ -5994,7 +6019,7 @@ function stackedTableBands(items) {
|
|
|
5994
6019
|
const caption = (start, end) => lines.slice(start, end).some((line) => /^Table\s+\d+\s*[:.]/i.test(mergeLineSimple(line).trim()));
|
|
5995
6020
|
while (runs.length > 0 && !caption(runs[runs.length - 1].end, lines.length)) runs.pop();
|
|
5996
6021
|
if (runs.length < 2) return null;
|
|
5997
|
-
if (runs.some((run, i) => !caption(run.end, _nullishCoalesce(_optionalChain([runs, 'access',
|
|
6022
|
+
if (runs.some((run, i) => !caption(run.end, _nullishCoalesce(_optionalChain([runs, 'access', _171 => _171[i + 1], 'optionalAccess', _172 => _172.start]), () => ( lines.length))))) return null;
|
|
5998
6023
|
const tables = runs.map((run) => lines.slice(run.start, run.end).flat());
|
|
5999
6024
|
const between = runs.slice(0, -1).map((run, i) => lines.slice(run.end, runs[i + 1].start).flat());
|
|
6000
6025
|
const tail = lines.slice(runs[runs.length - 1].end);
|
|
@@ -6262,7 +6287,7 @@ function splitTrailingColumnRegion(items) {
|
|
|
6262
6287
|
}
|
|
6263
6288
|
function panelBlocks(items, panel, pageNum) {
|
|
6264
6289
|
const lines = groupByY([...items].sort((a, b) => b.y - a.y || a.x - b.x));
|
|
6265
|
-
const faceOf = (line) => _nullishCoalesce(_optionalChain([dominantStyle, 'call',
|
|
6290
|
+
const faceOf = (line) => _nullishCoalesce(_optionalChain([dominantStyle, 'call', _173 => _173(line), 'optionalAccess', _174 => _174.fontName]), () => ( ""));
|
|
6266
6291
|
const runs = [];
|
|
6267
6292
|
for (const line of lines) {
|
|
6268
6293
|
const last = runs[runs.length - 1];
|
|
@@ -6444,7 +6469,7 @@ function validWrapBands(items, bands) {
|
|
|
6444
6469
|
}
|
|
6445
6470
|
function inheritedWrapBands(items) {
|
|
6446
6471
|
const source = XY_WRAP_ITEMS.get(items[0]);
|
|
6447
|
-
const present = _optionalChain([source, 'optionalAccess',
|
|
6472
|
+
const present = _optionalChain([source, 'optionalAccess', _175 => _175.length]) === items.length ? new Set(items) : null;
|
|
6448
6473
|
const sameLeaf = present && source.every((item) => present.has(item));
|
|
6449
6474
|
return sameLeaf ? validWrapBands(items, _nullishCoalesce(XY_WRAP_BANDS.get(items[0]), () => ( []))) : [];
|
|
6450
6475
|
}
|
|
@@ -6483,7 +6508,7 @@ function wrappedLineBands(items, inherited) {
|
|
|
6483
6508
|
left: box.x,
|
|
6484
6509
|
right: box.x + box.width,
|
|
6485
6510
|
y: row.reduce((n, i) => n + i.y, 0) / row.length,
|
|
6486
|
-
fontSize: _nullishCoalesce(_optionalChain([dominantStyle, 'call',
|
|
6511
|
+
fontSize: _nullishCoalesce(_optionalChain([dominantStyle, 'call', _176 => _176(row), 'optionalAccess', _177 => _177.fontSize]), () => ( 0)),
|
|
6487
6512
|
sources: row.map((item) => ({ item, state: { ...item } }))
|
|
6488
6513
|
};
|
|
6489
6514
|
});
|
|
@@ -6619,10 +6644,10 @@ function pushLineParagraphs(out, yLines, pageNum, lex) {
|
|
|
6619
6644
|
const lines = attachDropCaps(yLines).map((items) => ({ items, text: mergeLineSimple(items) })).filter((l) => l.text.trim());
|
|
6620
6645
|
const geo = lines.map((l) => {
|
|
6621
6646
|
const b = computeBBox(l.items, pageNum);
|
|
6622
|
-
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',
|
|
6647
|
+
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', _178 => _178(l.items), 'optionalAccess', _179 => _179.fontSize]), () => ( 0)) };
|
|
6623
6648
|
});
|
|
6624
6649
|
const joins = bodyLineJoins(geo, lex);
|
|
6625
|
-
const first = _optionalChain([lines, 'access',
|
|
6650
|
+
const first = _optionalChain([lines, 'access', _180 => _180[0], 'optionalAccess', _181 => _181.items, 'access', _182 => _182[0]]);
|
|
6626
6651
|
const bands = first ? _nullishCoalesce(XY_WRAP_BANDS.get(first), () => ( [])) : [];
|
|
6627
6652
|
const hasBand = (top, bottom) => {
|
|
6628
6653
|
let lo = 0, hi = bands.length;
|
|
@@ -6699,15 +6724,15 @@ function computeMedianFontSizeFromFreq(freq) {
|
|
|
6699
6724
|
function detectHeadings(blocks, medianFontSize) {
|
|
6700
6725
|
for (let bi = 0; bi < blocks.length; bi++) {
|
|
6701
6726
|
const block = blocks[bi];
|
|
6702
|
-
if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access',
|
|
6727
|
+
if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access', _183 => _183.style, 'optionalAccess', _184 => _184.fontSize])) continue;
|
|
6703
6728
|
const text = block.text.trim();
|
|
6704
6729
|
if (text.length === 0 || text.length > 200) continue;
|
|
6705
6730
|
if (/^\d+$/.test(text) && !isChapterNumber(block, blocks[bi + 1], medianFontSize)) continue;
|
|
6706
6731
|
const ratio = block.style.fontSize / medianFontSize;
|
|
6707
6732
|
let level = 0;
|
|
6708
|
-
if (ratio >=
|
|
6709
|
-
else if (ratio >=
|
|
6710
|
-
else if (ratio >=
|
|
6733
|
+
if (ratio >= _chunkV3IMDOZEcjs.HEADING_RATIO_H1) level = 1;
|
|
6734
|
+
else if (ratio >= _chunkV3IMDOZEcjs.HEADING_RATIO_H2) level = 2;
|
|
6735
|
+
else if (ratio >= _chunkV3IMDOZEcjs.HEADING_RATIO_H3) level = 3;
|
|
6711
6736
|
if (level > 0) {
|
|
6712
6737
|
block.type = "heading";
|
|
6713
6738
|
block.level = level;
|
|
@@ -6716,21 +6741,21 @@ function detectHeadings(blocks, medianFontSize) {
|
|
|
6716
6741
|
}
|
|
6717
6742
|
}
|
|
6718
6743
|
function isChapterNumber(block, next, medianFontSize) {
|
|
6719
|
-
const size = _nullishCoalesce(_optionalChain([block, 'access',
|
|
6720
|
-
const nextSize = _nullishCoalesce(_optionalChain([next, 'optionalAccess',
|
|
6721
|
-
const text = _nullishCoalesce(_optionalChain([next, 'optionalAccess',
|
|
6722
|
-
const a = block.bbox, b = _optionalChain([next, 'optionalAccess',
|
|
6723
|
-
return /^\d{1,2}$/.test(_nullishCoalesce(_optionalChain([block, 'access',
|
|
6744
|
+
const size = _nullishCoalesce(_optionalChain([block, 'access', _185 => _185.style, 'optionalAccess', _186 => _186.fontSize]), () => ( 0));
|
|
6745
|
+
const nextSize = _nullishCoalesce(_optionalChain([next, 'optionalAccess', _187 => _187.style, 'optionalAccess', _188 => _188.fontSize]), () => ( 0));
|
|
6746
|
+
const text = _nullishCoalesce(_optionalChain([next, 'optionalAccess', _189 => _189.text, 'optionalAccess', _190 => _190.trim, 'call', _191 => _191()]), () => ( ""));
|
|
6747
|
+
const a = block.bbox, b = _optionalChain([next, 'optionalAccess', _192 => _192.bbox]);
|
|
6748
|
+
return /^\d{1,2}$/.test(_nullishCoalesce(_optionalChain([block, 'access', _193 => _193.text, 'optionalAccess', _194 => _194.trim, 'call', _195 => _195()]), () => ( ""))) && size >= medianFontSize * 2.5 && !!next && (next.type === "paragraph" || next.type === "heading") && next.pageNumber === block.pageNumber && nextSize >= medianFontSize * _chunkV3IMDOZEcjs.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;
|
|
6724
6749
|
}
|
|
6725
6750
|
function mergeStackedHeadingLines(blocks, medianFontSize) {
|
|
6726
6751
|
for (let i = 0; i < blocks.length - 1; ) {
|
|
6727
6752
|
const a = blocks[i], b = blocks[i + 1];
|
|
6728
6753
|
const ab = a.bbox, bb = b.bbox;
|
|
6729
|
-
const af = _nullishCoalesce(_optionalChain([a, 'access',
|
|
6754
|
+
const af = _nullishCoalesce(_optionalChain([a, 'access', _196 => _196.style, 'optionalAccess', _197 => _197.fontSize]), () => ( 0)), bf = _nullishCoalesce(_optionalChain([b, 'access', _198 => _198.style, 'optionalAccess', _199 => _199.fontSize]), () => ( 0));
|
|
6730
6755
|
const gap = ab && bb ? ab.y - (bb.y + bb.height) : Infinity;
|
|
6731
|
-
const centered = ab && bb && _optionalChain([a, 'access',
|
|
6756
|
+
const centered = ab && bb && _optionalChain([a, 'access', _200 => _200.style, 'optionalAccess', _201 => _201.fontName]) === _optionalChain([b, 'access', _202 => _202.style, 'optionalAccess', _203 => _203.fontName]) && Math.abs(ab.x + ab.width / 2 - (bb.x + bb.width / 2)) <= Math.max(5, af * 0.5);
|
|
6732
6757
|
const sameAnchor = ab && bb && Math.abs(ab.x - bb.x) <= 5;
|
|
6733
|
-
const wrapped = sameAnchor && _optionalChain([a, 'access',
|
|
6758
|
+
const wrapped = sameAnchor && _optionalChain([a, 'access', _204 => _204.style, 'optionalAccess', _205 => _205.fontName]) === _optionalChain([b, 'access', _206 => _206.style, 'optionalAccess', _207 => _207.fontName]) && af === bf && ab.width >= bb.width * 0.95 && (_nullishCoalesce(_optionalChain([a, 'access', _208 => _208.text, 'optionalAccess', _209 => _209.trim, 'call', _210 => _210(), 'access', _211 => _211.split, 'call', _212 => _212(/\s+/), 'access', _213 => _213.length]), () => ( 0))) >= 3;
|
|
6734
6759
|
const displayStack = centered && gap <= Math.min(af, bf) * 0.3 && Math.max(af, bf) <= Math.min(af, bf) * 1.45;
|
|
6735
6760
|
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)) {
|
|
6736
6761
|
i++;
|
|
@@ -6759,25 +6784,25 @@ function detectTypographyHeadings(blocks) {
|
|
|
6759
6784
|
if (page.some((block) => block.type === "heading")) continue;
|
|
6760
6785
|
const faceWeight = /* @__PURE__ */ new Map();
|
|
6761
6786
|
for (const block of page) {
|
|
6762
|
-
if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access',
|
|
6787
|
+
if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access', _214 => _214.style, 'optionalAccess', _215 => _215.fontName])) continue;
|
|
6763
6788
|
const faces = FACE_CHARS.get(block);
|
|
6764
6789
|
if (faces) for (const [face, n] of faces) faceWeight.set(face, (_nullishCoalesce(faceWeight.get(face), () => ( 0))) + n);
|
|
6765
6790
|
else faceWeight.set(block.style.fontName, (_nullishCoalesce(faceWeight.get(block.style.fontName), () => ( 0))) + block.text.length);
|
|
6766
6791
|
}
|
|
6767
|
-
const bodyFace = _optionalChain([[...faceWeight], 'access',
|
|
6792
|
+
const bodyFace = _optionalChain([[...faceWeight], 'access', _216 => _216.sort, 'call', _217 => _217((a, b) => b[1] - a[1]), 'access', _218 => _218[0], 'optionalAccess', _219 => _219[0]]);
|
|
6768
6793
|
if (!bodyFace || (_nullishCoalesce(faceWeight.get(bodyFace), () => ( 0))) < 250) continue;
|
|
6769
6794
|
const sizeWeight = /* @__PURE__ */ new Map();
|
|
6770
6795
|
for (const block of page) {
|
|
6771
|
-
if (block.type !== "paragraph" || !_optionalChain([block, 'access',
|
|
6796
|
+
if (block.type !== "paragraph" || !_optionalChain([block, 'access', _220 => _220.style, 'optionalAccess', _221 => _221.fontSize])) continue;
|
|
6772
6797
|
const faces = FACE_CHARS.get(block);
|
|
6773
|
-
const chars = faces ? _nullishCoalesce(faces.get(bodyFace), () => ( 0)) : block.style.fontName === bodyFace ? _nullishCoalesce(_optionalChain([block, 'access',
|
|
6798
|
+
const chars = faces ? _nullishCoalesce(faces.get(bodyFace), () => ( 0)) : block.style.fontName === bodyFace ? _nullishCoalesce(_optionalChain([block, 'access', _222 => _222.text, 'optionalAccess', _223 => _223.length]), () => ( 0)) : 0;
|
|
6774
6799
|
if (chars) sizeWeight.set(block.style.fontSize, (_nullishCoalesce(sizeWeight.get(block.style.fontSize), () => ( 0))) + chars);
|
|
6775
6800
|
}
|
|
6776
|
-
const bodySize = _nullishCoalesce(_optionalChain([[...sizeWeight], 'access',
|
|
6801
|
+
const bodySize = _nullishCoalesce(_optionalChain([[...sizeWeight], 'access', _224 => _224.sort, 'call', _225 => _225((a, b) => b[1] - a[1]), 'access', _226 => _226[0], 'optionalAccess', _227 => _227[0]]), () => ( 0));
|
|
6777
6802
|
for (let i = 0; i < page.length; i++) {
|
|
6778
6803
|
const block = page[i];
|
|
6779
6804
|
const { text, bbox, style } = block;
|
|
6780
|
-
if (block.type !== "paragraph" || !text || !bbox || !_optionalChain([style, 'optionalAccess',
|
|
6805
|
+
if (block.type !== "paragraph" || !text || !bbox || !_optionalChain([style, 'optionalAccess', _228 => _228.fontName]) || !style.fontSize) continue;
|
|
6781
6806
|
const title = text.trim();
|
|
6782
6807
|
const numbered = /^\d+(?:\.\d+)*\.?\s+[A-Z가-힣]/.test(title);
|
|
6783
6808
|
const faces = FACE_CHARS.get(block);
|
|
@@ -6807,16 +6832,16 @@ function detectDocumentStyleHeadings(blocks) {
|
|
|
6807
6832
|
for (const page of byPage.values()) {
|
|
6808
6833
|
const faceChars = /* @__PURE__ */ new Map();
|
|
6809
6834
|
for (const block of page) {
|
|
6810
|
-
if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access',
|
|
6835
|
+
if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access', _229 => _229.style, 'optionalAccess', _230 => _230.fontName])) continue;
|
|
6811
6836
|
faceChars.set(block.style.fontName, (_nullishCoalesce(faceChars.get(block.style.fontName), () => ( 0))) + block.text.length);
|
|
6812
6837
|
}
|
|
6813
|
-
const bodyFace = _optionalChain([[...faceChars], 'access',
|
|
6838
|
+
const bodyFace = _optionalChain([[...faceChars], 'access', _231 => _231.sort, 'call', _232 => _232((a, b) => b[1] - a[1]), 'access', _233 => _233[0], 'optionalAccess', _234 => _234[0]]);
|
|
6814
6839
|
if (!bodyFace || (_nullishCoalesce(faceChars.get(bodyFace), () => ( 0))) < 100) continue;
|
|
6815
|
-
const labels = page.filter((b) => b.type === "paragraph" && b.text && b.bbox && _optionalChain([b, 'access',
|
|
6840
|
+
const labels = page.filter((b) => b.type === "paragraph" && b.text && b.bbox && _optionalChain([b, 'access', _235 => _235.style, 'optionalAccess', _236 => _236.fontName]) && b.style.fontName !== bodyFace && b.text.trim().length >= 3 && b.text.trim().length <= 40);
|
|
6816
6841
|
for (const label of labels) {
|
|
6817
|
-
const peers = labels.filter((b) => _optionalChain([b, 'access',
|
|
6842
|
+
const peers = labels.filter((b) => _optionalChain([b, 'access', _237 => _237.style, 'optionalAccess', _238 => _238.fontName]) === _optionalChain([label, 'access', _239 => _239.style, 'optionalAccess', _240 => _240.fontName]) && Math.abs(b.bbox.y - label.bbox.y) <= 3 && Math.abs(b.bbox.x - label.bbox.x) >= 60);
|
|
6818
6843
|
if (peers.length < 2) continue;
|
|
6819
|
-
const value = page.find((b) => b.type === "paragraph" && b.bbox && _optionalChain([b, 'access',
|
|
6844
|
+
const value = page.find((b) => b.type === "paragraph" && b.bbox && _optionalChain([b, 'access', _241 => _241.style, 'optionalAccess', _242 => _242.fontName]) !== _optionalChain([label, 'access', _243 => _243.style, 'optionalAccess', _244 => _244.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);
|
|
6820
6845
|
if (value) {
|
|
6821
6846
|
label.type = "heading";
|
|
6822
6847
|
label.level = 2;
|
|
@@ -6825,7 +6850,7 @@ function detectDocumentStyleHeadings(blocks) {
|
|
|
6825
6850
|
const first = page.find((b) => b.type !== "image" && b.type !== "separator");
|
|
6826
6851
|
const second = page[page.indexOf(first) + 1];
|
|
6827
6852
|
const third = page[page.indexOf(first) + 2];
|
|
6828
|
-
if (!first || !second || !third || first.type !== "list" && first.type !== "paragraph" || second.type !== "paragraph" || !first.text || !second.text || !first.bbox || !second.bbox || !_optionalChain([first, 'access',
|
|
6853
|
+
if (!first || !second || !third || first.type !== "list" && first.type !== "paragraph" || second.type !== "paragraph" || !first.text || !second.text || !first.bbox || !second.bbox || !_optionalChain([first, 'access', _245 => _245.style, 'optionalAccess', _246 => _246.fontName]) || !_optionalChain([second, 'access', _247 => _247.style, 'optionalAccess', _248 => _248.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', _249 => _249.style, 'optionalAccess', _250 => _250.fontName]) !== bodyFace) continue;
|
|
6829
6854
|
first.type = "heading";
|
|
6830
6855
|
first.level = 1;
|
|
6831
6856
|
first.text = `${first.text.trim()} ${second.text.trim()}`;
|
|
@@ -6849,18 +6874,18 @@ function detectSiblingStyleHeadings(blocks) {
|
|
|
6849
6874
|
for (const page of byPage.values()) {
|
|
6850
6875
|
const bodyChars = /* @__PURE__ */ new Map();
|
|
6851
6876
|
for (const block of page) {
|
|
6852
|
-
if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access',
|
|
6877
|
+
if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access', _251 => _251.style, 'optionalAccess', _252 => _252.fontName])) continue;
|
|
6853
6878
|
const face = block.style.fontName;
|
|
6854
6879
|
bodyChars.set(face, (_nullishCoalesce(bodyChars.get(face), () => ( 0))) + block.text.length);
|
|
6855
6880
|
}
|
|
6856
|
-
const bodyFace = _optionalChain([[...bodyChars], 'access',
|
|
6857
|
-
const anchors = page.filter((b) => b.type === "heading" && b.text && _optionalChain([b, 'access',
|
|
6881
|
+
const bodyFace = _optionalChain([[...bodyChars], 'access', _253 => _253.sort, 'call', _254 => _254((a, b) => b[1] - a[1]), 'access', _255 => _255[0], 'optionalAccess', _256 => _256[0]]);
|
|
6882
|
+
const anchors = page.filter((b) => b.type === "heading" && b.text && _optionalChain([b, 'access', _257 => _257.style, 'optionalAccess', _258 => _258.fontName]) && b.style.fontName !== bodyFace);
|
|
6858
6883
|
for (const anchor of anchors) {
|
|
6859
6884
|
const numbered = /^([A-Z])\.\d+\s+/.exec(anchor.text.trim());
|
|
6860
6885
|
const lettered = /^([A-Z])\s+/.exec(anchor.text.trim());
|
|
6861
|
-
const peers = anchors.filter((b) => _optionalChain([b, 'access',
|
|
6886
|
+
const peers = anchors.filter((b) => _optionalChain([b, 'access', _259 => _259.style, 'optionalAccess', _260 => _260.fontName]) === _optionalChain([anchor, 'access', _261 => _261.style, 'optionalAccess', _262 => _262.fontName]) && Math.abs((_nullishCoalesce(_optionalChain([b, 'access', _263 => _263.style, 'optionalAccess', _264 => _264.fontSize]), () => ( 0))) - (_nullishCoalesce(_optionalChain([anchor, 'access', _265 => _265.style, 'optionalAccess', _266 => _266.fontSize]), () => ( 0)))) < 0.5);
|
|
6862
6887
|
if (peers.length < 2 && !numbered && !lettered) continue;
|
|
6863
|
-
const candidates = page.filter((b) => b.type === "paragraph" && b.text && b.bbox && _optionalChain([b, 'access',
|
|
6888
|
+
const candidates = page.filter((b) => b.type === "paragraph" && b.text && b.bbox && _optionalChain([b, 'access', _267 => _267.style, 'optionalAccess', _268 => _268.fontName]) === _optionalChain([anchor, 'access', _269 => _269.style, 'optionalAccess', _270 => _270.fontName]) && Math.abs((_nullishCoalesce(_optionalChain([b, 'access', _271 => _271.style, 'optionalAccess', _272 => _272.fontSize]), () => ( 0))) - (_nullishCoalesce(_optionalChain([anchor, 'access', _273 => _273.style, 'optionalAccess', _274 => _274.fontSize]), () => ( 0)))) < 0.5 && b.text.trim().length >= 3 && b.text.trim().length <= 80 && b.bbox.height <= (_nullishCoalesce(_optionalChain([b, 'access', _275 => _275.style, 'optionalAccess', _276 => _276.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()));
|
|
6864
6889
|
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));
|
|
6865
6890
|
if (siblings.length < (numbered || lettered ? 1 : 2)) continue;
|
|
6866
6891
|
for (const sibling of siblings) {
|
|
@@ -6879,13 +6904,13 @@ function detectRepeatedPageLabels(blocks) {
|
|
|
6879
6904
|
}
|
|
6880
6905
|
for (const page of byPage.values()) {
|
|
6881
6906
|
const bodyChars = /* @__PURE__ */ new Map();
|
|
6882
|
-
for (const b of page) if (b.type === "paragraph" && b.text && _optionalChain([b, 'access',
|
|
6907
|
+
for (const b of page) if (b.type === "paragraph" && b.text && _optionalChain([b, 'access', _277 => _277.style, 'optionalAccess', _278 => _278.fontName])) {
|
|
6883
6908
|
const faces = FACE_CHARS.get(b);
|
|
6884
6909
|
if (faces) for (const [face, n] of faces) bodyChars.set(face, (_nullishCoalesce(bodyChars.get(face), () => ( 0))) + n);
|
|
6885
6910
|
else bodyChars.set(b.style.fontName, (_nullishCoalesce(bodyChars.get(b.style.fontName), () => ( 0))) + b.text.length);
|
|
6886
6911
|
}
|
|
6887
|
-
const bodyFace = _optionalChain([[...bodyChars], 'access',
|
|
6888
|
-
const candidates = page.filter((b) => b.type === "paragraph" && b.text && b.bbox && _optionalChain([b, 'access',
|
|
6912
|
+
const bodyFace = _optionalChain([[...bodyChars], 'access', _279 => _279.sort, 'call', _280 => _280((a, b) => b[1] - a[1]), 'access', _281 => _281[0], 'optionalAccess', _282 => _282[0]]);
|
|
6913
|
+
const candidates = page.filter((b) => b.type === "paragraph" && b.text && b.bbox && _optionalChain([b, 'access', _283 => _283.style, 'optionalAccess', _284 => _284.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);
|
|
6889
6914
|
const groups = /* @__PURE__ */ new Map();
|
|
6890
6915
|
for (const b of candidates) {
|
|
6891
6916
|
const key = `${b.style.fontName}:${b.style.fontSize}`;
|
|
@@ -6921,19 +6946,19 @@ function detectPageLeadHeadings(blocks) {
|
|
|
6921
6946
|
for (const page of byPage.values()) {
|
|
6922
6947
|
const content = page.filter((b) => b.type !== "image" && b.type !== "separator" && !(b.type === "paragraph" && !b.style));
|
|
6923
6948
|
const [first, second, third] = content;
|
|
6924
|
-
if (!_optionalChain([first, 'optionalAccess',
|
|
6949
|
+
if (!_optionalChain([first, 'optionalAccess', _285 => _285.bbox]) || !first.text || !_optionalChain([first, 'access', _286 => _286.style, 'optionalAccess', _287 => _287.fontSize]) || !second) continue;
|
|
6925
6950
|
const firstText = first.text.trim();
|
|
6926
6951
|
const captionLike = /^(?:Figure|Fig\.?|Table|표|그림)\s*\d/i;
|
|
6927
6952
|
const hasImage = page.some((b) => b.type === "image");
|
|
6928
|
-
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',
|
|
6953
|
+
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', _288 => _288.text, 'optionalAccess', _289 => _289.trim, 'call', _290 => _290()]), () => ( ""))) && (_nullishCoalesce(_optionalChain([second, 'access', _291 => _291.text, 'optionalAccess', _292 => _292.length]), () => ( 0))) >= 100 && second.bbox && first.bbox.y - (second.bbox.y + second.bbox.height) >= first.style.fontSize);
|
|
6929
6954
|
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);
|
|
6930
|
-
const firstIsSection = first.type === "list" && /^\d+\.\s+[A-Z][A-Z\s]{12,}$/.test(firstText) && second.type === "paragraph" && (_nullishCoalesce(_optionalChain([second, 'access',
|
|
6955
|
+
const firstIsSection = first.type === "list" && /^\d+\.\s+[A-Z][A-Z\s]{12,}$/.test(firstText) && second.type === "paragraph" && (_nullishCoalesce(_optionalChain([second, 'access', _293 => _293.text, 'optionalAccess', _294 => _294.length]), () => ( 0))) >= 100;
|
|
6931
6956
|
if (firstIsTitle || firstAboveProse || firstIsSection) {
|
|
6932
6957
|
first.type = "heading";
|
|
6933
6958
|
first.level = 1;
|
|
6934
6959
|
}
|
|
6935
|
-
if (first.type !== "heading" || captionLike.test(firstText) || second.type !== "paragraph" || !second.text || !second.bbox || !_optionalChain([second, 'access',
|
|
6936
|
-
const distinctFace = _optionalChain([third, 'access',
|
|
6960
|
+
if (first.type !== "heading" || captionLike.test(firstText) || second.type !== "paragraph" || !second.text || !second.bbox || !_optionalChain([second, 'access', _295 => _295.style, 'optionalAccess', _296 => _296.fontName]) || !second.style.fontSize || !_optionalChain([third, 'optionalAccess', _297 => _297.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;
|
|
6961
|
+
const distinctFace = _optionalChain([third, 'access', _298 => _298.style, 'optionalAccess', _299 => _299.fontName]) !== second.style.fontName;
|
|
6937
6962
|
const namedContents = /^Table of Contents$/i.test(second.text.trim());
|
|
6938
6963
|
if (distinctFace && third.text.length >= 60 || namedContents) {
|
|
6939
6964
|
second.type = "heading";
|
|
@@ -6944,24 +6969,24 @@ function detectPageLeadHeadings(blocks) {
|
|
|
6944
6969
|
function refineDocumentStyleHeadings(blocks) {
|
|
6945
6970
|
const faceChars = /* @__PURE__ */ new Map();
|
|
6946
6971
|
for (const block of blocks) {
|
|
6947
|
-
if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access',
|
|
6972
|
+
if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access', _300 => _300.style, 'optionalAccess', _301 => _301.fontName])) continue;
|
|
6948
6973
|
faceChars.set(block.style.fontName, (_nullishCoalesce(faceChars.get(block.style.fontName), () => ( 0))) + block.text.length);
|
|
6949
6974
|
}
|
|
6950
6975
|
const [bodyFace, bodyChars] = _nullishCoalesce([...faceChars].sort((a, b) => b[1] - a[1])[0], () => ( []));
|
|
6951
6976
|
if (!bodyFace || !bodyChars || bodyChars < 300) return;
|
|
6952
6977
|
for (let i = 0; i < blocks.length; i++) {
|
|
6953
6978
|
const block = blocks[i];
|
|
6954
|
-
const text = _nullishCoalesce(_optionalChain([block, 'access',
|
|
6979
|
+
const text = _nullishCoalesce(_optionalChain([block, 'access', _302 => _302.text, 'optionalAccess', _303 => _303.trim, 'call', _304 => _304()]), () => ( ""));
|
|
6955
6980
|
if (block.type === "heading" && /(?:https?:\/\/|www\.|^arxiv:|^doi:)/i.test(text)) {
|
|
6956
6981
|
block.type = "paragraph";
|
|
6957
6982
|
block.level = void 0;
|
|
6958
6983
|
continue;
|
|
6959
6984
|
}
|
|
6960
6985
|
const box = block.bbox, style = block.style;
|
|
6961
|
-
if (block.type !== "paragraph" || !box || !_optionalChain([style, 'optionalAccess',
|
|
6986
|
+
if (block.type !== "paragraph" || !box || !_optionalChain([style, 'optionalAccess', _305 => _305.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;
|
|
6962
6987
|
const previous = blocks[i - 1], next = blocks[i + 1];
|
|
6963
|
-
const pb = _optionalChain([previous, 'optionalAccess',
|
|
6964
|
-
if (!pb || !nb || previous.pageNumber !== block.pageNumber || next.pageNumber !== block.pageNumber || previous.type !== "paragraph" && previous.type !== "heading" || next.type !== "paragraph" || _optionalChain([next, 'access',
|
|
6988
|
+
const pb = _optionalChain([previous, 'optionalAccess', _306 => _306.bbox]), nb = _optionalChain([next, 'optionalAccess', _307 => _307.bbox]);
|
|
6989
|
+
if (!pb || !nb || previous.pageNumber !== block.pageNumber || next.pageNumber !== block.pageNumber || previous.type !== "paragraph" && previous.type !== "heading" || next.type !== "paragraph" || _optionalChain([next, 'access', _308 => _308.style, 'optionalAccess', _309 => _309.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;
|
|
6965
6990
|
block.type = "heading";
|
|
6966
6991
|
block.level = 2;
|
|
6967
6992
|
}
|
|
@@ -7011,7 +7036,7 @@ function detectMarkerHeadings(blocks) {
|
|
|
7011
7036
|
block.level = 4;
|
|
7012
7037
|
continue;
|
|
7013
7038
|
}
|
|
7014
|
-
if (/^[가-힣]{2,6}$/.test(text) && _optionalChain([block, 'access',
|
|
7039
|
+
if (/^[가-힣]{2,6}$/.test(text) && _optionalChain([block, 'access', _310 => _310.style, 'optionalAccess', _311 => _311.fontSize])) {
|
|
7015
7040
|
const prev = blocks[i - 1];
|
|
7016
7041
|
const next = blocks[i + 1];
|
|
7017
7042
|
const prevIsStructural = !prev || prev.type === "table" || prev.type === "heading" || prev.type === "separator";
|
|
@@ -7052,7 +7077,7 @@ function detectTableCaptions(blocks) {
|
|
|
7052
7077
|
block.table.caption = blocks[i - 1].text.trim();
|
|
7053
7078
|
blocks.splice(i - 1, 1);
|
|
7054
7079
|
i--;
|
|
7055
|
-
} else if (isCaptionCandidate(blocks[i + 1], block) && _optionalChain([blocks, 'access',
|
|
7080
|
+
} else if (isCaptionCandidate(blocks[i + 1], block) && _optionalChain([blocks, 'access', _312 => _312[i + 2], 'optionalAccess', _313 => _313.type]) !== "table") {
|
|
7056
7081
|
const cap = blocks[i + 1].bbox, tbl = block.bbox;
|
|
7057
7082
|
block.table.caption = blocks[i + 1].text.trim();
|
|
7058
7083
|
if (cap && tbl && cap.y + cap.height <= tbl.y + 1) block.table.captionBelow = true;
|
|
@@ -7137,7 +7162,7 @@ function detectKoreanListBlocks(blocks) {
|
|
|
7137
7162
|
}
|
|
7138
7163
|
const listType = label.family === "arabicDot" ? "ordered" : "unordered";
|
|
7139
7164
|
const listBlock = { ...b, type: "list", listType };
|
|
7140
|
-
const pb = _optionalChain([lastTopLevelList, 'optionalAccess',
|
|
7165
|
+
const pb = _optionalChain([lastTopLevelList, 'optionalAccess', _314 => _314.bbox]), cb = b.bbox;
|
|
7141
7166
|
const notIndented = depth > 0 && !!pb && !!cb && pb.page === cb.page && cb.x >= pb.x + pb.width && cb.y >= pb.y + pb.height;
|
|
7142
7167
|
if (notIndented) familyStack = [label.family];
|
|
7143
7168
|
if (depth === 0 || notIndented) {
|
|
@@ -7295,7 +7320,7 @@ function removeHeaderFooterBlocks(blocks, pageHeights, warnings, notes, tables =
|
|
|
7295
7320
|
const b = blocks[bi];
|
|
7296
7321
|
const cellTexts = b.type === "table" && b.table ? b.table.cells.flat().map((c) => c.text.trim()).filter(Boolean) : [];
|
|
7297
7322
|
const headBox = cellTexts.length <= 4 && !!b.bbox && b.bbox.height <= (_nullishCoalesce(pageHeights.get(b.bbox.page), () => ( Infinity))) * 0.05;
|
|
7298
|
-
const text = !tables ? _optionalChain([b, 'access',
|
|
7323
|
+
const text = !tables ? _optionalChain([b, 'access', _315 => _315.text, 'optionalAccess', _316 => _316.trim, 'call', _317 => _317()]) : cellTexts.length ? (headBox ? [...cellTexts].sort() : cellTexts).join(" | ") : void 0;
|
|
7299
7324
|
if (!b.bbox || !b.pageNumber || !text) continue;
|
|
7300
7325
|
const ph = pageHeights.get(b.bbox.page) || pageHeights.get(b.pageNumber);
|
|
7301
7326
|
if (!ph) continue;
|
|
@@ -7328,7 +7353,7 @@ function removeHeaderFooterBlocks(blocks, pageHeights, warnings, notes, tables =
|
|
|
7328
7353
|
for (const [p, count] of patternCount) {
|
|
7329
7354
|
const pages = [..._nullishCoalesce(patternPages.get(p), () => ( []))];
|
|
7330
7355
|
const span2 = pages.length ? Math.max(...pages) - Math.min(...pages) + 1 : 0;
|
|
7331
|
-
const varying = !tables && (_nullishCoalesce(_optionalChain([patternNumbers, 'access',
|
|
7356
|
+
const varying = !tables && (_nullishCoalesce(_optionalChain([patternNumbers, 'access', _318 => _318.get, 'call', _319 => _319(p), 'optionalAccess', _320 => _320.size]), () => ( 0))) > 1;
|
|
7332
7357
|
const occ = _nullishCoalesce(patternOcc.get(p), () => ( []));
|
|
7333
7358
|
const dense = pages.length >= span2 * 0.4;
|
|
7334
7359
|
const loose = looseVaryingNumber(occ, entries === topEntries) && (entries === bottomEntries || dense || tracksPages(occ));
|
|
@@ -7340,8 +7365,8 @@ function removeHeaderFooterBlocks(blocks, pageHeights, warnings, notes, tables =
|
|
|
7340
7365
|
for (const e of entries) {
|
|
7341
7366
|
const norm = e.text.replace(/\d+/g, "#");
|
|
7342
7367
|
if (!repeatedPatterns.has(norm)) continue;
|
|
7343
|
-
const noteMark = _optionalChain([e, 'access',
|
|
7344
|
-
if (noteMark && _optionalChain([notes, 'optionalAccess',
|
|
7368
|
+
const noteMark = _optionalChain([e, 'access', _321 => _321.text, 'access', _322 => _322.match, 'call', _323 => _323(/^\d{1,3}\)/), 'optionalAccess', _324 => _324[0]]);
|
|
7369
|
+
if (noteMark && _optionalChain([notes, 'optionalAccess', _325 => _325.get, 'call', _326 => _326(e.page), 'optionalAccess', _327 => _327.marks, 'access', _328 => _328.some, 'call', _329 => _329((m) => m.mark === noteMark)])) continue;
|
|
7345
7370
|
const cand = blocks[e.blockIdx];
|
|
7346
7371
|
const cb = cand.bbox;
|
|
7347
7372
|
const tableNote = /^(?:주\s*(?:\d+\s*[).:]|[::])|(?:자료|출처)\s*[::]|\*\s+\S)/.test(e.text.replace(/ \| /g, " ")) && blocks.some((o) => {
|
|
@@ -7355,7 +7380,7 @@ function removeHeaderFooterBlocks(blocks, pageHeights, warnings, notes, tables =
|
|
|
7355
7380
|
if (bi === e.blockIdx) continue;
|
|
7356
7381
|
const o = blocks[bi];
|
|
7357
7382
|
if (!o.bbox || o.bbox.page !== cb.page) continue;
|
|
7358
|
-
const oNorm = _optionalChain([o, 'access',
|
|
7383
|
+
const oNorm = _optionalChain([o, 'access', _330 => _330.text, 'optionalAccess', _331 => _331.trim, 'call', _332 => _332(), 'access', _333 => _333.replace, 'call', _334 => _334(/\d+/g, "#")]);
|
|
7359
7384
|
if (oNorm && repeatedPatterns.has(oNorm)) continue;
|
|
7360
7385
|
const overlap2 = Math.min(cb.y + cb.height, o.bbox.y + o.bbox.height) - Math.max(cb.y, o.bbox.y);
|
|
7361
7386
|
if (overlap2 >= cb.height * 0.5) {
|
|
@@ -7483,7 +7508,7 @@ function recordRowRules(table, cells, bbox, hs) {
|
|
|
7483
7508
|
function markImageCell(cell) {
|
|
7484
7509
|
IMAGE_CELLS.add(cell);
|
|
7485
7510
|
}
|
|
7486
|
-
var emptyCell = (cell) => !cell || !_optionalChain([cell, 'access',
|
|
7511
|
+
var emptyCell = (cell) => !cell || !_optionalChain([cell, 'access', _335 => _335.text, 'optionalAccess', _336 => _336.trim, 'call', _337 => _337()]) && !_optionalChain([cell, 'access', _338 => _338.blocks, 'optionalAccess', _339 => _339.length]) && !IMAGE_CELLS.has(cell);
|
|
7487
7512
|
function trimTable(table) {
|
|
7488
7513
|
let cols = table.cols;
|
|
7489
7514
|
while (cols > 0 && table.cells.every((row) => emptyCell(row[cols - 1]))) cols--;
|
|
@@ -7499,7 +7524,7 @@ function trimTable(table) {
|
|
|
7499
7524
|
function trimTrailingEmptyTableCols(blocks) {
|
|
7500
7525
|
for (const b of blocks) {
|
|
7501
7526
|
if (b.type !== "table" || !b.table) continue;
|
|
7502
|
-
for (const row of b.table.cells) for (const cell of row) if (_optionalChain([cell, 'access',
|
|
7527
|
+
for (const row of b.table.cells) for (const cell of row) if (_optionalChain([cell, 'access', _340 => _340.blocks, 'optionalAccess', _341 => _341.length])) trimTrailingEmptyTableCols(cell.blocks);
|
|
7503
7528
|
trimTable(b.table);
|
|
7504
7529
|
}
|
|
7505
7530
|
}
|
|
@@ -7519,7 +7544,7 @@ function mergeSliverColumns(grid, colXs, maxWidth) {
|
|
|
7519
7544
|
}
|
|
7520
7545
|
const ok = owner.every((row) => {
|
|
7521
7546
|
const o = row[c];
|
|
7522
|
-
return !!o && (o.colSpan > 1 || !o.text.trim() && !_optionalChain([o, 'access',
|
|
7547
|
+
return !!o && (o.colSpan > 1 || !o.text.trim() && !_optionalChain([o, 'access', _342 => _342.blocks, 'optionalAccess', _343 => _343.length]));
|
|
7523
7548
|
});
|
|
7524
7549
|
if (!ok) continue;
|
|
7525
7550
|
const spanning = /* @__PURE__ */ new Set();
|
|
@@ -7546,7 +7571,7 @@ var multiply = (m, t) => [
|
|
|
7546
7571
|
m[1] * t[4] + m[3] * t[5] + m[5]
|
|
7547
7572
|
];
|
|
7548
7573
|
function hollowCircle(image) {
|
|
7549
|
-
if (!_optionalChain([image, 'optionalAccess',
|
|
7574
|
+
if (!_optionalChain([image, 'optionalAccess', _344 => _344.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;
|
|
7550
7575
|
const stride = image.kind === _pdfmjs.ImageKind.RGB_24BPP ? 3 : image.kind === _pdfmjs.ImageKind.RGBA_32BPP ? 4 : 0;
|
|
7551
7576
|
const { width, height, data } = image;
|
|
7552
7577
|
if (!stride || data.length < width * height * stride) return false;
|
|
@@ -7611,9 +7636,9 @@ function smallVisibleImagePaints(fnArray, argsArray) {
|
|
|
7611
7636
|
const op = fnArray[i], args = argsArray[i];
|
|
7612
7637
|
if (op === _pdfmjs.OPS.save || op === _pdfmjs.OPS.paintFormXObjectBegin) {
|
|
7613
7638
|
stack.push({ ctm, alpha, clip, unknownClip });
|
|
7614
|
-
const matrix = op === _pdfmjs.OPS.paintFormXObjectBegin ? _optionalChain([args, 'optionalAccess',
|
|
7639
|
+
const matrix = op === _pdfmjs.OPS.paintFormXObjectBegin ? _optionalChain([args, 'optionalAccess', _345 => _345[0]]) : void 0;
|
|
7615
7640
|
if (Array.isArray(matrix) && matrix.length >= 6) ctm = multiply(ctm, matrix);
|
|
7616
|
-
const bounds = op === _pdfmjs.OPS.paintFormXObjectBegin ? _optionalChain([args, 'optionalAccess',
|
|
7641
|
+
const bounds = op === _pdfmjs.OPS.paintFormXObjectBegin ? _optionalChain([args, 'optionalAccess', _346 => _346[1]]) : void 0;
|
|
7617
7642
|
if (Array.isArray(bounds) && bounds.length === 4) {
|
|
7618
7643
|
const box = rectangle(bounds[0], bounds[1], bounds[2] - bounds[0], bounds[3] - bounds[1]);
|
|
7619
7644
|
if (box && ctm[1] === 0 && ctm[2] === 0) intersectClip(box);
|
|
@@ -7621,17 +7646,17 @@ function smallVisibleImagePaints(fnArray, argsArray) {
|
|
|
7621
7646
|
}
|
|
7622
7647
|
} else if (op === _pdfmjs.OPS.restore || op === _pdfmjs.OPS.paintFormXObjectEnd) {
|
|
7623
7648
|
const state = stack.pop();
|
|
7624
|
-
ctm = _nullishCoalesce(_optionalChain([state, 'optionalAccess',
|
|
7625
|
-
alpha = _nullishCoalesce(_optionalChain([state, 'optionalAccess',
|
|
7626
|
-
clip = _nullishCoalesce(_optionalChain([state, 'optionalAccess',
|
|
7627
|
-
unknownClip = _nullishCoalesce(_optionalChain([state, 'optionalAccess',
|
|
7649
|
+
ctm = _nullishCoalesce(_optionalChain([state, 'optionalAccess', _347 => _347.ctm]), () => ( [1, 0, 0, 1, 0, 0]));
|
|
7650
|
+
alpha = _nullishCoalesce(_optionalChain([state, 'optionalAccess', _348 => _348.alpha]), () => ( 1));
|
|
7651
|
+
clip = _nullishCoalesce(_optionalChain([state, 'optionalAccess', _349 => _349.clip]), () => ( null));
|
|
7652
|
+
unknownClip = _nullishCoalesce(_optionalChain([state, 'optionalAccess', _350 => _350.unknownClip]), () => ( false));
|
|
7628
7653
|
} else if (op === _pdfmjs.OPS.setGState) {
|
|
7629
|
-
for (const [key, value] of _nullishCoalesce(_optionalChain([args, 'optionalAccess',
|
|
7654
|
+
for (const [key, value] of _nullishCoalesce(_optionalChain([args, 'optionalAccess', _351 => _351[0]]), () => ( []))) {
|
|
7630
7655
|
if (key === "ca") alpha = typeof value === "number" ? value : 0;
|
|
7631
7656
|
}
|
|
7632
7657
|
} else if (op === _pdfmjs.OPS.constructPath) {
|
|
7633
7658
|
const [operations, coordinates] = args;
|
|
7634
|
-
pathRect = pathRect === void 0 && _optionalChain([operations, 'optionalAccess',
|
|
7659
|
+
pathRect = pathRect === void 0 && _optionalChain([operations, 'optionalAccess', _352 => _352.length]) === 1 && operations[0] === _pdfmjs.OPS.rectangle && _optionalChain([coordinates, 'optionalAccess', _353 => _353.length]) >= 4 && ctm[1] === 0 && ctm[2] === 0 ? rectangle(coordinates[0], coordinates[1], coordinates[2], coordinates[3]) : null;
|
|
7635
7660
|
} else if (op === _pdfmjs.OPS.clip || op === _pdfmjs.OPS.eoClip) pendingClip = true;
|
|
7636
7661
|
else if ([
|
|
7637
7662
|
_pdfmjs.OPS.endPath,
|
|
@@ -7651,7 +7676,7 @@ function smallVisibleImagePaints(fnArray, argsArray) {
|
|
|
7651
7676
|
pendingClip = false;
|
|
7652
7677
|
pathRect = void 0;
|
|
7653
7678
|
} else if (op === _pdfmjs.OPS.transform && Array.isArray(args) && args.length >= 6) ctm = multiply(ctm, args);
|
|
7654
|
-
else if (op === _pdfmjs.OPS.paintImageXObject && typeof _optionalChain([args, 'optionalAccess',
|
|
7679
|
+
else if (op === _pdfmjs.OPS.paintImageXObject && typeof _optionalChain([args, 'optionalAccess', _354 => _354[0]]) === "string") {
|
|
7655
7680
|
if (typeof args[1] !== "number" || typeof args[2] !== "number" || args[1] < 16 || args[1] > 128 || args[2] < 16 || args[2] > 128) continue;
|
|
7656
7681
|
const box = extractImageRegions([_pdfmjs.OPS.transform, _pdfmjs.OPS.paintImageXObject], [ctm, args])[0];
|
|
7657
7682
|
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;
|
|
@@ -7670,14 +7695,14 @@ async function restoreImageBullets(items, page, fnArray, argsArray, shapes = /*
|
|
|
7670
7695
|
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];
|
|
7671
7696
|
if (!line || /^[○●•◦□■∙]/.test(line.text.trim()) || !/\p{L}/u.test(line.text)) continue;
|
|
7672
7697
|
const row = items.filter((item) => Math.abs(item.y - line.y) <= 2 && item.x >= line.x);
|
|
7673
|
-
if (row.reduce((n, item) => n + (_nullishCoalesce(_optionalChain([item, 'access',
|
|
7698
|
+
if (row.reduce((n, item) => n + (_nullishCoalesce(_optionalChain([item, 'access', _355 => _355.text, 'access', _356 => _356.match, 'call', _357 => _357(/\p{L}/gu), 'optionalAccess', _358 => _358.length]), () => ( 0))), 0) < 12 || items.some((item) => item !== line && Math.abs(item.y - line.y) <= 2 && item.x < line.x)) continue;
|
|
7674
7699
|
candidates.push({ id, x: box.x1, width, line });
|
|
7675
7700
|
}
|
|
7676
7701
|
let restored = 0;
|
|
7677
7702
|
const used = /* @__PURE__ */ new Set();
|
|
7678
7703
|
for (const candidate of candidates) {
|
|
7679
7704
|
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);
|
|
7680
|
-
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',
|
|
7705
|
+
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', _359 => _359.text, 'access', _360 => _360.match, 'call', _361 => _361(/\p{L}/gu), 'optionalAccess', _362 => _362.length]), () => ( 0))) >= 12).sort((a, b) => b.y - a.y);
|
|
7681
7706
|
const numberedList = numbered.some((item, index) => index > 0 && item.text.trim().charCodeAt(0) === numbered[index - 1].text.trim().charCodeAt(0) + 1);
|
|
7682
7707
|
if (!same.length && !numberedList || used.has(candidate.line)) continue;
|
|
7683
7708
|
if (!shapes.has(candidate.id)) shapes.set(candidate.id, hollowCircle(await resolveImagePixels(page, candidate.id)));
|
|
@@ -7743,7 +7768,7 @@ function groupFlowBoxUnits(blocks, grids, hs, vs, images) {
|
|
|
7743
7768
|
return units;
|
|
7744
7769
|
}
|
|
7745
7770
|
function arrowDirection(image) {
|
|
7746
|
-
if (!_optionalChain([image, 'optionalAccess',
|
|
7771
|
+
if (!_optionalChain([image, 'optionalAccess', _363 => _363.data]) || image.width < 16 || image.width > 128 || image.height < 16 || image.height > 128) return 0;
|
|
7747
7772
|
const { width, height, data } = image;
|
|
7748
7773
|
const stride = image.kind === _pdfmjs.ImageKind.RGB_24BPP ? 3 : image.kind === _pdfmjs.ImageKind.RGBA_32BPP ? 4 : 0;
|
|
7749
7774
|
if (!stride || data.length < width * height * stride) return 0;
|
|
@@ -7811,7 +7836,7 @@ function isSideTabTable(box, table, others, pageWidth, pageHeight) {
|
|
|
7811
7836
|
function removeSideTabs(blocks, pageWidths) {
|
|
7812
7837
|
const edges = /* @__PURE__ */ new Map();
|
|
7813
7838
|
for (const b of blocks) {
|
|
7814
|
-
if (!b.bbox || b.pageNumber === void 0 || [..._nullishCoalesce(_optionalChain([b, 'access',
|
|
7839
|
+
if (!b.bbox || b.pageNumber === void 0 || [..._nullishCoalesce(_optionalChain([b, 'access', _364 => _364.text, 'optionalAccess', _365 => _365.trim, 'call', _366 => _366()]), () => ( ""))].length <= MAX_CHARS) continue;
|
|
7815
7840
|
const e = _nullishCoalesce(edges.get(b.pageNumber), () => ( { lefts: [], rights: [] }));
|
|
7816
7841
|
e.lefts.push(b.bbox.x);
|
|
7817
7842
|
e.rights.push(b.bbox.x + b.bbox.width);
|
|
@@ -7827,7 +7852,7 @@ function removeSideTabs(blocks, pageWidths) {
|
|
|
7827
7852
|
const fallback = all.length ? { left: q(all.map((e) => e.left), 0.5), right: q(all.map((e) => e.right), 0.5) } : void 0;
|
|
7828
7853
|
const key = (b) => {
|
|
7829
7854
|
const w = b.pageNumber !== void 0 ? pageWidths.get(b.pageNumber) : void 0;
|
|
7830
|
-
const text = _optionalChain([b, 'access',
|
|
7855
|
+
const text = _optionalChain([b, 'access', _367 => _367.text, 'optionalAccess', _368 => _368.trim, 'call', _369 => _369()]);
|
|
7831
7856
|
const area = _nullishCoalesce((b.pageNumber !== void 0 ? body.get(b.pageNumber) : void 0), () => ( fallback));
|
|
7832
7857
|
if (b.type === "table") {
|
|
7833
7858
|
if (!w || !b.bbox || !b.table || !SIDE_TAB_TABLES.has(b.table)) return null;
|
|
@@ -8458,16 +8483,16 @@ function isProseSpread(items) {
|
|
|
8458
8483
|
for (let i = 1; i < sorted.length; i++) {
|
|
8459
8484
|
gaps.push(sorted[i].x - (sorted[i - 1].x + sorted[i - 1].w));
|
|
8460
8485
|
}
|
|
8461
|
-
const maxGap =
|
|
8486
|
+
const maxGap = _chunkMANE7HAZcjs.safeMax.call(void 0, gaps);
|
|
8462
8487
|
const avgLen = items.reduce((s, i) => s + i.text.length, 0) / items.length;
|
|
8463
8488
|
if (items.length >= 4 && maxGap < 40 && avgLen < 5) return true;
|
|
8464
|
-
const minGap =
|
|
8489
|
+
const minGap = _chunkMANE7HAZcjs.safeMin.call(void 0, gaps);
|
|
8465
8490
|
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)));
|
|
8466
8491
|
}
|
|
8467
8492
|
function detectColumns(yLines) {
|
|
8468
8493
|
const allItems = yLines.flat();
|
|
8469
8494
|
if (allItems.length === 0) return null;
|
|
8470
|
-
const pageWidth =
|
|
8495
|
+
const pageWidth = _chunkMANE7HAZcjs.safeMax.call(void 0, allItems.map((i) => i.x + i.w)) - _chunkMANE7HAZcjs.safeMin.call(void 0, allItems.map((i) => i.x));
|
|
8471
8496
|
if (pageWidth < 100) return null;
|
|
8472
8497
|
let bigoLineIdx = -1;
|
|
8473
8498
|
for (let i = 0; i < yLines.length; i++) {
|
|
@@ -8692,7 +8717,7 @@ var UNDER_BOX_PAIR_MAX_EM = 2.2;
|
|
|
8692
8717
|
var UNDER_BOX_PAIR_OVERLAP = 0.8;
|
|
8693
8718
|
function markUnderlineItems(items, horizontals, verticals, nonRules) {
|
|
8694
8719
|
const underlines = [];
|
|
8695
|
-
if (_optionalChain([nonRules, 'optionalAccess',
|
|
8720
|
+
if (_optionalChain([nonRules, 'optionalAccess', _370 => _370.size])) horizontals = horizontals.filter((line) => !nonRules.has(line));
|
|
8696
8721
|
if (items.length === 0 || horizontals.length === 0) return underlines;
|
|
8697
8722
|
const tightOwners = /* @__PURE__ */ new Map();
|
|
8698
8723
|
const tightlyOwned = (line) => {
|
|
@@ -8798,7 +8823,7 @@ function hasBoxTopPair(line, maxH, horizontals, cellItems) {
|
|
|
8798
8823
|
if (ow <= 0) continue;
|
|
8799
8824
|
const overlap2 = Math.min(line.x2, o.x2) - Math.max(line.x1, o.x1);
|
|
8800
8825
|
if (overlap2 / Math.max(w, ow) < UNDER_BOX_PAIR_OVERLAP) continue;
|
|
8801
|
-
const covered = _nullishCoalesce(_optionalChain([cellItems, 'optionalAccess',
|
|
8826
|
+
const covered = _nullishCoalesce(_optionalChain([cellItems, 'optionalAccess', _371 => _371.reduce, 'call', _372 => _372((sum, item) => {
|
|
8802
8827
|
const below = item.y - o.y1;
|
|
8803
8828
|
if (below < 0.5 || below > 3 || !item.text.trim()) return sum;
|
|
8804
8829
|
return sum + Math.max(0, Math.min(o.x2, item.x + item.w) - Math.max(o.x1, item.x));
|
|
@@ -8865,13 +8890,13 @@ function partTex(group) {
|
|
|
8865
8890
|
const base = Math.min(...g.filter((i) => i.fontSize >= size * SCRIPT_SIZE_RATIO).map((i) => i.y));
|
|
8866
8891
|
let s = "", run = "";
|
|
8867
8892
|
const flush = () => {
|
|
8868
|
-
if (run) s +=
|
|
8893
|
+
if (run) s += _chunkV3IMDOZEcjs.toTex.call(void 0, run);
|
|
8869
8894
|
run = "";
|
|
8870
8895
|
};
|
|
8871
8896
|
g.forEach((it, k) => {
|
|
8872
8897
|
if (it.fontSize < size * SCRIPT_SIZE_RATIO && it.y - base >= size * SCRIPT_RISE_EM) {
|
|
8873
8898
|
flush();
|
|
8874
|
-
s += `^{${
|
|
8899
|
+
s += `^{${_chunkV3IMDOZEcjs.toTex.call(void 0, it.text)}}`;
|
|
8875
8900
|
return;
|
|
8876
8901
|
}
|
|
8877
8902
|
if (k && it.x - (g[k - 1].x + g[k - 1].w) > spaceGapThreshold(it.fontSize)) run += " ";
|
|
@@ -9044,12 +9069,12 @@ function rebuildUnitLine(items, grid) {
|
|
|
9044
9069
|
function prependUnitRow(cells, cols, line, usedItems) {
|
|
9045
9070
|
const text = cleanCellText(line.map((item) => item.text).join(""));
|
|
9046
9071
|
cells.unshift(Array.from({ length: cols }, (_, c) => ({ text: c === 0 ? text : "", colSpan: c === 0 ? cols : 1, rowSpan: 1 })));
|
|
9047
|
-
for (const cell of cells[0])
|
|
9072
|
+
for (const cell of cells[0]) _chunkV3IMDOZEcjs.CELL_EDGES.set(cell, NO_EDGES);
|
|
9048
9073
|
for (const item of line) usedItems.add(item);
|
|
9049
9074
|
}
|
|
9050
9075
|
function attachUnitRow(items, grid, cells, cols, usedItems) {
|
|
9051
9076
|
const all = cells.flat();
|
|
9052
|
-
if (all.filter((c) => c.text.trim()).length * 2 < all.length || UNIT.test(_nullishCoalesce(_optionalChain([cells, 'access',
|
|
9077
|
+
if (all.filter((c) => c.text.trim()).length * 2 < all.length || UNIT.test(_nullishCoalesce(_optionalChain([cells, 'access', _373 => _373[0], 'optionalAccess', _374 => _374[0], 'optionalAccess', _375 => _375.text]), () => ( "")))) return false;
|
|
9053
9078
|
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);
|
|
9054
9079
|
let nearest = Infinity;
|
|
9055
9080
|
for (const it of above) nearest = Math.min(nearest, it.y);
|
|
@@ -9084,7 +9109,7 @@ function closeShadedTableEdges(clipGrids, horizontals, verticals, fillRects) {
|
|
|
9084
9109
|
let hs = horizontals, vs = verticals;
|
|
9085
9110
|
const restored = [];
|
|
9086
9111
|
for (const grid of clipGrids) {
|
|
9087
|
-
if (grid.clipParent || grid.rowYs.length !== 2 || grid.colXs.length < 3 || !_optionalChain([grid, 'access',
|
|
9112
|
+
if (grid.clipParent || grid.rowYs.length !== 2 || grid.colXs.length < 3 || !_optionalChain([grid, 'access', _376 => _376.cells, 'optionalAccess', _377 => _377.length]) || grid.cells.some((c) => c.filler || c.rowSpan !== 1 || c.colSpan !== 1)) continue;
|
|
9088
9113
|
const { x1, x2, y1: mid, y2: top } = grid.bbox;
|
|
9089
9114
|
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;
|
|
9090
9115
|
const topRule = hs.find((h) => near2(h.y1, top) && near2(h.x1, x1) && near2(h.x2, x2));
|
|
@@ -9548,7 +9573,7 @@ function takeFrameSpanningText(items, cutX, pageNum, lex) {
|
|
|
9548
9573
|
const rows = groupByY([...items].sort((a, b) => b.y - a.y || a.x - b.x)).map((line) => {
|
|
9549
9574
|
const runs = [];
|
|
9550
9575
|
for (const item of [...line].sort((a, b) => a.x - b.x)) {
|
|
9551
|
-
const run = runs[runs.length - 1], prev = _optionalChain([run, 'optionalAccess',
|
|
9576
|
+
const run = runs[runs.length - 1], prev = _optionalChain([run, 'optionalAccess', _378 => _378[run.length - 1]]);
|
|
9552
9577
|
if (prev && item.x - (prev.x + prev.w) <= Math.max(prev.fontSize, item.fontSize) * 0.6) run.push(item);
|
|
9553
9578
|
else runs.push([item]);
|
|
9554
9579
|
}
|
|
@@ -9592,7 +9617,7 @@ function groupFrameParagraphUnits(units, frames) {
|
|
|
9592
9617
|
for (const unit of units) for (const block of unit) source.set(block, unit);
|
|
9593
9618
|
const members = /* @__PURE__ */ new Map(), emitted = /* @__PURE__ */ new Set();
|
|
9594
9619
|
for (const frame of frames) {
|
|
9595
|
-
if (frame.length < 2 || frame.some((block) => block.type !== "paragraph" || _optionalChain([source, 'access',
|
|
9620
|
+
if (frame.length < 2 || frame.some((block) => block.type !== "paragraph" || _optionalChain([source, 'access', _379 => _379.get, 'call', _380 => _380(block), 'optionalAccess', _381 => _381.length]) !== 1)) continue;
|
|
9596
9621
|
for (const block of frame) members.set(block, frame);
|
|
9597
9622
|
}
|
|
9598
9623
|
const out = [];
|
|
@@ -9605,7 +9630,7 @@ function groupFrameParagraphUnits(units, frames) {
|
|
|
9605
9630
|
}
|
|
9606
9631
|
}
|
|
9607
9632
|
for (const unit of out) {
|
|
9608
|
-
if (unit.length < 2 || _optionalChain([FRAME_READING_UNITS, 'access',
|
|
9633
|
+
if (unit.length < 2 || _optionalChain([FRAME_READING_UNITS, 'access', _382 => _382.get, 'call', _383 => _383(unit[0]), 'optionalAccess', _384 => _384.blocks]) === unit) continue;
|
|
9609
9634
|
const bs = unit.map((b) => b.bbox).filter((b) => !!b);
|
|
9610
9635
|
if (bs.length !== unit.length) continue;
|
|
9611
9636
|
const x = Math.min(...bs.map((b) => b.x)), y = Math.min(...bs.map((b) => b.y));
|
|
@@ -9622,14 +9647,14 @@ function groupFrameParagraphUnits(units, frames) {
|
|
|
9622
9647
|
function recordFrameTitle(table, source, pageNum) {
|
|
9623
9648
|
if (!CLIP_TABLES.has(table) || table.rows !== 1 || table.cols !== 3 || source.length < 2) return;
|
|
9624
9649
|
const cells = table.cells[0];
|
|
9625
|
-
if (cells.length !== 3 || cells.some((c) => c.colSpan !== 1 || c.rowSpan !== 1 || _optionalChain([c, 'access',
|
|
9650
|
+
if (cells.length !== 3 || cells.some((c) => c.colSpan !== 1 || c.rowSpan !== 1 || _optionalChain([c, 'access', _385 => _385.blocks, 'optionalAccess', _386 => _386.length]) || c.text.includes("\n"))) return;
|
|
9626
9651
|
const [label, spacer, title] = cells;
|
|
9627
9652
|
if (!/^(?:붙임|별첨|첨부|부록)\s*\d{1,3}$/.test(label.text.trim()) || spacer.text.trim() || !title.text.trim()) return;
|
|
9628
9653
|
if (cells.some((c) => {
|
|
9629
|
-
const e =
|
|
9654
|
+
const e = _chunkV3IMDOZEcjs.CELL_EDGES.get(c);
|
|
9630
9655
|
return !e || e.t || e.b || e.l || e.r;
|
|
9631
9656
|
})) return;
|
|
9632
|
-
const xs = TABLE_COLXS.get(table), style = dominantStyle(source), fs = _nullishCoalesce(_optionalChain([style, 'optionalAccess',
|
|
9657
|
+
const xs = TABLE_COLXS.get(table), style = dominantStyle(source), fs = _nullishCoalesce(_optionalChain([style, 'optionalAccess', _387 => _387.fontSize]), () => ( 0));
|
|
9633
9658
|
if (!xs || xs.length !== 4 || fs <= 0) return;
|
|
9634
9659
|
const width = xs[3] - xs[0], gap = xs[2] - xs[1];
|
|
9635
9660
|
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;
|
|
@@ -9693,7 +9718,7 @@ function extendNestedShadedHeaders(clipGrids, lineGrids, horizontals, verticals,
|
|
|
9693
9718
|
const extended = [];
|
|
9694
9719
|
for (let i = 0; i < clipGrids.length; i++) {
|
|
9695
9720
|
const c = clipGrids[i], parent = c.clipParent;
|
|
9696
|
-
if (!parent || c.rowYs.length !== 2 || c.colXs.length < 3 || !_optionalChain([c, 'access',
|
|
9721
|
+
if (!parent || c.rowYs.length !== 2 || c.colXs.length < 3 || !_optionalChain([c, 'access', _388 => _388.cells, 'optionalAccess', _389 => _389.length]) || c.cells.some((cell) => cell.filler || cell.rowSpan !== 1 || cell.colSpan !== 1)) continue;
|
|
9697
9722
|
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;
|
|
9698
9723
|
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;
|
|
9699
9724
|
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)));
|
|
@@ -9716,7 +9741,7 @@ function attachSideTabBlocks(tab, body, pageNum) {
|
|
|
9716
9741
|
bbox: computeBBox(items, pageNum),
|
|
9717
9742
|
style: dominantStyle(items)
|
|
9718
9743
|
});
|
|
9719
|
-
const prefix = ordered.filter((g) => !_optionalChain([caps, 'optionalAccess',
|
|
9744
|
+
const prefix = ordered.filter((g) => !_optionalChain([caps, 'optionalAccess', _390 => _390.has, 'call', _391 => _391(g)])).map((g) => ({
|
|
9720
9745
|
type: "paragraph",
|
|
9721
9746
|
text: g.text.trim(),
|
|
9722
9747
|
pageNumber: pageNum,
|
|
@@ -9725,7 +9750,7 @@ function attachSideTabBlocks(tab, body, pageNum) {
|
|
|
9725
9750
|
}));
|
|
9726
9751
|
const groups = /* @__PURE__ */ new Map();
|
|
9727
9752
|
for (const g of ordered) {
|
|
9728
|
-
const cap = _optionalChain([caps, 'optionalAccess',
|
|
9753
|
+
const cap = _optionalChain([caps, 'optionalAccess', _392 => _392.get, 'call', _393 => _393(g)]);
|
|
9729
9754
|
if (cap) groups.set(cap, [..._nullishCoalesce(groups.get(cap), () => ( [])), g]);
|
|
9730
9755
|
}
|
|
9731
9756
|
for (const [cap, glyphs] of groups) {
|
|
@@ -9756,7 +9781,7 @@ function extractPageBlocksWithLines(items, pageNum, opList, pageWidth, pageHeigh
|
|
|
9756
9781
|
let prev = null;
|
|
9757
9782
|
for (const line of streamLines(items)) {
|
|
9758
9783
|
lex.addLine(mergeLineSimple(line));
|
|
9759
|
-
const fs = _nullishCoalesce(_optionalChain([dominantStyle, 'call',
|
|
9784
|
+
const fs = _nullishCoalesce(_optionalChain([dominantStyle, 'call', _394 => _394(line), 'optionalAccess', _395 => _395.fontSize]), () => ( 0));
|
|
9760
9785
|
const left = Math.min(...line.map((i) => i.x)), right = Math.max(...line.map((i) => i.x + i.w));
|
|
9761
9786
|
const y = line.reduce((n, i) => n + i.y, 0) / line.length;
|
|
9762
9787
|
const wide = fs > 0 && right - left >= 12 * fs;
|
|
@@ -9770,7 +9795,7 @@ function extractPageBlocksWithLines(items, pageNum, opList, pageWidth, pageHeigh
|
|
|
9770
9795
|
const filled = fillBlanks(items, horizontals, verticals);
|
|
9771
9796
|
items = filled.items;
|
|
9772
9797
|
horizontals = filled.horizontals;
|
|
9773
|
-
const prevPage = _optionalChain([carry, 'optionalAccess',
|
|
9798
|
+
const prevPage = _optionalChain([carry, 'optionalAccess', _396 => _396.page]) === pageNum - 1 ? carry.clip : void 0;
|
|
9774
9799
|
const clipResult = detectTables ? buildClipCellGrids(extracted.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 };
|
|
9775
9800
|
if (carry) {
|
|
9776
9801
|
carry.page = pageNum;
|
|
@@ -9814,6 +9839,7 @@ function extractPageBlocksWithLines(items, pageNum, opList, pageWidth, pageHeigh
|
|
|
9814
9839
|
const ocrItems = items.length > 0 && items.every((it) => it.fontName === "ocr");
|
|
9815
9840
|
let lineGrids = detectTables ? buildTableGrids(horizontals, verticals, !ocrItems) : [];
|
|
9816
9841
|
if (ocrItems && lineGrids.length) {
|
|
9842
|
+
lineGrids = lineGrids.map((g) => openSideColumns(g, horizontals, verticals, items, lineGrids));
|
|
9817
9843
|
for (const [grid, gutters] of ocrGutterVerticals(lineGrids, items)) {
|
|
9818
9844
|
const { x1, y1, x2, y2 } = grid.bbox, tol = 1.5;
|
|
9819
9845
|
const within = (l) => Math.min(l.x1, l.x2) >= x1 - tol && Math.max(l.x1, l.x2) <= x2 + tol && Math.min(l.y1, l.y2) >= y1 - tol && Math.max(l.y1, l.y2) <= y2 + tol;
|
|
@@ -9839,6 +9865,26 @@ function extractPageBlocksWithLines(items, pageNum, opList, pageWidth, pageHeigh
|
|
|
9839
9865
|
if (grids.length === 1 && grids[0].rowYs.length === 2 && grids[0].colXs.length === 2 && grids[0].bbox.x2 - grids[0].bbox.x1 > pageWidth * 1.2 && grids[0].bbox.y2 - grids[0].bbox.y1 > pageHeight * 1.2) {
|
|
9840
9866
|
return extractPageBlocksFallback(items, pageNum, true, detectTables, lex, figures());
|
|
9841
9867
|
}
|
|
9868
|
+
const ocrSpan = ocrItems ? Math.max(...items.map((it) => it.y + it.h)) - Math.min(...items.map((it) => it.y)) : 0;
|
|
9869
|
+
if (ocrItems && ocrSpan >= pageHeight * 0.5) {
|
|
9870
|
+
for (let i = grids.length - 1; i >= 0; i--) {
|
|
9871
|
+
const g = grids[i];
|
|
9872
|
+
if (g.rowYs.length !== 2 || g.colXs.length !== 2 || g.cells || (g.bbox.x2 - g.bbox.x1) * (g.bbox.y2 - g.bbox.y1) < pageWidth * pageHeight * 0.5) continue;
|
|
9873
|
+
const inner = grids.filter((o) => o !== g && o.bbox.x1 >= g.bbox.x1 - 2 && o.bbox.x2 <= g.bbox.x2 + 2 && o.bbox.y1 >= g.bbox.y1 - 2 && o.bbox.y2 <= g.bbox.y2 + 2);
|
|
9874
|
+
if (inner.length === 0) continue;
|
|
9875
|
+
grids.splice(i, 1);
|
|
9876
|
+
for (const o of inner) {
|
|
9877
|
+
const spans = (x, toX) => [o.bbox.y1, o.bbox.y2].every((y) => horizontals.some((h) => Math.abs(h.y1 - y) < 3 && Math.min(h.x1, h.x2) <= Math.min(x, toX) + 4 && Math.max(h.x1, h.x2) >= Math.max(x, toX) - 4));
|
|
9878
|
+
let colXs = o.colXs;
|
|
9879
|
+
if (o.bbox.x1 - g.bbox.x1 > 20 && spans(g.bbox.x1, o.bbox.x2)) colXs = [g.bbox.x1, ...colXs];
|
|
9880
|
+
if (g.bbox.x2 - o.bbox.x2 > 20 && spans(o.bbox.x1, g.bbox.x2)) colXs = [...colXs, g.bbox.x2];
|
|
9881
|
+
if (colXs !== o.colXs) grids[grids.indexOf(o)] = { ...o, colXs, bbox: { ...o.bbox, x1: colXs[0], x2: colXs[colXs.length - 1] } };
|
|
9882
|
+
}
|
|
9883
|
+
}
|
|
9884
|
+
}
|
|
9885
|
+
if (ocrItems && ocrSpan >= pageHeight * 0.5 && grids.length > 0 && grids.every((g) => g.rowYs.length === 2 && g.colXs.length === 2 && !g.cells && ((g.bbox.x2 - g.bbox.x1) * (g.bbox.y2 - g.bbox.y1) < pageWidth * pageHeight * 0.02 || g.bbox.x2 - g.bbox.x1 < pageWidth * 0.55))) {
|
|
9886
|
+
return _nullishCoalesce(ruledColumnBlocks(items, horizontals, verticals, pageWidth, pageHeight, pageNum, detectTables, lex), () => ( extractPageBlocksFallback(items, pageNum, true, detectTables, lex, figures())));
|
|
9887
|
+
}
|
|
9842
9888
|
const ruled = detectTables && clipGrids.length === 0 ? detectRuledBandTables(horizontals, verticals, items, pageNum) : [];
|
|
9843
9889
|
if (detectTables && clipGrids.length === 0 && ruled.length === 0 && lineGrids.length === 0) ruled.push(...detectTextBoxTables(extracted.hiddenBoxes, items, pageNum));
|
|
9844
9890
|
if (ruled.length > 0) {
|
|
@@ -9856,7 +9902,23 @@ function extractPageBlocksWithLines(items, pageNum, opList, pageWidth, pageHeigh
|
|
|
9856
9902
|
const imageRegions = extractImageRegions(opList.fnArray, opList.argsArray).filter((r) => r.x2 - r.x1 >= 8 && r.y2 - r.y1 >= 8);
|
|
9857
9903
|
return extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, horizontals, verticals, imageRegions, lex, [], rawRules, verifiedRightArrows);
|
|
9858
9904
|
}
|
|
9859
|
-
return extractPageBlocksFallback(items, pageNum, true, detectTables, lex, figures());
|
|
9905
|
+
return _nullishCoalesce((ocrItems ? ruledColumnBlocks(items, horizontals, verticals, pageWidth, pageHeight, pageNum, detectTables, lex) : null), () => ( extractPageBlocksFallback(items, pageNum, true, detectTables, lex, figures())));
|
|
9906
|
+
}
|
|
9907
|
+
function ruledColumnBlocks(items, horizontals, verticals, pageWidth, pageHeight, pageNum, detectTables, lex) {
|
|
9908
|
+
const rule = verticals.find((v) => {
|
|
9909
|
+
const x2 = v.x1, top2 = Math.max(v.y1, v.y2), bottom2 = Math.min(v.y1, v.y2);
|
|
9910
|
+
if (x2 < pageWidth * 0.4 || x2 > pageWidth * 0.6 || top2 - bottom2 < pageHeight * 0.45) return false;
|
|
9911
|
+
return !horizontals.some((h) => Math.min(h.x1, h.x2) < x2 - 5 && Math.max(h.x1, h.x2) > x2 + 5 && h.y1 > bottom2 + 5 && h.y1 < top2 - 5);
|
|
9912
|
+
});
|
|
9913
|
+
if (!rule) return null;
|
|
9914
|
+
const x = rule.x1, top = Math.max(rule.y1, rule.y2), bottom = Math.min(rule.y1, rule.y2);
|
|
9915
|
+
const mid = (it) => it.y + it.h / 2;
|
|
9916
|
+
const head = items.filter((it) => mid(it) > top), foot = items.filter((it) => mid(it) < bottom);
|
|
9917
|
+
const body = items.filter((it) => mid(it) <= top && mid(it) >= bottom);
|
|
9918
|
+
const left = body.filter((it) => it.x + it.w <= x + 2), right = body.filter((it) => it.x >= x - 2);
|
|
9919
|
+
if (left.length < 3 || right.length < 3 || left.length + right.length < body.length) return null;
|
|
9920
|
+
const read = (group, full) => group.length ? extractPageBlocksFallback(group, pageNum, full, detectTables, lex) : [];
|
|
9921
|
+
return [...read(head, false), ...read(left, false), ...read(right, false), ...read(foot, false)];
|
|
9860
9922
|
}
|
|
9861
9923
|
var STRIKE_MAX_THICKNESS = 2;
|
|
9862
9924
|
var STRIKE_MAX_THICKNESS_RATIO = 0.25;
|
|
@@ -9916,7 +9978,38 @@ function rotatedGridBlocks(grid, tableItems, horizontals, verticals, pageNum, pa
|
|
|
9916
9978
|
const bbox = { page: pageNum, x: b.x1, y: b.y1, width: b.x2 - b.x1, height: b.y2 - b.y1 };
|
|
9917
9979
|
return out.map((blk) => ({ ...blk, bbox }));
|
|
9918
9980
|
}
|
|
9919
|
-
|
|
9981
|
+
function openSideColumns(g, horizontals, verticals, items, grids = []) {
|
|
9982
|
+
if (g.cells || g.colXs.length < 4) return g;
|
|
9983
|
+
const { x1, x2, y1, y2 } = g.bbox;
|
|
9984
|
+
const inside = items.filter((it) => it.text.trim() && it.x >= x1 - 2 && it.x + it.w <= x2 + 2 && it.y >= y1 && it.y + it.h <= y2);
|
|
9985
|
+
if (!inside.length || inside.filter((it) => /^[\d.,%()+\-−–△▲▽▼\s]+$/.test(it.text.trim())).length < inside.length * 0.5) return g;
|
|
9986
|
+
const free = (a, b) => !grids.some((o) => o !== g && o.bbox.x1 < b - 2 && o.bbox.x2 > a + 2 && o.bbox.y1 < y2 - 2 && o.bbox.y2 > y1 + 2);
|
|
9987
|
+
const reach = (y, side) => {
|
|
9988
|
+
const ends = horizontals.filter((h) => Math.abs(h.y1 - y) <= 3).map((h) => [Math.min(h.x1, h.x2), Math.max(h.x1, h.x2)]).filter(([a, b]) => side < 0 ? a <= x1 - 15 && b >= x1 - 3 : b >= x2 + 15 && a <= x2 + 3).map(([a, b]) => side < 0 ? a : b);
|
|
9989
|
+
return ends.length ? side < 0 ? Math.min(...ends) : Math.max(...ends) : null;
|
|
9990
|
+
};
|
|
9991
|
+
const textBetween = (a, b) => free(a, b) && items.some((it) => it.text.trim() && it.x >= a - 2 && it.x + it.w <= b + 2 && it.y >= y1 && it.y + it.h <= y2);
|
|
9992
|
+
let colXs = g.colXs;
|
|
9993
|
+
const lt = reach(y2, -1), lb = reach(y1, -1);
|
|
9994
|
+
if (lt !== null && lb !== null) {
|
|
9995
|
+
const left = Math.max(lt, lb);
|
|
9996
|
+
if (textBetween(left, x1)) {
|
|
9997
|
+
colXs = [left, ...colXs];
|
|
9998
|
+
verticals.push({ x1: left, y1, x2: left, y2, lineWidth: 1 });
|
|
9999
|
+
}
|
|
10000
|
+
}
|
|
10001
|
+
const rt = reach(y2, 1), rb = reach(y1, 1);
|
|
10002
|
+
if (rt !== null && rb !== null) {
|
|
10003
|
+
const right = Math.min(rt, rb);
|
|
10004
|
+
if (textBetween(x2, right)) {
|
|
10005
|
+
colXs = [...colXs, right];
|
|
10006
|
+
verticals.push({ x1: right, y1, x2: right, y2, lineWidth: 1 });
|
|
10007
|
+
}
|
|
10008
|
+
}
|
|
10009
|
+
return colXs === g.colXs ? g : { ...g, colXs, bbox: { ...g.bbox, x1: colXs[0], x2: colXs[colXs.length - 1] } };
|
|
10010
|
+
}
|
|
10011
|
+
var OCR_NUMERIC_MAX_ROWS = 40;
|
|
10012
|
+
var OCR_NUMERIC_MAX_ROWS_FRAMED = 12;
|
|
9920
10013
|
function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, horizontals, verticals, imageRegions = [], lex, ruled = [], rawRules = horizontals, verifiedRightArrows = []) {
|
|
9921
10014
|
const ocrPage = items.length > 0 && items.every((i) => i.fontName === "ocr");
|
|
9922
10015
|
const blocks = [];
|
|
@@ -9994,7 +10087,7 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
|
|
|
9994
10087
|
const nested = pendingNested.length ? takePendingNested(pendingNested, cell.bbox, !!grid.cells) : [];
|
|
9995
10088
|
const lone = nested.length === 1 && !cellItems.length ? nested[0] : null;
|
|
9996
10089
|
const cw = cell.bbox.x2 - cell.bbox.x1;
|
|
9997
|
-
if (_optionalChain([lone, 'optionalAccess',
|
|
10090
|
+
if (_optionalChain([lone, 'optionalAccess', _397 => _397.table]) && lone.bbox && lone.table.rows === 1 && lone.table.cols === 1 && CLIP_TABLES.has(lone.table) && !_optionalChain([lone, 'access', _398 => _398.table, 'access', _399 => _399.cells, 'access', _400 => _400[0], 'access', _401 => _401[0], 'access', _402 => _402.blocks, 'optionalAccess', _403 => _403.some, 'call', _404 => _404((b2) => b2.type === "table")]) && lone.bbox.width >= cw * 0.9 && /^[^\n]{1,30}$/.test(lone.table.cells[0][0].text.trim())) {
|
|
9998
10091
|
irGrid[cell.row][cell.col] = { text: lone.table.cells[0][0].text, colSpan: cell.colSpan, rowSpan: cell.rowSpan };
|
|
9999
10092
|
takeClipCellEdges(cell, irGrid[cell.row][cell.col]);
|
|
10000
10093
|
continue;
|
|
@@ -10038,22 +10131,25 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
|
|
|
10038
10131
|
let finalGrid = irGrid;
|
|
10039
10132
|
let finalRows = numRows;
|
|
10040
10133
|
let rebuiltUsed = false;
|
|
10134
|
+
let keptRows = null;
|
|
10041
10135
|
const unitLine = !grid.cells && numRows >= 3 && numRows <= 5 && numCols >= 3 ? rebuildUnitLine(items, grid) : [];
|
|
10042
10136
|
const numericBody = ocrPage && numRows >= 3 && (() => {
|
|
10043
10137
|
const ls = irGrid.slice(1).flat().flatMap((c) => c.text.split("\n")).map((t) => t.trim()).filter(Boolean);
|
|
10044
10138
|
const numericLine = (t) => {
|
|
10045
10139
|
const cs = t.replace(/\s+/g, "");
|
|
10046
|
-
return cs.length > 0 && (_nullishCoalesce(_optionalChain([cs, 'access',
|
|
10140
|
+
return cs.length > 0 && (_nullishCoalesce(_optionalChain([cs, 'access', _405 => _405.match, 'call', _406 => _406(/[\d.,%()+\-−–—△▲▽▼]/g), 'optionalAccess', _407 => _407.length]), () => ( 0))) >= cs.length * 0.85;
|
|
10047
10141
|
};
|
|
10048
10142
|
const bulletList = irGrid.slice(1).flat().some((c) => c.text.split("\n").filter((t) => /^\s*(?:[○◦•□■▪]|-\s*[^\d\s.,−-])/.test(t)).length >= 2);
|
|
10049
10143
|
return !bulletList && ls.length > 0 && ls.filter(numericLine).length >= ls.length * 0.5;
|
|
10050
10144
|
})();
|
|
10051
|
-
const
|
|
10145
|
+
const layoutProse = irGrid.some((row) => row.some((c) => c.colSpan >= numCols - 1 && c.text.length > 60));
|
|
10146
|
+
const maxRows = numericBody ? layoutProse ? OCR_NUMERIC_MAX_ROWS_FRAMED : OCR_NUMERIC_MAX_ROWS : 5;
|
|
10052
10147
|
if (!grid.cells && numRows <= maxRows && numCols >= 3 && !nestedAttached && (numRows <= 2 || unitLine.length > 0 || numericBody)) {
|
|
10053
10148
|
const kept = /* @__PURE__ */ new Map();
|
|
10054
10149
|
const rebuilt = normalizeUndersegmentedTable(irGrid, grid.colXs, textItems, grid.rowYs, kept, maxRows);
|
|
10055
10150
|
if (rebuilt) {
|
|
10056
10151
|
rebuiltUsed = true;
|
|
10152
|
+
if (ocrPage && numRows >= 3) keptRows = new Set(kept.values());
|
|
10057
10153
|
if (!ocrPage) kept.clear();
|
|
10058
10154
|
const newRow = new Map([...kept].map(([n, o]) => [o, n]));
|
|
10059
10155
|
const spanRows = (r, span2) => {
|
|
@@ -10063,8 +10159,8 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
|
|
|
10063
10159
|
finalGrid = rebuilt.map((row, i) => {
|
|
10064
10160
|
const o = kept.get(i);
|
|
10065
10161
|
return row.map((rawText, c) => {
|
|
10066
|
-
const src = o === void 0 ? void 0 : _optionalChain([irGrid, 'access',
|
|
10067
|
-
return { text: cleanCellText(rawText), colSpan: _nullishCoalesce(_optionalChain([src, 'optionalAccess',
|
|
10162
|
+
const src = o === void 0 ? void 0 : _optionalChain([irGrid, 'access', _408 => _408[o], 'optionalAccess', _409 => _409[c]]);
|
|
10163
|
+
return { text: cleanCellText(rawText), colSpan: _nullishCoalesce(_optionalChain([src, 'optionalAccess', _410 => _410.colSpan]), () => ( 1)), rowSpan: src ? spanRows(o, src.rowSpan) : 1 };
|
|
10068
10164
|
});
|
|
10069
10165
|
});
|
|
10070
10166
|
finalRows = finalGrid.length;
|
|
@@ -10074,15 +10170,24 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
|
|
|
10074
10170
|
for (let ti = 0; ti < textItems.length; ti++) {
|
|
10075
10171
|
if (!assignedItems.has(textItems[ti])) usedItems.delete(owners[ti]);
|
|
10076
10172
|
}
|
|
10173
|
+
} else if (keptRows) {
|
|
10174
|
+
const inExpanded = (it) => {
|
|
10175
|
+
const cy = it.y + (it.h > 0 ? it.h : it.fontSize) / 2;
|
|
10176
|
+
for (let r = 1; r < numRows; r++) if (!keptRows.has(r) && cy <= grid.rowYs[r] + 1 && cy >= grid.rowYs[r + 1] - 1) return true;
|
|
10177
|
+
return false;
|
|
10178
|
+
};
|
|
10179
|
+
for (let ti = 0; ti < textItems.length; ti++) {
|
|
10180
|
+
if (!assignedItems.has(textItems[ti]) && !inExpanded(textItems[ti])) usedItems.delete(owners[ti]);
|
|
10181
|
+
}
|
|
10077
10182
|
}
|
|
10078
|
-
if (unitLine.length > 0 && rebuiltUsed && !/^\s*\(\s*단위\s*[::]/.test(_nullishCoalesce(_optionalChain([finalGrid, 'access',
|
|
10183
|
+
if (unitLine.length > 0 && rebuiltUsed && !/^\s*\(\s*단위\s*[::]/.test(_nullishCoalesce(_optionalChain([finalGrid, 'access', _411 => _411[0], 'optionalAccess', _412 => _412[0], 'optionalAccess', _413 => _413.text]), () => ( "")))) {
|
|
10079
10184
|
prependUnitRow(finalGrid, numCols, unitLine, usedItems);
|
|
10080
10185
|
finalRows++;
|
|
10081
10186
|
}
|
|
10082
10187
|
if (!rebuiltUsed && attachUnitRow(items, grid, finalGrid, numCols, usedItems)) finalRows++;
|
|
10083
10188
|
let semanticOneColumn = false;
|
|
10084
10189
|
if (!grid.cells && !nestedAttached && numCols === 1 && numGridRows >= 2) {
|
|
10085
|
-
const populatedRows = finalGrid.filter((row) => _optionalChain([row, 'access',
|
|
10190
|
+
const populatedRows = finalGrid.filter((row) => _optionalChain([row, 'access', _414 => _414[0], 'optionalAccess', _415 => _415.text, 'access', _416 => _416.trim, 'call', _417 => _417()]));
|
|
10086
10191
|
if (populatedRows.length >= 4) {
|
|
10087
10192
|
const fontSizes = tableItems.map((item) => item.fontSize).filter((size) => size > 0).sort((a, b) => a - b);
|
|
10088
10193
|
const medianFont = _nullishCoalesce(fontSizes[Math.floor(fontSizes.length / 2)], () => ( 0));
|
|
@@ -10180,7 +10285,7 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
|
|
|
10180
10285
|
height: grid.bbox.y2 - grid.bbox.y1
|
|
10181
10286
|
};
|
|
10182
10287
|
if (numRows === 1 && numCols === 1 && gridW < pageWidth * 0.35) {
|
|
10183
|
-
const prose = _nullishCoalesce(_optionalChain([finalGrid, 'access',
|
|
10288
|
+
const prose = _nullishCoalesce(_optionalChain([finalGrid, 'access', _418 => _418[0], 'optionalAccess', _419 => _419[0], 'optionalAccess', _420 => _420.text]), () => ( ""));
|
|
10184
10289
|
const besideLines = (side) => new Set(side.map((it) => Math.round(it.y / 3))).size;
|
|
10185
10290
|
const rightLines = items.filter((it) => it.x >= grid.bbox.x2 + 3 && it.y >= grid.bbox.y1 && it.y <= grid.bbox.y2);
|
|
10186
10291
|
const leftLines = items.filter((it) => it.x + it.w <= grid.bbox.x1 - 3 && it.y >= grid.bbox.y1 && it.y <= grid.bbox.y2);
|
|
@@ -10199,8 +10304,8 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
|
|
|
10199
10304
|
}
|
|
10200
10305
|
}
|
|
10201
10306
|
if (!grid.cells && !nestedAttached && shouldDemoteTable(irTable)) {
|
|
10202
|
-
const paragraphs = numRows === 1 && numCols === 1 ? _optionalChain([irTable, 'access',
|
|
10203
|
-
if (_optionalChain([paragraphs, 'optionalAccess',
|
|
10307
|
+
const paragraphs = numRows === 1 && numCols === 1 ? _optionalChain([irTable, 'access', _421 => _421.cells, 'access', _422 => _422[0], 'optionalAccess', _423 => _423[0], 'optionalAccess', _424 => _424.blocks]) : void 0;
|
|
10308
|
+
if (_optionalChain([paragraphs, 'optionalAccess', _425 => _425.length])) {
|
|
10204
10309
|
blocks.push(...paragraphs);
|
|
10205
10310
|
frameParagraphUnits.push(paragraphs);
|
|
10206
10311
|
recordFrameReadingUnit(paragraphs, tableBbox);
|
|
@@ -10247,7 +10352,7 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
|
|
|
10247
10352
|
const clusterResults = (proseColumns ? [] : detectClusterTables(clusterItems, pageNum, void 0, lex)).filter((cr) => {
|
|
10248
10353
|
const b = cr.bbox;
|
|
10249
10354
|
const overlapX = (x) => Math.min(x.x + x.width, b.x + b.width) - Math.max(x.x, b.x);
|
|
10250
|
-
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',
|
|
10355
|
+
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', _426 => _426.text, 'optionalAccess', _427 => _427.match, 'call', _428 => _428(/\p{L}/gu), 'optionalAccess', _429 => _429.length]), () => ( 0))) >= 10 && overlapX(x.bbox) >= 0.8 * b.width : x.type === "table" && !ocrPage && _optionalChain([x, 'access', _430 => _430.table, 'optionalAccess', _431 => _431.cols]) === cr.table.cols && overlapX(x.bbox) >= 0.5 * Math.min(x.bbox.width, b.width)));
|
|
10251
10356
|
});
|
|
10252
10357
|
if (clusterResults.length > 0) {
|
|
10253
10358
|
const ciToIdx = /* @__PURE__ */ new Map();
|
|
@@ -10284,7 +10389,7 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
|
|
|
10284
10389
|
groupSizes.push(1);
|
|
10285
10390
|
}
|
|
10286
10391
|
const allY = remaining.map((i) => i.y);
|
|
10287
|
-
const pageH =
|
|
10392
|
+
const pageH = _chunkMANE7HAZcjs.safeMax.call(void 0, allY) - _chunkMANE7HAZcjs.safeMin.call(void 0, allY);
|
|
10288
10393
|
const gapThreshold = Math.max(15, pageH * 0.03);
|
|
10289
10394
|
const sides = frameColumnTextBands(remaining, spanning, gx);
|
|
10290
10395
|
const textBlocks = [];
|
|
@@ -10300,7 +10405,7 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
|
|
|
10300
10405
|
finalTextBlocks.push(...detectListBlocks(textBlocks));
|
|
10301
10406
|
} else {
|
|
10302
10407
|
const allY = remaining.map((i) => i.y);
|
|
10303
|
-
const pageH =
|
|
10408
|
+
const pageH = _chunkMANE7HAZcjs.safeMax.call(void 0, allY) - _chunkMANE7HAZcjs.safeMin.call(void 0, allY);
|
|
10304
10409
|
const gapThreshold = Math.max(15, pageH * 0.03);
|
|
10305
10410
|
const groups = xyCutOrder(remaining, gapThreshold);
|
|
10306
10411
|
const textBlocks = [];
|
|
@@ -10601,6 +10706,10 @@ function extractPageBlocksFallback(items, pageNum, fullPage = false, detectTable
|
|
|
10601
10706
|
}
|
|
10602
10707
|
const rejected = { prose: 0 };
|
|
10603
10708
|
const clusterResults = detectTables ? detectClusterTables(clusterItems, pageNum, rejected, lex) : [];
|
|
10709
|
+
if (rejected.cutX !== void 0) {
|
|
10710
|
+
const groups = splitTwoColumnProse(items, rejected.cutX);
|
|
10711
|
+
if (groups.length > 1 && groups.every((g) => g.length < items.length)) return groups.flatMap((g) => extractPageBlocksFallback(g, pageNum, false, detectTables, lex));
|
|
10712
|
+
}
|
|
10604
10713
|
if (clusterResults.length > 0) {
|
|
10605
10714
|
const ciToIdx = /* @__PURE__ */ new Map();
|
|
10606
10715
|
for (let ci = 0; ci < clusterItems.length; ci++) ciToIdx.set(clusterItems[ci], ci);
|
|
@@ -10632,7 +10741,7 @@ function extractPageBlocksFallback(items, pageNum, fullPage = false, detectTable
|
|
|
10632
10741
|
blocks.push(...columnTextToBlocks(tableText, pageNum, bbox, dominantStyle(items)));
|
|
10633
10742
|
} else {
|
|
10634
10743
|
const allY = items.map((i) => i.y);
|
|
10635
|
-
const pageHeight =
|
|
10744
|
+
const pageHeight = _chunkMANE7HAZcjs.safeMax.call(void 0, allY) - _chunkMANE7HAZcjs.safeMin.call(void 0, allY);
|
|
10636
10745
|
const gapThreshold = Math.max(15, pageHeight * 0.03);
|
|
10637
10746
|
const orderedGroups = proseCutX !== null ? splitTwoColumnProse(items, proseCutX) : xyCutOrder(items, gapThreshold, 0, void 0, minGap);
|
|
10638
10747
|
for (const group of orderedGroups) {
|
|
@@ -10664,19 +10773,19 @@ function mergeOcrImageRegions(blocks, page, regions, ocrBlocks) {
|
|
|
10664
10773
|
const overlapH = Math.max(0, Math.min(b.y + b.height, region.y2) - Math.max(b.y, region.y1));
|
|
10665
10774
|
return overlapW * overlapH >= b.width * b.height * 0.8;
|
|
10666
10775
|
});
|
|
10667
|
-
const labels = candidates.filter((b) => b.type === "paragraph" && b.bbox.height <= 24 && (_nullishCoalesce(_optionalChain([b, 'access',
|
|
10776
|
+
const labels = candidates.filter((b) => b.type === "paragraph" && b.bbox.height <= 24 && (_nullishCoalesce(_optionalChain([b, 'access', _432 => _432.text, 'optionalAccess', _433 => _433.match, 'call', _434 => _434(/[\p{L}\p{N}]/gu), 'optionalAccess', _435 => _435.length]), () => ( 0))) >= 2);
|
|
10668
10777
|
const axisFragments = rotatedAxisFragments(candidates);
|
|
10669
10778
|
const accepted = candidates.filter((b) => {
|
|
10670
|
-
if (b.type === "paragraph") return (_nullishCoalesce(_optionalChain([b, 'access',
|
|
10779
|
+
if (b.type === "paragraph") return (_nullishCoalesce(_optionalChain([b, 'access', _436 => _436.text, 'optionalAccess', _437 => _437.match, 'call', _438 => _438(/[\p{L}\p{N}]/gu), 'optionalAccess', _439 => _439.length]), () => ( 0))) >= 2 || !axisFragments.has(b) && (supportedDiagramLabel(b, labels, region) || axisTick(b, candidates));
|
|
10671
10780
|
const t = b.table;
|
|
10672
10781
|
if (b.type !== "table" || !t || UNRULED_REGION_TABLES.has(b)) return false;
|
|
10673
10782
|
const lone = t.cells.filter((row) => row.filter((c) => c.text.trim()).length === 1 && row.some((c) => c.colSpan === t.cols)).length;
|
|
10674
10783
|
if (t.rows >= 2 && lone * 2 >= t.rows) return false;
|
|
10675
10784
|
if (t.rows === 1 && t.cols === 1) {
|
|
10676
|
-
const text = _nullishCoalesce(_optionalChain([t, 'access',
|
|
10677
|
-
return (_nullishCoalesce(_optionalChain([text, 'access',
|
|
10785
|
+
const text = _nullishCoalesce(_optionalChain([t, 'access', _440 => _440.cells, 'access', _441 => _441[0], 'optionalAccess', _442 => _442[0], 'optionalAccess', _443 => _443.text]), () => ( ""));
|
|
10786
|
+
return (_nullishCoalesce(_optionalChain([text, 'access', _444 => _444.match, 'call', _445 => _445(/\n/g), 'optionalAccess', _446 => _446.length]), () => ( 0))) >= 5 && (_nullishCoalesce(_optionalChain([text, 'access', _447 => _447.match, 'call', _448 => _448(/\d/g), 'optionalAccess', _449 => _449.length]), () => ( 0))) >= text.length * 0.25;
|
|
10678
10787
|
}
|
|
10679
|
-
const headerLabels = _nullishCoalesce(_optionalChain([t, 'access',
|
|
10788
|
+
const headerLabels = _nullishCoalesce(_optionalChain([t, 'access', _450 => _450.cells, 'access', _451 => _451[0], 'optionalAccess', _452 => _452.filter, 'call', _453 => _453((c) => c.text.replace(/[^A-Za-z가-힣]/g, "").length >= 2), 'access', _454 => _454.length]), () => ( 0));
|
|
10680
10789
|
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);
|
|
10681
10790
|
});
|
|
10682
10791
|
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, () => ( "")))) : []);
|
|
@@ -10693,14 +10802,14 @@ function mergeOcrImageRegions(blocks, page, regions, ocrBlocks) {
|
|
|
10693
10802
|
for (const block of selected) {
|
|
10694
10803
|
if (seen2.has(block)) continue;
|
|
10695
10804
|
const frame = FRAME_READING_UNITS.get(block);
|
|
10696
|
-
const source = _optionalChain([frame, 'optionalAccess',
|
|
10805
|
+
const source = _optionalChain([frame, 'optionalAccess', _455 => _455.blocks, 'access', _456 => _456.every, 'call', _457 => _457((member) => selectedSet.has(member))]) ? frame.blocks : [block];
|
|
10697
10806
|
source.forEach((member) => seen2.add(member));
|
|
10698
10807
|
const available = source.filter((member) => !hasOriginal(member));
|
|
10699
10808
|
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 }));
|
|
10700
10809
|
for (const unit of units) {
|
|
10701
10810
|
const b = unit.bbox;
|
|
10702
10811
|
const index = blocks.findIndex((existing) => {
|
|
10703
|
-
const e = _nullishCoalesce(_optionalChain([FRAME_READING_UNITS, 'access',
|
|
10812
|
+
const e = _nullishCoalesce(_optionalChain([FRAME_READING_UNITS, 'access', _458 => _458.get, 'call', _459 => _459(existing), 'optionalAccess', _460 => _460.bbox]), () => ( existing.bbox));
|
|
10704
10813
|
if (existing.pageNumber !== page || !e) return false;
|
|
10705
10814
|
const beside = e.y < region.y2 && e.y + e.height > region.y1 && e.x >= region.x2 - 1;
|
|
10706
10815
|
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;
|
|
@@ -10718,16 +10827,16 @@ function mergeOcrImageRegions(blocks, page, regions, ocrBlocks) {
|
|
|
10718
10827
|
}
|
|
10719
10828
|
function axisTick(block, candidates) {
|
|
10720
10829
|
const b = block.bbox;
|
|
10721
|
-
if (!/^\d$/u.test(_nullishCoalesce(_optionalChain([block, 'access',
|
|
10722
|
-
const numeric = candidates.filter((o) => o !== block && o.type === "paragraph" && o.bbox && /^[\d\s.,%+−-]+$/u.test(_nullishCoalesce(_optionalChain([o, 'access',
|
|
10830
|
+
if (!/^\d$/u.test(_nullishCoalesce(_optionalChain([block, 'access', _461 => _461.text, 'optionalAccess', _462 => _462.trim, 'call', _463 => _463()]), () => ( "")))) return false;
|
|
10831
|
+
const numeric = candidates.filter((o) => o !== block && o.type === "paragraph" && o.bbox && /^[\d\s.,%+−-]+$/u.test(_nullishCoalesce(_optionalChain([o, 'access', _464 => _464.text, 'optionalAccess', _465 => _465.trim, 'call', _466 => _466()]), () => ( ""))) && /\d/u.test(_nullishCoalesce(o.text, () => ( ""))) && Math.max(o.bbox.height, b.height) <= Math.min(o.bbox.height, b.height) * 2);
|
|
10723
10832
|
const cy = b.y + b.height / 2, right = b.x + b.width;
|
|
10724
10833
|
const row = numeric.filter((o) => Math.abs(o.bbox.y + o.bbox.height / 2 - cy) <= Math.min(o.bbox.height, b.height) * 0.35);
|
|
10725
10834
|
const column = numeric.filter((o) => Math.abs(o.bbox.x + o.bbox.width - right) <= Math.max(o.bbox.height, b.height) * 0.5);
|
|
10726
10835
|
return row.length >= 2 || column.length >= 2;
|
|
10727
10836
|
}
|
|
10728
10837
|
function supportedDiagramLabel(block, labels, region) {
|
|
10729
|
-
const b = block.bbox, text = _nullishCoalesce(_optionalChain([block, 'access',
|
|
10730
|
-
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',
|
|
10838
|
+
const b = block.bbox, text = _nullishCoalesce(_optionalChain([block, 'access', _467 => _467.text, 'optionalAccess', _468 => _468.trim, 'call', _469 => _469()]), () => ( ""));
|
|
10839
|
+
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', _470 => _470.text, 'optionalAccess', _471 => _471.match, 'call', _472 => _472(/\p{N}/gu), 'optionalAccess', _473 => _473.length]), () => ( 0))) >= 2).length < 2) return false;
|
|
10731
10840
|
let above = false, below = false;
|
|
10732
10841
|
for (const label of labels) {
|
|
10733
10842
|
const a = label.bbox, em = Math.max(b.height, a.height);
|
|
@@ -10742,7 +10851,7 @@ function rotatedAxisFragments(candidates) {
|
|
|
10742
10851
|
const paragraphs = candidates.filter((b) => b.type === "paragraph" && b.bbox.height <= 24);
|
|
10743
10852
|
const axes = [];
|
|
10744
10853
|
for (const block of paragraphs) {
|
|
10745
|
-
const b = block.bbox, text = _nullishCoalesce(_optionalChain([block, 'access',
|
|
10854
|
+
const b = block.bbox, text = _nullishCoalesce(_optionalChain([block, 'access', _474 => _474.text, 'optionalAccess', _475 => _475.trim, 'call', _476 => _476()]), () => ( ""));
|
|
10746
10855
|
if (!/^[\d\s.,%+−-]+$/u.test(text) || !/\d/u.test(text) || b.width > b.height * 6) continue;
|
|
10747
10856
|
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);
|
|
10748
10857
|
if (axis) axis.push(block);
|
|
@@ -10759,8 +10868,8 @@ function rotatedAxisFragments(candidates) {
|
|
|
10759
10868
|
const em = Math.max(...axis.map((a) => a.bbox.height)), right = axis[0].bbox.x + axis[0].bbox.width;
|
|
10760
10869
|
if (top - bottom < em * 6) continue;
|
|
10761
10870
|
const left = paragraphs.filter((block) => {
|
|
10762
|
-
const b = block.bbox, text = _nullishCoalesce(_optionalChain([block, 'access',
|
|
10763
|
-
return /\p{Script=Latin}/u.test(text) && (_nullishCoalesce(_optionalChain([text, 'access',
|
|
10871
|
+
const b = block.bbox, text = _nullishCoalesce(_optionalChain([block, 'access', _477 => _477.text, 'optionalAccess', _478 => _478.trim, 'call', _479 => _479()]), () => ( ""));
|
|
10872
|
+
return /\p{Script=Latin}/u.test(text) && (_nullishCoalesce(_optionalChain([text, 'access', _480 => _480.match, 'call', _481 => _481(/[\p{L}\p{N}]/gu), 'optionalAccess', _482 => _482.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;
|
|
10764
10873
|
});
|
|
10765
10874
|
const stack = left.filter((a) => left.some((b) => {
|
|
10766
10875
|
if (a === b || !aligned(a, b)) return false;
|
|
@@ -10770,7 +10879,7 @@ function rotatedAxisFragments(candidates) {
|
|
|
10770
10879
|
if (stack.length < 2) continue;
|
|
10771
10880
|
for (const block of paragraphs) {
|
|
10772
10881
|
const b = block.bbox;
|
|
10773
|
-
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',
|
|
10882
|
+
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', _483 => _483.text, 'optionalAccess', _484 => _484.trim, 'call', _485 => _485()]), () => ( ""))) && stack.some((s) => aligned(s, block))) fragments.add(block);
|
|
10774
10883
|
}
|
|
10775
10884
|
}
|
|
10776
10885
|
return fragments;
|
|
@@ -10875,4 +10984,4 @@ function rowParagraphs(block) {
|
|
|
10875
10984
|
|
|
10876
10985
|
|
|
10877
10986
|
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.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.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;
|
|
10878
|
-
//# sourceMappingURL=chunk-
|
|
10987
|
+
//# sourceMappingURL=chunk-XYVTCXAG.cjs.map
|