kordoc 4.24.65 → 4.24.67
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 +5 -5
- package/dist/{-3Q26OZHW.js → -7TPBQODI.js} +21 -21
- package/dist/{chunk-VQZIP2UW.js → chunk-3AEPELHI.js} +10 -10
- package/dist/{chunk-7DQI7BU6.js → chunk-3Q7VWFSC.js} +2 -2
- package/dist/{chunk-FTMDZ4Y5.js → chunk-4RRWKO2T.js} +3 -3
- package/dist/{chunk-LXRBEPYC.js → chunk-4YLZR2X6.js} +2 -2
- package/dist/{chunk-ABA2Z4LT.js → chunk-5Z2TRKU7.js} +2 -2
- package/dist/{chunk-GITPHKYL.cjs → chunk-6RA4KZHK.cjs} +8 -8
- package/dist/{chunk-GITPHKYL.cjs.map → chunk-6RA4KZHK.cjs.map} +1 -1
- package/dist/{chunk-BYTIJ226.js → chunk-73EKNKTF.js} +2 -2
- package/dist/{chunk-I2HHHJF5.js → chunk-7TYITQPR.js} +2 -2
- package/dist/{chunk-VMR3QMB5.js → chunk-7ULJRLAV.js} +58 -13
- package/dist/chunk-7ULJRLAV.js.map +1 -0
- package/dist/{chunk-PWSUGKMS.js → chunk-B4ILQPEH.js} +2 -2
- package/dist/{chunk-DQQ6C7WA.js → chunk-DHYKBCDL.js} +2 -2
- package/dist/{chunk-JW6PNIXI.js → chunk-DUPB5XGN.js} +7 -7
- package/dist/{chunk-B4ZNG3G7.cjs → chunk-E7QOWHAY.cjs} +229 -181
- package/dist/chunk-E7QOWHAY.cjs.map +1 -0
- package/dist/{chunk-4T4Y2WRR.cjs → chunk-FABG65BG.cjs} +2 -2
- package/dist/{chunk-4T4Y2WRR.cjs.map → chunk-FABG65BG.cjs.map} +1 -1
- package/dist/{chunk-AKYUE4JE.js → chunk-FARHGCF2.js} +2 -2
- package/dist/{chunk-UJI2ZP6M.cjs → chunk-FIR4AEWA.cjs} +104 -104
- package/dist/{chunk-UJI2ZP6M.cjs.map → chunk-FIR4AEWA.cjs.map} +1 -1
- package/dist/{chunk-RH6E2YVG.js → chunk-FYAFEINW.js} +2 -2
- package/dist/{chunk-3Z7WJCP2.js → chunk-GJMIO344.js} +2 -2
- package/dist/{chunk-NTMN5UKQ.js → chunk-HFER3UG6.js} +60 -12
- package/dist/chunk-HFER3UG6.js.map +1 -0
- package/dist/{chunk-EG47QXJE.js → chunk-HHKGOBE2.js} +5 -5
- package/dist/{chunk-6J5RTSBG.cjs → chunk-HY3O6EDL.cjs} +3 -3
- package/dist/{chunk-6J5RTSBG.cjs.map → chunk-HY3O6EDL.cjs.map} +1 -1
- package/dist/{chunk-XS254L5R.js → chunk-JS6P3636.js} +3 -3
- package/dist/{chunk-BPNJBWKQ.js → chunk-K23AEIDZ.js} +15 -15
- package/dist/{chunk-Y6UT3AYV.js → chunk-L5GKQX4P.js} +61 -13
- package/dist/chunk-L5GKQX4P.js.map +1 -0
- package/dist/{chunk-KUAPGGQE.js → chunk-LLQAB3SS.js} +6 -6
- package/dist/{chunk-NBBT2EYG.js → chunk-MKDM6JB4.js} +2 -2
- package/dist/{chunk-ZMJVWAH2.cjs → chunk-MT5WGKV7.cjs} +58 -58
- package/dist/{chunk-ZMJVWAH2.cjs.map → chunk-MT5WGKV7.cjs.map} +1 -1
- package/dist/{chunk-3JHKWOVZ.js → chunk-NMRQGQML.js} +57 -12
- package/dist/chunk-NMRQGQML.js.map +1 -0
- package/dist/{chunk-CLI5IIY3.js → chunk-NOWCGRKY.js} +2 -2
- package/dist/{chunk-B4AKPVWA.cjs → chunk-OFWBSK6D.cjs} +142 -97
- package/dist/chunk-OFWBSK6D.cjs.map +1 -0
- package/dist/{chunk-UYEZER77.js → chunk-OILA3YTC.js} +2 -2
- package/dist/{chunk-DKSSS4ED.js → chunk-OMFCOSBY.js} +2 -2
- package/dist/{chunk-AX34AL6K.js → chunk-Q2O6KEL3.js} +2 -2
- package/dist/{chunk-U2TSYPPM.js → chunk-QZTECR6E.js} +2 -2
- package/dist/{chunk-6R4M2LVY.js → chunk-SBJ4MJDD.js} +2 -2
- package/dist/{chunk-GZC4XIKW.js → chunk-SOAIESRF.js} +5 -5
- package/dist/{chunk-MTUGM4ZK.js → chunk-T7RMYBYP.js} +6 -6
- package/dist/{chunk-TYJFA5S7.js → chunk-TYE5W7RJ.js} +2 -2
- package/dist/{chunk-S5XPBZQ6.cjs → chunk-UXWQYWSJ.cjs} +3 -3
- package/dist/{chunk-S5XPBZQ6.cjs.map → chunk-UXWQYWSJ.cjs.map} +1 -1
- package/dist/{chunk-BRDRZHVC.js → chunk-WECXPIBP.js} +2 -2
- package/dist/{chunk-TN2C7M6Q.js → chunk-WGUANGGA.js} +11 -11
- package/dist/{chunk-27ZUZMQY.js → chunk-XV554HLH.js} +5 -5
- package/dist/{chunk-7PTPUYYJ.js → chunk-ZT2YHDRX.js} +3 -3
- package/dist/chunks-XSXJ7WHX.js +11 -0
- package/dist/cli.js +45 -45
- package/dist/{formula-HNVGC323.cjs → formula-2IC5OKZ6.cjs} +9 -9
- package/dist/{formula-HNVGC323.cjs.map → formula-2IC5OKZ6.cjs.map} +1 -1
- package/dist/{formula-WDYM2TBT.js → formula-7ZWQ6LS2.js} +3 -3
- package/dist/{formula-N6HZBMYV.js → formula-OKSR2NJY.js} +4 -4
- package/dist/generator-6YIOSSFN.cjs +12 -0
- package/dist/{generator-GJID5Q4V.cjs.map → generator-6YIOSSFN.cjs.map} +1 -1
- package/dist/generator-GYR4PZAJ.js +18 -0
- package/dist/generator-HAJKBJRD.js +11 -0
- package/dist/{hancom-TJ2T5WD7.js → hancom-42PJQLYF.js} +2 -2
- package/dist/{hancom-XNW5F3S5.js → hancom-PBWLHPG6.js} +2 -2
- package/dist/{hancom-Y4QJMNTG.cjs → hancom-RM65BNHD.cjs} +5 -5
- package/dist/{hancom-Y4QJMNTG.cjs.map → hancom-RM65BNHD.cjs.map} +1 -1
- package/dist/{image-ocr-HXQV325C.js → image-ocr-B32JZFLP.js} +7 -7
- package/dist/{image-ocr-2P6OUO7R.cjs → image-ocr-IIPN7IH6.cjs} +28 -28
- package/dist/{image-ocr-2P6OUO7R.cjs.map → image-ocr-IIPN7IH6.cjs.map} +1 -1
- package/dist/{image-ocr-EEI3UA36.js → image-ocr-S4U3UXRJ.js} +10 -10
- package/dist/index.cjs +1115 -1115
- package/dist/index.js +9 -9
- package/dist/mcp.js +36 -36
- package/dist/memo-ZQOVJ7UJ.js +17 -0
- package/dist/{model-bundle-QMXOK6ML.js → model-bundle-MJJ73AEH.js} +5 -5
- package/dist/{models-VRTWSRWY.js → models-G4JXJ2ON.js} +5 -5
- package/dist/{parse-worker-v2-4YEQVFDN.js → parse-worker-v2-TLTNAXAZ.js} +22 -22
- package/dist/{parser-5X3O5FMI.cjs → parser-OXRSENMG.cjs} +166 -166
- package/dist/{parser-5X3O5FMI.cjs.map → parser-OXRSENMG.cjs.map} +1 -1
- package/dist/{parser-6ZIQHTU7.js → parser-TWCVEECS.js} +9 -9
- package/dist/{parser-4FZWTV4P.js → parser-YQA3F7IL.js} +12 -12
- package/dist/{pdf-ocr-TIYXB6UN.js → pdf-ocr-2BQ4ME6Y.js} +6 -6
- package/dist/{pdf-ocr-HHWYGVYA.js → pdf-ocr-BA5LM535.js} +9 -9
- package/dist/pdf-ocr-GKN76Y2W.cjs +43 -0
- package/dist/{pdf-ocr-47CN4L3H.cjs.map → pdf-ocr-GKN76Y2W.cjs.map} +1 -1
- package/dist/{profile-io-6FHN5UEA.js → profile-io-PBYC4MTQ.js} +3 -3
- package/dist/{rasterize-JFBYSQSV.js → rasterize-B3H32G23.js} +3 -3
- package/dist/{redact-doc-PYL7KZBW.js → redact-doc-QY7DXOQE.js} +21 -21
- package/dist/{render-6V2YIVO3.js → render-SRJ6ZIYE.js} +12 -12
- package/dist/{rewrite-fallback-53SOLUTC.js → rewrite-fallback-WVGGZ2QV.js} +13 -13
- package/dist/seal-J7SSWMVR.js +16 -0
- package/dist/{setup-LFIDDDUO.js → setup-EHHJHPIQ.js} +3 -3
- package/dist/{to-hwpx-VPIDINZP.js → to-hwpx-BYNLZ2U3.js} +4 -4
- package/dist/{to-hwpx-PVXV4MP3.js → to-hwpx-ESTHBOHH.js} +7 -7
- package/dist/to-hwpx-Y53M4SSD.cjs +16 -0
- package/dist/{to-hwpx-SNIR5XQE.cjs.map → to-hwpx-Y53M4SSD.cjs.map} +1 -1
- package/dist/visual-DVJGGPVU.js +38 -0
- package/dist/{watch-RDE5VTIX.js → watch-KJMMJVZ4.js} +22 -22
- package/package.json +1 -1
- package/dist/chunk-3JHKWOVZ.js.map +0 -1
- package/dist/chunk-B4AKPVWA.cjs.map +0 -1
- package/dist/chunk-B4ZNG3G7.cjs.map +0 -1
- package/dist/chunk-NTMN5UKQ.js.map +0 -1
- package/dist/chunk-VMR3QMB5.js.map +0 -1
- package/dist/chunk-Y6UT3AYV.js.map +0 -1
- package/dist/chunks-LAMEBTHT.js +0 -11
- package/dist/generator-GJID5Q4V.cjs +0 -12
- package/dist/generator-LGSVRPVO.js +0 -11
- package/dist/generator-QQTCTEMZ.js +0 -18
- package/dist/memo-JYBL4KYT.js +0 -17
- package/dist/pdf-ocr-47CN4L3H.cjs +0 -43
- package/dist/seal-KRIMAC4M.js +0 -16
- package/dist/to-hwpx-SNIR5XQE.cjs +0 -16
- package/dist/visual-HKD7SS2K.js +0 -38
- /package/dist/{-3Q26OZHW.js.map → -7TPBQODI.js.map} +0 -0
- /package/dist/{chunk-VQZIP2UW.js.map → chunk-3AEPELHI.js.map} +0 -0
- /package/dist/{chunk-7DQI7BU6.js.map → chunk-3Q7VWFSC.js.map} +0 -0
- /package/dist/{chunk-FTMDZ4Y5.js.map → chunk-4RRWKO2T.js.map} +0 -0
- /package/dist/{chunk-LXRBEPYC.js.map → chunk-4YLZR2X6.js.map} +0 -0
- /package/dist/{chunk-ABA2Z4LT.js.map → chunk-5Z2TRKU7.js.map} +0 -0
- /package/dist/{chunk-BYTIJ226.js.map → chunk-73EKNKTF.js.map} +0 -0
- /package/dist/{chunk-I2HHHJF5.js.map → chunk-7TYITQPR.js.map} +0 -0
- /package/dist/{chunk-PWSUGKMS.js.map → chunk-B4ILQPEH.js.map} +0 -0
- /package/dist/{chunk-DQQ6C7WA.js.map → chunk-DHYKBCDL.js.map} +0 -0
- /package/dist/{chunk-JW6PNIXI.js.map → chunk-DUPB5XGN.js.map} +0 -0
- /package/dist/{chunk-AKYUE4JE.js.map → chunk-FARHGCF2.js.map} +0 -0
- /package/dist/{chunk-RH6E2YVG.js.map → chunk-FYAFEINW.js.map} +0 -0
- /package/dist/{chunk-3Z7WJCP2.js.map → chunk-GJMIO344.js.map} +0 -0
- /package/dist/{chunk-EG47QXJE.js.map → chunk-HHKGOBE2.js.map} +0 -0
- /package/dist/{chunk-XS254L5R.js.map → chunk-JS6P3636.js.map} +0 -0
- /package/dist/{chunk-BPNJBWKQ.js.map → chunk-K23AEIDZ.js.map} +0 -0
- /package/dist/{chunk-KUAPGGQE.js.map → chunk-LLQAB3SS.js.map} +0 -0
- /package/dist/{chunk-NBBT2EYG.js.map → chunk-MKDM6JB4.js.map} +0 -0
- /package/dist/{chunk-CLI5IIY3.js.map → chunk-NOWCGRKY.js.map} +0 -0
- /package/dist/{chunk-UYEZER77.js.map → chunk-OILA3YTC.js.map} +0 -0
- /package/dist/{chunk-DKSSS4ED.js.map → chunk-OMFCOSBY.js.map} +0 -0
- /package/dist/{chunk-AX34AL6K.js.map → chunk-Q2O6KEL3.js.map} +0 -0
- /package/dist/{chunk-U2TSYPPM.js.map → chunk-QZTECR6E.js.map} +0 -0
- /package/dist/{chunk-6R4M2LVY.js.map → chunk-SBJ4MJDD.js.map} +0 -0
- /package/dist/{chunk-GZC4XIKW.js.map → chunk-SOAIESRF.js.map} +0 -0
- /package/dist/{chunk-MTUGM4ZK.js.map → chunk-T7RMYBYP.js.map} +0 -0
- /package/dist/{chunk-TYJFA5S7.js.map → chunk-TYE5W7RJ.js.map} +0 -0
- /package/dist/{chunk-BRDRZHVC.js.map → chunk-WECXPIBP.js.map} +0 -0
- /package/dist/{chunk-TN2C7M6Q.js.map → chunk-WGUANGGA.js.map} +0 -0
- /package/dist/{chunk-27ZUZMQY.js.map → chunk-XV554HLH.js.map} +0 -0
- /package/dist/{chunk-7PTPUYYJ.js.map → chunk-ZT2YHDRX.js.map} +0 -0
- /package/dist/{chunks-LAMEBTHT.js.map → chunks-XSXJ7WHX.js.map} +0 -0
- /package/dist/{formula-WDYM2TBT.js.map → formula-7ZWQ6LS2.js.map} +0 -0
- /package/dist/{formula-N6HZBMYV.js.map → formula-OKSR2NJY.js.map} +0 -0
- /package/dist/{generator-LGSVRPVO.js.map → generator-GYR4PZAJ.js.map} +0 -0
- /package/dist/{generator-QQTCTEMZ.js.map → generator-HAJKBJRD.js.map} +0 -0
- /package/dist/{hancom-TJ2T5WD7.js.map → hancom-42PJQLYF.js.map} +0 -0
- /package/dist/{hancom-XNW5F3S5.js.map → hancom-PBWLHPG6.js.map} +0 -0
- /package/dist/{image-ocr-HXQV325C.js.map → image-ocr-B32JZFLP.js.map} +0 -0
- /package/dist/{image-ocr-EEI3UA36.js.map → image-ocr-S4U3UXRJ.js.map} +0 -0
- /package/dist/{memo-JYBL4KYT.js.map → memo-ZQOVJ7UJ.js.map} +0 -0
- /package/dist/{model-bundle-QMXOK6ML.js.map → model-bundle-MJJ73AEH.js.map} +0 -0
- /package/dist/{models-VRTWSRWY.js.map → models-G4JXJ2ON.js.map} +0 -0
- /package/dist/{parse-worker-v2-4YEQVFDN.js.map → parse-worker-v2-TLTNAXAZ.js.map} +0 -0
- /package/dist/{parser-6ZIQHTU7.js.map → parser-TWCVEECS.js.map} +0 -0
- /package/dist/{parser-4FZWTV4P.js.map → parser-YQA3F7IL.js.map} +0 -0
- /package/dist/{pdf-ocr-HHWYGVYA.js.map → pdf-ocr-2BQ4ME6Y.js.map} +0 -0
- /package/dist/{pdf-ocr-TIYXB6UN.js.map → pdf-ocr-BA5LM535.js.map} +0 -0
- /package/dist/{profile-io-6FHN5UEA.js.map → profile-io-PBYC4MTQ.js.map} +0 -0
- /package/dist/{rasterize-JFBYSQSV.js.map → rasterize-B3H32G23.js.map} +0 -0
- /package/dist/{redact-doc-PYL7KZBW.js.map → redact-doc-QY7DXOQE.js.map} +0 -0
- /package/dist/{render-6V2YIVO3.js.map → render-SRJ6ZIYE.js.map} +0 -0
- /package/dist/{rewrite-fallback-53SOLUTC.js.map → rewrite-fallback-WVGGZ2QV.js.map} +0 -0
- /package/dist/{seal-KRIMAC4M.js.map → seal-J7SSWMVR.js.map} +0 -0
- /package/dist/{setup-LFIDDDUO.js.map → setup-EHHJHPIQ.js.map} +0 -0
- /package/dist/{to-hwpx-PVXV4MP3.js.map → to-hwpx-BYNLZ2U3.js.map} +0 -0
- /package/dist/{to-hwpx-VPIDINZP.js.map → to-hwpx-ESTHBOHH.js.map} +0 -0
- /package/dist/{visual-HKD7SS2K.js.map → visual-DVJGGPVU.js.map} +0 -0
- /package/dist/{watch-RDE5VTIX.js.map → watch-KJMMJVZ4.js.map} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class;
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var _chunkHY3O6EDLcjs = require('./chunk-HY3O6EDL.cjs');
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
@@ -9,11 +9,11 @@ var _chunk6J5RTSBGcjs = require('./chunk-6J5RTSBG.cjs');
|
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _chunk6RA4KZHKcjs = require('./chunk-6RA4KZHK.cjs');
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
|
|
16
|
-
var
|
|
16
|
+
var _chunkFABG65BGcjs = require('./chunk-FABG65BG.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 _chunkHY3O6EDLcjs.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 _chunkHY3O6EDLcjs.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);
|
|
@@ -2234,6 +2234,7 @@ function hasShadedRowBands(host, clips, fills, verticals, horizontals) {
|
|
|
2234
2234
|
|
|
2235
2235
|
// src/pdf/table-grid.ts
|
|
2236
2236
|
var CONNECT_TOL = 5;
|
|
2237
|
+
var CLOSED_BOX_GAP = 10;
|
|
2237
2238
|
var MIN_COL_WIDTH = 15;
|
|
2238
2239
|
var NARROW_RUN_MIN_WIDTH = 12;
|
|
2239
2240
|
var NARROW_RUN_MAX_WIDTH = 20;
|
|
@@ -2436,7 +2437,11 @@ function buildTableGrids(horizontals, verticals, narrowRuns = true) {
|
|
|
2436
2437
|
x2: validColXs[validColXs.length - 1],
|
|
2437
2438
|
y2: validRowYs[0]
|
|
2438
2439
|
};
|
|
2439
|
-
|
|
2440
|
+
const edgeTol = Math.max(CONNECT_TOL, coordMergeTol);
|
|
2441
|
+
const sideClosed = (x) => vLines.some((l) => Math.abs(l.x1 - x) <= edgeTol && Math.min(l.y1, l.y2) <= bbox.y1 + edgeTol && Math.max(l.y1, l.y2) >= bbox.y2 - edgeTol);
|
|
2442
|
+
const capClosed = (y) => hLines.some((l) => Math.abs(l.y1 - y) <= edgeTol && Math.abs(Math.min(l.x1, l.x2) - bbox.x1) <= edgeTol && Math.abs(Math.max(l.x1, l.x2) - bbox.x2) <= edgeTol);
|
|
2443
|
+
const closedBox = sideClosed(bbox.x1) && sideClosed(bbox.x2) && capClosed(bbox.y1) && capClosed(bbox.y2);
|
|
2444
|
+
grids.push({ rowYs: validRowYs, colXs: validColXs, bbox, vertexRadius: groupRadius, ...nested ? { lineNested: true } : {}, ...closedBox ? { closedBox: true } : {} });
|
|
2440
2445
|
}
|
|
2441
2446
|
return [...mergeAdjacentGrids(grids.filter((g) => !g.lineNested)), ...grids.filter((g) => g.lineNested)];
|
|
2442
2447
|
}
|
|
@@ -2541,7 +2546,8 @@ function mergeAdjacentGrids(grids) {
|
|
|
2541
2546
|
const mergeTol = Math.max(VERTEX_MERGE_FACTOR * Math.max(prev.vertexRadius, curr.vertexRadius), 6) * 3;
|
|
2542
2547
|
const colMatch = prev.colXs.every((x, ci) => Math.abs(x - curr.colXs[ci]) <= mergeTol);
|
|
2543
2548
|
const verticalGap = prev.bbox.y1 - curr.bbox.y2;
|
|
2544
|
-
|
|
2549
|
+
const maxGap = prev.closedBox && curr.closedBox && prev.colXs.length > 2 ? CLOSED_BOX_GAP : 20;
|
|
2550
|
+
if (colMatch && verticalGap >= -CONNECT_TOL && verticalGap <= maxGap) {
|
|
2545
2551
|
const allRowYs = [.../* @__PURE__ */ new Set([...prev.rowYs, ...curr.rowYs])].sort((a, b) => b - a);
|
|
2546
2552
|
merged[merged.length - 1] = {
|
|
2547
2553
|
rowYs: allRowYs,
|
|
@@ -3407,16 +3413,16 @@ function recordOpenEndCellEdges(grid, cells, horizontals) {
|
|
|
3407
3413
|
}
|
|
3408
3414
|
function takeClipCellEdges(from, to) {
|
|
3409
3415
|
const e = CLIP_CELL_EDGES.get(from);
|
|
3410
|
-
if (e)
|
|
3416
|
+
if (e) _chunk6RA4KZHKcjs.CELL_EDGES.set(to, e);
|
|
3411
3417
|
}
|
|
3412
3418
|
function hasOpenCellSeam(a, b) {
|
|
3413
|
-
const u =
|
|
3419
|
+
const u = _chunk6RA4KZHKcjs.CELL_EDGES.get(a), d = _chunk6RA4KZHKcjs.CELL_EDGES.get(b);
|
|
3414
3420
|
return !!u && !!d && u.t && !u.b && !d.t && d.b && u.l && u.r && d.l && d.r;
|
|
3415
3421
|
}
|
|
3416
3422
|
function joinCellEdges(a, b) {
|
|
3417
|
-
const u =
|
|
3423
|
+
const u = _chunk6RA4KZHKcjs.CELL_EDGES.get(a), d = _chunk6RA4KZHKcjs.CELL_EDGES.get(b);
|
|
3418
3424
|
if (!u || !d) return;
|
|
3419
|
-
|
|
3425
|
+
_chunk6RA4KZHKcjs.CELL_EDGES.set(a, { t: u.t, b: d.b, l: u.l || d.l, r: u.r || d.r });
|
|
3420
3426
|
}
|
|
3421
3427
|
|
|
3422
3428
|
// src/pdf/cell-extract.ts
|
|
@@ -3592,12 +3598,13 @@ function tagScripts(text, lines) {
|
|
|
3592
3598
|
const [s, e, kind] = marks[m];
|
|
3593
3599
|
out = out.slice(0, s) + `<${kind}>` + out.slice(s, e) + `</${kind}>` + out.slice(e);
|
|
3594
3600
|
}
|
|
3595
|
-
return
|
|
3601
|
+
return _chunk6RA4KZHKcjs.tidyScriptTags.call(void 0, out);
|
|
3596
3602
|
}
|
|
3597
3603
|
|
|
3598
3604
|
// src/pdf/line-wrap.ts
|
|
3599
3605
|
var MARKUP = /<\/?u>|~~/g;
|
|
3600
3606
|
var LINK_MARKUP = /(?<!!)\[([^\]\n]*)\]\([^)\s]+\)/g;
|
|
3607
|
+
var CITE_LINK = /제\d+(조|항|호)(?:의\d+)?( ?)(?=제\d+(?:항|호|목))/g;
|
|
3601
3608
|
var bump = (m, k) => {
|
|
3602
3609
|
m.set(k, (_nullishCoalesce(m.get(k), () => ( 0))) + 1);
|
|
3603
3610
|
};
|
|
@@ -3607,7 +3614,7 @@ var bump2 = (m, k1, k2) => {
|
|
|
3607
3614
|
if (!inner) m.set(k1, inner = /* @__PURE__ */ new Map());
|
|
3608
3615
|
bump(inner, k2);
|
|
3609
3616
|
};
|
|
3610
|
-
var WrapLexicon = (_class = class {constructor() { _class.prototype.__init.call(this);_class.prototype.__init2.call(this);_class.prototype.__init3.call(this);_class.prototype.__init4.call(this);_class.prototype.__init5.call(this);_class.prototype.__init6.call(this);_class.prototype.__init7.call(this);_class.prototype.__init8.call(this);_class.prototype.__init9.call(this); }
|
|
3617
|
+
var WrapLexicon = (_class = class {constructor() { _class.prototype.__init.call(this);_class.prototype.__init2.call(this);_class.prototype.__init3.call(this);_class.prototype.__init4.call(this);_class.prototype.__init5.call(this);_class.prototype.__init6.call(this);_class.prototype.__init7.call(this);_class.prototype.__init8.call(this);_class.prototype.__init9.call(this);_class.prototype.__init10.call(this); }
|
|
3611
3618
|
__init() {this.joined1 = /* @__PURE__ */ new Map()}
|
|
3612
3619
|
__init2() {this.joined2 = /* @__PURE__ */ new Map()}
|
|
3613
3620
|
__init3() {this.spaced1 = /* @__PURE__ */ new Map()}
|
|
@@ -3620,8 +3627,11 @@ var WrapLexicon = (_class = class {constructor() { _class.prototype.__init.call(
|
|
|
3620
3627
|
__init7() {this.heads = /* @__PURE__ */ new Set()}
|
|
3621
3628
|
/** 줄 안 이웃 어절의 앞 어절 한글 꼬리 + 뒤 어절 첫 음절("지식재산 보") — 어절 머리 증거의 거부권 */
|
|
3622
3629
|
__init8() {this.spacedHeads = /* @__PURE__ */ new Set()}
|
|
3630
|
+
/** 줄 안 조문 인용 이음 — 앞 단위(조·항·호)별 붙여 쓴 "제3조제1항"·띄운 "제3조 제1항" 수. 문서마다, 단위마다 표기가 갈린다
|
|
3631
|
+
* ("제17조제2항 제8호" — 조·항은 붙이고 항·호는 띄움, 퇴직공직자 취업심사 보도자료) */
|
|
3632
|
+
__init9() {this.cites = /* @__PURE__ */ new Map()}
|
|
3623
3633
|
/** 쪽 줄 흐름에서 넓은 줄 사이 기준선 간격(글자 크기별) — 줄 둘뿐인 묶음은 묶음 안에 견줄 간격이 없어 넓은 줄 간격 본문을 문단 경계로 봤다 */
|
|
3624
|
-
|
|
3634
|
+
__init10() {this.pitches = []}
|
|
3625
3635
|
/** 줄 흐름의 이웃한 넓은 두 줄(같은 글자 크기) 사이 간격 하나를 더한다 */
|
|
3626
3636
|
addPitch(fontSize, pitch) {
|
|
3627
3637
|
if (fontSize > 0 && pitch > 0 && pitch < 4 * fontSize) this.pitches.push({ fs: fontSize, pitch });
|
|
@@ -3634,6 +3644,12 @@ var WrapLexicon = (_class = class {constructor() { _class.prototype.__init.call(
|
|
|
3634
3644
|
/** 줄 글 한 줄을 증거로 더한다 — 탭(큰 갭)으로 나뉜 조각은 다른 칸·단이라 조각 사이는 어절 경계 증거로 쓰지 않는다 */
|
|
3635
3645
|
addLine(text) {
|
|
3636
3646
|
for (const seg of text.replace(MARKUP, "").split(" ")) {
|
|
3647
|
+
for (const m of seg.matchAll(CITE_LINK)) {
|
|
3648
|
+
const c = _nullishCoalesce(this.cites.get(m[1]), () => ( { joined: 0, spaced: 0 }));
|
|
3649
|
+
if (m[2]) c.spaced++;
|
|
3650
|
+
else c.joined++;
|
|
3651
|
+
this.cites.set(m[1], c);
|
|
3652
|
+
}
|
|
3637
3653
|
const toks = seg.split(" ").filter((t) => t && !t.includes("]("));
|
|
3638
3654
|
for (let i = 0; i < toks.length; i++) {
|
|
3639
3655
|
const t = toks[i], n = t.length;
|
|
@@ -3660,6 +3676,11 @@ var WrapLexicon = (_class = class {constructor() { _class.prototype.__init.call(
|
|
|
3660
3676
|
}
|
|
3661
3677
|
}
|
|
3662
3678
|
}
|
|
3679
|
+
/** 이 단위(조·항·호) 뒤 조문 인용 꺾임을 붙일까 — 문서 줄 안에서 붙여 쓴 쪽이 많으면 true, 띄운 쪽이 많으면 false, 증거 없으면 null */
|
|
3680
|
+
citationJoins(unit) {
|
|
3681
|
+
const c = this.cites.get(unit);
|
|
3682
|
+
return !c || c.joined === c.spaced ? null : c.joined > c.spaced;
|
|
3683
|
+
}
|
|
3663
3684
|
/** 문서 줄 안에서 홀로 선 어절로 나온 적 있나 */
|
|
3664
3685
|
isWord(word) {
|
|
3665
3686
|
return (_nullishCoalesce(this.words.get(word), () => ( 0))) > 0;
|
|
@@ -3751,7 +3772,7 @@ var ITEM_HEAD = /^(?:[□■◆◇○●◎◦▪▫•※▶▷►❍❏❑✓
|
|
|
3751
3772
|
function startsNewItem(prevText, nextText) {
|
|
3752
3773
|
const t = nextText.replace(MARKUP, "").trimStart();
|
|
3753
3774
|
const prev = prevText.replace(MARKUP, "").trimEnd();
|
|
3754
|
-
return ITEM_HEAD.test(t) && !(/^다\./.test(t) && /[가-힣]$/.test(prev)) && !(/\(\d+\.\d*$/.test(prev) && /^\d/.test(t));
|
|
3775
|
+
return ITEM_HEAD.test(t) && !(/^다\./.test(t) && /[가-힣]$/.test(prev)) && !(/\(\d+\.\d*$/.test(prev) && /^\d/.test(t)) && !(/제\d+(?:조(?:의\d+)?|항)$/.test(prev) && /^제\d+[항호]/.test(t));
|
|
3755
3776
|
}
|
|
3756
3777
|
function wrapJoiner(prevText, nextText, lex, heads = true) {
|
|
3757
3778
|
const prev = prevText.replace(MARKUP, "").trimEnd(), next = nextText.replace(MARKUP, "").trimStart();
|
|
@@ -3773,7 +3794,13 @@ function wrapJoiner(prevText, nextText, lex, heads = true) {
|
|
|
3773
3794
|
}
|
|
3774
3795
|
if (/[·ㆍ‧-]/.test(a) && !/[·ㆍ‧…]{2}$/.test(prev) && /[가-힣A-Za-z0-9]/.test(b)) return "";
|
|
3775
3796
|
if (/[A-Za-z]/.test(a) && /[A-Za-z]/.test(b) || /\d/.test(a) && /\d/.test(b)) return " ";
|
|
3776
|
-
|
|
3797
|
+
if (/(?:^|[^가-힣])제$/.test(left) && /^\d+(?:조|항|호|목|장|절|편|관)/.test(right)) return "";
|
|
3798
|
+
const cite = left.match(/제\d+(조|항|호)(?:의\d+)?$/);
|
|
3799
|
+
if (cite && /^제\d+(?:항|호|목)/.test(right)) {
|
|
3800
|
+
const joins = _optionalChain([lex, 'optionalAccess', _87 => _87.citationJoins, 'call', _88 => _88(cite[1])]);
|
|
3801
|
+
if (joins != null) return joins ? "" : " ";
|
|
3802
|
+
}
|
|
3803
|
+
const ev = _optionalChain([lex, 'optionalAccess', _89 => _89.evidence, 'call', _90 => _90(left, right)]);
|
|
3777
3804
|
if (ev != null) return ev;
|
|
3778
3805
|
if (lex && /[가-힣A-Za-z0-9]$/.test(left) && /^[가-힣A-Za-z0-9]/.test(right) && lex.joinedWord(left, right.replace(/[.,)」』’”;:]+$/, ""))) return "";
|
|
3779
3806
|
if (/\d$/.test(left) && COUNTER.test(right)) return "";
|
|
@@ -3781,7 +3808,7 @@ function wrapJoiner(prevText, nextText, lex, heads = true) {
|
|
|
3781
3808
|
const r1 = right.replace(/[.,)」』’”]+$/, "");
|
|
3782
3809
|
if (lex && /[가-힣]$/.test(left) && /^[가-힣]$/.test(r1) && !STANDALONE_SYLLABLE.test(r1) && !lex.isWord(r1) && !lex.isWord(right)) return "";
|
|
3783
3810
|
if (lex && heads) {
|
|
3784
|
-
const tail = _optionalChain([left, 'access',
|
|
3811
|
+
const tail = _optionalChain([left, 'access', _91 => _91.match, 'call', _92 => _92(/[가-힣]+$/), 'optionalAccess', _93 => _93[0]]), run = _optionalChain([right, 'access', _94 => _94.match, 'call', _95 => _95(/^[가-힣]+/), 'optionalAccess', _96 => _96[0]]);
|
|
3785
3812
|
if (tail && run && !STANDALONE_SYLLABLE.test(tail) && lex.startsWord(tail + run.slice(0, 2)) && !lex.spacedHead(tail, run[0])) return "";
|
|
3786
3813
|
if (/[가-힣]{2}$/.test(left) && /^\([^()\s]*\)/.test(right) && !endsAsWord(left) && !/(?:함|음|됨|임|다)$/.test(left) && !BARE_UNIT_PAREN.test(right) && !/^\(\d/.test(right)) return "";
|
|
3787
3814
|
}
|
|
@@ -3816,14 +3843,14 @@ function joinPageBreakWraps(blocks, lex) {
|
|
|
3816
3843
|
if (a.type !== "paragraph" && a.type !== "list" || b.type !== "paragraph") continue;
|
|
3817
3844
|
const last = a.bbox && PARA_LAST_LINE.get(a.bbox), fs = last ? last.fontSize : 0;
|
|
3818
3845
|
if (!last || fs <= 0 || (_nullishCoalesce(pageRight.get(a.pageNumber), () => ( Infinity))) - last.right >= BODY_FULL_TOL * fs) continue;
|
|
3819
|
-
if (last.width < BODY_MIN_WIDTH_EM * fs || Math.abs((_nullishCoalesce(_optionalChain([b, 'access',
|
|
3846
|
+
if (last.width < BODY_MIN_WIDTH_EM * fs || Math.abs((_nullishCoalesce(_optionalChain([b, 'access', _97 => _97.style, 'optionalAccess', _98 => _98.fontSize]), () => ( 0))) - fs) > 0.15 * fs) continue;
|
|
3820
3847
|
const bt = b.text.replace(MARKUP, "");
|
|
3821
3848
|
if (startsNewItem(a.text, b.text) || PAGE_REF_TAIL.test(a.text) || PAGE_ITEM_HEAD.test(bt)) continue;
|
|
3822
3849
|
if (PAGE_HEAD_MARK.test(bt) && !(/^[\u25a0-\u25ff]/.test(bt) && a.text.includes(bt[0]))) continue;
|
|
3823
3850
|
const firstLeft = b.bbox && PARA_FIRST_LEFT.get(b.bbox);
|
|
3824
3851
|
const indented = firstLeft === void 0 || firstLeft - (_nullishCoalesce(pageLeft.get(b.pageNumber), () => ( firstLeft))) >= 0.3 * fs;
|
|
3825
3852
|
if (indented && SENTENCE_END.test(a.text.replace(MARKUP, "").trimEnd())) continue;
|
|
3826
|
-
if (Math.round(_nullishCoalesce(_optionalChain([b, 'access',
|
|
3853
|
+
if (Math.round(_nullishCoalesce(_optionalChain([b, 'access', _99 => _99.style, 'optionalAccess', _100 => _100.fontSize]), () => ( 0))) !== Math.round(fs) && titleLike(b.text)) continue;
|
|
3827
3854
|
if (/\t/.test(a.text.slice(a.text.lastIndexOf("\n") + 1).replace(/^\S{1,8}\t/, "")) && titleLike(bt.trim().split("\n")[0])) continue;
|
|
3828
3855
|
const joined = wrapJoiner(a.text, b.text, lex);
|
|
3829
3856
|
const head = a.text, joiner = joined === "" && last.spaceAfter ? " " : joined;
|
|
@@ -3872,7 +3899,7 @@ function bodyLineJoins(lines, lex) {
|
|
|
3872
3899
|
for (const l of lines) if (!HANGING.test(l.text) && l.right > inner) inner = l.right;
|
|
3873
3900
|
const full = (l) => right - l.right < BODY_FULL_TOL * l.fontSize || right - inner <= 1.2 * l.fontSize && inner - l.right < BODY_FULL_TOL * l.fontSize;
|
|
3874
3901
|
const nextWordNoRoom = (a, b) => {
|
|
3875
|
-
const w = _optionalChain([b, 'access',
|
|
3902
|
+
const w = _optionalChain([b, 'access', _101 => _101.text, 'access', _102 => _102.trim, 'call', _103 => _103(), 'access', _104 => _104.match, 'call', _105 => _105(/^\S+/), 'optionalAccess', _106 => _106[0]]);
|
|
3876
3903
|
const n = [...b.text.trim()].length;
|
|
3877
3904
|
if (!w || n === 0) return false;
|
|
3878
3905
|
const em = (b.right - b.left) / n;
|
|
@@ -3898,7 +3925,7 @@ function bodyLineJoins(lines, lex) {
|
|
|
3898
3925
|
const a = lines[i], b = lines[i + 1];
|
|
3899
3926
|
const fs = a.fontSize;
|
|
3900
3927
|
const own = i === i1 ? p2 : p1;
|
|
3901
|
-
const others = Number.isFinite(own) ? own : _nullishCoalesce(_optionalChain([lex, 'optionalAccess',
|
|
3928
|
+
const others = Number.isFinite(own) ? own : _nullishCoalesce(_optionalChain([lex, 'optionalAccess', _107 => _107.bodyPitch, 'call', _108 => _108(fs)]), () => ( Infinity));
|
|
3902
3929
|
const maxPitch = Number.isFinite(others) ? Math.min(BODY_MAX_PITCH_ABS_EM * fs, Math.max(BODY_MAX_PITCH_EM * fs, others * BODY_PITCH_REL)) : BODY_MAX_PITCH_EM * fs;
|
|
3903
3930
|
const wordWrap = ragged && !full(a) && nextWordNoRoom(a, b) && !MULTI_LEVEL_NUMBER.test(b.text.trimStart());
|
|
3904
3931
|
const wraps = fs > 0 && (full(a) || wordWrap) && a.right - a.left >= BODY_MIN_WIDTH_EM * fs && a.y - b.y > 0 && a.y - b.y < maxPitch && Math.abs(b.fontSize - fs) <= 0.15 * fs && !startsNewItem(a.text, b.text) && !(SENTENCE_END.test(a.text.trimEnd()) && MULTI_LEVEL_NUMBER.test(b.text.trimStart()));
|
|
@@ -4071,7 +4098,7 @@ function cellTextToString(items, wrap) {
|
|
|
4071
4098
|
const merged = mergeSuperscriptRows(lines).map((line) => sortLineByX(line));
|
|
4072
4099
|
const textLines = merged.map((s) => {
|
|
4073
4100
|
if (s.length === 1) return s[0].text;
|
|
4074
|
-
if (s.length === 2 && /^[가-힣]$/.test(s[0].text) && /^[가-힣]$/.test(s[1].text) && !!_optionalChain([wrap, 'optionalAccess',
|
|
4101
|
+
if (s.length === 2 && /^[가-힣]$/.test(s[0].text) && /^[가-힣]$/.test(s[1].text) && !!_optionalChain([wrap, 'optionalAccess', _109 => _109.lex]) && (wrap.lex.isWord(s[0].text + s[1].text) || wrap.lex.evidence(s[0].text, s[1].text) === "" || REGION_LABELS.has(s[0].text + s[1].text)) && s[1].x - (s[0].x + s[0].w) >= Math.max(s[0].fontSize, s[1].fontSize) * 1.5 && s[1].x + s[1].w - s[0].x >= wrap.box.x2 - wrap.box.x1 - Math.max(s[0].fontSize, s[1].fontSize) * 2) return s[0].text + s[1].text;
|
|
4075
4102
|
const evenSpaced = detectEvenSpacedItems(s, true);
|
|
4076
4103
|
const tracked = trackedSpaces(s);
|
|
4077
4104
|
const hangulLine = s.some((it) => /[가-힣]/.test(it.text));
|
|
@@ -4087,7 +4114,7 @@ function cellTextToString(items, wrap) {
|
|
|
4087
4114
|
result += s[j].text;
|
|
4088
4115
|
} else if (s[j].hasSpaceBefore && exactGap(s[j - 1], s[j], gap) >= avgFs * 0.05) {
|
|
4089
4116
|
result += " " + s[j].text;
|
|
4090
|
-
} else if (gap > spaceGapThreshold(avgFs) || _optionalChain([tracked, 'optionalAccess',
|
|
4117
|
+
} else if (gap > spaceGapThreshold(avgFs) || _optionalChain([tracked, 'optionalAccess', _110 => _110[j]])) {
|
|
4091
4118
|
result += " " + s[j].text;
|
|
4092
4119
|
} else {
|
|
4093
4120
|
result += s[j].text;
|
|
@@ -4214,12 +4241,12 @@ function markEvenRun(items, visible, result, start, end) {
|
|
|
4214
4241
|
}
|
|
4215
4242
|
function mergeCellTextLines(textLines, wrap) {
|
|
4216
4243
|
if (textLines.length <= 1) return textLines[0] || "";
|
|
4217
|
-
const numberWrapped = (k) => !!_optionalChain([wrap, 'optionalAccess',
|
|
4244
|
+
const numberWrapped = (k) => !!_optionalChain([wrap, 'optionalAccess', _111 => _111.wraps, 'access', _112 => _112[k]]) && (_nullishCoalesce(_optionalChain([wrap, 'access', _113 => _113.wide, 'optionalAccess', _114 => _114[k]]), () => ( true)));
|
|
4218
4245
|
const merged = [textLines[0]];
|
|
4219
4246
|
for (let i = 1; i < textLines.length; i++) {
|
|
4220
4247
|
const prev = merged[merged.length - 1];
|
|
4221
4248
|
const curr = textLines[i];
|
|
4222
|
-
if (wrap ? wrap.wraps[i - 1] && !_optionalChain([wrap, 'access',
|
|
4249
|
+
if (wrap ? wrap.wraps[i - 1] && !_optionalChain([wrap, 'access', _115 => _115.spaced, 'optionalAccess', _116 => _116[i - 1]]) && !startsNewItem(prev, curr) && wrapJoiner(prev, curr, wrap.lex, false) === "" : /[가-힣]$/.test(prev) && /^[가-힣]+$/.test(curr) && curr.length <= 8 && !curr.includes(" ")) {
|
|
4223
4250
|
merged[merged.length - 1] = prev + curr;
|
|
4224
4251
|
} else if (curr.trim().length <= 3 && /^[)\]%}]/.test(curr.trim())) {
|
|
4225
4252
|
merged[merged.length - 1] = prev + curr.trim();
|
|
@@ -4359,34 +4386,34 @@ function normalizeUndersegmentedTable(originalCells, colXs, items, rowYs, kept,
|
|
|
4359
4386
|
if (numRows > maxRows || numCols < MIN_UNDERSEGMENTED_COLUMNS) return null;
|
|
4360
4387
|
if (items.length === 0) return null;
|
|
4361
4388
|
if (numRows >= 3) {
|
|
4362
|
-
if (_optionalChain([rowYs, 'optionalAccess',
|
|
4389
|
+
if (_optionalChain([rowYs, 'optionalAccess', _117 => _117.length]) !== numRows + 1) return null;
|
|
4363
4390
|
const rebuilt2 = [];
|
|
4364
4391
|
let expanded = 0;
|
|
4365
4392
|
const ocr = items.every((it) => it.fontName === "ocr");
|
|
4366
4393
|
for (let r = 0; r < numRows; r++) {
|
|
4367
4394
|
const row = originalCells[r].map((cell) => cell.text);
|
|
4368
4395
|
if (r === 0 || numRows === 3 && r === 1) {
|
|
4369
|
-
_optionalChain([kept, 'optionalAccess',
|
|
4396
|
+
_optionalChain([kept, 'optionalAccess', _118 => _118.set, 'call', _119 => _119(rebuilt2.length, r)]);
|
|
4370
4397
|
rebuilt2.push(row);
|
|
4371
4398
|
continue;
|
|
4372
4399
|
}
|
|
4373
4400
|
const span2 = Math.min(numRows - r, Math.max(1, ...originalCells[r].map((cell) => _nullishCoalesce(cell.rowSpan, () => ( 1)))));
|
|
4374
4401
|
const filled = originalCells[r].filter((cell) => cell.text.trim());
|
|
4375
4402
|
const spanning = filled.filter((cell) => (_nullishCoalesce(cell.rowSpan, () => ( 1))) >= span2);
|
|
4376
|
-
const loose = ocr && filled.length >= MIN_UNDERSEGMENTED_COLUMNS && spanning.length * 2 > filled.length && originalCells.slice(r + 1, r + span2).every((cells) => cells.every((cell, c) => !cell.text.trim() || (_nullishCoalesce(_optionalChain([originalCells, 'access',
|
|
4403
|
+
const loose = ocr && filled.length >= MIN_UNDERSEGMENTED_COLUMNS && spanning.length * 2 > filled.length && originalCells.slice(r + 1, r + span2).every((cells) => cells.every((cell, c) => !cell.text.trim() || (_nullishCoalesce(_optionalChain([originalCells, 'access', _120 => _120[r], 'access', _121 => _121[c], 'optionalAccess', _122 => _122.rowSpan]), () => ( 1))) === 1));
|
|
4377
4404
|
const band = span2 > 1 && (loose || originalCells.slice(r + 1, r + span2).every((cells) => cells.every((cell) => !cell.text.trim()))) ? span2 : 1;
|
|
4378
4405
|
const rowItems = items.filter((item) => itemCenterY(item) <= rowYs[r] + 1 && itemCenterY(item) >= rowYs[r + band] - 1);
|
|
4379
4406
|
const body = normalizeUndersegmentedTable([originalCells[r]], colXs, rowItems, void 0, void 0, void 0, band > 1 ? 2 : MIN_ALIGNED_LINES);
|
|
4380
4407
|
if (body) {
|
|
4381
4408
|
originalCells[r].forEach((cell, c) => {
|
|
4382
4409
|
const cols = Array.from({ length: Math.max(1, _nullishCoalesce(cell.colSpan, () => ( 1))) }, (_, k) => c + k);
|
|
4383
|
-
if (cell.text.trim() && body.every((cells) => cols.every((k) => !_optionalChain([cells, 'access',
|
|
4410
|
+
if (cell.text.trim() && body.every((cells) => cols.every((k) => !_optionalChain([cells, 'access', _123 => _123[k], 'optionalAccess', _124 => _124.trim, 'call', _125 => _125()])))) body[0][c] = cell.text;
|
|
4384
4411
|
});
|
|
4385
4412
|
rebuilt2.push(...body);
|
|
4386
4413
|
expanded++;
|
|
4387
4414
|
r += band - 1;
|
|
4388
4415
|
} else {
|
|
4389
|
-
_optionalChain([kept, 'optionalAccess',
|
|
4416
|
+
_optionalChain([kept, 'optionalAccess', _126 => _126.set, 'call', _127 => _127(rebuilt2.length, r)]);
|
|
4390
4417
|
rebuilt2.push(row);
|
|
4391
4418
|
}
|
|
4392
4419
|
}
|
|
@@ -4470,7 +4497,7 @@ function sortLineByX(items) {
|
|
|
4470
4497
|
e++;
|
|
4471
4498
|
}
|
|
4472
4499
|
const run = items.slice(s, e), seqs = run.map((i) => i.seq);
|
|
4473
|
-
const ok = !wide ? !run.some((i) => _optionalChain([i, 'access',
|
|
4500
|
+
const ok = !wide ? !run.some((i) => _optionalChain([i, 'access', _128 => _128.text, 'optionalAccess', _129 => _129.startsWith, 'call', _130 => _130("$")])) : Math.max(...seqs) - Math.min(...seqs) <= 2 * (e - s - 1) && run.every((i) => Math.abs((_nullishCoalesce(i.fontSize, () => ( 0))) - (_nullishCoalesce(run[0].fontSize, () => ( 0)))) <= 0.5);
|
|
4474
4501
|
if (e - s > 1 && seqs.every((q) => q !== void 0) && ok) {
|
|
4475
4502
|
run.sort((a, b) => a.seq - b.seq);
|
|
4476
4503
|
for (let k = 0; k < run.length; k++) items[s + k] = run[k];
|
|
@@ -4482,8 +4509,8 @@ function sortLineByX(items) {
|
|
|
4482
4509
|
function isCjkLatinAutospace(prevText, nextText, gap, fontSize, hangulLine = false) {
|
|
4483
4510
|
if (!(gap < fontSize * 0.35)) return false;
|
|
4484
4511
|
if (hangulLine) return false;
|
|
4485
|
-
const a = prevText.slice(-1), b = _nullishCoalesce(nextText[0], () => ( ""));
|
|
4486
|
-
const cjk = /[\u3040-\u30ff\u3400-\u9fff\uf900-\ufaff]/, latin = /[A-Za-z0-9]/;
|
|
4512
|
+
const a = prevText.replace(/(?:<\/?u>|~~)+$/, "").slice(-1), b = _nullishCoalesce(nextText.replace(/^(?:<\/?u>|~~)+/, "")[0], () => ( ""));
|
|
4513
|
+
const cjk = /[\u3000-\u303f\u3040-\u30ff\u3400-\u9fff\uf900-\ufaff\uff00-\uffef]/, latin = /[A-Za-z0-9]/;
|
|
4487
4514
|
return cjk.test(a) && latin.test(b) || latin.test(a) && cjk.test(b);
|
|
4488
4515
|
}
|
|
4489
4516
|
function filterHiddenText(items, pageWidth, pageHeight, originX = 0, originY = 0) {
|
|
@@ -4516,7 +4543,9 @@ function collapseEvenSpacing(text, whole = true) {
|
|
|
4516
4543
|
const before = text.slice(0, offset).replace(/(?:<\/?u>|~~)+$/, "");
|
|
4517
4544
|
const after = text.slice(offset + match.length).replace(/^(?:<\/?u>|~~)+/, "");
|
|
4518
4545
|
if (/\S$/.test(before) || /^\S/.test(after)) return match;
|
|
4519
|
-
|
|
4546
|
+
if (isDateUnitBlank(match.split(" "))) return match;
|
|
4547
|
+
const parts = match.split(/ 및 (?=[가-힣\d])/);
|
|
4548
|
+
return parts.length > 1 ? parts.map((p) => p.replace(/ /g, "")).join(" \uBC0F ") : match.replace(/ /g, "");
|
|
4520
4549
|
}
|
|
4521
4550
|
);
|
|
4522
4551
|
}
|
|
@@ -4540,7 +4569,7 @@ function dominantStyle(items) {
|
|
|
4540
4569
|
let maxCount = 0, dominantSize = 0;
|
|
4541
4570
|
for (const i of items) {
|
|
4542
4571
|
if (i.fontSize <= 0) continue;
|
|
4543
|
-
const count = (freq.get(i.fontSize) || 0) + Math.max(1, _nullishCoalesce(_optionalChain([i, 'access',
|
|
4572
|
+
const count = (freq.get(i.fontSize) || 0) + Math.max(1, _nullishCoalesce(_optionalChain([i, 'access', _131 => _131.text, 'access', _132 => _132.match, 'call', _133 => _133(/[\p{L}\p{N}]/gu), 'optionalAccess', _134 => _134.length]), () => ( 0)));
|
|
4544
4573
|
freq.set(i.fontSize, count);
|
|
4545
4574
|
if (count > maxCount) {
|
|
4546
4575
|
maxCount = count;
|
|
@@ -4548,7 +4577,7 @@ function dominantStyle(items) {
|
|
|
4548
4577
|
}
|
|
4549
4578
|
}
|
|
4550
4579
|
if (dominantSize === 0) return void 0;
|
|
4551
|
-
const fontName = _optionalChain([items, 'access',
|
|
4580
|
+
const fontName = _optionalChain([items, 'access', _135 => _135.find, 'call', _136 => _136((i) => i.fontSize === dominantSize), 'optionalAccess', _137 => _137.fontName]) || void 0;
|
|
4552
4581
|
return fontName ? { fontSize: dominantSize, fontName } : { fontSize: dominantSize };
|
|
4553
4582
|
}
|
|
4554
4583
|
function normalizeItems(rawItems) {
|
|
@@ -4562,7 +4591,8 @@ function normalizeItems(rawItems) {
|
|
|
4562
4591
|
const x = Math.round(i.transform[4]);
|
|
4563
4592
|
const y = Math.round(i.transform[5]);
|
|
4564
4593
|
if (!i.str.trim()) {
|
|
4565
|
-
|
|
4594
|
+
const fs = Math.hypot(i.transform[0], i.transform[1]);
|
|
4595
|
+
spacePositions.push({ x, y, synthetic: i.synthetic, ...i.width >= fs * 0.2 ? { wide: { start: i.transform[4], end: i.transform[4] + i.width, w: i.width } } : {} });
|
|
4566
4596
|
continue;
|
|
4567
4597
|
}
|
|
4568
4598
|
const scaleX = Math.hypot(i.transform[0], i.transform[1]);
|
|
@@ -4653,6 +4683,7 @@ function normalizeItems(rawItems) {
|
|
|
4653
4683
|
if (nearest) {
|
|
4654
4684
|
nearest.syntheticSpace = (nearest.hasSpaceBefore ? nearest.syntheticSpace === true : true) && sp.synthetic === true;
|
|
4655
4685
|
nearest.hasSpaceBefore = true;
|
|
4686
|
+
if (sp.wide && nearest.fx !== void 0 && sp.wide.end - nearest.fx <= sp.wide.w * 0.5) nearest.wideSpace = sp.wide.start;
|
|
4656
4687
|
}
|
|
4657
4688
|
}
|
|
4658
4689
|
}
|
|
@@ -4701,7 +4732,7 @@ function splitAroundOverlays(c, overlays) {
|
|
|
4701
4732
|
const ov = overlays.filter((o) => {
|
|
4702
4733
|
for (let at = c.text.indexOf(o.text); at >= 0; at = c.text.indexOf(o.text, at + 1)) {
|
|
4703
4734
|
const prefix = c.text.slice(0, at);
|
|
4704
|
-
const est = c.x + glyphUnits(prefix.replace(/\s+/g, "")) * a0 + (_nullishCoalesce(_optionalChain([prefix, 'access',
|
|
4735
|
+
const est = c.x + glyphUnits(prefix.replace(/\s+/g, "")) * a0 + (_nullishCoalesce(_optionalChain([prefix, 'access', _138 => _138.match, 'call', _139 => _139(/\s+/g), 'optionalAccess', _140 => _140.length]), () => ( 0))) * ws;
|
|
4705
4736
|
if (Math.abs(est - o.x) <= OVERLAY_DUP_EM * fs) return false;
|
|
4706
4737
|
}
|
|
4707
4738
|
return true;
|
|
@@ -4863,7 +4894,7 @@ function trackedSpaces(sorted, med = trackingShift([sorted])) {
|
|
|
4863
4894
|
});
|
|
4864
4895
|
}
|
|
4865
4896
|
function mergeLineSimple(items) {
|
|
4866
|
-
if (items.length <= 1) return _optionalChain([items, 'access',
|
|
4897
|
+
if (items.length <= 1) return _optionalChain([items, 'access', _141 => _141[0], 'optionalAccess', _142 => _142.text]) || "";
|
|
4867
4898
|
const sorted = sortLineByX([...items]);
|
|
4868
4899
|
const tracked = trackedSpaces(sorted);
|
|
4869
4900
|
const isEvenSpaced = detectEvenSpacedItems(sorted);
|
|
@@ -4886,7 +4917,9 @@ function mergeLineSimple(items) {
|
|
|
4886
4917
|
result += sorted[i].text;
|
|
4887
4918
|
continue;
|
|
4888
4919
|
}
|
|
4889
|
-
|
|
4920
|
+
const ws = sorted[i].wideSpace;
|
|
4921
|
+
const roundedSpace = sorted[i - 1].fx === void 0 && sorted[i].fx === void 0 && sorted[i].syntheticSpace === false && ws !== void 0 && ws >= sorted[i - 1].x + sorted[i - 1].w - 1 && gap >= 0;
|
|
4922
|
+
if (sorted[i].hasSpaceBefore && (exactGap(sorted[i - 1], sorted[i], gap) >= avgFs * 0.05 || roundedSpace)) {
|
|
4890
4923
|
result += " ";
|
|
4891
4924
|
result += sorted[i].text;
|
|
4892
4925
|
continue;
|
|
@@ -4896,7 +4929,7 @@ function mergeLineSimple(items) {
|
|
|
4896
4929
|
result += sorted[i].text;
|
|
4897
4930
|
continue;
|
|
4898
4931
|
}
|
|
4899
|
-
if (gap > spaceGapThreshold(avgFs) || _optionalChain([tracked, 'optionalAccess',
|
|
4932
|
+
if (gap > spaceGapThreshold(avgFs) || _optionalChain([tracked, 'optionalAccess', _143 => _143[i]])) result += " ";
|
|
4900
4933
|
result += sorted[i].text;
|
|
4901
4934
|
}
|
|
4902
4935
|
return result;
|
|
@@ -4953,7 +4986,7 @@ function isProseTable(table) {
|
|
|
4953
4986
|
if (!(long > 0 && long >= total * 0.5 && longRows >= rows * 0.4)) return false;
|
|
4954
4987
|
for (let c = 0; c < table.cols; c++) {
|
|
4955
4988
|
const filled = table.cells.map((row) => row[c]).filter((cell) => cell && cell.colSpan < table.cols && cell.text.trim()).map((cell) => cell.text.trim());
|
|
4956
|
-
if (filled.length >= 3 && filled.length >= rows * 0.6 && filled.every((text) => text.length <= 30 && (_nullishCoalesce(_optionalChain([text, 'access',
|
|
4989
|
+
if (filled.length >= 3 && filled.length >= rows * 0.6 && filled.every((text) => text.length <= 30 && (_nullishCoalesce(_optionalChain([text, 'access', _144 => _144.match, 'call', _145 => _145(/\p{L}/gu), 'optionalAccess', _146 => _146.length]), () => ( 0))) >= 2)) return false;
|
|
4957
4990
|
}
|
|
4958
4991
|
return true;
|
|
4959
4992
|
}
|
|
@@ -4982,7 +5015,7 @@ var TICK = /^-?[\d,]+(?:\.\d+)?%?$/;
|
|
|
4982
5015
|
var QUANTITY = /^[-−–]?[\d,]*\.?\d+%?$/;
|
|
4983
5016
|
var quantity = (token) => Number(token.replace(/^[−–]/, "-").replace(/[,%]/g, ""));
|
|
4984
5017
|
function isValueAxisColumn(table, c) {
|
|
4985
|
-
const lines = table.cells.flatMap((row) => (_nullishCoalesce(_optionalChain([row, 'access',
|
|
5018
|
+
const lines = table.cells.flatMap((row) => (_nullishCoalesce(_optionalChain([row, 'access', _147 => _147[c], 'optionalAccess', _148 => _148.text]), () => ( ""))).split("\n").map((line) => line.trim().split(/\s+/)));
|
|
4986
5019
|
const others = table.cells.flatMap((row) => row.filter((_, k) => k !== c).map((cell) => cell.text.trim().split(/\s+/))).filter((tokens) => tokens.every((token) => QUANTITY.test(token))).flat().map(quantity).filter((v) => !(Number.isInteger(v) && v >= 1900 && v <= 2100));
|
|
4987
5020
|
for (const ticks of [lines.flat().filter((t) => TICK.test(t)).map(quantity), lines.map((tokens) => tokens[0]).filter((t) => TICK.test(t)).map(quantity)]) {
|
|
4988
5021
|
const run = fallingRun(ticks);
|
|
@@ -5015,7 +5048,7 @@ function isChartTable(table, ocr = false) {
|
|
|
5015
5048
|
if (numeric < texts.length * 0.5) return false;
|
|
5016
5049
|
if (ocr && table.cols >= 3 && table.cells.slice(0, 3).some((row) => row.filter((cell) => /[가-힣]{2}/.test(cell.text)).length >= 2)) return false;
|
|
5017
5050
|
for (let c = 0; c < table.cols; c++) {
|
|
5018
|
-
if (!ocr ? isValueAxisColumn(table, c) : hasValueAxis(table.cells.flatMap((row) => (_nullishCoalesce(_optionalChain([row, 'access',
|
|
5051
|
+
if (!ocr ? isValueAxisColumn(table, c) : hasValueAxis(table.cells.flatMap((row) => (_nullishCoalesce(_optionalChain([row, 'access', _149 => _149[c], 'optionalAccess', _150 => _150.text]), () => ( ""))).split(/\s+/)).filter((t) => TICK.test(t)).map((t) => Number(t.replace(/[,%]/g, ""))))) return true;
|
|
5019
5052
|
}
|
|
5020
5053
|
const values = texts.filter((text) => text.split(/\s+/).every((token) => QUANTITY.test(token))).length;
|
|
5021
5054
|
const cells = table.rows * table.cols;
|
|
@@ -5024,7 +5057,7 @@ function isChartTable(table, ocr = false) {
|
|
|
5024
5057
|
function isProseFragmentTable(table) {
|
|
5025
5058
|
const texts = table.cells.flat().map((cell) => cell.text.trim()).filter(Boolean);
|
|
5026
5059
|
if (texts.length < 4) return false;
|
|
5027
|
-
const hangul = (text) => _nullishCoalesce(_optionalChain([text, 'access',
|
|
5060
|
+
const hangul = (text) => _nullishCoalesce(_optionalChain([text, 'access', _151 => _151.match, 'call', _152 => _152(/[가-힣]/g), 'optionalAccess', _153 => _153.length]), () => ( 0));
|
|
5028
5061
|
if (texts.filter((text) => hangul(text) >= 2).length < texts.length * 0.7) return false;
|
|
5029
5062
|
if (texts.length >= 12 && texts.filter((text) => hangul(text) >= 15 && !text.includes("\n")).length >= texts.length * 0.4) return true;
|
|
5030
5063
|
return texts.filter((text) => /(?:[다요고서는을를에게지며면어아야니까던]|[.,?!])$/.test(text)).length >= texts.length * 0.3;
|
|
@@ -5077,7 +5110,7 @@ function clusterCellLines(items) {
|
|
|
5077
5110
|
}
|
|
5078
5111
|
var WRAP_INDENT_MAX = 3;
|
|
5079
5112
|
function joinClusterCellLines(lines, box, lex) {
|
|
5080
|
-
let out = _nullishCoalesce(_optionalChain([lines, 'access',
|
|
5113
|
+
let out = _nullishCoalesce(_optionalChain([lines, 'access', _154 => _154[0], 'optionalAccess', _155 => _155.text]), () => ( ""));
|
|
5081
5114
|
for (let i = 1; i < lines.length; i++) {
|
|
5082
5115
|
const a = lines[i - 1], b = lines[i];
|
|
5083
5116
|
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) === "";
|
|
@@ -5205,7 +5238,7 @@ function detectClusterTables(items, pageNum, rejected, lex) {
|
|
|
5205
5238
|
}
|
|
5206
5239
|
return results.filter((r) => {
|
|
5207
5240
|
const twoColumns = isTwoColumnProse(r);
|
|
5208
|
-
const prose = twoColumns || isProseTable(r.table) || [...r.usedItems].every((it) => it.fontName === "ocr") && isProseFragmentTable(r.table);
|
|
5241
|
+
const prose = twoColumns || isProseTable(r.table) || gaplessCjkLines(r) || [...r.usedItems].every((it) => it.fontName === "ocr") && isProseFragmentTable(r.table);
|
|
5209
5242
|
if (prose && rejected) rejected.prose++;
|
|
5210
5243
|
if (twoColumns && rejected && [...r.usedItems].every((it) => it.fontName === "ocr")) {
|
|
5211
5244
|
const used = [...r.usedItems].sort((a, b) => a.x - b.x);
|
|
@@ -5224,6 +5257,21 @@ function detectClusterTables(items, pageNum, rejected, lex) {
|
|
|
5224
5257
|
return !prose;
|
|
5225
5258
|
});
|
|
5226
5259
|
}
|
|
5260
|
+
function gaplessCjkLines(r) {
|
|
5261
|
+
let lines = 0, gapless = 0;
|
|
5262
|
+
for (const row of groupByBaseline([...r.usedItems].filter((i) => i.text.trim()))) {
|
|
5263
|
+
const sorted = [...row.items].sort((a, b) => a.x - b.x);
|
|
5264
|
+
if (sorted.length < 2) continue;
|
|
5265
|
+
lines++;
|
|
5266
|
+
const text = sorted.map((i) => i.text).join("").replace(/\s+/g, "");
|
|
5267
|
+
if ([...text].filter((c) => CJK_CHAR.test(c)).length < text.length * 0.5) continue;
|
|
5268
|
+
let maxGap = 0;
|
|
5269
|
+
for (let k = [...sorted[0].text.trim()].length <= 2 ? 2 : 1; k < sorted.length; k++) maxGap = Math.max(maxGap, sorted[k].x - (sorted[k - 1].x + sorted[k - 1].w));
|
|
5270
|
+
if (maxGap < sorted[0].fontSize * 0.5) gapless++;
|
|
5271
|
+
}
|
|
5272
|
+
return gapless >= 3 && gapless >= lines * 0.6;
|
|
5273
|
+
}
|
|
5274
|
+
var CJK_CHAR = /[\u3000-\u303f\u3040-\u30ff\u3400-\u9fff\uf900-\ufaff\uff00-\uffef]/;
|
|
5227
5275
|
var SIDE_TAB_MIN = 6;
|
|
5228
5276
|
var SIDE_TAB_BAND_MIN = 4;
|
|
5229
5277
|
var SIDE_TAB_BAND = 0.12;
|
|
@@ -5364,7 +5412,7 @@ function detectAlignedTwoColumnTables(rows, pageNum) {
|
|
|
5364
5412
|
continue;
|
|
5365
5413
|
}
|
|
5366
5414
|
const top = rows[i - 1];
|
|
5367
|
-
const title = _optionalChain([top, 'optionalAccess',
|
|
5415
|
+
const title = _optionalChain([top, 'optionalAccess', _156 => _156.items, 'access', _157 => _157.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;
|
|
5368
5416
|
const tableRows = title ? [title, ...body] : body;
|
|
5369
5417
|
const cells = tableRows.map((row, idx) => {
|
|
5370
5418
|
if (title && idx === 0) return [{ text: row.items[0].text, colSpan: 2, rowSpan: 1 }, { text: "", colSpan: 1, rowSpan: 1 }];
|
|
@@ -5421,12 +5469,12 @@ function isTwoColumnProse(r) {
|
|
|
5421
5469
|
if (t.rows < (ocr ? 6 : 8)) return false;
|
|
5422
5470
|
const dense = [];
|
|
5423
5471
|
for (let c = 0; c < t.cols; c++) {
|
|
5424
|
-
const filled = t.cells.filter((row) => _optionalChain([row, 'access',
|
|
5472
|
+
const filled = t.cells.filter((row) => _optionalChain([row, 'access', _158 => _158[c], 'optionalAccess', _159 => _159.text, 'access', _160 => _160.trim, 'call', _161 => _161()])).length;
|
|
5425
5473
|
if (filled / t.rows >= 0.3) dense.push(c);
|
|
5426
5474
|
}
|
|
5427
5475
|
if (dense.length !== 2) return false;
|
|
5428
5476
|
for (const c of dense) {
|
|
5429
|
-
const lens = t.cells.map((row) => _nullishCoalesce(_optionalChain([row, 'access',
|
|
5477
|
+
const lens = t.cells.map((row) => _nullishCoalesce(_optionalChain([row, 'access', _162 => _162[c], 'optionalAccess', _163 => _163.text, 'access', _164 => _164.replace, 'call', _165 => _165(/\s+/g, ""), 'access', _166 => _166.length]), () => ( 0))).filter((n) => n > 0);
|
|
5430
5478
|
const avg = lens.reduce((s, v) => s + v, 0) / (lens.length || 1);
|
|
5431
5479
|
if (avg < (ocr ? 15 : 12)) return false;
|
|
5432
5480
|
}
|
|
@@ -5888,7 +5936,7 @@ function assignRowItems(items, columns, numCols, headerFace) {
|
|
|
5888
5936
|
const runs = [];
|
|
5889
5937
|
for (const it of sorted) {
|
|
5890
5938
|
const last = runs[runs.length - 1];
|
|
5891
|
-
const prev = _optionalChain([last, 'optionalAccess',
|
|
5939
|
+
const prev = _optionalChain([last, 'optionalAccess', _167 => _167[last.length - 1]]);
|
|
5892
5940
|
if (prev && it.x - (prev.x + prev.w) <= Math.max(0.5, it.fontSize * 0.05) && !it.hasSpaceBefore) last.push(it);
|
|
5893
5941
|
else runs.push([it]);
|
|
5894
5942
|
}
|
|
@@ -5939,7 +5987,7 @@ function assignRowItems(items, columns, numCols, headerFace) {
|
|
|
5939
5987
|
assignedGroups.add(gi);
|
|
5940
5988
|
usedCols.add(ci);
|
|
5941
5989
|
}
|
|
5942
|
-
const colOf = groups.map((g) => _nullishCoalesce(_optionalChain([result, 'access',
|
|
5990
|
+
const colOf = groups.map((g) => _nullishCoalesce(_optionalChain([result, 'access', _168 => _168.find, 'call', _169 => _169((a) => a.items === g), 'optionalAccess', _170 => _170.col]), () => ( -1)));
|
|
5943
5991
|
if (groups.length <= numCols && colOf.some((c, g) => g > 0 && c < colOf[g - 1])) {
|
|
5944
5992
|
const G = groups.length, cost = (g, c2) => Math.abs(groupCenters[g] - colCenters[c2]);
|
|
5945
5993
|
const best = groups.map(() => new Array(numCols).fill(Infinity)), from = groups.map(() => new Array(numCols).fill(-1));
|
|
@@ -5976,7 +6024,7 @@ function assignRowItems(items, columns, numCols, headerFace) {
|
|
|
5976
6024
|
function buildClusterTable(rows, columns, pageNum, lex) {
|
|
5977
6025
|
const numRows = rows.length;
|
|
5978
6026
|
if (numRows < MIN_ROWS || columns.length < MIN_COLS) return null;
|
|
5979
|
-
const headFaces = new Set(_optionalChain([rows, 'access',
|
|
6027
|
+
const headFaces = new Set(_optionalChain([rows, 'access', _171 => _171[0], 'optionalAccess', _172 => _172.items, 'access', _173 => _173.map, 'call', _174 => _174((i) => i.fontName)]));
|
|
5980
6028
|
const headerFace = headFaces.size === 1 && rows.slice(1).every((row) => row.items.every((i) => !headFaces.has(i.fontName))) ? [...headFaces][0] : void 0;
|
|
5981
6029
|
const assigned = rows.map((row, r) => assignRowItems(row.items, columns, columns.length, r === 0 ? headerFace : void 0));
|
|
5982
6030
|
const cuts = supportedOcrColumnCuts(assigned);
|
|
@@ -6047,7 +6095,7 @@ function buildClusterTable(rows, columns, pageNum, lex) {
|
|
|
6047
6095
|
const nonEmptyCols = cells[r].filter((c) => c.text.trim()).length;
|
|
6048
6096
|
if (nonEmptyCols !== 1) continue;
|
|
6049
6097
|
if (cells[r][0].text.trim() !== "") continue;
|
|
6050
|
-
const contentText = _optionalChain([cells, 'access',
|
|
6098
|
+
const contentText = _optionalChain([cells, 'access', _175 => _175[r], 'access', _176 => _176.find, 'call', _177 => _177((c) => c.text.trim()), 'optionalAccess', _178 => _178.text, 'access', _179 => _179.trim, 'call', _180 => _180()]) || "";
|
|
6051
6099
|
if (/^[○●▶\-·]/.test(contentText)) continue;
|
|
6052
6100
|
for (let pr = r - 1; pr >= 0; pr--) {
|
|
6053
6101
|
if (cells[pr].some((c) => c.text.trim())) {
|
|
@@ -6280,7 +6328,7 @@ function stackedTableBands(items) {
|
|
|
6280
6328
|
const caption = (start, end) => lines.slice(start, end).some((line) => /^Table\s+\d+\s*[:.]/i.test(mergeLineSimple(line).trim()));
|
|
6281
6329
|
while (runs.length > 0 && !caption(runs[runs.length - 1].end, lines.length)) runs.pop();
|
|
6282
6330
|
if (runs.length < 2) return null;
|
|
6283
|
-
if (runs.some((run, i) => !caption(run.end, _nullishCoalesce(_optionalChain([runs, 'access',
|
|
6331
|
+
if (runs.some((run, i) => !caption(run.end, _nullishCoalesce(_optionalChain([runs, 'access', _181 => _181[i + 1], 'optionalAccess', _182 => _182.start]), () => ( lines.length))))) return null;
|
|
6284
6332
|
const tables = runs.map((run) => lines.slice(run.start, run.end).flat());
|
|
6285
6333
|
const between = runs.slice(0, -1).map((run, i) => lines.slice(run.end, runs[i + 1].start).flat());
|
|
6286
6334
|
const tail = lines.slice(runs[runs.length - 1].end);
|
|
@@ -6548,7 +6596,7 @@ function splitTrailingColumnRegion(items) {
|
|
|
6548
6596
|
}
|
|
6549
6597
|
function panelBlocks(items, panel, pageNum) {
|
|
6550
6598
|
const lines = groupByY([...items].sort((a, b) => b.y - a.y || a.x - b.x));
|
|
6551
|
-
const faceOf = (line) => _nullishCoalesce(_optionalChain([dominantStyle, 'call',
|
|
6599
|
+
const faceOf = (line) => _nullishCoalesce(_optionalChain([dominantStyle, 'call', _183 => _183(line), 'optionalAccess', _184 => _184.fontName]), () => ( ""));
|
|
6552
6600
|
const runs = [];
|
|
6553
6601
|
for (const line of lines) {
|
|
6554
6602
|
const last = runs[runs.length - 1];
|
|
@@ -6755,7 +6803,7 @@ function validWrapBands(items, bands) {
|
|
|
6755
6803
|
}
|
|
6756
6804
|
function inheritedWrapBands(items) {
|
|
6757
6805
|
const source = XY_WRAP_ITEMS.get(items[0]);
|
|
6758
|
-
const present = _optionalChain([source, 'optionalAccess',
|
|
6806
|
+
const present = _optionalChain([source, 'optionalAccess', _185 => _185.length]) === items.length ? new Set(items) : null;
|
|
6759
6807
|
const sameLeaf = present && source.every((item) => present.has(item));
|
|
6760
6808
|
return sameLeaf ? validWrapBands(items, _nullishCoalesce(XY_WRAP_BANDS.get(items[0]), () => ( []))) : [];
|
|
6761
6809
|
}
|
|
@@ -6794,7 +6842,7 @@ function wrappedLineBands(items, inherited) {
|
|
|
6794
6842
|
left: box.x,
|
|
6795
6843
|
right: box.x + box.width,
|
|
6796
6844
|
y: row.reduce((n, i) => n + i.y, 0) / row.length,
|
|
6797
|
-
fontSize: _nullishCoalesce(_optionalChain([dominantStyle, 'call',
|
|
6845
|
+
fontSize: _nullishCoalesce(_optionalChain([dominantStyle, 'call', _186 => _186(row), 'optionalAccess', _187 => _187.fontSize]), () => ( 0)),
|
|
6798
6846
|
sources: row.map((item) => ({ item, state: { ...item } }))
|
|
6799
6847
|
};
|
|
6800
6848
|
});
|
|
@@ -6930,10 +6978,10 @@ function pushLineParagraphs(out, yLines, pageNum, lex) {
|
|
|
6930
6978
|
const lines = attachDropCaps(yLines).map((items) => ({ items, text: mergeLineSimple(items) })).filter((l) => l.text.trim());
|
|
6931
6979
|
const geo = lines.map((l) => {
|
|
6932
6980
|
const b = computeBBox(l.items, pageNum);
|
|
6933
|
-
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',
|
|
6981
|
+
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', _188 => _188(l.items), 'optionalAccess', _189 => _189.fontSize]), () => ( 0)) };
|
|
6934
6982
|
});
|
|
6935
6983
|
const joins = bodyLineJoins(geo, lex);
|
|
6936
|
-
const first = _optionalChain([lines, 'access',
|
|
6984
|
+
const first = _optionalChain([lines, 'access', _190 => _190[0], 'optionalAccess', _191 => _191.items, 'access', _192 => _192[0]]);
|
|
6937
6985
|
const bands = first ? _nullishCoalesce(XY_WRAP_BANDS.get(first), () => ( [])) : [];
|
|
6938
6986
|
const hasBand = (top, bottom) => {
|
|
6939
6987
|
let lo = 0, hi = bands.length;
|
|
@@ -7010,15 +7058,15 @@ function computeMedianFontSizeFromFreq(freq) {
|
|
|
7010
7058
|
function detectHeadings(blocks, medianFontSize) {
|
|
7011
7059
|
for (let bi = 0; bi < blocks.length; bi++) {
|
|
7012
7060
|
const block = blocks[bi];
|
|
7013
|
-
if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access',
|
|
7061
|
+
if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access', _193 => _193.style, 'optionalAccess', _194 => _194.fontSize])) continue;
|
|
7014
7062
|
const text = block.text.trim();
|
|
7015
7063
|
if (text.length === 0 || text.length > 200) continue;
|
|
7016
7064
|
if (/^\d+$/.test(text) && !isChapterNumber(block, blocks[bi + 1], medianFontSize)) continue;
|
|
7017
7065
|
const ratio = block.style.fontSize / medianFontSize;
|
|
7018
7066
|
let level = 0;
|
|
7019
|
-
if (ratio >=
|
|
7020
|
-
else if (ratio >=
|
|
7021
|
-
else if (ratio >=
|
|
7067
|
+
if (ratio >= _chunk6RA4KZHKcjs.HEADING_RATIO_H1) level = 1;
|
|
7068
|
+
else if (ratio >= _chunk6RA4KZHKcjs.HEADING_RATIO_H2) level = 2;
|
|
7069
|
+
else if (ratio >= _chunk6RA4KZHKcjs.HEADING_RATIO_H3) level = 3;
|
|
7022
7070
|
if (level > 0) {
|
|
7023
7071
|
block.type = "heading";
|
|
7024
7072
|
block.level = level;
|
|
@@ -7027,21 +7075,21 @@ function detectHeadings(blocks, medianFontSize) {
|
|
|
7027
7075
|
}
|
|
7028
7076
|
}
|
|
7029
7077
|
function isChapterNumber(block, next, medianFontSize) {
|
|
7030
|
-
const size = _nullishCoalesce(_optionalChain([block, 'access',
|
|
7031
|
-
const nextSize = _nullishCoalesce(_optionalChain([next, 'optionalAccess',
|
|
7032
|
-
const text = _nullishCoalesce(_optionalChain([next, 'optionalAccess',
|
|
7033
|
-
const a = block.bbox, b = _optionalChain([next, 'optionalAccess',
|
|
7034
|
-
return /^\d{1,2}$/.test(_nullishCoalesce(_optionalChain([block, 'access',
|
|
7078
|
+
const size = _nullishCoalesce(_optionalChain([block, 'access', _195 => _195.style, 'optionalAccess', _196 => _196.fontSize]), () => ( 0));
|
|
7079
|
+
const nextSize = _nullishCoalesce(_optionalChain([next, 'optionalAccess', _197 => _197.style, 'optionalAccess', _198 => _198.fontSize]), () => ( 0));
|
|
7080
|
+
const text = _nullishCoalesce(_optionalChain([next, 'optionalAccess', _199 => _199.text, 'optionalAccess', _200 => _200.trim, 'call', _201 => _201()]), () => ( ""));
|
|
7081
|
+
const a = block.bbox, b = _optionalChain([next, 'optionalAccess', _202 => _202.bbox]);
|
|
7082
|
+
return /^\d{1,2}$/.test(_nullishCoalesce(_optionalChain([block, 'access', _203 => _203.text, 'optionalAccess', _204 => _204.trim, 'call', _205 => _205()]), () => ( ""))) && size >= medianFontSize * 2.5 && !!next && (next.type === "paragraph" || next.type === "heading") && next.pageNumber === block.pageNumber && nextSize >= medianFontSize * _chunk6RA4KZHKcjs.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;
|
|
7035
7083
|
}
|
|
7036
7084
|
function mergeStackedHeadingLines(blocks, medianFontSize) {
|
|
7037
7085
|
for (let i = 0; i < blocks.length - 1; ) {
|
|
7038
7086
|
const a = blocks[i], b = blocks[i + 1];
|
|
7039
7087
|
const ab = a.bbox, bb = b.bbox;
|
|
7040
|
-
const af = _nullishCoalesce(_optionalChain([a, 'access',
|
|
7088
|
+
const af = _nullishCoalesce(_optionalChain([a, 'access', _206 => _206.style, 'optionalAccess', _207 => _207.fontSize]), () => ( 0)), bf = _nullishCoalesce(_optionalChain([b, 'access', _208 => _208.style, 'optionalAccess', _209 => _209.fontSize]), () => ( 0));
|
|
7041
7089
|
const gap = ab && bb ? ab.y - (bb.y + bb.height) : Infinity;
|
|
7042
|
-
const centered = ab && bb && _optionalChain([a, 'access',
|
|
7090
|
+
const centered = ab && bb && _optionalChain([a, 'access', _210 => _210.style, 'optionalAccess', _211 => _211.fontName]) === _optionalChain([b, 'access', _212 => _212.style, 'optionalAccess', _213 => _213.fontName]) && Math.abs(ab.x + ab.width / 2 - (bb.x + bb.width / 2)) <= Math.max(5, af * 0.5);
|
|
7043
7091
|
const sameAnchor = ab && bb && Math.abs(ab.x - bb.x) <= 5;
|
|
7044
|
-
const wrapped = sameAnchor && _optionalChain([a, 'access',
|
|
7092
|
+
const wrapped = sameAnchor && _optionalChain([a, 'access', _214 => _214.style, 'optionalAccess', _215 => _215.fontName]) === _optionalChain([b, 'access', _216 => _216.style, 'optionalAccess', _217 => _217.fontName]) && af === bf && ab.width >= bb.width * 0.95 && (_nullishCoalesce(_optionalChain([a, 'access', _218 => _218.text, 'optionalAccess', _219 => _219.trim, 'call', _220 => _220(), 'access', _221 => _221.split, 'call', _222 => _222(/\s+/), 'access', _223 => _223.length]), () => ( 0))) >= 3;
|
|
7045
7093
|
const displayStack = centered && gap <= Math.min(af, bf) * 0.3 && Math.max(af, bf) <= Math.min(af, bf) * 1.45;
|
|
7046
7094
|
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)) {
|
|
7047
7095
|
i++;
|
|
@@ -7070,25 +7118,25 @@ function detectTypographyHeadings(blocks) {
|
|
|
7070
7118
|
if (page.some((block) => block.type === "heading")) continue;
|
|
7071
7119
|
const faceWeight = /* @__PURE__ */ new Map();
|
|
7072
7120
|
for (const block of page) {
|
|
7073
|
-
if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access',
|
|
7121
|
+
if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access', _224 => _224.style, 'optionalAccess', _225 => _225.fontName])) continue;
|
|
7074
7122
|
const faces = FACE_CHARS.get(block);
|
|
7075
7123
|
if (faces) for (const [face, n] of faces) faceWeight.set(face, (_nullishCoalesce(faceWeight.get(face), () => ( 0))) + n);
|
|
7076
7124
|
else faceWeight.set(block.style.fontName, (_nullishCoalesce(faceWeight.get(block.style.fontName), () => ( 0))) + block.text.length);
|
|
7077
7125
|
}
|
|
7078
|
-
const bodyFace = _optionalChain([[...faceWeight], 'access',
|
|
7126
|
+
const bodyFace = _optionalChain([[...faceWeight], 'access', _226 => _226.sort, 'call', _227 => _227((a, b) => b[1] - a[1]), 'access', _228 => _228[0], 'optionalAccess', _229 => _229[0]]);
|
|
7079
7127
|
if (!bodyFace || (_nullishCoalesce(faceWeight.get(bodyFace), () => ( 0))) < 250) continue;
|
|
7080
7128
|
const sizeWeight = /* @__PURE__ */ new Map();
|
|
7081
7129
|
for (const block of page) {
|
|
7082
|
-
if (block.type !== "paragraph" || !_optionalChain([block, 'access',
|
|
7130
|
+
if (block.type !== "paragraph" || !_optionalChain([block, 'access', _230 => _230.style, 'optionalAccess', _231 => _231.fontSize])) continue;
|
|
7083
7131
|
const faces = FACE_CHARS.get(block);
|
|
7084
|
-
const chars = faces ? _nullishCoalesce(faces.get(bodyFace), () => ( 0)) : block.style.fontName === bodyFace ? _nullishCoalesce(_optionalChain([block, 'access',
|
|
7132
|
+
const chars = faces ? _nullishCoalesce(faces.get(bodyFace), () => ( 0)) : block.style.fontName === bodyFace ? _nullishCoalesce(_optionalChain([block, 'access', _232 => _232.text, 'optionalAccess', _233 => _233.length]), () => ( 0)) : 0;
|
|
7085
7133
|
if (chars) sizeWeight.set(block.style.fontSize, (_nullishCoalesce(sizeWeight.get(block.style.fontSize), () => ( 0))) + chars);
|
|
7086
7134
|
}
|
|
7087
|
-
const bodySize = _nullishCoalesce(_optionalChain([[...sizeWeight], 'access',
|
|
7135
|
+
const bodySize = _nullishCoalesce(_optionalChain([[...sizeWeight], 'access', _234 => _234.sort, 'call', _235 => _235((a, b) => b[1] - a[1]), 'access', _236 => _236[0], 'optionalAccess', _237 => _237[0]]), () => ( 0));
|
|
7088
7136
|
for (let i = 0; i < page.length; i++) {
|
|
7089
7137
|
const block = page[i];
|
|
7090
7138
|
const { text, bbox, style } = block;
|
|
7091
|
-
if (block.type !== "paragraph" || !text || !bbox || !_optionalChain([style, 'optionalAccess',
|
|
7139
|
+
if (block.type !== "paragraph" || !text || !bbox || !_optionalChain([style, 'optionalAccess', _238 => _238.fontName]) || !style.fontSize) continue;
|
|
7092
7140
|
const title = text.trim();
|
|
7093
7141
|
const numbered = /^\d+(?:\.\d+)*\.?\s+[A-Z가-힣]/.test(title);
|
|
7094
7142
|
const faces = FACE_CHARS.get(block);
|
|
@@ -7118,16 +7166,16 @@ function detectDocumentStyleHeadings(blocks) {
|
|
|
7118
7166
|
for (const page of byPage.values()) {
|
|
7119
7167
|
const faceChars = /* @__PURE__ */ new Map();
|
|
7120
7168
|
for (const block of page) {
|
|
7121
|
-
if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access',
|
|
7169
|
+
if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access', _239 => _239.style, 'optionalAccess', _240 => _240.fontName])) continue;
|
|
7122
7170
|
faceChars.set(block.style.fontName, (_nullishCoalesce(faceChars.get(block.style.fontName), () => ( 0))) + block.text.length);
|
|
7123
7171
|
}
|
|
7124
|
-
const bodyFace = _optionalChain([[...faceChars], 'access',
|
|
7172
|
+
const bodyFace = _optionalChain([[...faceChars], 'access', _241 => _241.sort, 'call', _242 => _242((a, b) => b[1] - a[1]), 'access', _243 => _243[0], 'optionalAccess', _244 => _244[0]]);
|
|
7125
7173
|
if (!bodyFace || (_nullishCoalesce(faceChars.get(bodyFace), () => ( 0))) < 100) continue;
|
|
7126
|
-
const labels = page.filter((b) => b.type === "paragraph" && b.text && b.bbox && _optionalChain([b, 'access',
|
|
7174
|
+
const labels = page.filter((b) => b.type === "paragraph" && b.text && b.bbox && _optionalChain([b, 'access', _245 => _245.style, 'optionalAccess', _246 => _246.fontName]) && b.style.fontName !== bodyFace && b.text.trim().length >= 3 && b.text.trim().length <= 40);
|
|
7127
7175
|
for (const label of labels) {
|
|
7128
|
-
const peers = labels.filter((b) => _optionalChain([b, 'access',
|
|
7176
|
+
const peers = labels.filter((b) => _optionalChain([b, 'access', _247 => _247.style, 'optionalAccess', _248 => _248.fontName]) === _optionalChain([label, 'access', _249 => _249.style, 'optionalAccess', _250 => _250.fontName]) && Math.abs(b.bbox.y - label.bbox.y) <= 3 && Math.abs(b.bbox.x - label.bbox.x) >= 60);
|
|
7129
7177
|
if (peers.length < 2) continue;
|
|
7130
|
-
const value = page.find((b) => b.type === "paragraph" && b.bbox && _optionalChain([b, 'access',
|
|
7178
|
+
const value = page.find((b) => b.type === "paragraph" && b.bbox && _optionalChain([b, 'access', _251 => _251.style, 'optionalAccess', _252 => _252.fontName]) !== _optionalChain([label, 'access', _253 => _253.style, 'optionalAccess', _254 => _254.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);
|
|
7131
7179
|
if (value) {
|
|
7132
7180
|
label.type = "heading";
|
|
7133
7181
|
label.level = 2;
|
|
@@ -7136,7 +7184,7 @@ function detectDocumentStyleHeadings(blocks) {
|
|
|
7136
7184
|
const first = page.find((b) => b.type !== "image" && b.type !== "separator");
|
|
7137
7185
|
const second = page[page.indexOf(first) + 1];
|
|
7138
7186
|
const third = page[page.indexOf(first) + 2];
|
|
7139
|
-
if (!first || !second || !third || first.type !== "list" && first.type !== "paragraph" || second.type !== "paragraph" || !first.text || !second.text || !first.bbox || !second.bbox || !_optionalChain([first, 'access',
|
|
7187
|
+
if (!first || !second || !third || first.type !== "list" && first.type !== "paragraph" || second.type !== "paragraph" || !first.text || !second.text || !first.bbox || !second.bbox || !_optionalChain([first, 'access', _255 => _255.style, 'optionalAccess', _256 => _256.fontName]) || !_optionalChain([second, 'access', _257 => _257.style, 'optionalAccess', _258 => _258.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', _259 => _259.style, 'optionalAccess', _260 => _260.fontName]) !== bodyFace) continue;
|
|
7140
7188
|
first.type = "heading";
|
|
7141
7189
|
first.level = 1;
|
|
7142
7190
|
first.text = `${first.text.trim()} ${second.text.trim()}`;
|
|
@@ -7160,18 +7208,18 @@ function detectSiblingStyleHeadings(blocks) {
|
|
|
7160
7208
|
for (const page of byPage.values()) {
|
|
7161
7209
|
const bodyChars = /* @__PURE__ */ new Map();
|
|
7162
7210
|
for (const block of page) {
|
|
7163
|
-
if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access',
|
|
7211
|
+
if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access', _261 => _261.style, 'optionalAccess', _262 => _262.fontName])) continue;
|
|
7164
7212
|
const face = block.style.fontName;
|
|
7165
7213
|
bodyChars.set(face, (_nullishCoalesce(bodyChars.get(face), () => ( 0))) + block.text.length);
|
|
7166
7214
|
}
|
|
7167
|
-
const bodyFace = _optionalChain([[...bodyChars], 'access',
|
|
7168
|
-
const anchors = page.filter((b) => b.type === "heading" && b.text && _optionalChain([b, 'access',
|
|
7215
|
+
const bodyFace = _optionalChain([[...bodyChars], 'access', _263 => _263.sort, 'call', _264 => _264((a, b) => b[1] - a[1]), 'access', _265 => _265[0], 'optionalAccess', _266 => _266[0]]);
|
|
7216
|
+
const anchors = page.filter((b) => b.type === "heading" && b.text && _optionalChain([b, 'access', _267 => _267.style, 'optionalAccess', _268 => _268.fontName]) && b.style.fontName !== bodyFace);
|
|
7169
7217
|
for (const anchor of anchors) {
|
|
7170
7218
|
const numbered = /^([A-Z])\.\d+\s+/.exec(anchor.text.trim());
|
|
7171
7219
|
const lettered = /^([A-Z])\s+/.exec(anchor.text.trim());
|
|
7172
|
-
const peers = anchors.filter((b) => _optionalChain([b, 'access',
|
|
7220
|
+
const peers = anchors.filter((b) => _optionalChain([b, 'access', _269 => _269.style, 'optionalAccess', _270 => _270.fontName]) === _optionalChain([anchor, 'access', _271 => _271.style, 'optionalAccess', _272 => _272.fontName]) && Math.abs((_nullishCoalesce(_optionalChain([b, 'access', _273 => _273.style, 'optionalAccess', _274 => _274.fontSize]), () => ( 0))) - (_nullishCoalesce(_optionalChain([anchor, 'access', _275 => _275.style, 'optionalAccess', _276 => _276.fontSize]), () => ( 0)))) < 0.5);
|
|
7173
7221
|
if (peers.length < 2 && !numbered && !lettered) continue;
|
|
7174
|
-
const candidates = page.filter((b) => b.type === "paragraph" && b.text && b.bbox && _optionalChain([b, 'access',
|
|
7222
|
+
const candidates = page.filter((b) => b.type === "paragraph" && b.text && b.bbox && _optionalChain([b, 'access', _277 => _277.style, 'optionalAccess', _278 => _278.fontName]) === _optionalChain([anchor, 'access', _279 => _279.style, 'optionalAccess', _280 => _280.fontName]) && Math.abs((_nullishCoalesce(_optionalChain([b, 'access', _281 => _281.style, 'optionalAccess', _282 => _282.fontSize]), () => ( 0))) - (_nullishCoalesce(_optionalChain([anchor, 'access', _283 => _283.style, 'optionalAccess', _284 => _284.fontSize]), () => ( 0)))) < 0.5 && b.text.trim().length >= 3 && b.text.trim().length <= 80 && b.bbox.height <= (_nullishCoalesce(_optionalChain([b, 'access', _285 => _285.style, 'optionalAccess', _286 => _286.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()));
|
|
7175
7223
|
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));
|
|
7176
7224
|
if (siblings.length < (numbered || lettered ? 1 : 2)) continue;
|
|
7177
7225
|
for (const sibling of siblings) {
|
|
@@ -7190,13 +7238,13 @@ function detectRepeatedPageLabels(blocks) {
|
|
|
7190
7238
|
}
|
|
7191
7239
|
for (const page of byPage.values()) {
|
|
7192
7240
|
const bodyChars = /* @__PURE__ */ new Map();
|
|
7193
|
-
for (const b of page) if (b.type === "paragraph" && b.text && _optionalChain([b, 'access',
|
|
7241
|
+
for (const b of page) if (b.type === "paragraph" && b.text && _optionalChain([b, 'access', _287 => _287.style, 'optionalAccess', _288 => _288.fontName])) {
|
|
7194
7242
|
const faces = FACE_CHARS.get(b);
|
|
7195
7243
|
if (faces) for (const [face, n] of faces) bodyChars.set(face, (_nullishCoalesce(bodyChars.get(face), () => ( 0))) + n);
|
|
7196
7244
|
else bodyChars.set(b.style.fontName, (_nullishCoalesce(bodyChars.get(b.style.fontName), () => ( 0))) + b.text.length);
|
|
7197
7245
|
}
|
|
7198
|
-
const bodyFace = _optionalChain([[...bodyChars], 'access',
|
|
7199
|
-
const candidates = page.filter((b) => b.type === "paragraph" && b.text && b.bbox && _optionalChain([b, 'access',
|
|
7246
|
+
const bodyFace = _optionalChain([[...bodyChars], 'access', _289 => _289.sort, 'call', _290 => _290((a, b) => b[1] - a[1]), 'access', _291 => _291[0], 'optionalAccess', _292 => _292[0]]);
|
|
7247
|
+
const candidates = page.filter((b) => b.type === "paragraph" && b.text && b.bbox && _optionalChain([b, 'access', _293 => _293.style, 'optionalAccess', _294 => _294.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);
|
|
7200
7248
|
const groups = /* @__PURE__ */ new Map();
|
|
7201
7249
|
for (const b of candidates) {
|
|
7202
7250
|
const key = `${b.style.fontName}:${b.style.fontSize}`;
|
|
@@ -7232,19 +7280,19 @@ function detectPageLeadHeadings(blocks) {
|
|
|
7232
7280
|
for (const page of byPage.values()) {
|
|
7233
7281
|
const content = page.filter((b) => b.type !== "image" && b.type !== "separator" && !(b.type === "paragraph" && !b.style));
|
|
7234
7282
|
const [first, second, third] = content;
|
|
7235
|
-
if (!_optionalChain([first, 'optionalAccess',
|
|
7283
|
+
if (!_optionalChain([first, 'optionalAccess', _295 => _295.bbox]) || !first.text || !_optionalChain([first, 'access', _296 => _296.style, 'optionalAccess', _297 => _297.fontSize]) || !second) continue;
|
|
7236
7284
|
const firstText = first.text.trim();
|
|
7237
7285
|
const captionLike = /^(?:Figure|Fig\.?|Table|표|그림)\s*\d/i;
|
|
7238
7286
|
const hasImage = page.some((b) => b.type === "image");
|
|
7239
|
-
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',
|
|
7287
|
+
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', _298 => _298.text, 'optionalAccess', _299 => _299.trim, 'call', _300 => _300()]), () => ( ""))) && (_nullishCoalesce(_optionalChain([second, 'access', _301 => _301.text, 'optionalAccess', _302 => _302.length]), () => ( 0))) >= 100 && second.bbox && first.bbox.y - (second.bbox.y + second.bbox.height) >= first.style.fontSize);
|
|
7240
7288
|
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);
|
|
7241
|
-
const firstIsSection = first.type === "list" && /^\d+\.\s+[A-Z][A-Z\s]{12,}$/.test(firstText) && second.type === "paragraph" && (_nullishCoalesce(_optionalChain([second, 'access',
|
|
7289
|
+
const firstIsSection = first.type === "list" && /^\d+\.\s+[A-Z][A-Z\s]{12,}$/.test(firstText) && second.type === "paragraph" && (_nullishCoalesce(_optionalChain([second, 'access', _303 => _303.text, 'optionalAccess', _304 => _304.length]), () => ( 0))) >= 100;
|
|
7242
7290
|
if (firstIsTitle || firstAboveProse || firstIsSection) {
|
|
7243
7291
|
first.type = "heading";
|
|
7244
7292
|
first.level = 1;
|
|
7245
7293
|
}
|
|
7246
|
-
if (first.type !== "heading" || captionLike.test(firstText) || second.type !== "paragraph" || !second.text || !second.bbox || !_optionalChain([second, 'access',
|
|
7247
|
-
const distinctFace = _optionalChain([third, 'access',
|
|
7294
|
+
if (first.type !== "heading" || captionLike.test(firstText) || second.type !== "paragraph" || !second.text || !second.bbox || !_optionalChain([second, 'access', _305 => _305.style, 'optionalAccess', _306 => _306.fontName]) || !second.style.fontSize || !_optionalChain([third, 'optionalAccess', _307 => _307.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;
|
|
7295
|
+
const distinctFace = _optionalChain([third, 'access', _308 => _308.style, 'optionalAccess', _309 => _309.fontName]) !== second.style.fontName;
|
|
7248
7296
|
const namedContents = /^Table of Contents$/i.test(second.text.trim());
|
|
7249
7297
|
if (distinctFace && third.text.length >= 60 || namedContents) {
|
|
7250
7298
|
second.type = "heading";
|
|
@@ -7255,24 +7303,24 @@ function detectPageLeadHeadings(blocks) {
|
|
|
7255
7303
|
function refineDocumentStyleHeadings(blocks) {
|
|
7256
7304
|
const faceChars = /* @__PURE__ */ new Map();
|
|
7257
7305
|
for (const block of blocks) {
|
|
7258
|
-
if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access',
|
|
7306
|
+
if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access', _310 => _310.style, 'optionalAccess', _311 => _311.fontName])) continue;
|
|
7259
7307
|
faceChars.set(block.style.fontName, (_nullishCoalesce(faceChars.get(block.style.fontName), () => ( 0))) + block.text.length);
|
|
7260
7308
|
}
|
|
7261
7309
|
const [bodyFace, bodyChars] = _nullishCoalesce([...faceChars].sort((a, b) => b[1] - a[1])[0], () => ( []));
|
|
7262
7310
|
if (!bodyFace || !bodyChars || bodyChars < 300) return;
|
|
7263
7311
|
for (let i = 0; i < blocks.length; i++) {
|
|
7264
7312
|
const block = blocks[i];
|
|
7265
|
-
const text = _nullishCoalesce(_optionalChain([block, 'access',
|
|
7313
|
+
const text = _nullishCoalesce(_optionalChain([block, 'access', _312 => _312.text, 'optionalAccess', _313 => _313.trim, 'call', _314 => _314()]), () => ( ""));
|
|
7266
7314
|
if (block.type === "heading" && /(?:https?:\/\/|www\.|^arxiv:|^doi:)/i.test(text)) {
|
|
7267
7315
|
block.type = "paragraph";
|
|
7268
7316
|
block.level = void 0;
|
|
7269
7317
|
continue;
|
|
7270
7318
|
}
|
|
7271
7319
|
const box = block.bbox, style = block.style;
|
|
7272
|
-
if (block.type !== "paragraph" || !box || !_optionalChain([style, 'optionalAccess',
|
|
7320
|
+
if (block.type !== "paragraph" || !box || !_optionalChain([style, 'optionalAccess', _315 => _315.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;
|
|
7273
7321
|
const previous = blocks[i - 1], next = blocks[i + 1];
|
|
7274
|
-
const pb = _optionalChain([previous, 'optionalAccess',
|
|
7275
|
-
if (!pb || !nb || previous.pageNumber !== block.pageNumber || next.pageNumber !== block.pageNumber || previous.type !== "paragraph" && previous.type !== "heading" || next.type !== "paragraph" || _optionalChain([next, 'access',
|
|
7322
|
+
const pb = _optionalChain([previous, 'optionalAccess', _316 => _316.bbox]), nb = _optionalChain([next, 'optionalAccess', _317 => _317.bbox]);
|
|
7323
|
+
if (!pb || !nb || previous.pageNumber !== block.pageNumber || next.pageNumber !== block.pageNumber || previous.type !== "paragraph" && previous.type !== "heading" || next.type !== "paragraph" || _optionalChain([next, 'access', _318 => _318.style, 'optionalAccess', _319 => _319.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;
|
|
7276
7324
|
block.type = "heading";
|
|
7277
7325
|
block.level = 2;
|
|
7278
7326
|
}
|
|
@@ -7322,7 +7370,7 @@ function detectMarkerHeadings(blocks) {
|
|
|
7322
7370
|
block.level = 4;
|
|
7323
7371
|
continue;
|
|
7324
7372
|
}
|
|
7325
|
-
if (/^[가-힣]{2,6}$/.test(text) && _optionalChain([block, 'access',
|
|
7373
|
+
if (/^[가-힣]{2,6}$/.test(text) && _optionalChain([block, 'access', _320 => _320.style, 'optionalAccess', _321 => _321.fontSize])) {
|
|
7326
7374
|
const prev = blocks[i - 1];
|
|
7327
7375
|
const next = blocks[i + 1];
|
|
7328
7376
|
const prevIsStructural = !prev || prev.type === "table" || prev.type === "heading" || prev.type === "separator";
|
|
@@ -7363,7 +7411,7 @@ function detectTableCaptions(blocks) {
|
|
|
7363
7411
|
block.table.caption = blocks[i - 1].text.trim();
|
|
7364
7412
|
blocks.splice(i - 1, 1);
|
|
7365
7413
|
i--;
|
|
7366
|
-
} else if (isCaptionCandidate(blocks[i + 1], block) && _optionalChain([blocks, 'access',
|
|
7414
|
+
} else if (isCaptionCandidate(blocks[i + 1], block) && _optionalChain([blocks, 'access', _322 => _322[i + 2], 'optionalAccess', _323 => _323.type]) !== "table") {
|
|
7367
7415
|
const cap = blocks[i + 1].bbox, tbl = block.bbox;
|
|
7368
7416
|
block.table.caption = blocks[i + 1].text.trim();
|
|
7369
7417
|
if (cap && tbl && cap.y + cap.height <= tbl.y + 1) block.table.captionBelow = true;
|
|
@@ -7448,7 +7496,7 @@ function detectKoreanListBlocks(blocks) {
|
|
|
7448
7496
|
}
|
|
7449
7497
|
const listType = label.family === "arabicDot" ? "ordered" : "unordered";
|
|
7450
7498
|
const listBlock = { ...b, type: "list", listType };
|
|
7451
|
-
const pb = _optionalChain([lastTopLevelList, 'optionalAccess',
|
|
7499
|
+
const pb = _optionalChain([lastTopLevelList, 'optionalAccess', _324 => _324.bbox]), cb = b.bbox;
|
|
7452
7500
|
const notIndented = depth > 0 && !!pb && !!cb && pb.page === cb.page && cb.x >= pb.x + pb.width && cb.y >= pb.y + pb.height;
|
|
7453
7501
|
if (notIndented) familyStack = [label.family];
|
|
7454
7502
|
if (depth === 0 || notIndented) {
|
|
@@ -7606,7 +7654,7 @@ function removeHeaderFooterBlocks(blocks, pageHeights, warnings, notes, tables =
|
|
|
7606
7654
|
const b = blocks[bi];
|
|
7607
7655
|
const cellTexts = b.type === "table" && b.table ? b.table.cells.flat().map((c) => c.text.trim()).filter(Boolean) : [];
|
|
7608
7656
|
const headBox = cellTexts.length <= 4 && !!b.bbox && b.bbox.height <= (_nullishCoalesce(pageHeights.get(b.bbox.page), () => ( Infinity))) * 0.05;
|
|
7609
|
-
const text = !tables ? _optionalChain([b, 'access',
|
|
7657
|
+
const text = !tables ? _optionalChain([b, 'access', _325 => _325.text, 'optionalAccess', _326 => _326.trim, 'call', _327 => _327()]) : cellTexts.length ? (headBox ? [...cellTexts].sort() : cellTexts).join(" | ") : void 0;
|
|
7610
7658
|
if (!b.bbox || !b.pageNumber || !text) continue;
|
|
7611
7659
|
const ph = pageHeights.get(b.bbox.page) || pageHeights.get(b.pageNumber);
|
|
7612
7660
|
if (!ph) continue;
|
|
@@ -7639,7 +7687,7 @@ function removeHeaderFooterBlocks(blocks, pageHeights, warnings, notes, tables =
|
|
|
7639
7687
|
for (const [p, count] of patternCount) {
|
|
7640
7688
|
const pages = [..._nullishCoalesce(patternPages.get(p), () => ( []))];
|
|
7641
7689
|
const span2 = pages.length ? Math.max(...pages) - Math.min(...pages) + 1 : 0;
|
|
7642
|
-
const varying = !tables && (_nullishCoalesce(_optionalChain([patternNumbers, 'access',
|
|
7690
|
+
const varying = !tables && (_nullishCoalesce(_optionalChain([patternNumbers, 'access', _328 => _328.get, 'call', _329 => _329(p), 'optionalAccess', _330 => _330.size]), () => ( 0))) > 1;
|
|
7643
7691
|
const occ = _nullishCoalesce(patternOcc.get(p), () => ( []));
|
|
7644
7692
|
const dense = pages.length >= span2 * 0.4;
|
|
7645
7693
|
const loose = looseVaryingNumber(occ, entries === topEntries) && (entries === bottomEntries || dense || tracksPages(occ));
|
|
@@ -7651,8 +7699,8 @@ function removeHeaderFooterBlocks(blocks, pageHeights, warnings, notes, tables =
|
|
|
7651
7699
|
for (const e of entries) {
|
|
7652
7700
|
const norm = e.text.replace(/\d+/g, "#");
|
|
7653
7701
|
if (!repeatedPatterns.has(norm)) continue;
|
|
7654
|
-
const noteMark = _optionalChain([e, 'access',
|
|
7655
|
-
if (noteMark && _optionalChain([notes, 'optionalAccess',
|
|
7702
|
+
const noteMark = _optionalChain([e, 'access', _331 => _331.text, 'access', _332 => _332.match, 'call', _333 => _333(/^\d{1,3}\)/), 'optionalAccess', _334 => _334[0]]);
|
|
7703
|
+
if (noteMark && _optionalChain([notes, 'optionalAccess', _335 => _335.get, 'call', _336 => _336(e.page), 'optionalAccess', _337 => _337.marks, 'access', _338 => _338.some, 'call', _339 => _339((m) => m.mark === noteMark)])) continue;
|
|
7656
7704
|
const cand = blocks[e.blockIdx];
|
|
7657
7705
|
const cb = cand.bbox;
|
|
7658
7706
|
const tableNote = /^(?:주\s*(?:\d+\s*[).:]|[::])|(?:자료|출처)\s*[::]|\*\s+\S)/.test(e.text.replace(/ \| /g, " ")) && blocks.some((o) => {
|
|
@@ -7666,7 +7714,7 @@ function removeHeaderFooterBlocks(blocks, pageHeights, warnings, notes, tables =
|
|
|
7666
7714
|
if (bi === e.blockIdx) continue;
|
|
7667
7715
|
const o = blocks[bi];
|
|
7668
7716
|
if (!o.bbox || o.bbox.page !== cb.page) continue;
|
|
7669
|
-
const oNorm = _optionalChain([o, 'access',
|
|
7717
|
+
const oNorm = _optionalChain([o, 'access', _340 => _340.text, 'optionalAccess', _341 => _341.trim, 'call', _342 => _342(), 'access', _343 => _343.replace, 'call', _344 => _344(/\d+/g, "#")]);
|
|
7670
7718
|
if (oNorm && repeatedPatterns.has(oNorm)) continue;
|
|
7671
7719
|
const overlap2 = Math.min(cb.y + cb.height, o.bbox.y + o.bbox.height) - Math.max(cb.y, o.bbox.y);
|
|
7672
7720
|
if (overlap2 >= cb.height * 0.5) {
|
|
@@ -7794,7 +7842,7 @@ function recordRowRules(table, cells, bbox, hs) {
|
|
|
7794
7842
|
function markImageCell(cell) {
|
|
7795
7843
|
IMAGE_CELLS.add(cell);
|
|
7796
7844
|
}
|
|
7797
|
-
var emptyCell = (cell) => !cell || !_optionalChain([cell, 'access',
|
|
7845
|
+
var emptyCell = (cell) => !cell || !_optionalChain([cell, 'access', _345 => _345.text, 'optionalAccess', _346 => _346.trim, 'call', _347 => _347()]) && !_optionalChain([cell, 'access', _348 => _348.blocks, 'optionalAccess', _349 => _349.length]) && !IMAGE_CELLS.has(cell);
|
|
7798
7846
|
function trimTable(table) {
|
|
7799
7847
|
let cols = table.cols;
|
|
7800
7848
|
while (cols > 0 && table.cells.every((row) => emptyCell(row[cols - 1]))) cols--;
|
|
@@ -7810,7 +7858,7 @@ function trimTable(table) {
|
|
|
7810
7858
|
function trimTrailingEmptyTableCols(blocks) {
|
|
7811
7859
|
for (const b of blocks) {
|
|
7812
7860
|
if (b.type !== "table" || !b.table) continue;
|
|
7813
|
-
for (const row of b.table.cells) for (const cell of row) if (_optionalChain([cell, 'access',
|
|
7861
|
+
for (const row of b.table.cells) for (const cell of row) if (_optionalChain([cell, 'access', _350 => _350.blocks, 'optionalAccess', _351 => _351.length])) trimTrailingEmptyTableCols(cell.blocks);
|
|
7814
7862
|
trimTable(b.table);
|
|
7815
7863
|
}
|
|
7816
7864
|
}
|
|
@@ -7830,7 +7878,7 @@ function mergeSliverColumns(grid, colXs, maxWidth) {
|
|
|
7830
7878
|
}
|
|
7831
7879
|
const ok = owner.every((row) => {
|
|
7832
7880
|
const o = row[c];
|
|
7833
|
-
return !!o && (o.colSpan > 1 || !o.text.trim() && !_optionalChain([o, 'access',
|
|
7881
|
+
return !!o && (o.colSpan > 1 || !o.text.trim() && !_optionalChain([o, 'access', _352 => _352.blocks, 'optionalAccess', _353 => _353.length]));
|
|
7834
7882
|
});
|
|
7835
7883
|
if (!ok) continue;
|
|
7836
7884
|
const spanning = /* @__PURE__ */ new Set();
|
|
@@ -7857,7 +7905,7 @@ var multiply = (m, t) => [
|
|
|
7857
7905
|
m[1] * t[4] + m[3] * t[5] + m[5]
|
|
7858
7906
|
];
|
|
7859
7907
|
function hollowCircle(image) {
|
|
7860
|
-
if (!_optionalChain([image, 'optionalAccess',
|
|
7908
|
+
if (!_optionalChain([image, 'optionalAccess', _354 => _354.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;
|
|
7861
7909
|
const stride = image.kind === _pdfmjs.ImageKind.RGB_24BPP ? 3 : image.kind === _pdfmjs.ImageKind.RGBA_32BPP ? 4 : 0;
|
|
7862
7910
|
const { width, height, data } = image;
|
|
7863
7911
|
if (!stride || data.length < width * height * stride) return false;
|
|
@@ -7922,9 +7970,9 @@ function smallVisibleImagePaints(fnArray, argsArray) {
|
|
|
7922
7970
|
const op = fnArray[i], args = argsArray[i];
|
|
7923
7971
|
if (op === _pdfmjs.OPS.save || op === _pdfmjs.OPS.paintFormXObjectBegin) {
|
|
7924
7972
|
stack.push({ ctm, alpha, clip, unknownClip });
|
|
7925
|
-
const matrix = op === _pdfmjs.OPS.paintFormXObjectBegin ? _optionalChain([args, 'optionalAccess',
|
|
7973
|
+
const matrix = op === _pdfmjs.OPS.paintFormXObjectBegin ? _optionalChain([args, 'optionalAccess', _355 => _355[0]]) : void 0;
|
|
7926
7974
|
if (Array.isArray(matrix) && matrix.length >= 6) ctm = multiply(ctm, matrix);
|
|
7927
|
-
const bounds = op === _pdfmjs.OPS.paintFormXObjectBegin ? _optionalChain([args, 'optionalAccess',
|
|
7975
|
+
const bounds = op === _pdfmjs.OPS.paintFormXObjectBegin ? _optionalChain([args, 'optionalAccess', _356 => _356[1]]) : void 0;
|
|
7928
7976
|
if (Array.isArray(bounds) && bounds.length === 4) {
|
|
7929
7977
|
const box = rectangle(bounds[0], bounds[1], bounds[2] - bounds[0], bounds[3] - bounds[1]);
|
|
7930
7978
|
if (box && ctm[1] === 0 && ctm[2] === 0) intersectClip(box);
|
|
@@ -7932,17 +7980,17 @@ function smallVisibleImagePaints(fnArray, argsArray) {
|
|
|
7932
7980
|
}
|
|
7933
7981
|
} else if (op === _pdfmjs.OPS.restore || op === _pdfmjs.OPS.paintFormXObjectEnd) {
|
|
7934
7982
|
const state = stack.pop();
|
|
7935
|
-
ctm = _nullishCoalesce(_optionalChain([state, 'optionalAccess',
|
|
7936
|
-
alpha = _nullishCoalesce(_optionalChain([state, 'optionalAccess',
|
|
7937
|
-
clip = _nullishCoalesce(_optionalChain([state, 'optionalAccess',
|
|
7938
|
-
unknownClip = _nullishCoalesce(_optionalChain([state, 'optionalAccess',
|
|
7983
|
+
ctm = _nullishCoalesce(_optionalChain([state, 'optionalAccess', _357 => _357.ctm]), () => ( [1, 0, 0, 1, 0, 0]));
|
|
7984
|
+
alpha = _nullishCoalesce(_optionalChain([state, 'optionalAccess', _358 => _358.alpha]), () => ( 1));
|
|
7985
|
+
clip = _nullishCoalesce(_optionalChain([state, 'optionalAccess', _359 => _359.clip]), () => ( null));
|
|
7986
|
+
unknownClip = _nullishCoalesce(_optionalChain([state, 'optionalAccess', _360 => _360.unknownClip]), () => ( false));
|
|
7939
7987
|
} else if (op === _pdfmjs.OPS.setGState) {
|
|
7940
|
-
for (const [key, value] of _nullishCoalesce(_optionalChain([args, 'optionalAccess',
|
|
7988
|
+
for (const [key, value] of _nullishCoalesce(_optionalChain([args, 'optionalAccess', _361 => _361[0]]), () => ( []))) {
|
|
7941
7989
|
if (key === "ca") alpha = typeof value === "number" ? value : 0;
|
|
7942
7990
|
}
|
|
7943
7991
|
} else if (op === _pdfmjs.OPS.constructPath) {
|
|
7944
7992
|
const [operations, coordinates] = args;
|
|
7945
|
-
pathRect = pathRect === void 0 && _optionalChain([operations, 'optionalAccess',
|
|
7993
|
+
pathRect = pathRect === void 0 && _optionalChain([operations, 'optionalAccess', _362 => _362.length]) === 1 && operations[0] === _pdfmjs.OPS.rectangle && _optionalChain([coordinates, 'optionalAccess', _363 => _363.length]) >= 4 && ctm[1] === 0 && ctm[2] === 0 ? rectangle(coordinates[0], coordinates[1], coordinates[2], coordinates[3]) : null;
|
|
7946
7994
|
} else if (op === _pdfmjs.OPS.clip || op === _pdfmjs.OPS.eoClip) pendingClip = true;
|
|
7947
7995
|
else if ([
|
|
7948
7996
|
_pdfmjs.OPS.endPath,
|
|
@@ -7962,7 +8010,7 @@ function smallVisibleImagePaints(fnArray, argsArray) {
|
|
|
7962
8010
|
pendingClip = false;
|
|
7963
8011
|
pathRect = void 0;
|
|
7964
8012
|
} else if (op === _pdfmjs.OPS.transform && Array.isArray(args) && args.length >= 6) ctm = multiply(ctm, args);
|
|
7965
|
-
else if (op === _pdfmjs.OPS.paintImageXObject && typeof _optionalChain([args, 'optionalAccess',
|
|
8013
|
+
else if (op === _pdfmjs.OPS.paintImageXObject && typeof _optionalChain([args, 'optionalAccess', _364 => _364[0]]) === "string") {
|
|
7966
8014
|
if (typeof args[1] !== "number" || typeof args[2] !== "number" || args[1] < 16 || args[1] > 128 || args[2] < 16 || args[2] > 128) continue;
|
|
7967
8015
|
const box = extractImageRegions([_pdfmjs.OPS.transform, _pdfmjs.OPS.paintImageXObject], [ctm, args])[0];
|
|
7968
8016
|
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;
|
|
@@ -7981,14 +8029,14 @@ async function restoreImageBullets(items, page, fnArray, argsArray, shapes = /*
|
|
|
7981
8029
|
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];
|
|
7982
8030
|
if (!line || /^[○●•◦□■∙]/.test(line.text.trim()) || !/\p{L}/u.test(line.text)) continue;
|
|
7983
8031
|
const row = items.filter((item) => Math.abs(item.y - line.y) <= 2 && item.x >= line.x);
|
|
7984
|
-
if (row.reduce((n, item) => n + (_nullishCoalesce(_optionalChain([item, 'access',
|
|
8032
|
+
if (row.reduce((n, item) => n + (_nullishCoalesce(_optionalChain([item, 'access', _365 => _365.text, 'access', _366 => _366.match, 'call', _367 => _367(/\p{L}/gu), 'optionalAccess', _368 => _368.length]), () => ( 0))), 0) < 12 || items.some((item) => item !== line && Math.abs(item.y - line.y) <= 2 && item.x < line.x)) continue;
|
|
7985
8033
|
candidates.push({ id, x: box.x1, width, line });
|
|
7986
8034
|
}
|
|
7987
8035
|
let restored = 0;
|
|
7988
8036
|
const used = /* @__PURE__ */ new Set();
|
|
7989
8037
|
for (const candidate of candidates) {
|
|
7990
8038
|
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);
|
|
7991
|
-
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',
|
|
8039
|
+
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', _369 => _369.text, 'access', _370 => _370.match, 'call', _371 => _371(/\p{L}/gu), 'optionalAccess', _372 => _372.length]), () => ( 0))) >= 12).sort((a, b) => b.y - a.y);
|
|
7992
8040
|
const numberedList = numbered.some((item, index) => index > 0 && item.text.trim().charCodeAt(0) === numbered[index - 1].text.trim().charCodeAt(0) + 1);
|
|
7993
8041
|
if (!same.length && !numberedList || used.has(candidate.line)) continue;
|
|
7994
8042
|
if (!shapes.has(candidate.id)) shapes.set(candidate.id, hollowCircle(await resolveImagePixels(page, candidate.id)));
|
|
@@ -8054,7 +8102,7 @@ function groupFlowBoxUnits(blocks, grids, hs, vs, images) {
|
|
|
8054
8102
|
return units;
|
|
8055
8103
|
}
|
|
8056
8104
|
function arrowDirection(image) {
|
|
8057
|
-
if (!_optionalChain([image, 'optionalAccess',
|
|
8105
|
+
if (!_optionalChain([image, 'optionalAccess', _373 => _373.data]) || image.width < 16 || image.width > 128 || image.height < 16 || image.height > 128) return 0;
|
|
8058
8106
|
const { width, height, data } = image;
|
|
8059
8107
|
const stride = image.kind === _pdfmjs.ImageKind.RGB_24BPP ? 3 : image.kind === _pdfmjs.ImageKind.RGBA_32BPP ? 4 : 0;
|
|
8060
8108
|
if (!stride || data.length < width * height * stride) return 0;
|
|
@@ -8122,7 +8170,7 @@ function isSideTabTable(box, table, others, pageWidth, pageHeight) {
|
|
|
8122
8170
|
function removeSideTabs(blocks, pageWidths) {
|
|
8123
8171
|
const edges = /* @__PURE__ */ new Map();
|
|
8124
8172
|
for (const b of blocks) {
|
|
8125
|
-
if (!b.bbox || b.pageNumber === void 0 || [..._nullishCoalesce(_optionalChain([b, 'access',
|
|
8173
|
+
if (!b.bbox || b.pageNumber === void 0 || [..._nullishCoalesce(_optionalChain([b, 'access', _374 => _374.text, 'optionalAccess', _375 => _375.trim, 'call', _376 => _376()]), () => ( ""))].length <= MAX_CHARS) continue;
|
|
8126
8174
|
const e = _nullishCoalesce(edges.get(b.pageNumber), () => ( { lefts: [], rights: [] }));
|
|
8127
8175
|
e.lefts.push(b.bbox.x);
|
|
8128
8176
|
e.rights.push(b.bbox.x + b.bbox.width);
|
|
@@ -8138,7 +8186,7 @@ function removeSideTabs(blocks, pageWidths) {
|
|
|
8138
8186
|
const fallback = all.length ? { left: q(all.map((e) => e.left), 0.5), right: q(all.map((e) => e.right), 0.5) } : void 0;
|
|
8139
8187
|
const key = (b) => {
|
|
8140
8188
|
const w = b.pageNumber !== void 0 ? pageWidths.get(b.pageNumber) : void 0;
|
|
8141
|
-
const text = _optionalChain([b, 'access',
|
|
8189
|
+
const text = _optionalChain([b, 'access', _377 => _377.text, 'optionalAccess', _378 => _378.trim, 'call', _379 => _379()]);
|
|
8142
8190
|
const area = _nullishCoalesce((b.pageNumber !== void 0 ? body.get(b.pageNumber) : void 0), () => ( fallback));
|
|
8143
8191
|
if (b.type === "table") {
|
|
8144
8192
|
if (!w || !b.bbox || !b.table || !SIDE_TAB_TABLES.has(b.table)) return null;
|
|
@@ -8801,16 +8849,16 @@ function isProseSpread(items) {
|
|
|
8801
8849
|
for (let i = 1; i < sorted.length; i++) {
|
|
8802
8850
|
gaps.push(sorted[i].x - (sorted[i - 1].x + sorted[i - 1].w));
|
|
8803
8851
|
}
|
|
8804
|
-
const maxGap =
|
|
8852
|
+
const maxGap = _chunkFABG65BGcjs.safeMax.call(void 0, gaps);
|
|
8805
8853
|
const avgLen = items.reduce((s, i) => s + i.text.length, 0) / items.length;
|
|
8806
8854
|
if (items.length >= 4 && maxGap < 40 && avgLen < 5) return true;
|
|
8807
|
-
const minGap =
|
|
8855
|
+
const minGap = _chunkFABG65BGcjs.safeMin.call(void 0, gaps);
|
|
8808
8856
|
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)));
|
|
8809
8857
|
}
|
|
8810
8858
|
function detectColumns(yLines) {
|
|
8811
8859
|
const allItems = yLines.flat();
|
|
8812
8860
|
if (allItems.length === 0) return null;
|
|
8813
|
-
const pageWidth =
|
|
8861
|
+
const pageWidth = _chunkFABG65BGcjs.safeMax.call(void 0, allItems.map((i) => i.x + i.w)) - _chunkFABG65BGcjs.safeMin.call(void 0, allItems.map((i) => i.x));
|
|
8814
8862
|
if (pageWidth < 100) return null;
|
|
8815
8863
|
let bigoLineIdx = -1;
|
|
8816
8864
|
for (let i = 0; i < yLines.length; i++) {
|
|
@@ -9035,7 +9083,7 @@ var UNDER_BOX_PAIR_MAX_EM = 2.2;
|
|
|
9035
9083
|
var UNDER_BOX_PAIR_OVERLAP = 0.8;
|
|
9036
9084
|
function markUnderlineItems(items, horizontals, verticals, nonRules) {
|
|
9037
9085
|
const underlines = [];
|
|
9038
|
-
if (_optionalChain([nonRules, 'optionalAccess',
|
|
9086
|
+
if (_optionalChain([nonRules, 'optionalAccess', _380 => _380.size])) horizontals = horizontals.filter((line) => !nonRules.has(line));
|
|
9039
9087
|
if (items.length === 0 || horizontals.length === 0) return underlines;
|
|
9040
9088
|
const tightOwners = /* @__PURE__ */ new Map();
|
|
9041
9089
|
const tightlyOwned = (line) => {
|
|
@@ -9141,7 +9189,7 @@ function hasBoxTopPair(line, maxH, horizontals, cellItems) {
|
|
|
9141
9189
|
if (ow <= 0) continue;
|
|
9142
9190
|
const overlap2 = Math.min(line.x2, o.x2) - Math.max(line.x1, o.x1);
|
|
9143
9191
|
if (overlap2 / Math.max(w, ow) < UNDER_BOX_PAIR_OVERLAP) continue;
|
|
9144
|
-
const covered = _nullishCoalesce(_optionalChain([cellItems, 'optionalAccess',
|
|
9192
|
+
const covered = _nullishCoalesce(_optionalChain([cellItems, 'optionalAccess', _381 => _381.reduce, 'call', _382 => _382((sum, item) => {
|
|
9145
9193
|
const below = item.y - o.y1;
|
|
9146
9194
|
if (below < 0.5 || below > 3 || !item.text.trim()) return sum;
|
|
9147
9195
|
return sum + Math.max(0, Math.min(o.x2, item.x + item.w) - Math.max(o.x1, item.x));
|
|
@@ -9208,13 +9256,13 @@ function partTex(group) {
|
|
|
9208
9256
|
const base = Math.min(...g.filter((i) => i.fontSize >= size * SCRIPT_SIZE_RATIO).map((i) => i.y));
|
|
9209
9257
|
let s = "", run = "";
|
|
9210
9258
|
const flush = () => {
|
|
9211
|
-
if (run) s +=
|
|
9259
|
+
if (run) s += _chunk6RA4KZHKcjs.toTex.call(void 0, run);
|
|
9212
9260
|
run = "";
|
|
9213
9261
|
};
|
|
9214
9262
|
g.forEach((it, k) => {
|
|
9215
9263
|
if (it.fontSize < size * SCRIPT_SIZE_RATIO && it.y - base >= size * SCRIPT_RISE_EM) {
|
|
9216
9264
|
flush();
|
|
9217
|
-
s += `^{${
|
|
9265
|
+
s += `^{${_chunk6RA4KZHKcjs.toTex.call(void 0, it.text)}}`;
|
|
9218
9266
|
return;
|
|
9219
9267
|
}
|
|
9220
9268
|
if (k && it.x - (g[k - 1].x + g[k - 1].w) > spaceGapThreshold(it.fontSize)) run += " ";
|
|
@@ -9387,12 +9435,12 @@ function rebuildUnitLine(items, grid) {
|
|
|
9387
9435
|
function prependUnitRow(cells, cols, line, usedItems) {
|
|
9388
9436
|
const text = cleanCellText(line.map((item) => item.text).join(""));
|
|
9389
9437
|
cells.unshift(Array.from({ length: cols }, (_, c) => ({ text: c === 0 ? text : "", colSpan: c === 0 ? cols : 1, rowSpan: 1 })));
|
|
9390
|
-
for (const cell of cells[0])
|
|
9438
|
+
for (const cell of cells[0]) _chunk6RA4KZHKcjs.CELL_EDGES.set(cell, NO_EDGES);
|
|
9391
9439
|
for (const item of line) usedItems.add(item);
|
|
9392
9440
|
}
|
|
9393
9441
|
function attachUnitRow(items, grid, cells, cols, usedItems) {
|
|
9394
9442
|
const all = cells.flat();
|
|
9395
|
-
if (all.filter((c) => c.text.trim()).length * 2 < all.length || UNIT.test(_nullishCoalesce(_optionalChain([cells, 'access',
|
|
9443
|
+
if (all.filter((c) => c.text.trim()).length * 2 < all.length || UNIT.test(_nullishCoalesce(_optionalChain([cells, 'access', _383 => _383[0], 'optionalAccess', _384 => _384[0], 'optionalAccess', _385 => _385.text]), () => ( "")))) return false;
|
|
9396
9444
|
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);
|
|
9397
9445
|
let nearest = Infinity;
|
|
9398
9446
|
for (const it of above) nearest = Math.min(nearest, it.y);
|
|
@@ -9427,7 +9475,7 @@ function closeShadedTableEdges(clipGrids, horizontals, verticals, fillRects) {
|
|
|
9427
9475
|
let hs = horizontals, vs = verticals;
|
|
9428
9476
|
const restored = [];
|
|
9429
9477
|
for (const grid of clipGrids) {
|
|
9430
|
-
if (grid.clipParent || grid.rowYs.length !== 2 || grid.colXs.length < 3 || !_optionalChain([grid, 'access',
|
|
9478
|
+
if (grid.clipParent || grid.rowYs.length !== 2 || grid.colXs.length < 3 || !_optionalChain([grid, 'access', _386 => _386.cells, 'optionalAccess', _387 => _387.length]) || grid.cells.some((c) => c.filler || c.rowSpan !== 1 || c.colSpan !== 1)) continue;
|
|
9431
9479
|
const { x1, x2, y1: mid, y2: top } = grid.bbox;
|
|
9432
9480
|
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;
|
|
9433
9481
|
const topRule = hs.find((h) => near2(h.y1, top) && near2(h.x1, x1) && near2(h.x2, x2));
|
|
@@ -9891,7 +9939,7 @@ function takeFrameSpanningText(items, cutX, pageNum, lex) {
|
|
|
9891
9939
|
const rows = groupByY([...items].sort((a, b) => b.y - a.y || a.x - b.x)).map((line) => {
|
|
9892
9940
|
const runs = [];
|
|
9893
9941
|
for (const item of [...line].sort((a, b) => a.x - b.x)) {
|
|
9894
|
-
const run = runs[runs.length - 1], prev = _optionalChain([run, 'optionalAccess',
|
|
9942
|
+
const run = runs[runs.length - 1], prev = _optionalChain([run, 'optionalAccess', _388 => _388[run.length - 1]]);
|
|
9895
9943
|
if (prev && item.x - (prev.x + prev.w) <= Math.max(prev.fontSize, item.fontSize) * 0.6) run.push(item);
|
|
9896
9944
|
else runs.push([item]);
|
|
9897
9945
|
}
|
|
@@ -9935,7 +9983,7 @@ function groupFrameParagraphUnits(units, frames) {
|
|
|
9935
9983
|
for (const unit of units) for (const block of unit) source.set(block, unit);
|
|
9936
9984
|
const members = /* @__PURE__ */ new Map(), emitted = /* @__PURE__ */ new Set();
|
|
9937
9985
|
for (const frame of frames) {
|
|
9938
|
-
if (frame.length < 2 || frame.some((block) => block.type !== "paragraph" || _optionalChain([source, 'access',
|
|
9986
|
+
if (frame.length < 2 || frame.some((block) => block.type !== "paragraph" || _optionalChain([source, 'access', _389 => _389.get, 'call', _390 => _390(block), 'optionalAccess', _391 => _391.length]) !== 1)) continue;
|
|
9939
9987
|
for (const block of frame) members.set(block, frame);
|
|
9940
9988
|
}
|
|
9941
9989
|
const out = [];
|
|
@@ -9948,7 +9996,7 @@ function groupFrameParagraphUnits(units, frames) {
|
|
|
9948
9996
|
}
|
|
9949
9997
|
}
|
|
9950
9998
|
for (const unit of out) {
|
|
9951
|
-
if (unit.length < 2 || _optionalChain([FRAME_READING_UNITS, 'access',
|
|
9999
|
+
if (unit.length < 2 || _optionalChain([FRAME_READING_UNITS, 'access', _392 => _392.get, 'call', _393 => _393(unit[0]), 'optionalAccess', _394 => _394.blocks]) === unit) continue;
|
|
9952
10000
|
const bs = unit.map((b) => b.bbox).filter((b) => !!b);
|
|
9953
10001
|
if (bs.length !== unit.length) continue;
|
|
9954
10002
|
const x = Math.min(...bs.map((b) => b.x)), y = Math.min(...bs.map((b) => b.y));
|
|
@@ -9965,14 +10013,14 @@ function groupFrameParagraphUnits(units, frames) {
|
|
|
9965
10013
|
function recordFrameTitle(table, source, pageNum) {
|
|
9966
10014
|
if (!CLIP_TABLES.has(table) || table.rows !== 1 || table.cols !== 3 || source.length < 2) return;
|
|
9967
10015
|
const cells = table.cells[0];
|
|
9968
|
-
if (cells.length !== 3 || cells.some((c) => c.colSpan !== 1 || c.rowSpan !== 1 || _optionalChain([c, 'access',
|
|
10016
|
+
if (cells.length !== 3 || cells.some((c) => c.colSpan !== 1 || c.rowSpan !== 1 || _optionalChain([c, 'access', _395 => _395.blocks, 'optionalAccess', _396 => _396.length]) || c.text.includes("\n"))) return;
|
|
9969
10017
|
const [label, spacer, title] = cells;
|
|
9970
10018
|
if (!/^(?:붙임|별첨|첨부|부록)\s*\d{1,3}$/.test(label.text.trim()) || spacer.text.trim() || !title.text.trim()) return;
|
|
9971
10019
|
if (cells.some((c) => {
|
|
9972
|
-
const e =
|
|
10020
|
+
const e = _chunk6RA4KZHKcjs.CELL_EDGES.get(c);
|
|
9973
10021
|
return !e || e.t || e.b || e.l || e.r;
|
|
9974
10022
|
})) return;
|
|
9975
|
-
const xs = TABLE_COLXS.get(table), style = dominantStyle(source), fs = _nullishCoalesce(_optionalChain([style, 'optionalAccess',
|
|
10023
|
+
const xs = TABLE_COLXS.get(table), style = dominantStyle(source), fs = _nullishCoalesce(_optionalChain([style, 'optionalAccess', _397 => _397.fontSize]), () => ( 0));
|
|
9976
10024
|
if (!xs || xs.length !== 4 || fs <= 0) return;
|
|
9977
10025
|
const width = xs[3] - xs[0], gap = xs[2] - xs[1];
|
|
9978
10026
|
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;
|
|
@@ -10036,7 +10084,7 @@ function extendNestedShadedHeaders(clipGrids, lineGrids, horizontals, verticals,
|
|
|
10036
10084
|
const extended = [];
|
|
10037
10085
|
for (let i = 0; i < clipGrids.length; i++) {
|
|
10038
10086
|
const c = clipGrids[i], parent = c.clipParent;
|
|
10039
|
-
if (!parent || c.rowYs.length !== 2 || c.colXs.length < 3 || !_optionalChain([c, 'access',
|
|
10087
|
+
if (!parent || c.rowYs.length !== 2 || c.colXs.length < 3 || !_optionalChain([c, 'access', _398 => _398.cells, 'optionalAccess', _399 => _399.length]) || c.cells.some((cell) => cell.filler || cell.rowSpan !== 1 || cell.colSpan !== 1)) continue;
|
|
10040
10088
|
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;
|
|
10041
10089
|
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;
|
|
10042
10090
|
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)));
|
|
@@ -10059,7 +10107,7 @@ function attachSideTabBlocks(tab, body, pageNum) {
|
|
|
10059
10107
|
bbox: computeBBox(items, pageNum),
|
|
10060
10108
|
style: dominantStyle(items)
|
|
10061
10109
|
});
|
|
10062
|
-
const prefix = ordered.filter((g) => !_optionalChain([caps, 'optionalAccess',
|
|
10110
|
+
const prefix = ordered.filter((g) => !_optionalChain([caps, 'optionalAccess', _400 => _400.has, 'call', _401 => _401(g)])).map((g) => ({
|
|
10063
10111
|
type: "paragraph",
|
|
10064
10112
|
text: g.text.trim(),
|
|
10065
10113
|
pageNumber: pageNum,
|
|
@@ -10068,7 +10116,7 @@ function attachSideTabBlocks(tab, body, pageNum) {
|
|
|
10068
10116
|
}));
|
|
10069
10117
|
const groups = /* @__PURE__ */ new Map();
|
|
10070
10118
|
for (const g of ordered) {
|
|
10071
|
-
const cap = _optionalChain([caps, 'optionalAccess',
|
|
10119
|
+
const cap = _optionalChain([caps, 'optionalAccess', _402 => _402.get, 'call', _403 => _403(g)]);
|
|
10072
10120
|
if (cap) groups.set(cap, [..._nullishCoalesce(groups.get(cap), () => ( [])), g]);
|
|
10073
10121
|
}
|
|
10074
10122
|
for (const [cap, glyphs] of groups) {
|
|
@@ -10100,7 +10148,7 @@ function extractPageBlocksWithLines(items, pageNum, opList, pageWidth, pageHeigh
|
|
|
10100
10148
|
let prev = null;
|
|
10101
10149
|
for (const line of streamLines(items)) {
|
|
10102
10150
|
lex.addLine(mergeLineSimple(line));
|
|
10103
|
-
const fs = _nullishCoalesce(_optionalChain([dominantStyle, 'call',
|
|
10151
|
+
const fs = _nullishCoalesce(_optionalChain([dominantStyle, 'call', _404 => _404(line), 'optionalAccess', _405 => _405.fontSize]), () => ( 0));
|
|
10104
10152
|
const left = Math.min(...line.map((i) => i.x)), right = Math.max(...line.map((i) => i.x + i.w));
|
|
10105
10153
|
const y = line.reduce((n, i) => n + i.y, 0) / line.length;
|
|
10106
10154
|
const wide = fs > 0 && right - left >= 12 * fs;
|
|
@@ -10114,7 +10162,7 @@ function extractPageBlocksWithLines(items, pageNum, opList, pageWidth, pageHeigh
|
|
|
10114
10162
|
const filled = fillBlanks(items, horizontals, verticals);
|
|
10115
10163
|
items = filled.items;
|
|
10116
10164
|
horizontals = filled.horizontals;
|
|
10117
|
-
const prevPage = _optionalChain([carry, 'optionalAccess',
|
|
10165
|
+
const prevPage = _optionalChain([carry, 'optionalAccess', _406 => _406.page]) === pageNum - 1 ? carry.clip : void 0;
|
|
10118
10166
|
const images = extractImageRegions(opList.fnArray, opList.argsArray);
|
|
10119
10167
|
const clipRects = images.length ? withoutImageOnlyClips(extracted.clipRects, images) : extracted.clipRects;
|
|
10120
10168
|
const clipResult = detectTables ? buildClipCellGrids(clipRects, horizontals, verticals, pageWidth, pageHeight, items.map((it) => ({ x: it.x + it.w / 2, y: it.y + it.h / 2 })), extracted.fillRects, prevPage) : { grids: [], containers: [], page: void 0 };
|
|
@@ -10409,7 +10457,7 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
|
|
|
10409
10457
|
const nested = pendingNested.length ? takePendingNested(pendingNested, cell.bbox, !!grid.cells) : [];
|
|
10410
10458
|
const lone = nested.length === 1 && !cellItems.length ? nested[0] : null;
|
|
10411
10459
|
const cw = cell.bbox.x2 - cell.bbox.x1;
|
|
10412
|
-
if (_optionalChain([lone, 'optionalAccess',
|
|
10460
|
+
if (_optionalChain([lone, 'optionalAccess', _407 => _407.table]) && lone.bbox && lone.table.rows === 1 && lone.table.cols === 1 && CLIP_TABLES.has(lone.table) && !_optionalChain([lone, 'access', _408 => _408.table, 'access', _409 => _409.cells, 'access', _410 => _410[0], 'access', _411 => _411[0], 'access', _412 => _412.blocks, 'optionalAccess', _413 => _413.some, 'call', _414 => _414((b2) => b2.type === "table")]) && lone.bbox.width >= cw * 0.9 && /^[^\n]{1,30}$/.test(lone.table.cells[0][0].text.trim())) {
|
|
10413
10461
|
irGrid[cell.row][cell.col] = { text: lone.table.cells[0][0].text, colSpan: cell.colSpan, rowSpan: cell.rowSpan };
|
|
10414
10462
|
takeClipCellEdges(cell, irGrid[cell.row][cell.col]);
|
|
10415
10463
|
continue;
|
|
@@ -10459,10 +10507,10 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
|
|
|
10459
10507
|
const ls = irGrid.slice(1).flat().flatMap((c) => c.text.split("\n")).map((t) => t.trim()).filter(Boolean);
|
|
10460
10508
|
const numericLine = (t) => {
|
|
10461
10509
|
const cs = t.replace(/\s+/g, "");
|
|
10462
|
-
return cs.length > 0 && (_nullishCoalesce(_optionalChain([cs, 'access',
|
|
10510
|
+
return cs.length > 0 && (_nullishCoalesce(_optionalChain([cs, 'access', _415 => _415.match, 'call', _416 => _416(/[\d.,%()+\-−–—△▲▽▼]/g), 'optionalAccess', _417 => _417.length]), () => ( 0))) >= cs.length * 0.85;
|
|
10463
10511
|
};
|
|
10464
10512
|
const labelValueLine = (t) => {
|
|
10465
|
-
const hangul = _nullishCoalesce(_optionalChain([t, 'access',
|
|
10513
|
+
const hangul = _nullishCoalesce(_optionalChain([t, 'access', _418 => _418.match, 'call', _419 => _419(/[가-힣]/g), 'optionalAccess', _420 => _420.length]), () => ( 0));
|
|
10466
10514
|
return hangul > 0 && hangul <= 6 && /\d,\d{3}/.test(t) && numericLine(t.replace(/[가-힣()]/g, ""));
|
|
10467
10515
|
};
|
|
10468
10516
|
const bulletLine = (t) => /^\s*[○◦•□■▪]/.test(t) || /^\s*-\s*[^\d\s.,−-]/.test(t) && t.replace(/\s+/g, "").length > 7;
|
|
@@ -10472,14 +10520,14 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
|
|
|
10472
10520
|
const share = ls.filter((t) => numericLine(t) || lvLines.has(t)).length / ls.length;
|
|
10473
10521
|
if (share >= 0.5) return true;
|
|
10474
10522
|
const colShares = Array.from({ length: numCols }, (_, c) => {
|
|
10475
|
-
const cl = irGrid.slice(1).flatMap((row) => (_nullishCoalesce(_optionalChain([row, 'access',
|
|
10523
|
+
const cl = irGrid.slice(1).flatMap((row) => (_nullishCoalesce(_optionalChain([row, 'access', _421 => _421[c], 'optionalAccess', _422 => _422.text]), () => ( ""))).split("\n")).map((t) => t.trim()).filter(Boolean);
|
|
10476
10524
|
return cl.length ? cl.filter(numericLine).length / cl.length : null;
|
|
10477
10525
|
}).filter((v) => v !== null);
|
|
10478
10526
|
return share >= 0.35 && colShares.some((v) => v >= 0.8) && colShares.every((v) => v >= 0.8 || v <= 0.2);
|
|
10479
10527
|
})();
|
|
10480
10528
|
const layoutProse = irGrid.some((row) => row.some((c) => c.colSpan >= numCols - 1 && c.text.length > 60));
|
|
10481
10529
|
const maxRows = numericBody ? layoutProse ? OCR_NUMERIC_MAX_ROWS_FRAMED : OCR_NUMERIC_MAX_ROWS : 5;
|
|
10482
|
-
const proseLine = (t) => (_nullishCoalesce(_optionalChain([t, 'access',
|
|
10530
|
+
const proseLine = (t) => (_nullishCoalesce(_optionalChain([t, 'access', _423 => _423.match, 'call', _424 => _424(/[가-힣]/g), 'optionalAccess', _425 => _425.length]), () => ( 0))) > 6 && !/^[-−]?[\d,.]+$/.test(t.replace(/\s+/g, ""));
|
|
10483
10531
|
const proseCols = numRows === 2 ? (_nullishCoalesce(irGrid[1], () => ( []))).filter((c) => {
|
|
10484
10532
|
const ls = c.text.split("\n").map((t) => t.trim()).filter(Boolean);
|
|
10485
10533
|
return ls.length >= 3 && ls.filter(proseLine).length >= ls.length * 0.6;
|
|
@@ -10500,8 +10548,8 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
|
|
|
10500
10548
|
finalGrid = rebuilt.map((row, i) => {
|
|
10501
10549
|
const o = kept.get(i);
|
|
10502
10550
|
return row.map((rawText, c) => {
|
|
10503
|
-
const src = o === void 0 ? void 0 : _optionalChain([irGrid, 'access',
|
|
10504
|
-
return { text: cleanCellText(rawText), colSpan: _nullishCoalesce(_optionalChain([src, 'optionalAccess',
|
|
10551
|
+
const src = o === void 0 ? void 0 : _optionalChain([irGrid, 'access', _426 => _426[o], 'optionalAccess', _427 => _427[c]]);
|
|
10552
|
+
return { text: cleanCellText(rawText), colSpan: _nullishCoalesce(_optionalChain([src, 'optionalAccess', _428 => _428.colSpan]), () => ( 1)), rowSpan: src ? spanRows(o, src.rowSpan) : 1 };
|
|
10505
10553
|
});
|
|
10506
10554
|
});
|
|
10507
10555
|
finalRows = finalGrid.length;
|
|
@@ -10521,14 +10569,14 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
|
|
|
10521
10569
|
if (!assignedItems.has(textItems[ti]) && !inExpanded(textItems[ti])) usedItems.delete(owners[ti]);
|
|
10522
10570
|
}
|
|
10523
10571
|
}
|
|
10524
|
-
if (unitLine.length > 0 && rebuiltUsed && !/^\s*\(\s*단위\s*[::]/.test(_nullishCoalesce(_optionalChain([finalGrid, 'access',
|
|
10572
|
+
if (unitLine.length > 0 && rebuiltUsed && !/^\s*\(\s*단위\s*[::]/.test(_nullishCoalesce(_optionalChain([finalGrid, 'access', _429 => _429[0], 'optionalAccess', _430 => _430[0], 'optionalAccess', _431 => _431.text]), () => ( "")))) {
|
|
10525
10573
|
prependUnitRow(finalGrid, numCols, unitLine, usedItems);
|
|
10526
10574
|
finalRows++;
|
|
10527
10575
|
}
|
|
10528
10576
|
if (!rebuiltUsed && attachUnitRow(items, grid, finalGrid, numCols, usedItems)) finalRows++;
|
|
10529
10577
|
let semanticOneColumn = false;
|
|
10530
10578
|
if (!grid.cells && !nestedAttached && numCols === 1 && numGridRows >= 2) {
|
|
10531
|
-
const populatedRows = finalGrid.filter((row) => _optionalChain([row, 'access',
|
|
10579
|
+
const populatedRows = finalGrid.filter((row) => _optionalChain([row, 'access', _432 => _432[0], 'optionalAccess', _433 => _433.text, 'access', _434 => _434.trim, 'call', _435 => _435()]));
|
|
10532
10580
|
if (populatedRows.length >= 4) {
|
|
10533
10581
|
const fontSizes = tableItems.map((item) => item.fontSize).filter((size) => size > 0).sort((a, b) => a - b);
|
|
10534
10582
|
const medianFont = _nullishCoalesce(fontSizes[Math.floor(fontSizes.length / 2)], () => ( 0));
|
|
@@ -10626,7 +10674,7 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
|
|
|
10626
10674
|
height: grid.bbox.y2 - grid.bbox.y1
|
|
10627
10675
|
};
|
|
10628
10676
|
if (numRows === 1 && numCols === 1 && gridW < pageWidth * 0.35) {
|
|
10629
|
-
const prose = _nullishCoalesce(_optionalChain([finalGrid, 'access',
|
|
10677
|
+
const prose = _nullishCoalesce(_optionalChain([finalGrid, 'access', _436 => _436[0], 'optionalAccess', _437 => _437[0], 'optionalAccess', _438 => _438.text]), () => ( ""));
|
|
10630
10678
|
const besideLines = (side) => new Set(side.map((it) => Math.round(it.y / 3))).size;
|
|
10631
10679
|
const rightLines = items.filter((it) => it.x >= grid.bbox.x2 + 3 && it.y >= grid.bbox.y1 && it.y <= grid.bbox.y2);
|
|
10632
10680
|
const leftLines = items.filter((it) => it.x + it.w <= grid.bbox.x1 - 3 && it.y >= grid.bbox.y1 && it.y <= grid.bbox.y2);
|
|
@@ -10645,8 +10693,8 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
|
|
|
10645
10693
|
}
|
|
10646
10694
|
}
|
|
10647
10695
|
if (!grid.cells && !nestedAttached && shouldDemoteTable(irTable)) {
|
|
10648
|
-
const paragraphs = numRows === 1 && numCols === 1 ? _optionalChain([irTable, 'access',
|
|
10649
|
-
if (_optionalChain([paragraphs, 'optionalAccess',
|
|
10696
|
+
const paragraphs = numRows === 1 && numCols === 1 ? _optionalChain([irTable, 'access', _439 => _439.cells, 'access', _440 => _440[0], 'optionalAccess', _441 => _441[0], 'optionalAccess', _442 => _442.blocks]) : void 0;
|
|
10697
|
+
if (_optionalChain([paragraphs, 'optionalAccess', _443 => _443.length])) {
|
|
10650
10698
|
blocks.push(...paragraphs);
|
|
10651
10699
|
frameParagraphUnits.push(paragraphs);
|
|
10652
10700
|
recordFrameReadingUnit(paragraphs, tableBbox);
|
|
@@ -10693,7 +10741,7 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
|
|
|
10693
10741
|
const clusterResults = (proseColumns ? [] : detectClusterTables(clusterItems, pageNum, void 0, lex)).filter((cr) => {
|
|
10694
10742
|
const b = cr.bbox;
|
|
10695
10743
|
const overlapX = (x) => Math.min(x.x + x.width, b.x + b.width) - Math.max(x.x, b.x);
|
|
10696
|
-
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',
|
|
10744
|
+
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', _444 => _444.text, 'optionalAccess', _445 => _445.match, 'call', _446 => _446(/\p{L}/gu), 'optionalAccess', _447 => _447.length]), () => ( 0))) >= 10 && overlapX(x.bbox) >= 0.8 * b.width : x.type === "table" && !ocrPage && _optionalChain([x, 'access', _448 => _448.table, 'optionalAccess', _449 => _449.cols]) === cr.table.cols && overlapX(x.bbox) >= 0.5 * Math.min(x.bbox.width, b.width)));
|
|
10697
10745
|
});
|
|
10698
10746
|
if (clusterResults.length > 0) {
|
|
10699
10747
|
const ciToIdx = /* @__PURE__ */ new Map();
|
|
@@ -10730,7 +10778,7 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
|
|
|
10730
10778
|
groupSizes.push(1);
|
|
10731
10779
|
}
|
|
10732
10780
|
const allY = remaining.map((i) => i.y);
|
|
10733
|
-
const pageH =
|
|
10781
|
+
const pageH = _chunkFABG65BGcjs.safeMax.call(void 0, allY) - _chunkFABG65BGcjs.safeMin.call(void 0, allY);
|
|
10734
10782
|
const gapThreshold = Math.max(15, pageH * 0.03);
|
|
10735
10783
|
const sides = frameColumnTextBands(remaining, spanning, gx);
|
|
10736
10784
|
const textBlocks = [];
|
|
@@ -10746,7 +10794,7 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
|
|
|
10746
10794
|
finalTextBlocks.push(...detectListBlocks(textBlocks));
|
|
10747
10795
|
} else {
|
|
10748
10796
|
const allY = remaining.map((i) => i.y);
|
|
10749
|
-
const pageH =
|
|
10797
|
+
const pageH = _chunkFABG65BGcjs.safeMax.call(void 0, allY) - _chunkFABG65BGcjs.safeMin.call(void 0, allY);
|
|
10750
10798
|
const gapThreshold = Math.max(15, pageH * 0.03);
|
|
10751
10799
|
const groups = xyCutOrder(remaining, gapThreshold);
|
|
10752
10800
|
const textBlocks = [];
|
|
@@ -11108,7 +11156,7 @@ function extractPageBlocksFallback(items, pageNum, fullPage = false, detectTable
|
|
|
11108
11156
|
blocks.push(...columnTextToBlocks(tableText, pageNum, bbox, dominantStyle(items)));
|
|
11109
11157
|
} else {
|
|
11110
11158
|
const allY = items.map((i) => i.y);
|
|
11111
|
-
const pageHeight =
|
|
11159
|
+
const pageHeight = _chunkFABG65BGcjs.safeMax.call(void 0, allY) - _chunkFABG65BGcjs.safeMin.call(void 0, allY);
|
|
11112
11160
|
const gapThreshold = Math.max(15, pageHeight * 0.03);
|
|
11113
11161
|
const orderedGroups = proseCutX !== null ? splitTwoColumnProse(items, proseCutX) : xyCutOrder(items, gapThreshold, 0, void 0, minGap);
|
|
11114
11162
|
for (const group of orderedGroups) {
|
|
@@ -11165,19 +11213,19 @@ function mergeOcrImageRegions(blocks, page, regions, ocrBlocks) {
|
|
|
11165
11213
|
const overlapH = Math.max(0, Math.min(b.y + b.height, region.y2) - Math.max(b.y, region.y1));
|
|
11166
11214
|
return overlapW * overlapH >= b.width * b.height * 0.8;
|
|
11167
11215
|
});
|
|
11168
|
-
const labels = candidates.filter((b) => b.type === "paragraph" && b.bbox.height <= 24 && (_nullishCoalesce(_optionalChain([b, 'access',
|
|
11216
|
+
const labels = candidates.filter((b) => b.type === "paragraph" && b.bbox.height <= 24 && (_nullishCoalesce(_optionalChain([b, 'access', _450 => _450.text, 'optionalAccess', _451 => _451.match, 'call', _452 => _452(/[\p{L}\p{N}]/gu), 'optionalAccess', _453 => _453.length]), () => ( 0))) >= 2);
|
|
11169
11217
|
const axisFragments = rotatedAxisFragments(candidates);
|
|
11170
11218
|
const accepted = candidates.filter((b) => {
|
|
11171
|
-
if (b.type === "paragraph") return (_nullishCoalesce(_optionalChain([b, 'access',
|
|
11219
|
+
if (b.type === "paragraph") return (_nullishCoalesce(_optionalChain([b, 'access', _454 => _454.text, 'optionalAccess', _455 => _455.match, 'call', _456 => _456(/[\p{L}\p{N}]/gu), 'optionalAccess', _457 => _457.length]), () => ( 0))) >= 2 || !axisFragments.has(b) && (supportedDiagramLabel(b, labels, region) || axisTick(b, candidates));
|
|
11172
11220
|
const t = b.table;
|
|
11173
11221
|
if (b.type !== "table" || !t || UNRULED_REGION_TABLES.has(b)) return false;
|
|
11174
11222
|
const lone = t.cells.filter((row) => row.filter((c) => c.text.trim()).length === 1 && row.some((c) => c.colSpan === t.cols)).length;
|
|
11175
11223
|
if (t.rows >= 2 && lone * 2 >= t.rows) return false;
|
|
11176
11224
|
if (t.rows === 1 && t.cols === 1) {
|
|
11177
|
-
const text = _nullishCoalesce(_optionalChain([t, 'access',
|
|
11178
|
-
return (_nullishCoalesce(_optionalChain([text, 'access',
|
|
11225
|
+
const text = _nullishCoalesce(_optionalChain([t, 'access', _458 => _458.cells, 'access', _459 => _459[0], 'optionalAccess', _460 => _460[0], 'optionalAccess', _461 => _461.text]), () => ( ""));
|
|
11226
|
+
return (_nullishCoalesce(_optionalChain([text, 'access', _462 => _462.match, 'call', _463 => _463(/\n/g), 'optionalAccess', _464 => _464.length]), () => ( 0))) >= 5 && (_nullishCoalesce(_optionalChain([text, 'access', _465 => _465.match, 'call', _466 => _466(/\d/g), 'optionalAccess', _467 => _467.length]), () => ( 0))) >= text.length * 0.25;
|
|
11179
11227
|
}
|
|
11180
|
-
const headerLabels = _nullishCoalesce(_optionalChain([t, 'access',
|
|
11228
|
+
const headerLabels = _nullishCoalesce(_optionalChain([t, 'access', _468 => _468.cells, 'access', _469 => _469[0], 'optionalAccess', _470 => _470.filter, 'call', _471 => _471((c) => c.text.replace(/[^A-Za-z가-힣]/g, "").length >= 2), 'access', _472 => _472.length]), () => ( 0));
|
|
11181
11229
|
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);
|
|
11182
11230
|
});
|
|
11183
11231
|
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, () => ( "")))) : []);
|
|
@@ -11194,14 +11242,14 @@ function mergeOcrImageRegions(blocks, page, regions, ocrBlocks) {
|
|
|
11194
11242
|
for (const block of selected) {
|
|
11195
11243
|
if (seen2.has(block)) continue;
|
|
11196
11244
|
const frame = FRAME_READING_UNITS.get(block);
|
|
11197
|
-
const source = _optionalChain([frame, 'optionalAccess',
|
|
11245
|
+
const source = _optionalChain([frame, 'optionalAccess', _473 => _473.blocks, 'access', _474 => _474.every, 'call', _475 => _475((member) => selectedSet.has(member))]) ? frame.blocks : [block];
|
|
11198
11246
|
source.forEach((member) => seen2.add(member));
|
|
11199
11247
|
const available = source.filter((member) => !hasOriginal(member));
|
|
11200
11248
|
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 }));
|
|
11201
11249
|
for (const unit of units) {
|
|
11202
11250
|
const b = unit.bbox;
|
|
11203
11251
|
const index = blocks.findIndex((existing) => {
|
|
11204
|
-
const e = _nullishCoalesce(_optionalChain([FRAME_READING_UNITS, 'access',
|
|
11252
|
+
const e = _nullishCoalesce(_optionalChain([FRAME_READING_UNITS, 'access', _476 => _476.get, 'call', _477 => _477(existing), 'optionalAccess', _478 => _478.bbox]), () => ( existing.bbox));
|
|
11205
11253
|
if (existing.pageNumber !== page || !e) return false;
|
|
11206
11254
|
const beside = e.y < region.y2 && e.y + e.height > region.y1 && e.x >= region.x2 - 1;
|
|
11207
11255
|
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;
|
|
@@ -11219,16 +11267,16 @@ function mergeOcrImageRegions(blocks, page, regions, ocrBlocks) {
|
|
|
11219
11267
|
}
|
|
11220
11268
|
function axisTick(block, candidates) {
|
|
11221
11269
|
const b = block.bbox;
|
|
11222
|
-
if (!/^\d$/u.test(_nullishCoalesce(_optionalChain([block, 'access',
|
|
11223
|
-
const numeric = candidates.filter((o) => o !== block && o.type === "paragraph" && o.bbox && /^[\d\s.,%+−-]+$/u.test(_nullishCoalesce(_optionalChain([o, 'access',
|
|
11270
|
+
if (!/^\d$/u.test(_nullishCoalesce(_optionalChain([block, 'access', _479 => _479.text, 'optionalAccess', _480 => _480.trim, 'call', _481 => _481()]), () => ( "")))) return false;
|
|
11271
|
+
const numeric = candidates.filter((o) => o !== block && o.type === "paragraph" && o.bbox && /^[\d\s.,%+−-]+$/u.test(_nullishCoalesce(_optionalChain([o, 'access', _482 => _482.text, 'optionalAccess', _483 => _483.trim, 'call', _484 => _484()]), () => ( ""))) && /\d/u.test(_nullishCoalesce(o.text, () => ( ""))) && Math.max(o.bbox.height, b.height) <= Math.min(o.bbox.height, b.height) * 2);
|
|
11224
11272
|
const cy = b.y + b.height / 2, right = b.x + b.width;
|
|
11225
11273
|
const row = numeric.filter((o) => Math.abs(o.bbox.y + o.bbox.height / 2 - cy) <= Math.min(o.bbox.height, b.height) * 0.35);
|
|
11226
11274
|
const column = numeric.filter((o) => Math.abs(o.bbox.x + o.bbox.width - right) <= Math.max(o.bbox.height, b.height) * 0.5);
|
|
11227
11275
|
return row.length >= 2 || column.length >= 2;
|
|
11228
11276
|
}
|
|
11229
11277
|
function supportedDiagramLabel(block, labels, region) {
|
|
11230
|
-
const b = block.bbox, text = _nullishCoalesce(_optionalChain([block, 'access',
|
|
11231
|
-
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',
|
|
11278
|
+
const b = block.bbox, text = _nullishCoalesce(_optionalChain([block, 'access', _485 => _485.text, 'optionalAccess', _486 => _486.trim, 'call', _487 => _487()]), () => ( ""));
|
|
11279
|
+
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', _488 => _488.text, 'optionalAccess', _489 => _489.match, 'call', _490 => _490(/\p{N}/gu), 'optionalAccess', _491 => _491.length]), () => ( 0))) >= 2).length < 2) return false;
|
|
11232
11280
|
let above = false, below = false;
|
|
11233
11281
|
for (const label of labels) {
|
|
11234
11282
|
const a = label.bbox, em = Math.max(b.height, a.height);
|
|
@@ -11243,7 +11291,7 @@ function rotatedAxisFragments(candidates) {
|
|
|
11243
11291
|
const paragraphs = candidates.filter((b) => b.type === "paragraph" && b.bbox.height <= 24);
|
|
11244
11292
|
const axes = [];
|
|
11245
11293
|
for (const block of paragraphs) {
|
|
11246
|
-
const b = block.bbox, text = _nullishCoalesce(_optionalChain([block, 'access',
|
|
11294
|
+
const b = block.bbox, text = _nullishCoalesce(_optionalChain([block, 'access', _492 => _492.text, 'optionalAccess', _493 => _493.trim, 'call', _494 => _494()]), () => ( ""));
|
|
11247
11295
|
if (!/^[\d\s.,%+−-]+$/u.test(text) || !/\d/u.test(text) || b.width > b.height * 6) continue;
|
|
11248
11296
|
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);
|
|
11249
11297
|
if (axis) axis.push(block);
|
|
@@ -11260,8 +11308,8 @@ function rotatedAxisFragments(candidates) {
|
|
|
11260
11308
|
const em = Math.max(...axis.map((a) => a.bbox.height)), right = axis[0].bbox.x + axis[0].bbox.width;
|
|
11261
11309
|
if (top - bottom < em * 6) continue;
|
|
11262
11310
|
const left = paragraphs.filter((block) => {
|
|
11263
|
-
const b = block.bbox, text = _nullishCoalesce(_optionalChain([block, 'access',
|
|
11264
|
-
return /\p{Script=Latin}/u.test(text) && (_nullishCoalesce(_optionalChain([text, 'access',
|
|
11311
|
+
const b = block.bbox, text = _nullishCoalesce(_optionalChain([block, 'access', _495 => _495.text, 'optionalAccess', _496 => _496.trim, 'call', _497 => _497()]), () => ( ""));
|
|
11312
|
+
return /\p{Script=Latin}/u.test(text) && (_nullishCoalesce(_optionalChain([text, 'access', _498 => _498.match, 'call', _499 => _499(/[\p{L}\p{N}]/gu), 'optionalAccess', _500 => _500.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;
|
|
11265
11313
|
});
|
|
11266
11314
|
const stack = left.filter((a) => left.some((b) => {
|
|
11267
11315
|
if (a === b || !aligned(a, b)) return false;
|
|
@@ -11271,7 +11319,7 @@ function rotatedAxisFragments(candidates) {
|
|
|
11271
11319
|
if (stack.length < 2) continue;
|
|
11272
11320
|
for (const block of paragraphs) {
|
|
11273
11321
|
const b = block.bbox;
|
|
11274
|
-
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',
|
|
11322
|
+
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', _501 => _501.text, 'optionalAccess', _502 => _502.trim, 'call', _503 => _503()]), () => ( ""))) && stack.some((s) => aligned(s, block))) fragments.add(block);
|
|
11275
11323
|
}
|
|
11276
11324
|
}
|
|
11277
11325
|
return fragments;
|
|
@@ -11378,4 +11426,4 @@ function rowParagraphs(block) {
|
|
|
11378
11426
|
|
|
11379
11427
|
|
|
11380
11428
|
exports.DEFAULT_OCR_MODELS = DEFAULT_OCR_MODELS; exports.resolveOcrModels = resolveOcrModels; exports.handwritingFallbackModels = handwritingFallbackModels; exports.ocrSelectionKey = ocrSelectionKey; exports.ocrSourcePath = ocrSourcePath; exports.ensureOcrModelsFor = ensureOcrModelsFor; exports.ocrModelsCached = ocrModelsCached; exports.parseCharacterDict = parseCharacterDict; exports.grayCrop = grayCrop; exports.inkStats = inkStats; exports.splitRowBands = splitRowBands; exports.leadingTriangle = leadingTriangle; exports.arrowGlyph = arrowGlyph; exports.leaderRuns = leaderRuns; exports.inkBounds = inkBounds; exports.bracketFeatures = bracketFeatures; exports.slantedPair = slantedPair; exports.romanStems = romanStems; exports.circledAt = circledAt; exports.ringBoxes = ringBoxes; exports.quoteHead = quoteHead; exports.edgeTrim = edgeTrim; exports.tallInkCount = tallInkCount; exports.gapGlyphs = gapGlyphs; exports.ringBullet = ringBullet; exports.dashRatio = dashRatio; exports.leadingRing = leadingRing; exports.discAt = discAt; exports.serifOne = serifOne; exports.starRun = starRun; exports.bracketShape = bracketShape; exports.leadingBullet = leadingBullet; exports.stackedGlyphBands = stackedGlyphBands; exports.rememberOcrTextGaps = rememberOcrTextGaps; exports.copyOcrTextGaps = copyOcrTextGaps; exports.findOcrTextGaps = findOcrTextGaps; exports.extractLines = extractLines; exports.extractImageRegions = extractImageRegions; exports.NO_EDGES = NO_EDGES; exports.hasOpenCellSeam = hasOpenCellSeam; exports.joinCellEdges = joinCellEdges; exports.filterHiddenText = filterHiddenText; exports.collapseEvenSpacing = collapseEvenSpacing; exports.computeBBox = computeBBox; exports.dominantStyle = dominantStyle; exports.normalizeItems = normalizeItems; exports.groupByY = groupByY; exports.mergeLineSimple = mergeLineSimple; exports.WrapLexicon = WrapLexicon; exports.startsNewItem = startsNewItem; exports.wrapJoiner = wrapJoiner; exports.joinPageBreakWraps = joinPageBreakWraps; exports.splitPageBreakWraps = splitPageBreakWraps; exports.latinSoftWrap = latinSoftWrap; exports.TOC_BLOCKS = TOC_BLOCKS; exports.computeMedianFontSizeFromFreq = computeMedianFontSizeFromFreq; exports.detectHeadings = detectHeadings; exports.mergeStackedHeadingLines = mergeStackedHeadingLines; exports.detectTypographyHeadings = detectTypographyHeadings; exports.detectDocumentStyleHeadings = detectDocumentStyleHeadings; exports.detectSiblingStyleHeadings = detectSiblingStyleHeadings; exports.detectRepeatedPageLabels = detectRepeatedPageLabels; exports.detectPageLeadHeadings = detectPageLeadHeadings; exports.refineDocumentStyleHeadings = refineDocumentStyleHeadings; exports.detectMarkerHeadings = detectMarkerHeadings; exports.detectTableCaptions = detectTableCaptions; exports.detectKoreanListBlocks = detectKoreanListBlocks; exports.removeHeaderFooterBlocks = removeHeaderFooterBlocks; exports.runningLinePatterns = runningLinePatterns; exports.stripAbsorbedRunningLines = stripAbsorbedRunningLines; exports.CLIP_TABLES = CLIP_TABLES; exports.FRAME_TITLE_BLOCKS = FRAME_TITLE_BLOCKS; exports.TABLE_COLXS = TABLE_COLXS; exports.TABLE_ROWYS = TABLE_ROWYS; exports.TABLE_TAIL = TABLE_TAIL; exports.PART_COLXS = PART_COLXS; exports.EMPTY_PARTS = EMPTY_PARTS; exports.IMAGE_CELLS = IMAGE_CELLS; exports.FILLER_CELLS = FILLER_CELLS; exports.CONT_PARTS = CONT_PARTS; exports.CELL_LINES = CELL_LINES; exports.ROW_RULES = ROW_RULES; exports.trimTrailingEmptyTableCols = trimTrailingEmptyTableCols; exports.restoreImageBullets = restoreImageBullets; exports.detectRightArrowRegions = detectRightArrowRegions; exports.removeSideTabs = removeSideTabs; exports.extractPageBlocksWithLines = extractPageBlocksWithLines; exports.UNRULED_REGION_TABLES = UNRULED_REGION_TABLES; exports.mergeOcrImageRegions = mergeOcrImageRegions;
|
|
11381
|
-
//# sourceMappingURL=chunk-
|
|
11429
|
+
//# sourceMappingURL=chunk-E7QOWHAY.cjs.map
|