kordoc 4.18.11 → 4.18.13
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 +2 -1
- package/dist/{-TUDCOQX6.js → -DC2OO5KO.js} +11 -11
- package/dist/{chunk-PF4O626Y.js → chunk-32ZUIHSY.js} +3 -3
- package/dist/{chunk-Q5GB73E7.cjs → chunk-3FGHQWJP.cjs} +151 -130
- package/dist/chunk-3FGHQWJP.cjs.map +1 -0
- package/dist/{chunk-GNXDTPP6.js → chunk-6AYTYTFY.js} +3 -3
- package/dist/{chunk-DT5OWHWO.cjs → chunk-6CQZMVXW.cjs} +3 -3
- package/dist/{chunk-DT5OWHWO.cjs.map → chunk-6CQZMVXW.cjs.map} +1 -1
- package/dist/{chunk-IUOGBCVI.cjs → chunk-6FW3AZWN.cjs} +6 -6
- package/dist/{chunk-IUOGBCVI.cjs.map → chunk-6FW3AZWN.cjs.map} +1 -1
- package/dist/{chunk-KFB7LHCB.js → chunk-7LOD4IGO.js} +4 -4
- package/dist/{chunk-5GVDHHHO.js → chunk-DHEUQXXR.js} +2 -2
- package/dist/{chunk-KA2NMWIC.js → chunk-EBXJ45VZ.js} +2 -2
- package/dist/{chunk-DU2DV4LO.js → chunk-EZSWBHHI.js} +2 -2
- package/dist/{chunk-7H5P475X.cjs → chunk-GGMIPTM5.cjs} +12 -12
- package/dist/{chunk-7H5P475X.cjs.map → chunk-GGMIPTM5.cjs.map} +1 -1
- package/dist/{chunk-PIRSOTKK.js → chunk-GSW7W7AL.js} +2 -2
- package/dist/{chunk-TYIUJKUT.js → chunk-GUH6HYSZ.js} +10 -10
- package/dist/{chunk-CNU4NPCC.js → chunk-INESPVEV.js} +26 -5
- package/dist/chunk-INESPVEV.js.map +1 -0
- package/dist/{chunk-DXRKZWC3.js → chunk-IRN5SDY2.js} +2 -2
- package/dist/{chunk-P6GO34IP.js → chunk-ISC2TH24.js} +2 -2
- package/dist/{chunk-WP6KG5Z7.js → chunk-JKHU7HID.js} +2 -2
- package/dist/{chunk-UAWOYMBR.js → chunk-JPSLMPFI.js} +2 -2
- package/dist/{chunk-QK6AJJMJ.js → chunk-JWTZ3OVZ.js} +2 -2
- package/dist/{chunk-FS6RCEF6.cjs → chunk-K6WSMTVU.cjs} +2 -2
- package/dist/{chunk-FS6RCEF6.cjs.map → chunk-K6WSMTVU.cjs.map} +1 -1
- package/dist/{chunk-56QHHRWD.js → chunk-LKA7Z2NH.js} +2 -2
- package/dist/{chunk-XJCWMVVY.js → chunk-PHMWSWHJ.js} +2 -2
- package/dist/{chunk-JZ3VPASI.js → chunk-PN5WWW56.js} +2 -2
- package/dist/{chunk-PC4U3XRK.cjs → chunk-RQEDNI4P.cjs} +3 -3
- package/dist/{chunk-PC4U3XRK.cjs.map → chunk-RQEDNI4P.cjs.map} +1 -1
- package/dist/{chunk-L7TALZNE.js → chunk-SVIOP7PE.js} +6 -6
- package/dist/{chunk-UG4GIJSH.js → chunk-V7LKQNC4.js} +2 -2
- package/dist/{chunk-DKVS6CFO.js → chunk-VDEENOPW.js} +2 -2
- package/dist/{chunk-UETNJSA7.js → chunk-XVB3PUPJ.js} +2 -2
- package/dist/{chunk-CMROXIWJ.js → chunk-ZNY5BRV6.js} +27 -6
- package/dist/chunk-ZNY5BRV6.js.map +1 -0
- package/dist/chunks-JZW2TXIZ.js +10 -0
- package/dist/cli.js +26 -26
- package/dist/{formula-5BPY5GQL.js → formula-DAMFHLQO.js} +3 -3
- package/dist/{formula-VUI2AJUZ.cjs → formula-HJNQGPRC.cjs} +9 -9
- package/dist/{formula-VUI2AJUZ.cjs.map → formula-HJNQGPRC.cjs.map} +1 -1
- package/dist/{formula-RA2JV55J.js → formula-YCAO5IVW.js} +4 -4
- package/dist/{image-ocr-3LUFXLSS.cjs → image-ocr-AZ25IOC7.cjs} +15 -15
- package/dist/{image-ocr-3LUFXLSS.cjs.map → image-ocr-AZ25IOC7.cjs.map} +1 -1
- package/dist/{image-ocr-MOGXLPIS.js → image-ocr-PAF76DAW.js} +9 -9
- package/dist/{image-ocr-QDNBFOLW.js → image-ocr-VH54SDZ7.js} +6 -6
- package/dist/index.cjs +277 -277
- package/dist/index.js +5 -5
- package/dist/mcp.js +22 -22
- package/dist/{model-bundle-PKJUJTPC.js → model-bundle-53CHDYCG.js} +5 -5
- package/dist/{models-ZZCRW54N.js → models-UVLAKK3M.js} +5 -5
- package/dist/{parser-SL5XDJYU.cjs → parser-HWAOPQYK.cjs} +126 -126
- package/dist/{parser-SL5XDJYU.cjs.map → parser-HWAOPQYK.cjs.map} +1 -1
- package/dist/{parser-PICN5MDD.js → parser-I4D3TRGU.js} +11 -11
- package/dist/{parser-IU4QXSEQ.js → parser-Z6PHB54O.js} +8 -8
- package/dist/pdf-ocr-F4ICXO7W.js +20 -0
- package/dist/pdf-ocr-HR6CXGTX.cjs +17 -0
- package/dist/{pdf-ocr-37GLDHR2.cjs.map → pdf-ocr-HR6CXGTX.cjs.map} +1 -1
- package/dist/pdf-ocr-JI3K7JIN.js +16 -0
- package/dist/{profile-io-TQXBV4NZ.js → profile-io-WHCWCOPW.js} +3 -3
- package/dist/{rasterize-QHUKA2N7.js → rasterize-5DZ3DHGH.js} +3 -3
- package/dist/{redact-doc-HHTMXA3E.js → redact-doc-RNJVMFGQ.js} +11 -11
- package/dist/{render-RZF6SNSN.js → render-NZ6RA6SW.js} +7 -7
- package/dist/seal-WHJ6O5HT.js +10 -0
- package/dist/{setup-IUCBBXYG.js → setup-U3EQNK4Z.js} +3 -3
- package/dist/visual-JDAS4R43.js +20 -0
- package/dist/{watch-G46MOBKP.js → watch-GB2M7XU6.js} +12 -12
- package/package.json +1 -1
- package/dist/chunk-CMROXIWJ.js.map +0 -1
- package/dist/chunk-CNU4NPCC.js.map +0 -1
- package/dist/chunk-Q5GB73E7.cjs.map +0 -1
- package/dist/chunks-ZZZGBVGM.js +0 -10
- package/dist/pdf-ocr-37GLDHR2.cjs +0 -17
- package/dist/pdf-ocr-7AWV7MY3.js +0 -20
- package/dist/pdf-ocr-UXP4CV6V.js +0 -16
- package/dist/seal-TBTMKXLY.js +0 -10
- package/dist/visual-I64Z7W3Q.js +0 -20
- /package/dist/{-TUDCOQX6.js.map → -DC2OO5KO.js.map} +0 -0
- /package/dist/{chunk-PF4O626Y.js.map → chunk-32ZUIHSY.js.map} +0 -0
- /package/dist/{chunk-GNXDTPP6.js.map → chunk-6AYTYTFY.js.map} +0 -0
- /package/dist/{chunk-KFB7LHCB.js.map → chunk-7LOD4IGO.js.map} +0 -0
- /package/dist/{chunk-5GVDHHHO.js.map → chunk-DHEUQXXR.js.map} +0 -0
- /package/dist/{chunk-KA2NMWIC.js.map → chunk-EBXJ45VZ.js.map} +0 -0
- /package/dist/{chunk-DU2DV4LO.js.map → chunk-EZSWBHHI.js.map} +0 -0
- /package/dist/{chunk-PIRSOTKK.js.map → chunk-GSW7W7AL.js.map} +0 -0
- /package/dist/{chunk-TYIUJKUT.js.map → chunk-GUH6HYSZ.js.map} +0 -0
- /package/dist/{chunk-DXRKZWC3.js.map → chunk-IRN5SDY2.js.map} +0 -0
- /package/dist/{chunk-P6GO34IP.js.map → chunk-ISC2TH24.js.map} +0 -0
- /package/dist/{chunk-WP6KG5Z7.js.map → chunk-JKHU7HID.js.map} +0 -0
- /package/dist/{chunk-UAWOYMBR.js.map → chunk-JPSLMPFI.js.map} +0 -0
- /package/dist/{chunk-QK6AJJMJ.js.map → chunk-JWTZ3OVZ.js.map} +0 -0
- /package/dist/{chunk-56QHHRWD.js.map → chunk-LKA7Z2NH.js.map} +0 -0
- /package/dist/{chunk-XJCWMVVY.js.map → chunk-PHMWSWHJ.js.map} +0 -0
- /package/dist/{chunk-JZ3VPASI.js.map → chunk-PN5WWW56.js.map} +0 -0
- /package/dist/{chunk-L7TALZNE.js.map → chunk-SVIOP7PE.js.map} +0 -0
- /package/dist/{chunk-UG4GIJSH.js.map → chunk-V7LKQNC4.js.map} +0 -0
- /package/dist/{chunk-DKVS6CFO.js.map → chunk-VDEENOPW.js.map} +0 -0
- /package/dist/{chunk-UETNJSA7.js.map → chunk-XVB3PUPJ.js.map} +0 -0
- /package/dist/{chunks-ZZZGBVGM.js.map → chunks-JZW2TXIZ.js.map} +0 -0
- /package/dist/{formula-5BPY5GQL.js.map → formula-DAMFHLQO.js.map} +0 -0
- /package/dist/{formula-RA2JV55J.js.map → formula-YCAO5IVW.js.map} +0 -0
- /package/dist/{image-ocr-MOGXLPIS.js.map → image-ocr-PAF76DAW.js.map} +0 -0
- /package/dist/{image-ocr-QDNBFOLW.js.map → image-ocr-VH54SDZ7.js.map} +0 -0
- /package/dist/{model-bundle-PKJUJTPC.js.map → model-bundle-53CHDYCG.js.map} +0 -0
- /package/dist/{models-ZZCRW54N.js.map → models-UVLAKK3M.js.map} +0 -0
- /package/dist/{parser-PICN5MDD.js.map → parser-I4D3TRGU.js.map} +0 -0
- /package/dist/{parser-IU4QXSEQ.js.map → parser-Z6PHB54O.js.map} +0 -0
- /package/dist/{pdf-ocr-7AWV7MY3.js.map → pdf-ocr-F4ICXO7W.js.map} +0 -0
- /package/dist/{pdf-ocr-UXP4CV6V.js.map → pdf-ocr-JI3K7JIN.js.map} +0 -0
- /package/dist/{profile-io-TQXBV4NZ.js.map → profile-io-WHCWCOPW.js.map} +0 -0
- /package/dist/{rasterize-QHUKA2N7.js.map → rasterize-5DZ3DHGH.js.map} +0 -0
- /package/dist/{redact-doc-HHTMXA3E.js.map → redact-doc-RNJVMFGQ.js.map} +0 -0
- /package/dist/{render-RZF6SNSN.js.map → render-NZ6RA6SW.js.map} +0 -0
- /package/dist/{seal-TBTMKXLY.js.map → seal-WHJ6O5HT.js.map} +0 -0
- /package/dist/{setup-IUCBBXYG.js.map → setup-U3EQNK4Z.js.map} +0 -0
- /package/dist/{visual-I64Z7W3Q.js.map → visual-JDAS4R43.js.map} +0 -0
- /package/dist/{watch-G46MOBKP.js.map → watch-GB2M7XU6.js.map} +0 -0
|
@@ -4,15 +4,15 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunk6FW3AZWNcjs = require('./chunk-6FW3AZWN.cjs');
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
var
|
|
11
|
+
var _chunk6CQZMVXWcjs = require('./chunk-6CQZMVXW.cjs');
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
var
|
|
15
|
+
var _chunkK6WSMTVUcjs = require('./chunk-K6WSMTVU.cjs');
|
|
16
16
|
|
|
17
17
|
// src/ocr/models.ts
|
|
18
18
|
var _path = require('path');
|
|
@@ -40,10 +40,10 @@ var OCR_REC_DICT = {
|
|
|
40
40
|
};
|
|
41
41
|
var ALL_OCR_MODELS = [OCR_DET_MODEL, OCR_REC_MODEL, OCR_REC_DICT];
|
|
42
42
|
function getOcrModelsDir() {
|
|
43
|
-
return
|
|
43
|
+
return _chunk6CQZMVXWcjs.getModelsDir.call(void 0, "ppocr");
|
|
44
44
|
}
|
|
45
45
|
async function ensureOcrModels(onProgress) {
|
|
46
|
-
return
|
|
46
|
+
return _chunk6CQZMVXWcjs.ensureModelsIn.call(void 0, getOcrModelsDir(), ALL_OCR_MODELS, onProgress);
|
|
47
47
|
}
|
|
48
48
|
async function ocrModelsCached() {
|
|
49
49
|
const dir = getOcrModelsDir();
|
|
@@ -2091,7 +2091,7 @@ function tagScripts(text, lines) {
|
|
|
2091
2091
|
const [s, e, kind] = marks[m];
|
|
2092
2092
|
out = out.slice(0, s) + `<${kind}>` + out.slice(s, e) + `</${kind}>` + out.slice(e);
|
|
2093
2093
|
}
|
|
2094
|
-
return
|
|
2094
|
+
return _chunk6FW3AZWNcjs.tidyScriptTags.call(void 0, out);
|
|
2095
2095
|
}
|
|
2096
2096
|
|
|
2097
2097
|
// src/pdf/line-wrap.ts
|
|
@@ -2242,8 +2242,15 @@ function wrapJoiner(prevText, nextText, lex) {
|
|
|
2242
2242
|
return " ";
|
|
2243
2243
|
}
|
|
2244
2244
|
var PARA_LAST_LINE = /* @__PURE__ */ new WeakMap();
|
|
2245
|
+
var PARA_FIRST_LEFT = /* @__PURE__ */ new WeakMap();
|
|
2245
2246
|
var PAGE_REF_TAIL = /(?:\t|…|·{2}|\.{3})\s*\d{1,4}(?:\s*\/\s*\d{1,4})?\s*$/;
|
|
2246
2247
|
var PAGE_HEAD_MARK = /^(?:[\u0000-\u001f\ue000-\uf8ff\u25a0-\u25ff\u2750-\u275f<〈《〔\[]|ㅇ\s)/;
|
|
2248
|
+
var PAGE_ITEM_HEAD = /^(?:\S{1,4}\t|\.\d{1,3}\s)/;
|
|
2249
|
+
var SENTENCE_END = /[.?!。][”"’」』)]?$/;
|
|
2250
|
+
var titleLike = (text) => {
|
|
2251
|
+
const t = text.replace(MARKUP, "").trim();
|
|
2252
|
+
return !t.includes("\n") && [...t].length <= 40 && !SENTENCE_END.test(t);
|
|
2253
|
+
};
|
|
2247
2254
|
var PAGE_BREAK_JOINS = /* @__PURE__ */ new WeakMap();
|
|
2248
2255
|
function joinPageBreakWraps(blocks, lex) {
|
|
2249
2256
|
const pageRight = /* @__PURE__ */ new Map();
|
|
@@ -2251,14 +2258,26 @@ function joinPageBreakWraps(blocks, lex) {
|
|
|
2251
2258
|
if (b.type !== "paragraph" || !b.bbox || !b.pageNumber) continue;
|
|
2252
2259
|
pageRight.set(b.pageNumber, Math.max(_nullishCoalesce(pageRight.get(b.pageNumber), () => ( -Infinity)), b.bbox.x + b.bbox.width));
|
|
2253
2260
|
}
|
|
2261
|
+
const pageLeft = /* @__PURE__ */ new Map();
|
|
2262
|
+
for (const b of blocks) {
|
|
2263
|
+
if (b.type !== "paragraph" || !b.bbox || !b.pageNumber) continue;
|
|
2264
|
+
pageLeft.set(b.pageNumber, Math.min(_nullishCoalesce(pageLeft.get(b.pageNumber), () => ( Infinity)), b.bbox.x));
|
|
2265
|
+
}
|
|
2254
2266
|
for (let i = blocks.length - 1; i > 0; i--) {
|
|
2255
2267
|
const a = blocks[i - 1], b = blocks[i];
|
|
2256
2268
|
if (!a.pageNumber || b.pageNumber !== a.pageNumber + 1 || !a.text || !b.text) continue;
|
|
2257
2269
|
if (a.type !== "paragraph" && a.type !== "list" || b.type !== "paragraph") continue;
|
|
2258
2270
|
const last = a.bbox && PARA_LAST_LINE.get(a.bbox), fs = last ? last.fontSize : 0;
|
|
2259
2271
|
if (!last || fs <= 0 || (_nullishCoalesce(pageRight.get(a.pageNumber), () => ( Infinity))) - last.right >= BODY_FULL_TOL * fs) continue;
|
|
2260
|
-
if (last.width < BODY_MIN_WIDTH_EM * fs || Math.
|
|
2261
|
-
|
|
2272
|
+
if (last.width < BODY_MIN_WIDTH_EM * fs || Math.abs((_nullishCoalesce(_optionalChain([b, 'access', _56 => _56.style, 'optionalAccess', _57 => _57.fontSize]), () => ( 0))) - fs) > 0.15 * fs) continue;
|
|
2273
|
+
const bt = b.text.replace(MARKUP, "");
|
|
2274
|
+
if (startsNewItem(a.text, b.text) || PAGE_REF_TAIL.test(a.text) || PAGE_ITEM_HEAD.test(bt)) continue;
|
|
2275
|
+
if (PAGE_HEAD_MARK.test(bt) && !(/^[\u25a0-\u25ff]/.test(bt) && a.text.includes(bt[0]))) continue;
|
|
2276
|
+
const firstLeft = b.bbox && PARA_FIRST_LEFT.get(b.bbox);
|
|
2277
|
+
const indented = firstLeft === void 0 || firstLeft - (_nullishCoalesce(pageLeft.get(b.pageNumber), () => ( firstLeft))) >= 0.3 * fs;
|
|
2278
|
+
if (indented && SENTENCE_END.test(a.text.replace(MARKUP, "").trimEnd())) continue;
|
|
2279
|
+
if (Math.round(_nullishCoalesce(_optionalChain([b, 'access', _58 => _58.style, 'optionalAccess', _59 => _59.fontSize]), () => ( 0))) !== Math.round(fs) && titleLike(b.text)) continue;
|
|
2280
|
+
if (/\t/.test(a.text.slice(a.text.lastIndexOf("\n") + 1).replace(/^\S{1,8}\t/, "")) && titleLike(bt.trim().split("\n")[0])) continue;
|
|
2262
2281
|
const head = a.text, joiner = wrapJoiner(a.text, b.text, lex);
|
|
2263
2282
|
a.text += joiner + b.text;
|
|
2264
2283
|
const later = b.bbox && PAGE_BREAK_JOINS.get(b.bbox) || [];
|
|
@@ -2305,7 +2324,7 @@ function bodyLineJoins(lines, lex) {
|
|
|
2305
2324
|
for (const l of lines) if (!HANGING.test(l.text) && l.right > inner) inner = l.right;
|
|
2306
2325
|
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;
|
|
2307
2326
|
const nextWordNoRoom = (a, b) => {
|
|
2308
|
-
const w = _optionalChain([b, 'access',
|
|
2327
|
+
const w = _optionalChain([b, 'access', _60 => _60.text, 'access', _61 => _61.trim, 'call', _62 => _62(), 'access', _63 => _63.match, 'call', _64 => _64(/^\S+/), 'optionalAccess', _65 => _65[0]]);
|
|
2309
2328
|
const n = [...b.text.trim()].length;
|
|
2310
2329
|
if (!w || n === 0) return false;
|
|
2311
2330
|
const em = (b.right - b.left) / n;
|
|
@@ -2481,7 +2500,7 @@ function cellTextToString(items, wrap) {
|
|
|
2481
2500
|
const merged = mergeSuperscriptRows(lines).map((line) => sortLineByX(line));
|
|
2482
2501
|
const textLines = merged.map((s) => {
|
|
2483
2502
|
if (s.length === 1) return s[0].text;
|
|
2484
|
-
if (s.length === 2 && /^[가-힣]$/.test(s[0].text) && /^[가-힣]$/.test(s[1].text) && !!_optionalChain([wrap, 'optionalAccess',
|
|
2503
|
+
if (s.length === 2 && /^[가-힣]$/.test(s[0].text) && /^[가-힣]$/.test(s[1].text) && !!_optionalChain([wrap, 'optionalAccess', _66 => _66.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;
|
|
2485
2504
|
const evenSpaced = detectEvenSpacedItems(s, true);
|
|
2486
2505
|
let result = s[0].text;
|
|
2487
2506
|
for (let j = 1; j < s.length; j++) {
|
|
@@ -2629,7 +2648,7 @@ function mergeCellTextLines(textLines, wrap) {
|
|
|
2629
2648
|
merged[merged.length - 1] = prev + curr.trim();
|
|
2630
2649
|
} else if (!wrap && /[,(]$/.test(prev.trim()) && curr.trim().length <= 15) {
|
|
2631
2650
|
merged[merged.length - 1] = prev + curr.trim();
|
|
2632
|
-
} else if (/[\d,]$/.test(prev) && /^[\d,]+[)\]]?$/.test(curr.trim()) && curr.trim().length <= 10 && !(/\d,\d{3}$/.test(prev) && /^\d/.test(curr.trim())) && !(/(?:^|[^\d,])\d{1,3}$/.test(prev) && /^(\d{1,3}(,\d{3})+|\d{1,3})$/.test(curr.trim()) && !_optionalChain([wrap, 'optionalAccess',
|
|
2651
|
+
} else if (/[\d,]$/.test(prev) && /^[\d,]+[)\]]?$/.test(curr.trim()) && curr.trim().length <= 10 && !(/\d,\d{3}$/.test(prev) && /^\d/.test(curr.trim())) && !(/(?:^|[^\d,])\d{1,3}$/.test(prev) && /^(\d{1,3}(,\d{3})+|\d{1,3})$/.test(curr.trim()) && !_optionalChain([wrap, 'optionalAccess', _67 => _67.wraps, 'access', _68 => _68[i - 1]])) && !(/(?:^|\s)\d{1,7}$/.test(prev) && /^\d{1,7}$/.test(curr.trim()) && !_optionalChain([wrap, 'optionalAccess', _69 => _69.wraps, 'access', _70 => _70[i - 1]]))) {
|
|
2633
2652
|
merged[merged.length - 1] = prev + curr.trim();
|
|
2634
2653
|
} else {
|
|
2635
2654
|
merged.push(curr);
|
|
@@ -2699,7 +2718,7 @@ function normalizeUndersegmentedTable(originalCells, colXs, items, rowYs) {
|
|
|
2699
2718
|
if (numRows > MAX_UNDERSEGMENTED_ROWS || numCols < MIN_UNDERSEGMENTED_COLUMNS) return null;
|
|
2700
2719
|
if (items.length === 0) return null;
|
|
2701
2720
|
if (numRows >= 3) {
|
|
2702
|
-
if (_optionalChain([rowYs, 'optionalAccess',
|
|
2721
|
+
if (_optionalChain([rowYs, 'optionalAccess', _71 => _71.length]) !== numRows + 1) return null;
|
|
2703
2722
|
const rebuilt2 = [];
|
|
2704
2723
|
let expanded = 0;
|
|
2705
2724
|
for (let r = 0; r < numRows; r++) {
|
|
@@ -2852,7 +2871,7 @@ function dominantStyle(items) {
|
|
|
2852
2871
|
let maxCount = 0, dominantSize = 0;
|
|
2853
2872
|
for (const i of items) {
|
|
2854
2873
|
if (i.fontSize <= 0) continue;
|
|
2855
|
-
const count = (freq.get(i.fontSize) || 0) + Math.max(1, _nullishCoalesce(_optionalChain([i, 'access',
|
|
2874
|
+
const count = (freq.get(i.fontSize) || 0) + Math.max(1, _nullishCoalesce(_optionalChain([i, 'access', _72 => _72.text, 'access', _73 => _73.match, 'call', _74 => _74(/[\p{L}\p{N}]/gu), 'optionalAccess', _75 => _75.length]), () => ( 0)));
|
|
2856
2875
|
freq.set(i.fontSize, count);
|
|
2857
2876
|
if (count > maxCount) {
|
|
2858
2877
|
maxCount = count;
|
|
@@ -2860,7 +2879,7 @@ function dominantStyle(items) {
|
|
|
2860
2879
|
}
|
|
2861
2880
|
}
|
|
2862
2881
|
if (dominantSize === 0) return void 0;
|
|
2863
|
-
const fontName = _optionalChain([items, 'access',
|
|
2882
|
+
const fontName = _optionalChain([items, 'access', _76 => _76.find, 'call', _77 => _77((i) => i.fontSize === dominantSize), 'optionalAccess', _78 => _78.fontName]) || void 0;
|
|
2864
2883
|
return fontName ? { fontSize: dominantSize, fontName } : { fontSize: dominantSize };
|
|
2865
2884
|
}
|
|
2866
2885
|
function normalizeItems(rawItems) {
|
|
@@ -2980,7 +2999,7 @@ function splitAroundOverlays(c, overlays) {
|
|
|
2980
2999
|
const ov = overlays.filter((o) => {
|
|
2981
3000
|
for (let at = c.text.indexOf(o.text); at >= 0; at = c.text.indexOf(o.text, at + 1)) {
|
|
2982
3001
|
const prefix = c.text.slice(0, at);
|
|
2983
|
-
const est = c.x + glyphUnits(prefix.replace(/\s+/g, "")) * a0 + (_nullishCoalesce(_optionalChain([prefix, 'access',
|
|
3002
|
+
const est = c.x + glyphUnits(prefix.replace(/\s+/g, "")) * a0 + (_nullishCoalesce(_optionalChain([prefix, 'access', _79 => _79.match, 'call', _80 => _80(/\s+/g), 'optionalAccess', _81 => _81.length]), () => ( 0))) * ws;
|
|
2984
3003
|
if (Math.abs(est - o.x) <= OVERLAY_DUP_EM * fs) return false;
|
|
2985
3004
|
}
|
|
2986
3005
|
return true;
|
|
@@ -3100,7 +3119,7 @@ function mergeSuperscriptLines(lines) {
|
|
|
3100
3119
|
return result;
|
|
3101
3120
|
}
|
|
3102
3121
|
function mergeLineSimple(items) {
|
|
3103
|
-
if (items.length <= 1) return _optionalChain([items, 'access',
|
|
3122
|
+
if (items.length <= 1) return _optionalChain([items, 'access', _82 => _82[0], 'optionalAccess', _83 => _83.text]) || "";
|
|
3104
3123
|
const sorted = sortLineByX([...items]);
|
|
3105
3124
|
const isEvenSpaced = detectEvenSpacedItems(sorted);
|
|
3106
3125
|
let result = sorted[0].text;
|
|
@@ -3245,7 +3264,7 @@ function splitTrailingColumnRegion(items) {
|
|
|
3245
3264
|
}
|
|
3246
3265
|
function panelBlocks(items, panel, pageNum) {
|
|
3247
3266
|
const lines = groupByY([...items].sort((a, b) => b.y - a.y || a.x - b.x));
|
|
3248
|
-
const faceOf = (line) => _nullishCoalesce(_optionalChain([dominantStyle, 'call',
|
|
3267
|
+
const faceOf = (line) => _nullishCoalesce(_optionalChain([dominantStyle, 'call', _84 => _84(line), 'optionalAccess', _85 => _85.fontName]), () => ( ""));
|
|
3249
3268
|
const runs = [];
|
|
3250
3269
|
for (const line of lines) {
|
|
3251
3270
|
const last = runs[runs.length - 1];
|
|
@@ -3420,7 +3439,7 @@ function validWrapBands(items, bands) {
|
|
|
3420
3439
|
}
|
|
3421
3440
|
function inheritedWrapBands(items) {
|
|
3422
3441
|
const source = XY_WRAP_ITEMS.get(items[0]);
|
|
3423
|
-
const present = _optionalChain([source, 'optionalAccess',
|
|
3442
|
+
const present = _optionalChain([source, 'optionalAccess', _86 => _86.length]) === items.length ? new Set(items) : null;
|
|
3424
3443
|
const sameLeaf = present && source.every((item) => present.has(item));
|
|
3425
3444
|
return sameLeaf ? validWrapBands(items, _nullishCoalesce(XY_WRAP_BANDS.get(items[0]), () => ( []))) : [];
|
|
3426
3445
|
}
|
|
@@ -3459,7 +3478,7 @@ function wrappedLineBands(items, inherited) {
|
|
|
3459
3478
|
left: box.x,
|
|
3460
3479
|
right: box.x + box.width,
|
|
3461
3480
|
y: row.reduce((n, i) => n + i.y, 0) / row.length,
|
|
3462
|
-
fontSize: _nullishCoalesce(_optionalChain([dominantStyle, 'call',
|
|
3481
|
+
fontSize: _nullishCoalesce(_optionalChain([dominantStyle, 'call', _87 => _87(row), 'optionalAccess', _88 => _88.fontSize]), () => ( 0)),
|
|
3463
3482
|
sources: row.map((item) => ({ item, state: { ...item } }))
|
|
3464
3483
|
};
|
|
3465
3484
|
});
|
|
@@ -3595,10 +3614,10 @@ function pushLineParagraphs(out, yLines, pageNum, lex) {
|
|
|
3595
3614
|
const lines = attachDropCaps(yLines).map((items) => ({ items, text: mergeLineSimple(items) })).filter((l) => l.text.trim());
|
|
3596
3615
|
const geo = lines.map((l) => {
|
|
3597
3616
|
const b = computeBBox(l.items, pageNum);
|
|
3598
|
-
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',
|
|
3617
|
+
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', _89 => _89(l.items), 'optionalAccess', _90 => _90.fontSize]), () => ( 0)) };
|
|
3599
3618
|
});
|
|
3600
3619
|
const joins = bodyLineJoins(geo, lex);
|
|
3601
|
-
const first = _optionalChain([lines, 'access',
|
|
3620
|
+
const first = _optionalChain([lines, 'access', _91 => _91[0], 'optionalAccess', _92 => _92.items, 'access', _93 => _93[0]]);
|
|
3602
3621
|
const bands = first ? _nullishCoalesce(XY_WRAP_BANDS.get(first), () => ( [])) : [];
|
|
3603
3622
|
const hasBand = (top, bottom) => {
|
|
3604
3623
|
let lo = 0, hi = bands.length;
|
|
@@ -3626,6 +3645,7 @@ function pushLineParagraphs(out, yLines, pageNum, lex) {
|
|
|
3626
3645
|
joins[1] = "\n";
|
|
3627
3646
|
}
|
|
3628
3647
|
for (let i = 0; i < lines.length; ) {
|
|
3648
|
+
const first2 = i;
|
|
3629
3649
|
let text = lines[i].text;
|
|
3630
3650
|
const items = [...lines[i].items];
|
|
3631
3651
|
const srcLines = [lines[i].items];
|
|
@@ -3640,6 +3660,7 @@ function pushLineParagraphs(out, yLines, pageNum, lex) {
|
|
|
3640
3660
|
for (const it of items) faces.set(it.fontName, (_nullishCoalesce(faces.get(it.fontName), () => ( 0))) + it.text.length);
|
|
3641
3661
|
FACE_CHARS.set(block, faces);
|
|
3642
3662
|
PARA_LAST_LINE.set(block.bbox, { right: geo[i].right, width: geo[i].right - geo[i].left, fontSize: geo[i].fontSize });
|
|
3663
|
+
PARA_FIRST_LEFT.set(block.bbox, geo[first2].left);
|
|
3643
3664
|
out.push(block);
|
|
3644
3665
|
i++;
|
|
3645
3666
|
}
|
|
@@ -3662,15 +3683,15 @@ function computeMedianFontSizeFromFreq(freq) {
|
|
|
3662
3683
|
function detectHeadings(blocks, medianFontSize) {
|
|
3663
3684
|
for (let bi = 0; bi < blocks.length; bi++) {
|
|
3664
3685
|
const block = blocks[bi];
|
|
3665
|
-
if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access',
|
|
3686
|
+
if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access', _94 => _94.style, 'optionalAccess', _95 => _95.fontSize])) continue;
|
|
3666
3687
|
const text = block.text.trim();
|
|
3667
3688
|
if (text.length === 0 || text.length > 200) continue;
|
|
3668
3689
|
if (/^\d+$/.test(text) && !isChapterNumber(block, blocks[bi + 1], medianFontSize)) continue;
|
|
3669
3690
|
const ratio = block.style.fontSize / medianFontSize;
|
|
3670
3691
|
let level = 0;
|
|
3671
|
-
if (ratio >=
|
|
3672
|
-
else if (ratio >=
|
|
3673
|
-
else if (ratio >=
|
|
3692
|
+
if (ratio >= _chunk6FW3AZWNcjs.HEADING_RATIO_H1) level = 1;
|
|
3693
|
+
else if (ratio >= _chunk6FW3AZWNcjs.HEADING_RATIO_H2) level = 2;
|
|
3694
|
+
else if (ratio >= _chunk6FW3AZWNcjs.HEADING_RATIO_H3) level = 3;
|
|
3674
3695
|
if (level > 0) {
|
|
3675
3696
|
block.type = "heading";
|
|
3676
3697
|
block.level = level;
|
|
@@ -3679,21 +3700,21 @@ function detectHeadings(blocks, medianFontSize) {
|
|
|
3679
3700
|
}
|
|
3680
3701
|
}
|
|
3681
3702
|
function isChapterNumber(block, next, medianFontSize) {
|
|
3682
|
-
const size = _nullishCoalesce(_optionalChain([block, 'access',
|
|
3683
|
-
const nextSize = _nullishCoalesce(_optionalChain([next, 'optionalAccess',
|
|
3684
|
-
const text = _nullishCoalesce(_optionalChain([next, 'optionalAccess',
|
|
3685
|
-
const a = block.bbox, b = _optionalChain([next, 'optionalAccess',
|
|
3686
|
-
return /^\d{1,2}$/.test(_nullishCoalesce(_optionalChain([block, 'access',
|
|
3703
|
+
const size = _nullishCoalesce(_optionalChain([block, 'access', _96 => _96.style, 'optionalAccess', _97 => _97.fontSize]), () => ( 0));
|
|
3704
|
+
const nextSize = _nullishCoalesce(_optionalChain([next, 'optionalAccess', _98 => _98.style, 'optionalAccess', _99 => _99.fontSize]), () => ( 0));
|
|
3705
|
+
const text = _nullishCoalesce(_optionalChain([next, 'optionalAccess', _100 => _100.text, 'optionalAccess', _101 => _101.trim, 'call', _102 => _102()]), () => ( ""));
|
|
3706
|
+
const a = block.bbox, b = _optionalChain([next, 'optionalAccess', _103 => _103.bbox]);
|
|
3707
|
+
return /^\d{1,2}$/.test(_nullishCoalesce(_optionalChain([block, 'access', _104 => _104.text, 'optionalAccess', _105 => _105.trim, 'call', _106 => _106()]), () => ( ""))) && size >= medianFontSize * 2.5 && !!next && (next.type === "paragraph" || next.type === "heading") && next.pageNumber === block.pageNumber && nextSize >= medianFontSize * _chunk6FW3AZWNcjs.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;
|
|
3687
3708
|
}
|
|
3688
3709
|
function mergeStackedHeadingLines(blocks, medianFontSize) {
|
|
3689
3710
|
for (let i = 0; i < blocks.length - 1; ) {
|
|
3690
3711
|
const a = blocks[i], b = blocks[i + 1];
|
|
3691
3712
|
const ab = a.bbox, bb = b.bbox;
|
|
3692
|
-
const af = _nullishCoalesce(_optionalChain([a, 'access',
|
|
3713
|
+
const af = _nullishCoalesce(_optionalChain([a, 'access', _107 => _107.style, 'optionalAccess', _108 => _108.fontSize]), () => ( 0)), bf = _nullishCoalesce(_optionalChain([b, 'access', _109 => _109.style, 'optionalAccess', _110 => _110.fontSize]), () => ( 0));
|
|
3693
3714
|
const gap = ab && bb ? ab.y - (bb.y + bb.height) : Infinity;
|
|
3694
|
-
const centered = ab && bb && _optionalChain([a, 'access',
|
|
3715
|
+
const centered = ab && bb && _optionalChain([a, 'access', _111 => _111.style, 'optionalAccess', _112 => _112.fontName]) === _optionalChain([b, 'access', _113 => _113.style, 'optionalAccess', _114 => _114.fontName]) && Math.abs(ab.x + ab.width / 2 - (bb.x + bb.width / 2)) <= Math.max(5, af * 0.5);
|
|
3695
3716
|
const sameAnchor = ab && bb && Math.abs(ab.x - bb.x) <= 5;
|
|
3696
|
-
const wrapped = sameAnchor && _optionalChain([a, 'access',
|
|
3717
|
+
const wrapped = sameAnchor && _optionalChain([a, 'access', _115 => _115.style, 'optionalAccess', _116 => _116.fontName]) === _optionalChain([b, 'access', _117 => _117.style, 'optionalAccess', _118 => _118.fontName]) && af === bf && ab.width >= bb.width * 0.95 && (_nullishCoalesce(_optionalChain([a, 'access', _119 => _119.text, 'optionalAccess', _120 => _120.trim, 'call', _121 => _121(), 'access', _122 => _122.split, 'call', _123 => _123(/\s+/), 'access', _124 => _124.length]), () => ( 0))) >= 3;
|
|
3697
3718
|
const displayStack = centered && gap <= Math.min(af, bf) * 0.3 && Math.max(af, bf) <= Math.min(af, bf) * 1.45;
|
|
3698
3719
|
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)) {
|
|
3699
3720
|
i++;
|
|
@@ -3722,25 +3743,25 @@ function detectTypographyHeadings(blocks) {
|
|
|
3722
3743
|
if (page.some((block) => block.type === "heading")) continue;
|
|
3723
3744
|
const faceWeight = /* @__PURE__ */ new Map();
|
|
3724
3745
|
for (const block of page) {
|
|
3725
|
-
if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access',
|
|
3746
|
+
if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access', _125 => _125.style, 'optionalAccess', _126 => _126.fontName])) continue;
|
|
3726
3747
|
const faces = FACE_CHARS.get(block);
|
|
3727
3748
|
if (faces) for (const [face, n] of faces) faceWeight.set(face, (_nullishCoalesce(faceWeight.get(face), () => ( 0))) + n);
|
|
3728
3749
|
else faceWeight.set(block.style.fontName, (_nullishCoalesce(faceWeight.get(block.style.fontName), () => ( 0))) + block.text.length);
|
|
3729
3750
|
}
|
|
3730
|
-
const bodyFace = _optionalChain([[...faceWeight], 'access',
|
|
3751
|
+
const bodyFace = _optionalChain([[...faceWeight], 'access', _127 => _127.sort, 'call', _128 => _128((a, b) => b[1] - a[1]), 'access', _129 => _129[0], 'optionalAccess', _130 => _130[0]]);
|
|
3731
3752
|
if (!bodyFace || (_nullishCoalesce(faceWeight.get(bodyFace), () => ( 0))) < 250) continue;
|
|
3732
3753
|
const sizeWeight = /* @__PURE__ */ new Map();
|
|
3733
3754
|
for (const block of page) {
|
|
3734
|
-
if (block.type !== "paragraph" || !_optionalChain([block, 'access',
|
|
3755
|
+
if (block.type !== "paragraph" || !_optionalChain([block, 'access', _131 => _131.style, 'optionalAccess', _132 => _132.fontSize])) continue;
|
|
3735
3756
|
const faces = FACE_CHARS.get(block);
|
|
3736
|
-
const chars = faces ? _nullishCoalesce(faces.get(bodyFace), () => ( 0)) : block.style.fontName === bodyFace ? _nullishCoalesce(_optionalChain([block, 'access',
|
|
3757
|
+
const chars = faces ? _nullishCoalesce(faces.get(bodyFace), () => ( 0)) : block.style.fontName === bodyFace ? _nullishCoalesce(_optionalChain([block, 'access', _133 => _133.text, 'optionalAccess', _134 => _134.length]), () => ( 0)) : 0;
|
|
3737
3758
|
if (chars) sizeWeight.set(block.style.fontSize, (_nullishCoalesce(sizeWeight.get(block.style.fontSize), () => ( 0))) + chars);
|
|
3738
3759
|
}
|
|
3739
|
-
const bodySize = _nullishCoalesce(_optionalChain([[...sizeWeight], 'access',
|
|
3760
|
+
const bodySize = _nullishCoalesce(_optionalChain([[...sizeWeight], 'access', _135 => _135.sort, 'call', _136 => _136((a, b) => b[1] - a[1]), 'access', _137 => _137[0], 'optionalAccess', _138 => _138[0]]), () => ( 0));
|
|
3740
3761
|
for (let i = 0; i < page.length; i++) {
|
|
3741
3762
|
const block = page[i];
|
|
3742
3763
|
const { text, bbox, style } = block;
|
|
3743
|
-
if (block.type !== "paragraph" || !text || !bbox || !_optionalChain([style, 'optionalAccess',
|
|
3764
|
+
if (block.type !== "paragraph" || !text || !bbox || !_optionalChain([style, 'optionalAccess', _139 => _139.fontName]) || !style.fontSize) continue;
|
|
3744
3765
|
const title = text.trim();
|
|
3745
3766
|
const numbered = /^\d+(?:\.\d+)*\.?\s+[A-Z가-힣]/.test(title);
|
|
3746
3767
|
const faces = FACE_CHARS.get(block);
|
|
@@ -3770,16 +3791,16 @@ function detectDocumentStyleHeadings(blocks) {
|
|
|
3770
3791
|
for (const page of byPage.values()) {
|
|
3771
3792
|
const faceChars = /* @__PURE__ */ new Map();
|
|
3772
3793
|
for (const block of page) {
|
|
3773
|
-
if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access',
|
|
3794
|
+
if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access', _140 => _140.style, 'optionalAccess', _141 => _141.fontName])) continue;
|
|
3774
3795
|
faceChars.set(block.style.fontName, (_nullishCoalesce(faceChars.get(block.style.fontName), () => ( 0))) + block.text.length);
|
|
3775
3796
|
}
|
|
3776
|
-
const bodyFace = _optionalChain([[...faceChars], 'access',
|
|
3797
|
+
const bodyFace = _optionalChain([[...faceChars], 'access', _142 => _142.sort, 'call', _143 => _143((a, b) => b[1] - a[1]), 'access', _144 => _144[0], 'optionalAccess', _145 => _145[0]]);
|
|
3777
3798
|
if (!bodyFace || (_nullishCoalesce(faceChars.get(bodyFace), () => ( 0))) < 100) continue;
|
|
3778
|
-
const labels = page.filter((b) => b.type === "paragraph" && b.text && b.bbox && _optionalChain([b, 'access',
|
|
3799
|
+
const labels = page.filter((b) => b.type === "paragraph" && b.text && b.bbox && _optionalChain([b, 'access', _146 => _146.style, 'optionalAccess', _147 => _147.fontName]) && b.style.fontName !== bodyFace && b.text.trim().length >= 3 && b.text.trim().length <= 40);
|
|
3779
3800
|
for (const label of labels) {
|
|
3780
|
-
const peers = labels.filter((b) => _optionalChain([b, 'access',
|
|
3801
|
+
const peers = labels.filter((b) => _optionalChain([b, 'access', _148 => _148.style, 'optionalAccess', _149 => _149.fontName]) === _optionalChain([label, 'access', _150 => _150.style, 'optionalAccess', _151 => _151.fontName]) && Math.abs(b.bbox.y - label.bbox.y) <= 3 && Math.abs(b.bbox.x - label.bbox.x) >= 60);
|
|
3781
3802
|
if (peers.length < 2) continue;
|
|
3782
|
-
const value = page.find((b) => b.type === "paragraph" && b.bbox && _optionalChain([b, 'access',
|
|
3803
|
+
const value = page.find((b) => b.type === "paragraph" && b.bbox && _optionalChain([b, 'access', _152 => _152.style, 'optionalAccess', _153 => _153.fontName]) !== _optionalChain([label, 'access', _154 => _154.style, 'optionalAccess', _155 => _155.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);
|
|
3783
3804
|
if (value) {
|
|
3784
3805
|
label.type = "heading";
|
|
3785
3806
|
label.level = 2;
|
|
@@ -3788,7 +3809,7 @@ function detectDocumentStyleHeadings(blocks) {
|
|
|
3788
3809
|
const first = page.find((b) => b.type !== "image" && b.type !== "separator");
|
|
3789
3810
|
const second = page[page.indexOf(first) + 1];
|
|
3790
3811
|
const third = page[page.indexOf(first) + 2];
|
|
3791
|
-
if (!first || !second || !third || first.type !== "list" && first.type !== "paragraph" || second.type !== "paragraph" || !first.text || !second.text || !first.bbox || !second.bbox || !_optionalChain([first, 'access',
|
|
3812
|
+
if (!first || !second || !third || first.type !== "list" && first.type !== "paragraph" || second.type !== "paragraph" || !first.text || !second.text || !first.bbox || !second.bbox || !_optionalChain([first, 'access', _156 => _156.style, 'optionalAccess', _157 => _157.fontName]) || !_optionalChain([second, 'access', _158 => _158.style, 'optionalAccess', _159 => _159.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', _160 => _160.style, 'optionalAccess', _161 => _161.fontName]) !== bodyFace) continue;
|
|
3792
3813
|
first.type = "heading";
|
|
3793
3814
|
first.level = 1;
|
|
3794
3815
|
first.text = `${first.text.trim()} ${second.text.trim()}`;
|
|
@@ -3812,18 +3833,18 @@ function detectSiblingStyleHeadings(blocks) {
|
|
|
3812
3833
|
for (const page of byPage.values()) {
|
|
3813
3834
|
const bodyChars = /* @__PURE__ */ new Map();
|
|
3814
3835
|
for (const block of page) {
|
|
3815
|
-
if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access',
|
|
3836
|
+
if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access', _162 => _162.style, 'optionalAccess', _163 => _163.fontName])) continue;
|
|
3816
3837
|
const face = block.style.fontName;
|
|
3817
3838
|
bodyChars.set(face, (_nullishCoalesce(bodyChars.get(face), () => ( 0))) + block.text.length);
|
|
3818
3839
|
}
|
|
3819
|
-
const bodyFace = _optionalChain([[...bodyChars], 'access',
|
|
3820
|
-
const anchors = page.filter((b) => b.type === "heading" && b.text && _optionalChain([b, 'access',
|
|
3840
|
+
const bodyFace = _optionalChain([[...bodyChars], 'access', _164 => _164.sort, 'call', _165 => _165((a, b) => b[1] - a[1]), 'access', _166 => _166[0], 'optionalAccess', _167 => _167[0]]);
|
|
3841
|
+
const anchors = page.filter((b) => b.type === "heading" && b.text && _optionalChain([b, 'access', _168 => _168.style, 'optionalAccess', _169 => _169.fontName]) && b.style.fontName !== bodyFace);
|
|
3821
3842
|
for (const anchor of anchors) {
|
|
3822
3843
|
const numbered = /^([A-Z])\.\d+\s+/.exec(anchor.text.trim());
|
|
3823
3844
|
const lettered = /^([A-Z])\s+/.exec(anchor.text.trim());
|
|
3824
|
-
const peers = anchors.filter((b) => _optionalChain([b, 'access',
|
|
3845
|
+
const peers = anchors.filter((b) => _optionalChain([b, 'access', _170 => _170.style, 'optionalAccess', _171 => _171.fontName]) === _optionalChain([anchor, 'access', _172 => _172.style, 'optionalAccess', _173 => _173.fontName]) && Math.abs((_nullishCoalesce(_optionalChain([b, 'access', _174 => _174.style, 'optionalAccess', _175 => _175.fontSize]), () => ( 0))) - (_nullishCoalesce(_optionalChain([anchor, 'access', _176 => _176.style, 'optionalAccess', _177 => _177.fontSize]), () => ( 0)))) < 0.5);
|
|
3825
3846
|
if (peers.length < 2 && !numbered && !lettered) continue;
|
|
3826
|
-
const candidates = page.filter((b) => b.type === "paragraph" && b.text && b.bbox && _optionalChain([b, 'access',
|
|
3847
|
+
const candidates = page.filter((b) => b.type === "paragraph" && b.text && b.bbox && _optionalChain([b, 'access', _178 => _178.style, 'optionalAccess', _179 => _179.fontName]) === _optionalChain([anchor, 'access', _180 => _180.style, 'optionalAccess', _181 => _181.fontName]) && Math.abs((_nullishCoalesce(_optionalChain([b, 'access', _182 => _182.style, 'optionalAccess', _183 => _183.fontSize]), () => ( 0))) - (_nullishCoalesce(_optionalChain([anchor, 'access', _184 => _184.style, 'optionalAccess', _185 => _185.fontSize]), () => ( 0)))) < 0.5 && b.text.trim().length >= 3 && b.text.trim().length <= 80 && b.bbox.height <= (_nullishCoalesce(_optionalChain([b, 'access', _186 => _186.style, 'optionalAccess', _187 => _187.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()));
|
|
3827
3848
|
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));
|
|
3828
3849
|
if (siblings.length < (numbered || lettered ? 1 : 2)) continue;
|
|
3829
3850
|
for (const sibling of siblings) {
|
|
@@ -3842,13 +3863,13 @@ function detectRepeatedPageLabels(blocks) {
|
|
|
3842
3863
|
}
|
|
3843
3864
|
for (const page of byPage.values()) {
|
|
3844
3865
|
const bodyChars = /* @__PURE__ */ new Map();
|
|
3845
|
-
for (const b of page) if (b.type === "paragraph" && b.text && _optionalChain([b, 'access',
|
|
3866
|
+
for (const b of page) if (b.type === "paragraph" && b.text && _optionalChain([b, 'access', _188 => _188.style, 'optionalAccess', _189 => _189.fontName])) {
|
|
3846
3867
|
const faces = FACE_CHARS.get(b);
|
|
3847
3868
|
if (faces) for (const [face, n] of faces) bodyChars.set(face, (_nullishCoalesce(bodyChars.get(face), () => ( 0))) + n);
|
|
3848
3869
|
else bodyChars.set(b.style.fontName, (_nullishCoalesce(bodyChars.get(b.style.fontName), () => ( 0))) + b.text.length);
|
|
3849
3870
|
}
|
|
3850
|
-
const bodyFace = _optionalChain([[...bodyChars], 'access',
|
|
3851
|
-
const candidates = page.filter((b) => b.type === "paragraph" && b.text && b.bbox && _optionalChain([b, 'access',
|
|
3871
|
+
const bodyFace = _optionalChain([[...bodyChars], 'access', _190 => _190.sort, 'call', _191 => _191((a, b) => b[1] - a[1]), 'access', _192 => _192[0], 'optionalAccess', _193 => _193[0]]);
|
|
3872
|
+
const candidates = page.filter((b) => b.type === "paragraph" && b.text && b.bbox && _optionalChain([b, 'access', _194 => _194.style, 'optionalAccess', _195 => _195.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);
|
|
3852
3873
|
const groups = /* @__PURE__ */ new Map();
|
|
3853
3874
|
for (const b of candidates) {
|
|
3854
3875
|
const key = `${b.style.fontName}:${b.style.fontSize}`;
|
|
@@ -3884,19 +3905,19 @@ function detectPageLeadHeadings(blocks) {
|
|
|
3884
3905
|
for (const page of byPage.values()) {
|
|
3885
3906
|
const content = page.filter((b) => b.type !== "image" && b.type !== "separator" && !(b.type === "paragraph" && !b.style));
|
|
3886
3907
|
const [first, second, third] = content;
|
|
3887
|
-
if (!_optionalChain([first, 'optionalAccess',
|
|
3908
|
+
if (!_optionalChain([first, 'optionalAccess', _196 => _196.bbox]) || !first.text || !_optionalChain([first, 'access', _197 => _197.style, 'optionalAccess', _198 => _198.fontSize]) || !second) continue;
|
|
3888
3909
|
const firstText = first.text.trim();
|
|
3889
3910
|
const captionLike = /^(?:Figure|Fig\.?|Table|표|그림)\s*\d/i;
|
|
3890
3911
|
const hasImage = page.some((b) => b.type === "image");
|
|
3891
|
-
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',
|
|
3912
|
+
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', _199 => _199.text, 'optionalAccess', _200 => _200.trim, 'call', _201 => _201()]), () => ( ""))) && (_nullishCoalesce(_optionalChain([second, 'access', _202 => _202.text, 'optionalAccess', _203 => _203.length]), () => ( 0))) >= 100 && second.bbox && first.bbox.y - (second.bbox.y + second.bbox.height) >= first.style.fontSize);
|
|
3892
3913
|
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);
|
|
3893
|
-
const firstIsSection = first.type === "list" && /^\d+\.\s+[A-Z][A-Z\s]{12,}$/.test(firstText) && second.type === "paragraph" && (_nullishCoalesce(_optionalChain([second, 'access',
|
|
3914
|
+
const firstIsSection = first.type === "list" && /^\d+\.\s+[A-Z][A-Z\s]{12,}$/.test(firstText) && second.type === "paragraph" && (_nullishCoalesce(_optionalChain([second, 'access', _204 => _204.text, 'optionalAccess', _205 => _205.length]), () => ( 0))) >= 100;
|
|
3894
3915
|
if (firstIsTitle || firstAboveProse || firstIsSection) {
|
|
3895
3916
|
first.type = "heading";
|
|
3896
3917
|
first.level = 1;
|
|
3897
3918
|
}
|
|
3898
|
-
if (first.type !== "heading" || captionLike.test(firstText) || second.type !== "paragraph" || !second.text || !second.bbox || !_optionalChain([second, 'access',
|
|
3899
|
-
const distinctFace = _optionalChain([third, 'access',
|
|
3919
|
+
if (first.type !== "heading" || captionLike.test(firstText) || second.type !== "paragraph" || !second.text || !second.bbox || !_optionalChain([second, 'access', _206 => _206.style, 'optionalAccess', _207 => _207.fontName]) || !second.style.fontSize || !_optionalChain([third, 'optionalAccess', _208 => _208.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;
|
|
3920
|
+
const distinctFace = _optionalChain([third, 'access', _209 => _209.style, 'optionalAccess', _210 => _210.fontName]) !== second.style.fontName;
|
|
3900
3921
|
const namedContents = /^Table of Contents$/i.test(second.text.trim());
|
|
3901
3922
|
if (distinctFace && third.text.length >= 60 || namedContents) {
|
|
3902
3923
|
second.type = "heading";
|
|
@@ -3907,24 +3928,24 @@ function detectPageLeadHeadings(blocks) {
|
|
|
3907
3928
|
function refineDocumentStyleHeadings(blocks) {
|
|
3908
3929
|
const faceChars = /* @__PURE__ */ new Map();
|
|
3909
3930
|
for (const block of blocks) {
|
|
3910
|
-
if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access',
|
|
3931
|
+
if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access', _211 => _211.style, 'optionalAccess', _212 => _212.fontName])) continue;
|
|
3911
3932
|
faceChars.set(block.style.fontName, (_nullishCoalesce(faceChars.get(block.style.fontName), () => ( 0))) + block.text.length);
|
|
3912
3933
|
}
|
|
3913
3934
|
const [bodyFace, bodyChars] = _nullishCoalesce([...faceChars].sort((a, b) => b[1] - a[1])[0], () => ( []));
|
|
3914
3935
|
if (!bodyFace || !bodyChars || bodyChars < 300) return;
|
|
3915
3936
|
for (let i = 0; i < blocks.length; i++) {
|
|
3916
3937
|
const block = blocks[i];
|
|
3917
|
-
const text = _nullishCoalesce(_optionalChain([block, 'access',
|
|
3938
|
+
const text = _nullishCoalesce(_optionalChain([block, 'access', _213 => _213.text, 'optionalAccess', _214 => _214.trim, 'call', _215 => _215()]), () => ( ""));
|
|
3918
3939
|
if (block.type === "heading" && /(?:https?:\/\/|www\.|^arxiv:|^doi:)/i.test(text)) {
|
|
3919
3940
|
block.type = "paragraph";
|
|
3920
3941
|
block.level = void 0;
|
|
3921
3942
|
continue;
|
|
3922
3943
|
}
|
|
3923
3944
|
const box = block.bbox, style = block.style;
|
|
3924
|
-
if (block.type !== "paragraph" || !box || !_optionalChain([style, 'optionalAccess',
|
|
3945
|
+
if (block.type !== "paragraph" || !box || !_optionalChain([style, 'optionalAccess', _216 => _216.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;
|
|
3925
3946
|
const previous = blocks[i - 1], next = blocks[i + 1];
|
|
3926
|
-
const pb = _optionalChain([previous, 'optionalAccess',
|
|
3927
|
-
if (!pb || !nb || previous.pageNumber !== block.pageNumber || next.pageNumber !== block.pageNumber || previous.type !== "paragraph" && previous.type !== "heading" || next.type !== "paragraph" || _optionalChain([next, 'access',
|
|
3947
|
+
const pb = _optionalChain([previous, 'optionalAccess', _217 => _217.bbox]), nb = _optionalChain([next, 'optionalAccess', _218 => _218.bbox]);
|
|
3948
|
+
if (!pb || !nb || previous.pageNumber !== block.pageNumber || next.pageNumber !== block.pageNumber || previous.type !== "paragraph" && previous.type !== "heading" || next.type !== "paragraph" || _optionalChain([next, 'access', _219 => _219.style, 'optionalAccess', _220 => _220.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;
|
|
3928
3949
|
block.type = "heading";
|
|
3929
3950
|
block.level = 2;
|
|
3930
3951
|
}
|
|
@@ -3974,7 +3995,7 @@ function detectMarkerHeadings(blocks) {
|
|
|
3974
3995
|
block.level = 4;
|
|
3975
3996
|
continue;
|
|
3976
3997
|
}
|
|
3977
|
-
if (/^[가-힣]{2,6}$/.test(text) && _optionalChain([block, 'access',
|
|
3998
|
+
if (/^[가-힣]{2,6}$/.test(text) && _optionalChain([block, 'access', _221 => _221.style, 'optionalAccess', _222 => _222.fontSize])) {
|
|
3978
3999
|
const prev = blocks[i - 1];
|
|
3979
4000
|
const next = blocks[i + 1];
|
|
3980
4001
|
const prevIsStructural = !prev || prev.type === "table" || prev.type === "heading" || prev.type === "separator";
|
|
@@ -4015,7 +4036,7 @@ function detectTableCaptions(blocks) {
|
|
|
4015
4036
|
block.table.caption = blocks[i - 1].text.trim();
|
|
4016
4037
|
blocks.splice(i - 1, 1);
|
|
4017
4038
|
i--;
|
|
4018
|
-
} else if (isCaptionCandidate(blocks[i + 1], block) && _optionalChain([blocks, 'access',
|
|
4039
|
+
} else if (isCaptionCandidate(blocks[i + 1], block) && _optionalChain([blocks, 'access', _223 => _223[i + 2], 'optionalAccess', _224 => _224.type]) !== "table") {
|
|
4019
4040
|
block.table.caption = blocks[i + 1].text.trim();
|
|
4020
4041
|
blocks.splice(i + 1, 1);
|
|
4021
4042
|
}
|
|
@@ -4234,7 +4255,7 @@ function removeHeaderFooterBlocks(blocks, pageHeights, warnings, notes, tables =
|
|
|
4234
4255
|
const bottomEntries = [];
|
|
4235
4256
|
for (let bi = 0; bi < blocks.length; bi++) {
|
|
4236
4257
|
const b = blocks[bi];
|
|
4237
|
-
const text = !tables ? _optionalChain([b, 'access',
|
|
4258
|
+
const text = !tables ? _optionalChain([b, 'access', _225 => _225.text, 'optionalAccess', _226 => _226.trim, 'call', _227 => _227()]) : b.type === "table" && b.table ? b.table.cells.flat().map((c) => c.text.trim()).filter(Boolean).join(" | ") : void 0;
|
|
4238
4259
|
if (!b.bbox || !b.pageNumber || !text) continue;
|
|
4239
4260
|
const ph = pageHeights.get(b.bbox.page) || pageHeights.get(b.pageNumber);
|
|
4240
4261
|
if (!ph) continue;
|
|
@@ -4265,7 +4286,7 @@ function removeHeaderFooterBlocks(blocks, pageHeights, warnings, notes, tables =
|
|
|
4265
4286
|
for (const [p, count] of patternCount) {
|
|
4266
4287
|
const pages = [..._nullishCoalesce(patternPages.get(p), () => ( []))];
|
|
4267
4288
|
const span = pages.length ? Math.max(...pages) - Math.min(...pages) + 1 : 0;
|
|
4268
|
-
const pageNumbered = !tables && (_nullishCoalesce(_optionalChain([patternNumbers, 'access',
|
|
4289
|
+
const pageNumbered = !tables && (_nullishCoalesce(_optionalChain([patternNumbers, 'access', _228 => _228.get, 'call', _229 => _229(p), 'optionalAccess', _230 => _230.size]), () => ( 0))) > 1;
|
|
4269
4290
|
if (count >= MIN_REPEAT2 && pages.length >= MIN_REPEAT2 && (pages.length >= span * 0.4 || pageNumbered)) {
|
|
4270
4291
|
repeatedPatterns.add(p);
|
|
4271
4292
|
}
|
|
@@ -4273,8 +4294,8 @@ function removeHeaderFooterBlocks(blocks, pageHeights, warnings, notes, tables =
|
|
|
4273
4294
|
for (const e of entries) {
|
|
4274
4295
|
const norm = e.text.replace(/\d+/g, "#");
|
|
4275
4296
|
if (!repeatedPatterns.has(norm)) continue;
|
|
4276
|
-
const noteMark = _optionalChain([e, 'access',
|
|
4277
|
-
if (noteMark && _optionalChain([notes, 'optionalAccess',
|
|
4297
|
+
const noteMark = _optionalChain([e, 'access', _231 => _231.text, 'access', _232 => _232.match, 'call', _233 => _233(/^\d{1,3}\)/), 'optionalAccess', _234 => _234[0]]);
|
|
4298
|
+
if (noteMark && _optionalChain([notes, 'optionalAccess', _235 => _235.get, 'call', _236 => _236(e.page), 'optionalAccess', _237 => _237.marks, 'access', _238 => _238.some, 'call', _239 => _239((m) => m.mark === noteMark)])) continue;
|
|
4278
4299
|
const cand = blocks[e.blockIdx];
|
|
4279
4300
|
const cb = cand.bbox;
|
|
4280
4301
|
const tableNote = /^(?:주\s*(?:\d+\s*[).:]|[::])|(?:자료|출처)\s*[::])/.test(e.text.replace(/ \| /g, " ")) && blocks.some((o) => {
|
|
@@ -4288,7 +4309,7 @@ function removeHeaderFooterBlocks(blocks, pageHeights, warnings, notes, tables =
|
|
|
4288
4309
|
if (bi === e.blockIdx) continue;
|
|
4289
4310
|
const o = blocks[bi];
|
|
4290
4311
|
if (!o.bbox || o.bbox.page !== cb.page) continue;
|
|
4291
|
-
const oNorm = _optionalChain([o, 'access',
|
|
4312
|
+
const oNorm = _optionalChain([o, 'access', _240 => _240.text, 'optionalAccess', _241 => _241.trim, 'call', _242 => _242(), 'access', _243 => _243.replace, 'call', _244 => _244(/\d+/g, "#")]);
|
|
4292
4313
|
if (oNorm && repeatedPatterns.has(oNorm)) continue;
|
|
4293
4314
|
const overlap2 = Math.min(cb.y + cb.height, o.bbox.y + o.bbox.height) - Math.max(cb.y, o.bbox.y);
|
|
4294
4315
|
if (overlap2 >= cb.height * 0.5) {
|
|
@@ -4363,7 +4384,7 @@ function recordRowRules(table, cells, bbox, hs) {
|
|
|
4363
4384
|
function markImageCell(cell) {
|
|
4364
4385
|
IMAGE_CELLS.add(cell);
|
|
4365
4386
|
}
|
|
4366
|
-
var emptyCell = (cell) => !cell || !_optionalChain([cell, 'access',
|
|
4387
|
+
var emptyCell = (cell) => !cell || !_optionalChain([cell, 'access', _245 => _245.text, 'optionalAccess', _246 => _246.trim, 'call', _247 => _247()]) && !_optionalChain([cell, 'access', _248 => _248.blocks, 'optionalAccess', _249 => _249.length]) && !IMAGE_CELLS.has(cell);
|
|
4367
4388
|
function trimTable(table) {
|
|
4368
4389
|
let cols = table.cols;
|
|
4369
4390
|
while (cols > 0 && table.cells.every((row) => emptyCell(row[cols - 1]))) cols--;
|
|
@@ -4379,7 +4400,7 @@ function trimTable(table) {
|
|
|
4379
4400
|
function trimTrailingEmptyTableCols(blocks) {
|
|
4380
4401
|
for (const b of blocks) {
|
|
4381
4402
|
if (b.type !== "table" || !b.table) continue;
|
|
4382
|
-
for (const row of b.table.cells) for (const cell of row) if (_optionalChain([cell, 'access',
|
|
4403
|
+
for (const row of b.table.cells) for (const cell of row) if (_optionalChain([cell, 'access', _250 => _250.blocks, 'optionalAccess', _251 => _251.length])) trimTrailingEmptyTableCols(cell.blocks);
|
|
4383
4404
|
trimTable(b.table);
|
|
4384
4405
|
}
|
|
4385
4406
|
}
|
|
@@ -4399,7 +4420,7 @@ function mergeSliverColumns(grid, colXs, maxWidth) {
|
|
|
4399
4420
|
}
|
|
4400
4421
|
const ok = owner.every((row) => {
|
|
4401
4422
|
const o = row[c];
|
|
4402
|
-
return !!o && (o.colSpan > 1 || !o.text.trim() && !_optionalChain([o, 'access',
|
|
4423
|
+
return !!o && (o.colSpan > 1 || !o.text.trim() && !_optionalChain([o, 'access', _252 => _252.blocks, 'optionalAccess', _253 => _253.length]));
|
|
4403
4424
|
});
|
|
4404
4425
|
if (!ok) continue;
|
|
4405
4426
|
const spanning = /* @__PURE__ */ new Set();
|
|
@@ -4426,7 +4447,7 @@ var multiply = (m, t) => [
|
|
|
4426
4447
|
m[1] * t[4] + m[3] * t[5] + m[5]
|
|
4427
4448
|
];
|
|
4428
4449
|
function hollowCircle(image) {
|
|
4429
|
-
if (!_optionalChain([image, 'optionalAccess',
|
|
4450
|
+
if (!_optionalChain([image, 'optionalAccess', _254 => _254.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;
|
|
4430
4451
|
const stride = image.kind === _pdfmjs.ImageKind.RGB_24BPP ? 3 : image.kind === _pdfmjs.ImageKind.RGBA_32BPP ? 4 : 0;
|
|
4431
4452
|
const { width, height, data } = image;
|
|
4432
4453
|
if (!stride || data.length < width * height * stride) return false;
|
|
@@ -4491,9 +4512,9 @@ function smallVisibleImagePaints(fnArray, argsArray) {
|
|
|
4491
4512
|
const op = fnArray[i], args = argsArray[i];
|
|
4492
4513
|
if (op === _pdfmjs.OPS.save || op === _pdfmjs.OPS.paintFormXObjectBegin) {
|
|
4493
4514
|
stack.push({ ctm, alpha, clip, unknownClip });
|
|
4494
|
-
const matrix = op === _pdfmjs.OPS.paintFormXObjectBegin ? _optionalChain([args, 'optionalAccess',
|
|
4515
|
+
const matrix = op === _pdfmjs.OPS.paintFormXObjectBegin ? _optionalChain([args, 'optionalAccess', _255 => _255[0]]) : void 0;
|
|
4495
4516
|
if (Array.isArray(matrix) && matrix.length >= 6) ctm = multiply(ctm, matrix);
|
|
4496
|
-
const bounds = op === _pdfmjs.OPS.paintFormXObjectBegin ? _optionalChain([args, 'optionalAccess',
|
|
4517
|
+
const bounds = op === _pdfmjs.OPS.paintFormXObjectBegin ? _optionalChain([args, 'optionalAccess', _256 => _256[1]]) : void 0;
|
|
4497
4518
|
if (Array.isArray(bounds) && bounds.length === 4) {
|
|
4498
4519
|
const box = rectangle(bounds[0], bounds[1], bounds[2] - bounds[0], bounds[3] - bounds[1]);
|
|
4499
4520
|
if (box && ctm[1] === 0 && ctm[2] === 0) intersectClip(box);
|
|
@@ -4501,17 +4522,17 @@ function smallVisibleImagePaints(fnArray, argsArray) {
|
|
|
4501
4522
|
}
|
|
4502
4523
|
} else if (op === _pdfmjs.OPS.restore || op === _pdfmjs.OPS.paintFormXObjectEnd) {
|
|
4503
4524
|
const state = stack.pop();
|
|
4504
|
-
ctm = _nullishCoalesce(_optionalChain([state, 'optionalAccess',
|
|
4505
|
-
alpha = _nullishCoalesce(_optionalChain([state, 'optionalAccess',
|
|
4506
|
-
clip = _nullishCoalesce(_optionalChain([state, 'optionalAccess',
|
|
4507
|
-
unknownClip = _nullishCoalesce(_optionalChain([state, 'optionalAccess',
|
|
4525
|
+
ctm = _nullishCoalesce(_optionalChain([state, 'optionalAccess', _257 => _257.ctm]), () => ( [1, 0, 0, 1, 0, 0]));
|
|
4526
|
+
alpha = _nullishCoalesce(_optionalChain([state, 'optionalAccess', _258 => _258.alpha]), () => ( 1));
|
|
4527
|
+
clip = _nullishCoalesce(_optionalChain([state, 'optionalAccess', _259 => _259.clip]), () => ( null));
|
|
4528
|
+
unknownClip = _nullishCoalesce(_optionalChain([state, 'optionalAccess', _260 => _260.unknownClip]), () => ( false));
|
|
4508
4529
|
} else if (op === _pdfmjs.OPS.setGState) {
|
|
4509
|
-
for (const [key, value] of _nullishCoalesce(_optionalChain([args, 'optionalAccess',
|
|
4530
|
+
for (const [key, value] of _nullishCoalesce(_optionalChain([args, 'optionalAccess', _261 => _261[0]]), () => ( []))) {
|
|
4510
4531
|
if (key === "ca") alpha = typeof value === "number" ? value : 0;
|
|
4511
4532
|
}
|
|
4512
4533
|
} else if (op === _pdfmjs.OPS.constructPath) {
|
|
4513
4534
|
const [operations, coordinates] = args;
|
|
4514
|
-
pathRect = pathRect === void 0 && _optionalChain([operations, 'optionalAccess',
|
|
4535
|
+
pathRect = pathRect === void 0 && _optionalChain([operations, 'optionalAccess', _262 => _262.length]) === 1 && operations[0] === _pdfmjs.OPS.rectangle && _optionalChain([coordinates, 'optionalAccess', _263 => _263.length]) >= 4 && ctm[1] === 0 && ctm[2] === 0 ? rectangle(coordinates[0], coordinates[1], coordinates[2], coordinates[3]) : null;
|
|
4515
4536
|
} else if (op === _pdfmjs.OPS.clip || op === _pdfmjs.OPS.eoClip) pendingClip = true;
|
|
4516
4537
|
else if ([
|
|
4517
4538
|
_pdfmjs.OPS.endPath,
|
|
@@ -4531,7 +4552,7 @@ function smallVisibleImagePaints(fnArray, argsArray) {
|
|
|
4531
4552
|
pendingClip = false;
|
|
4532
4553
|
pathRect = void 0;
|
|
4533
4554
|
} else if (op === _pdfmjs.OPS.transform && Array.isArray(args) && args.length >= 6) ctm = multiply(ctm, args);
|
|
4534
|
-
else if (op === _pdfmjs.OPS.paintImageXObject && typeof _optionalChain([args, 'optionalAccess',
|
|
4555
|
+
else if (op === _pdfmjs.OPS.paintImageXObject && typeof _optionalChain([args, 'optionalAccess', _264 => _264[0]]) === "string") {
|
|
4535
4556
|
if (typeof args[1] !== "number" || typeof args[2] !== "number" || args[1] < 16 || args[1] > 128 || args[2] < 16 || args[2] > 128) continue;
|
|
4536
4557
|
const box = extractImageRegions([_pdfmjs.OPS.transform, _pdfmjs.OPS.paintImageXObject], [ctm, args])[0];
|
|
4537
4558
|
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;
|
|
@@ -4550,14 +4571,14 @@ async function restoreImageBullets(items, page, fnArray, argsArray, shapes = /*
|
|
|
4550
4571
|
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];
|
|
4551
4572
|
if (!line || /^[○●•◦□■∙]/.test(line.text.trim()) || !/\p{L}/u.test(line.text)) continue;
|
|
4552
4573
|
const row = items.filter((item) => Math.abs(item.y - line.y) <= 2 && item.x >= line.x);
|
|
4553
|
-
if (row.reduce((n, item) => n + (_nullishCoalesce(_optionalChain([item, 'access',
|
|
4574
|
+
if (row.reduce((n, item) => n + (_nullishCoalesce(_optionalChain([item, 'access', _265 => _265.text, 'access', _266 => _266.match, 'call', _267 => _267(/\p{L}/gu), 'optionalAccess', _268 => _268.length]), () => ( 0))), 0) < 12 || items.some((item) => item !== line && Math.abs(item.y - line.y) <= 2 && item.x < line.x)) continue;
|
|
4554
4575
|
candidates.push({ id, x: box.x1, width, line });
|
|
4555
4576
|
}
|
|
4556
4577
|
let restored = 0;
|
|
4557
4578
|
const used = /* @__PURE__ */ new Set();
|
|
4558
4579
|
for (const candidate of candidates) {
|
|
4559
4580
|
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);
|
|
4560
|
-
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',
|
|
4581
|
+
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', _269 => _269.text, 'access', _270 => _270.match, 'call', _271 => _271(/\p{L}/gu), 'optionalAccess', _272 => _272.length]), () => ( 0))) >= 12).sort((a, b) => b.y - a.y);
|
|
4561
4582
|
const numberedList = numbered.some((item, index) => index > 0 && item.text.trim().charCodeAt(0) === numbered[index - 1].text.trim().charCodeAt(0) + 1);
|
|
4562
4583
|
if (!same.length && !numberedList || used.has(candidate.line)) continue;
|
|
4563
4584
|
if (!shapes.has(candidate.id)) shapes.set(candidate.id, hollowCircle(await resolveImagePixels(page, candidate.id)));
|
|
@@ -4623,7 +4644,7 @@ function groupFlowBoxUnits(blocks, grids, hs, vs, images) {
|
|
|
4623
4644
|
return units;
|
|
4624
4645
|
}
|
|
4625
4646
|
function arrowDirection(image) {
|
|
4626
|
-
if (!_optionalChain([image, 'optionalAccess',
|
|
4647
|
+
if (!_optionalChain([image, 'optionalAccess', _273 => _273.data]) || image.width < 16 || image.width > 128 || image.height < 16 || image.height > 128) return 0;
|
|
4627
4648
|
const { width, height, data } = image;
|
|
4628
4649
|
const stride = image.kind === _pdfmjs.ImageKind.RGB_24BPP ? 3 : image.kind === _pdfmjs.ImageKind.RGBA_32BPP ? 4 : 0;
|
|
4629
4650
|
if (!stride || data.length < width * height * stride) return 0;
|
|
@@ -4691,7 +4712,7 @@ function isSideTabTable(box, table, others, pageWidth, pageHeight) {
|
|
|
4691
4712
|
function removeSideTabs(blocks, pageWidths) {
|
|
4692
4713
|
const edges = /* @__PURE__ */ new Map();
|
|
4693
4714
|
for (const b of blocks) {
|
|
4694
|
-
if (!b.bbox || b.pageNumber === void 0 || [..._nullishCoalesce(_optionalChain([b, 'access',
|
|
4715
|
+
if (!b.bbox || b.pageNumber === void 0 || [..._nullishCoalesce(_optionalChain([b, 'access', _274 => _274.text, 'optionalAccess', _275 => _275.trim, 'call', _276 => _276()]), () => ( ""))].length <= MAX_CHARS) continue;
|
|
4695
4716
|
const e = _nullishCoalesce(edges.get(b.pageNumber), () => ( { lefts: [], rights: [] }));
|
|
4696
4717
|
e.lefts.push(b.bbox.x);
|
|
4697
4718
|
e.rights.push(b.bbox.x + b.bbox.width);
|
|
@@ -4707,7 +4728,7 @@ function removeSideTabs(blocks, pageWidths) {
|
|
|
4707
4728
|
const fallback = all.length ? { left: q(all.map((e) => e.left), 0.5), right: q(all.map((e) => e.right), 0.5) } : void 0;
|
|
4708
4729
|
const key = (b) => {
|
|
4709
4730
|
const w = b.pageNumber !== void 0 ? pageWidths.get(b.pageNumber) : void 0;
|
|
4710
|
-
const text = _optionalChain([b, 'access',
|
|
4731
|
+
const text = _optionalChain([b, 'access', _277 => _277.text, 'optionalAccess', _278 => _278.trim, 'call', _279 => _279()]);
|
|
4711
4732
|
const area = _nullishCoalesce((b.pageNumber !== void 0 ? body.get(b.pageNumber) : void 0), () => ( fallback));
|
|
4712
4733
|
if (b.type === "table") {
|
|
4713
4734
|
if (!w || !b.bbox || !b.table || !SIDE_TAB_TABLES.has(b.table)) return null;
|
|
@@ -4794,7 +4815,7 @@ function isProseTable(table) {
|
|
|
4794
4815
|
if (!(long > 0 && long >= total * 0.5 && longRows >= rows * 0.4)) return false;
|
|
4795
4816
|
for (let c = 0; c < table.cols; c++) {
|
|
4796
4817
|
const filled = table.cells.map((row) => row[c]).filter((cell) => cell && cell.colSpan < table.cols && cell.text.trim()).map((cell) => cell.text.trim());
|
|
4797
|
-
if (filled.length >= 3 && filled.length >= rows * 0.6 && filled.every((text) => text.length <= 30 && (_nullishCoalesce(_optionalChain([text, 'access',
|
|
4818
|
+
if (filled.length >= 3 && filled.length >= rows * 0.6 && filled.every((text) => text.length <= 30 && (_nullishCoalesce(_optionalChain([text, 'access', _280 => _280.match, 'call', _281 => _281(/\p{L}/gu), 'optionalAccess', _282 => _282.length]), () => ( 0))) >= 2)) return false;
|
|
4798
4819
|
}
|
|
4799
4820
|
return true;
|
|
4800
4821
|
}
|
|
@@ -4821,7 +4842,7 @@ function isChartTable(table) {
|
|
|
4821
4842
|
const numeric = texts.filter((text) => NUMERIC_CELL.test(text)).length;
|
|
4822
4843
|
if (numeric < texts.length * 0.5) return false;
|
|
4823
4844
|
for (let c = 0; c < table.cols; c++) {
|
|
4824
|
-
const ticks = table.cells.flatMap((row) => (_nullishCoalesce(_optionalChain([row, 'access',
|
|
4845
|
+
const ticks = table.cells.flatMap((row) => (_nullishCoalesce(_optionalChain([row, 'access', _283 => _283[c], 'optionalAccess', _284 => _284.text]), () => ( ""))).split(/\s+/)).filter((token) => /^-?[\d,]+(?:\.\d+)?%?$/.test(token)).map((token) => Number(token.replace(/[,%]/g, "")));
|
|
4825
4846
|
if (hasValueAxis(ticks)) return true;
|
|
4826
4847
|
}
|
|
4827
4848
|
const values = texts.filter((text) => text.split(/\s+/).every((token) => /^[-−–]?[\d,]*\.?\d+%?$/.test(token))).length;
|
|
@@ -5043,7 +5064,7 @@ function detectAlignedTwoColumnTables(rows, pageNum) {
|
|
|
5043
5064
|
continue;
|
|
5044
5065
|
}
|
|
5045
5066
|
const top = rows[i - 1];
|
|
5046
|
-
const title = _optionalChain([top, 'optionalAccess',
|
|
5067
|
+
const title = _optionalChain([top, 'optionalAccess', _285 => _285.items, 'access', _286 => _286.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;
|
|
5047
5068
|
const tableRows = title ? [title, ...body] : body;
|
|
5048
5069
|
const cells = tableRows.map((row, idx) => {
|
|
5049
5070
|
if (title && idx === 0) return [{ text: row.items[0].text, colSpan: 2, rowSpan: 1 }, { text: "", colSpan: 1, rowSpan: 1 }];
|
|
@@ -5099,12 +5120,12 @@ function isTwoColumnProse(r) {
|
|
|
5099
5120
|
if (t.rows < 8) return false;
|
|
5100
5121
|
const dense = [];
|
|
5101
5122
|
for (let c = 0; c < t.cols; c++) {
|
|
5102
|
-
const filled = t.cells.filter((row) => _optionalChain([row, 'access',
|
|
5123
|
+
const filled = t.cells.filter((row) => _optionalChain([row, 'access', _287 => _287[c], 'optionalAccess', _288 => _288.text, 'access', _289 => _289.trim, 'call', _290 => _290()])).length;
|
|
5103
5124
|
if (filled / t.rows >= 0.3) dense.push(c);
|
|
5104
5125
|
}
|
|
5105
5126
|
if (dense.length !== 2) return false;
|
|
5106
5127
|
for (const c of dense) {
|
|
5107
|
-
const lens = t.cells.map((row) => _nullishCoalesce(_optionalChain([row, 'access',
|
|
5128
|
+
const lens = t.cells.map((row) => _nullishCoalesce(_optionalChain([row, 'access', _291 => _291[c], 'optionalAccess', _292 => _292.text, 'access', _293 => _293.replace, 'call', _294 => _294(/\s+/g, ""), 'access', _295 => _295.length]), () => ( 0))).filter((n) => n > 0);
|
|
5108
5129
|
const avg = lens.reduce((s, v) => s + v, 0) / (lens.length || 1);
|
|
5109
5130
|
if (avg < 12) return false;
|
|
5110
5131
|
}
|
|
@@ -5500,7 +5521,7 @@ function assignRowItems(items, columns, numCols, headerFace) {
|
|
|
5500
5521
|
const runs = [];
|
|
5501
5522
|
for (const it of sorted) {
|
|
5502
5523
|
const last = runs[runs.length - 1];
|
|
5503
|
-
const prev = _optionalChain([last, 'optionalAccess',
|
|
5524
|
+
const prev = _optionalChain([last, 'optionalAccess', _296 => _296[last.length - 1]]);
|
|
5504
5525
|
if (prev && it.x - (prev.x + prev.w) <= Math.max(0.5, it.fontSize * 0.05) && !it.hasSpaceBefore) last.push(it);
|
|
5505
5526
|
else runs.push([it]);
|
|
5506
5527
|
}
|
|
@@ -5574,7 +5595,7 @@ function buildClusterTable(rows, columns, pageNum) {
|
|
|
5574
5595
|
() => Array.from({ length: numCols }, () => ({ text: "", colSpan: 1, rowSpan: 1 }))
|
|
5575
5596
|
);
|
|
5576
5597
|
const usedItems = /* @__PURE__ */ new Set();
|
|
5577
|
-
const headFaces = new Set(_optionalChain([rows, 'access',
|
|
5598
|
+
const headFaces = new Set(_optionalChain([rows, 'access', _297 => _297[0], 'optionalAccess', _298 => _298.items, 'access', _299 => _299.map, 'call', _300 => _300((i) => i.fontName)]));
|
|
5578
5599
|
const headerFace = headFaces.size === 1 && rows.slice(1).every((row) => row.items.every((i) => !headFaces.has(i.fontName))) ? [...headFaces][0] : void 0;
|
|
5579
5600
|
for (let r = 0; r < numRows; r++) {
|
|
5580
5601
|
const row = rows[r];
|
|
@@ -5604,7 +5625,7 @@ function buildClusterTable(rows, columns, pageNum) {
|
|
|
5604
5625
|
const nonEmptyCols = cells[r].filter((c) => c.text.trim()).length;
|
|
5605
5626
|
if (nonEmptyCols !== 1) continue;
|
|
5606
5627
|
if (cells[r][0].text.trim() !== "") continue;
|
|
5607
|
-
const contentText = _optionalChain([cells, 'access',
|
|
5628
|
+
const contentText = _optionalChain([cells, 'access', _301 => _301[r], 'access', _302 => _302.find, 'call', _303 => _303((c) => c.text.trim()), 'optionalAccess', _304 => _304.text, 'access', _305 => _305.trim, 'call', _306 => _306()]) || "";
|
|
5608
5629
|
if (/^[○●▶\-·]/.test(contentText)) continue;
|
|
5609
5630
|
for (let pr = r - 1; pr >= 0; pr--) {
|
|
5610
5631
|
if (cells[pr].some((c) => c.text.trim())) {
|
|
@@ -5995,16 +6016,16 @@ function isProseSpread(items) {
|
|
|
5995
6016
|
for (let i = 1; i < sorted.length; i++) {
|
|
5996
6017
|
gaps.push(sorted[i].x - (sorted[i - 1].x + sorted[i - 1].w));
|
|
5997
6018
|
}
|
|
5998
|
-
const maxGap =
|
|
6019
|
+
const maxGap = _chunkK6WSMTVUcjs.safeMax.call(void 0, gaps);
|
|
5999
6020
|
const avgLen = items.reduce((s, i) => s + i.text.length, 0) / items.length;
|
|
6000
6021
|
if (items.length >= 4 && maxGap < 40 && avgLen < 5) return true;
|
|
6001
|
-
const minGap =
|
|
6022
|
+
const minGap = _chunkK6WSMTVUcjs.safeMin.call(void 0, gaps);
|
|
6002
6023
|
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;
|
|
6003
6024
|
}
|
|
6004
6025
|
function detectColumns(yLines) {
|
|
6005
6026
|
const allItems = yLines.flat();
|
|
6006
6027
|
if (allItems.length === 0) return null;
|
|
6007
|
-
const pageWidth =
|
|
6028
|
+
const pageWidth = _chunkK6WSMTVUcjs.safeMax.call(void 0, allItems.map((i) => i.x + i.w)) - _chunkK6WSMTVUcjs.safeMin.call(void 0, allItems.map((i) => i.x));
|
|
6008
6029
|
if (pageWidth < 100) return null;
|
|
6009
6030
|
let bigoLineIdx = -1;
|
|
6010
6031
|
for (let i = 0; i < yLines.length; i++) {
|
|
@@ -6229,7 +6250,7 @@ var UNDER_BOX_PAIR_MAX_EM = 2.2;
|
|
|
6229
6250
|
var UNDER_BOX_PAIR_OVERLAP = 0.8;
|
|
6230
6251
|
function markUnderlineItems(items, horizontals, verticals, nonRules) {
|
|
6231
6252
|
const underlines = [];
|
|
6232
|
-
if (_optionalChain([nonRules, 'optionalAccess',
|
|
6253
|
+
if (_optionalChain([nonRules, 'optionalAccess', _307 => _307.size])) horizontals = horizontals.filter((line) => !nonRules.has(line));
|
|
6233
6254
|
if (items.length === 0 || horizontals.length === 0) return underlines;
|
|
6234
6255
|
const tightOwners = /* @__PURE__ */ new Map();
|
|
6235
6256
|
const tightlyOwned = (line) => {
|
|
@@ -6335,7 +6356,7 @@ function hasBoxTopPair(line, maxH, horizontals, cellItems) {
|
|
|
6335
6356
|
if (ow <= 0) continue;
|
|
6336
6357
|
const overlap2 = Math.min(line.x2, o.x2) - Math.max(line.x1, o.x1);
|
|
6337
6358
|
if (overlap2 / Math.max(w, ow) < UNDER_BOX_PAIR_OVERLAP) continue;
|
|
6338
|
-
const covered = _nullishCoalesce(_optionalChain([cellItems, 'optionalAccess',
|
|
6359
|
+
const covered = _nullishCoalesce(_optionalChain([cellItems, 'optionalAccess', _308 => _308.reduce, 'call', _309 => _309((sum, item) => {
|
|
6339
6360
|
const below = item.y - o.y1;
|
|
6340
6361
|
if (below < 0.5 || below > 3 || !item.text.trim()) return sum;
|
|
6341
6362
|
return sum + Math.max(0, Math.min(o.x2, item.x + item.w) - Math.max(o.x1, item.x));
|
|
@@ -6465,8 +6486,8 @@ function edgesOf(box, h, v, hNear = EDGE_NEAR2) {
|
|
|
6465
6486
|
}
|
|
6466
6487
|
function recordClipCellEdges(grids, horizontals, verticals, nonRules) {
|
|
6467
6488
|
if (!grids.some((g) => g.cells)) return;
|
|
6468
|
-
const h = rules(_optionalChain([nonRules, 'optionalAccess',
|
|
6469
|
-
const v = rules(_optionalChain([nonRules, 'optionalAccess',
|
|
6489
|
+
const h = rules(_optionalChain([nonRules, 'optionalAccess', _310 => _310.size]) ? horizontals.filter((l) => !nonRules.has(l)) : horizontals, "h");
|
|
6490
|
+
const v = rules(_optionalChain([nonRules, 'optionalAccess', _311 => _311.size]) ? verticals.filter((l) => !nonRules.has(l)) : verticals, "v");
|
|
6470
6491
|
for (const g of grids) for (const c of _nullishCoalesce(g.cells, () => ( []))) {
|
|
6471
6492
|
const near = c.filler ? Math.min(EDGE_NEAR2, (c.bbox.y2 - c.bbox.y1) / 3) : EDGE_NEAR2;
|
|
6472
6493
|
CLIP_CELL_EDGES.set(c, edgesOf(c.bbox, h, v, near));
|
|
@@ -6474,12 +6495,12 @@ function recordClipCellEdges(grids, horizontals, verticals, nonRules) {
|
|
|
6474
6495
|
}
|
|
6475
6496
|
function takeClipCellEdges(from, to) {
|
|
6476
6497
|
const e = CLIP_CELL_EDGES.get(from);
|
|
6477
|
-
if (e)
|
|
6498
|
+
if (e) _chunk6FW3AZWNcjs.CELL_EDGES.set(to, e);
|
|
6478
6499
|
}
|
|
6479
6500
|
function joinCellEdges(a, b) {
|
|
6480
|
-
const u =
|
|
6501
|
+
const u = _chunk6FW3AZWNcjs.CELL_EDGES.get(a), d = _chunk6FW3AZWNcjs.CELL_EDGES.get(b);
|
|
6481
6502
|
if (!u || !d) return;
|
|
6482
|
-
|
|
6503
|
+
_chunk6FW3AZWNcjs.CELL_EDGES.set(a, { t: u.t, b: d.b, l: u.l || d.l, r: u.r || d.r });
|
|
6483
6504
|
}
|
|
6484
6505
|
|
|
6485
6506
|
// src/pdf/table-unit-row.ts
|
|
@@ -6495,12 +6516,12 @@ function rebuildUnitLine(items, grid) {
|
|
|
6495
6516
|
function prependUnitRow(cells, cols, line, usedItems) {
|
|
6496
6517
|
const text = cleanCellText(line.map((item) => item.text).join(""));
|
|
6497
6518
|
cells.unshift(Array.from({ length: cols }, (_, c) => ({ text: c === 0 ? text : "", colSpan: c === 0 ? cols : 1, rowSpan: 1 })));
|
|
6498
|
-
for (const cell of cells[0])
|
|
6519
|
+
for (const cell of cells[0]) _chunk6FW3AZWNcjs.CELL_EDGES.set(cell, NO_EDGES);
|
|
6499
6520
|
for (const item of line) usedItems.add(item);
|
|
6500
6521
|
}
|
|
6501
6522
|
function attachUnitRow(items, grid, cells, cols, usedItems) {
|
|
6502
6523
|
const all = cells.flat();
|
|
6503
|
-
if (all.filter((c) => c.text.trim()).length * 2 < all.length || UNIT.test(_nullishCoalesce(_optionalChain([cells, 'access',
|
|
6524
|
+
if (all.filter((c) => c.text.trim()).length * 2 < all.length || UNIT.test(_nullishCoalesce(_optionalChain([cells, 'access', _312 => _312[0], 'optionalAccess', _313 => _313[0], 'optionalAccess', _314 => _314.text]), () => ( "")))) return false;
|
|
6504
6525
|
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);
|
|
6505
6526
|
let nearest = Infinity;
|
|
6506
6527
|
for (const it of above) nearest = Math.min(nearest, it.y);
|
|
@@ -6535,7 +6556,7 @@ function closeShadedTableEdges(clipGrids, horizontals, verticals, fillRects) {
|
|
|
6535
6556
|
let hs = horizontals, vs = verticals;
|
|
6536
6557
|
const restored = [];
|
|
6537
6558
|
for (const grid of clipGrids) {
|
|
6538
|
-
if (grid.clipParent || grid.rowYs.length !== 2 || grid.colXs.length < 3 || !_optionalChain([grid, 'access',
|
|
6559
|
+
if (grid.clipParent || grid.rowYs.length !== 2 || grid.colXs.length < 3 || !_optionalChain([grid, 'access', _315 => _315.cells, 'optionalAccess', _316 => _316.length]) || grid.cells.some((c) => c.filler || c.rowSpan !== 1 || c.colSpan !== 1)) continue;
|
|
6539
6560
|
const { x1, x2, y1: mid, y2: top } = grid.bbox;
|
|
6540
6561
|
if (!grid.cells.every((c) => fillRects.some((f) => near(f.x1, c.bbox.x1) && near(f.x2, c.bbox.x2) && near(f.y1, c.bbox.y1) && near(f.y2, c.bbox.y2)))) continue;
|
|
6541
6562
|
const topRule = hs.find((h) => near(h.y1, top) && near(h.x1, x1) && near(h.x2, x2));
|
|
@@ -6947,7 +6968,7 @@ function takeFrameSpanningText(items, cutX, pageNum, lex) {
|
|
|
6947
6968
|
const rows = groupByY([...items].sort((a, b) => b.y - a.y || a.x - b.x)).map((line) => {
|
|
6948
6969
|
const runs = [];
|
|
6949
6970
|
for (const item of [...line].sort((a, b) => a.x - b.x)) {
|
|
6950
|
-
const run = runs[runs.length - 1], prev = _optionalChain([run, 'optionalAccess',
|
|
6971
|
+
const run = runs[runs.length - 1], prev = _optionalChain([run, 'optionalAccess', _317 => _317[run.length - 1]]);
|
|
6951
6972
|
if (prev && item.x - (prev.x + prev.w) <= Math.max(prev.fontSize, item.fontSize) * 0.6) run.push(item);
|
|
6952
6973
|
else runs.push([item]);
|
|
6953
6974
|
}
|
|
@@ -6991,7 +7012,7 @@ function groupFrameParagraphUnits(units, frames) {
|
|
|
6991
7012
|
for (const unit of units) for (const block of unit) source.set(block, unit);
|
|
6992
7013
|
const members = /* @__PURE__ */ new Map(), emitted = /* @__PURE__ */ new Set();
|
|
6993
7014
|
for (const frame of frames) {
|
|
6994
|
-
if (frame.length < 2 || frame.some((block) => block.type !== "paragraph" || _optionalChain([source, 'access',
|
|
7015
|
+
if (frame.length < 2 || frame.some((block) => block.type !== "paragraph" || _optionalChain([source, 'access', _318 => _318.get, 'call', _319 => _319(block), 'optionalAccess', _320 => _320.length]) !== 1)) continue;
|
|
6995
7016
|
for (const block of frame) members.set(block, frame);
|
|
6996
7017
|
}
|
|
6997
7018
|
const out = [];
|
|
@@ -7004,7 +7025,7 @@ function groupFrameParagraphUnits(units, frames) {
|
|
|
7004
7025
|
}
|
|
7005
7026
|
}
|
|
7006
7027
|
for (const unit of out) {
|
|
7007
|
-
if (unit.length < 2 || _optionalChain([FRAME_READING_UNITS, 'access',
|
|
7028
|
+
if (unit.length < 2 || _optionalChain([FRAME_READING_UNITS, 'access', _321 => _321.get, 'call', _322 => _322(unit[0]), 'optionalAccess', _323 => _323.blocks]) === unit) continue;
|
|
7008
7029
|
const bs = unit.map((b) => b.bbox).filter((b) => !!b);
|
|
7009
7030
|
if (bs.length !== unit.length) continue;
|
|
7010
7031
|
const x = Math.min(...bs.map((b) => b.x)), y = Math.min(...bs.map((b) => b.y));
|
|
@@ -7021,14 +7042,14 @@ function groupFrameParagraphUnits(units, frames) {
|
|
|
7021
7042
|
function recordFrameTitle(table, source, pageNum) {
|
|
7022
7043
|
if (!CLIP_TABLES.has(table) || table.rows !== 1 || table.cols !== 3 || source.length < 2) return;
|
|
7023
7044
|
const cells = table.cells[0];
|
|
7024
|
-
if (cells.length !== 3 || cells.some((c) => c.colSpan !== 1 || c.rowSpan !== 1 || _optionalChain([c, 'access',
|
|
7045
|
+
if (cells.length !== 3 || cells.some((c) => c.colSpan !== 1 || c.rowSpan !== 1 || _optionalChain([c, 'access', _324 => _324.blocks, 'optionalAccess', _325 => _325.length]) || c.text.includes("\n"))) return;
|
|
7025
7046
|
const [label, spacer, title] = cells;
|
|
7026
7047
|
if (!/^(?:붙임|별첨|첨부|부록)\s*\d{1,3}$/.test(label.text.trim()) || spacer.text.trim() || !title.text.trim()) return;
|
|
7027
7048
|
if (cells.some((c) => {
|
|
7028
|
-
const e =
|
|
7049
|
+
const e = _chunk6FW3AZWNcjs.CELL_EDGES.get(c);
|
|
7029
7050
|
return !e || e.t || e.b || e.l || e.r;
|
|
7030
7051
|
})) return;
|
|
7031
|
-
const xs = TABLE_COLXS.get(table), style = dominantStyle(source), fs = _nullishCoalesce(_optionalChain([style, 'optionalAccess',
|
|
7052
|
+
const xs = TABLE_COLXS.get(table), style = dominantStyle(source), fs = _nullishCoalesce(_optionalChain([style, 'optionalAccess', _326 => _326.fontSize]), () => ( 0));
|
|
7032
7053
|
if (!xs || xs.length !== 4 || fs <= 0) return;
|
|
7033
7054
|
const width = xs[3] - xs[0], gap = xs[2] - xs[1];
|
|
7034
7055
|
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;
|
|
@@ -7086,7 +7107,7 @@ function extendNestedShadedHeaders(clipGrids, lineGrids, horizontals, verticals,
|
|
|
7086
7107
|
const extended = [];
|
|
7087
7108
|
for (let i = 0; i < clipGrids.length; i++) {
|
|
7088
7109
|
const c = clipGrids[i], parent = c.clipParent;
|
|
7089
|
-
if (!parent || c.rowYs.length !== 2 || c.colXs.length < 3 || !_optionalChain([c, 'access',
|
|
7110
|
+
if (!parent || c.rowYs.length !== 2 || c.colXs.length < 3 || !_optionalChain([c, 'access', _327 => _327.cells, 'optionalAccess', _328 => _328.length]) || c.cells.some((cell) => cell.filler || cell.rowSpan !== 1 || cell.colSpan !== 1)) continue;
|
|
7090
7111
|
if (!clipGrids.some((g) => g.rowYs.length === 2 && g.colXs.length === 2 && near(g.bbox.x1, parent.x1) && near(g.bbox.x2, parent.x2) && near(g.bbox.y1, parent.y1) && near(g.bbox.y2, parent.y2))) continue;
|
|
7091
7112
|
if (!c.cells.every((cell) => fills.some((f) => near(f.x1, cell.bbox.x1) && near(f.x2, cell.bbox.x2) && near(f.y1, cell.bbox.y1) && near(f.y2, cell.bbox.y2)))) continue;
|
|
7092
7113
|
const host = lineGrids.find((l) => l.rowYs.length > 2 && l.colXs.length === c.colXs.length && c.colXs.every((x, k) => near(x, l.colXs[k])) && c.rowYs.every((y, k) => near(y, l.rowYs[k])) && contains3(parent, l.bbox) && l.rowYs.every((y) => horizontals.some((h) => near(h.y1, y) && near(h.x1, l.bbox.x1) && near(h.x2, l.bbox.x2))) && l.colXs.every((x) => verticals.some((v) => near(v.x1, x) && v.y1 <= l.bbox.y1 + 1.5 && v.y2 >= l.bbox.y2 - 1.5)) && !clipGrids.some((o) => o !== c && !contains3(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)));
|
|
@@ -7109,7 +7130,7 @@ function attachSideTabBlocks(tab, body, pageNum) {
|
|
|
7109
7130
|
bbox: computeBBox(items, pageNum),
|
|
7110
7131
|
style: dominantStyle(items)
|
|
7111
7132
|
});
|
|
7112
|
-
const prefix = ordered.filter((g) => !_optionalChain([caps, 'optionalAccess',
|
|
7133
|
+
const prefix = ordered.filter((g) => !_optionalChain([caps, 'optionalAccess', _329 => _329.has, 'call', _330 => _330(g)])).map((g) => ({
|
|
7113
7134
|
type: "paragraph",
|
|
7114
7135
|
text: g.text.trim(),
|
|
7115
7136
|
pageNumber: pageNum,
|
|
@@ -7118,7 +7139,7 @@ function attachSideTabBlocks(tab, body, pageNum) {
|
|
|
7118
7139
|
}));
|
|
7119
7140
|
const groups = /* @__PURE__ */ new Map();
|
|
7120
7141
|
for (const g of ordered) {
|
|
7121
|
-
const cap = _optionalChain([caps, 'optionalAccess',
|
|
7142
|
+
const cap = _optionalChain([caps, 'optionalAccess', _331 => _331.get, 'call', _332 => _332(g)]);
|
|
7122
7143
|
if (cap) groups.set(cap, [..._nullishCoalesce(groups.get(cap), () => ( [])), g]);
|
|
7123
7144
|
}
|
|
7124
7145
|
for (const [cap, glyphs] of groups) {
|
|
@@ -7309,7 +7330,7 @@ function stackedTableBands(items) {
|
|
|
7309
7330
|
const caption = (start, end) => lines.slice(start, end).some((line) => /^Table\s+\d+\s*[:.]/i.test(mergeLineSimple(line).trim()));
|
|
7310
7331
|
while (runs.length > 0 && !caption(runs[runs.length - 1].end, lines.length)) runs.pop();
|
|
7311
7332
|
if (runs.length < 2) return null;
|
|
7312
|
-
if (runs.some((run, i) => !caption(run.end, _nullishCoalesce(_optionalChain([runs, 'access',
|
|
7333
|
+
if (runs.some((run, i) => !caption(run.end, _nullishCoalesce(_optionalChain([runs, 'access', _333 => _333[i + 1], 'optionalAccess', _334 => _334.start]), () => ( lines.length))))) return null;
|
|
7313
7334
|
const tables = runs.map((run) => lines.slice(run.start, run.end).flat());
|
|
7314
7335
|
const between = runs.slice(0, -1).map((run, i) => lines.slice(run.end, runs[i + 1].start).flat());
|
|
7315
7336
|
const tail = lines.slice(runs[runs.length - 1].end);
|
|
@@ -7478,7 +7499,7 @@ function extractPageBlocksWithLines(items, pageNum, opList, pageWidth, pageHeigh
|
|
|
7478
7499
|
const filled = fillBlanks(items, horizontals, verticals);
|
|
7479
7500
|
items = filled.items;
|
|
7480
7501
|
horizontals = filled.horizontals;
|
|
7481
|
-
const prevPage = _optionalChain([carry, 'optionalAccess',
|
|
7502
|
+
const prevPage = _optionalChain([carry, 'optionalAccess', _335 => _335.page]) === pageNum - 1 ? carry.clip : void 0;
|
|
7482
7503
|
const clipResult = detectTables ? buildClipCellGrids(extracted.clipRects, horizontals, verticals, pageWidth, pageHeight, items.map((it) => ({ x: it.x + it.w / 2, y: it.y + it.h / 2 })), extracted.fillRects, prevPage) : { grids: [], containers: [], page: void 0 };
|
|
7483
7504
|
if (carry) {
|
|
7484
7505
|
carry.page = pageNum;
|
|
@@ -7746,14 +7767,14 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
|
|
|
7746
7767
|
if (!assignedItems.has(textItems[ti])) usedItems.delete(tableItems[ti]);
|
|
7747
7768
|
}
|
|
7748
7769
|
}
|
|
7749
|
-
if (unitLine.length > 0 && rebuiltUsed && !/^\s*\(\s*단위\s*[::]/.test(_nullishCoalesce(_optionalChain([finalGrid, 'access',
|
|
7770
|
+
if (unitLine.length > 0 && rebuiltUsed && !/^\s*\(\s*단위\s*[::]/.test(_nullishCoalesce(_optionalChain([finalGrid, 'access', _336 => _336[0], 'optionalAccess', _337 => _337[0], 'optionalAccess', _338 => _338.text]), () => ( "")))) {
|
|
7750
7771
|
prependUnitRow(finalGrid, numCols, unitLine, usedItems);
|
|
7751
7772
|
finalRows++;
|
|
7752
7773
|
}
|
|
7753
7774
|
if (!rebuiltUsed && attachUnitRow(items, grid, finalGrid, numCols, usedItems)) finalRows++;
|
|
7754
7775
|
let semanticOneColumn = false;
|
|
7755
7776
|
if (!grid.cells && !nestedAttached && numCols === 1 && numGridRows >= 2) {
|
|
7756
|
-
const populatedRows = finalGrid.filter((row) => _optionalChain([row, 'access',
|
|
7777
|
+
const populatedRows = finalGrid.filter((row) => _optionalChain([row, 'access', _339 => _339[0], 'optionalAccess', _340 => _340.text, 'access', _341 => _341.trim, 'call', _342 => _342()]));
|
|
7757
7778
|
if (populatedRows.length >= 4) {
|
|
7758
7779
|
const fontSizes = tableItems.map((item) => item.fontSize).filter((size) => size > 0).sort((a, b) => a - b);
|
|
7759
7780
|
const medianFont = _nullishCoalesce(fontSizes[Math.floor(fontSizes.length / 2)], () => ( 0));
|
|
@@ -7839,7 +7860,7 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
|
|
|
7839
7860
|
height: grid.bbox.y2 - grid.bbox.y1
|
|
7840
7861
|
};
|
|
7841
7862
|
if (numRows === 1 && numCols === 1 && gridW < pageWidth * 0.35) {
|
|
7842
|
-
const prose = _nullishCoalesce(_optionalChain([finalGrid, 'access',
|
|
7863
|
+
const prose = _nullishCoalesce(_optionalChain([finalGrid, 'access', _343 => _343[0], 'optionalAccess', _344 => _344[0], 'optionalAccess', _345 => _345.text]), () => ( ""));
|
|
7843
7864
|
const besideLines = (side) => new Set(side.map((it) => Math.round(it.y / 3))).size;
|
|
7844
7865
|
const rightLines = items.filter((it) => it.x >= grid.bbox.x2 + 3 && it.y >= grid.bbox.y1 && it.y <= grid.bbox.y2);
|
|
7845
7866
|
const leftLines = items.filter((it) => it.x + it.w <= grid.bbox.x1 - 3 && it.y >= grid.bbox.y1 && it.y <= grid.bbox.y2);
|
|
@@ -7858,8 +7879,8 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
|
|
|
7858
7879
|
}
|
|
7859
7880
|
}
|
|
7860
7881
|
if (!grid.cells && !nestedAttached && shouldDemoteTable(irTable)) {
|
|
7861
|
-
const paragraphs = numRows === 1 && numCols === 1 ? _optionalChain([irTable, 'access',
|
|
7862
|
-
if (_optionalChain([paragraphs, 'optionalAccess',
|
|
7882
|
+
const paragraphs = numRows === 1 && numCols === 1 ? _optionalChain([irTable, 'access', _346 => _346.cells, 'access', _347 => _347[0], 'optionalAccess', _348 => _348[0], 'optionalAccess', _349 => _349.blocks]) : void 0;
|
|
7883
|
+
if (_optionalChain([paragraphs, 'optionalAccess', _350 => _350.length])) {
|
|
7863
7884
|
blocks.push(...paragraphs);
|
|
7864
7885
|
frameParagraphUnits.push(paragraphs);
|
|
7865
7886
|
recordFrameReadingUnit(paragraphs, tableBbox);
|
|
@@ -7900,7 +7921,7 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
|
|
|
7900
7921
|
const proseColumns = findTwoColumnProseCutX(clusterItems) !== null || detectPersistentColumnGutter(remaining.map((i) => ({ x: i.x, y: i.y, w: i.w, h: i.h > 0 ? i.h : i.fontSize }))) !== null;
|
|
7901
7922
|
const clusterResults = (proseColumns ? [] : detectClusterTables(clusterItems, pageNum)).filter((cr) => {
|
|
7902
7923
|
const b = cr.bbox;
|
|
7903
|
-
return !blocks.some((x) => x.type === "paragraph" && x.bbox && (_nullishCoalesce(_optionalChain([x, 'access',
|
|
7924
|
+
return !blocks.some((x) => x.type === "paragraph" && x.bbox && (_nullishCoalesce(_optionalChain([x, 'access', _351 => _351.text, 'optionalAccess', _352 => _352.match, 'call', _353 => _353(/\p{L}/gu), 'optionalAccess', _354 => _354.length]), () => ( 0))) >= 10 && Math.min(x.bbox.x + x.bbox.width, b.x + b.width) - Math.max(x.bbox.x, b.x) >= 0.8 * b.width && x.bbox.y >= b.y - 2 && x.bbox.y + x.bbox.height <= b.y + b.height + 2);
|
|
7904
7925
|
});
|
|
7905
7926
|
if (clusterResults.length > 0) {
|
|
7906
7927
|
const ciToIdx = /* @__PURE__ */ new Map();
|
|
@@ -7937,7 +7958,7 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
|
|
|
7937
7958
|
groupSizes.push(1);
|
|
7938
7959
|
}
|
|
7939
7960
|
const allY = remaining.map((i) => i.y);
|
|
7940
|
-
const pageH =
|
|
7961
|
+
const pageH = _chunkK6WSMTVUcjs.safeMax.call(void 0, allY) - _chunkK6WSMTVUcjs.safeMin.call(void 0, allY);
|
|
7941
7962
|
const gapThreshold = Math.max(15, pageH * 0.03);
|
|
7942
7963
|
const sides = frameColumnTextBands(remaining, spanning, gx);
|
|
7943
7964
|
const textBlocks = [];
|
|
@@ -7953,7 +7974,7 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
|
|
|
7953
7974
|
finalTextBlocks.push(...detectListBlocks(textBlocks));
|
|
7954
7975
|
} else {
|
|
7955
7976
|
const allY = remaining.map((i) => i.y);
|
|
7956
|
-
const pageH =
|
|
7977
|
+
const pageH = _chunkK6WSMTVUcjs.safeMax.call(void 0, allY) - _chunkK6WSMTVUcjs.safeMin.call(void 0, allY);
|
|
7957
7978
|
const groups = xyCutOrder(remaining, Math.max(15, pageH * 0.03));
|
|
7958
7979
|
const textBlocks = [];
|
|
7959
7980
|
for (const group of groups) {
|
|
@@ -8278,7 +8299,7 @@ function extractPageBlocksFallback(items, pageNum, fullPage = false, detectTable
|
|
|
8278
8299
|
blocks.push(...columnTextToBlocks(tableText, pageNum, bbox, dominantStyle(items)));
|
|
8279
8300
|
} else {
|
|
8280
8301
|
const allY = items.map((i) => i.y);
|
|
8281
|
-
const pageHeight =
|
|
8302
|
+
const pageHeight = _chunkK6WSMTVUcjs.safeMax.call(void 0, allY) - _chunkK6WSMTVUcjs.safeMin.call(void 0, allY);
|
|
8282
8303
|
const gapThreshold = Math.max(15, pageHeight * 0.03);
|
|
8283
8304
|
const orderedGroups = proseCutX !== null ? splitTwoColumnProse(items, proseCutX) : xyCutOrder(items, gapThreshold);
|
|
8284
8305
|
for (const group of orderedGroups) {
|
|
@@ -8357,4 +8378,4 @@ function extractPageBlocksFallback(items, pageNum, fullPage = false, detectTable
|
|
|
8357
8378
|
|
|
8358
8379
|
|
|
8359
8380
|
exports.OCR_DET_MODEL = OCR_DET_MODEL; exports.OCR_REC_MODEL = OCR_REC_MODEL; exports.OCR_REC_DICT = OCR_REC_DICT; exports.getOcrModelsDir = getOcrModelsDir; exports.ensureOcrModels = ensureOcrModels; exports.ocrModelsCached = ocrModelsCached; exports.parseCharacterDict = parseCharacterDict; exports.extractLines = extractLines; exports.extractImageRegions = extractImageRegions; 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.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.NO_EDGES = NO_EDGES; exports.joinCellEdges = joinCellEdges; exports.FRAME_READING_UNITS = FRAME_READING_UNITS; exports.recordFrameReadingUnit = recordFrameReadingUnit; exports.restoreImageBullets = restoreImageBullets; exports.detectRightArrowRegions = detectRightArrowRegions; exports.removeSideTabs = removeSideTabs; exports.extractPageBlocksWithLines = extractPageBlocksWithLines;
|
|
8360
|
-
//# sourceMappingURL=chunk-
|
|
8381
|
+
//# sourceMappingURL=chunk-3FGHQWJP.cjs.map
|