kordoc 4.24.21 → 4.24.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/dist/{-IS4RXPEZ.js → -VCEFVSND.js} +11 -11
- package/dist/{chunk-Z6ONQ63K.js → chunk-35PIJFN6.js} +2 -2
- package/dist/{chunk-NRCG3ASU.js → chunk-3B7SMRWJ.js} +2 -2
- package/dist/{chunk-PDOWSDNM.js → chunk-4F6KDOS5.js} +2 -2
- package/dist/{chunk-OMGCVZ4W.cjs → chunk-4REIOZGL.cjs} +2 -2
- package/dist/{chunk-OMGCVZ4W.cjs.map → chunk-4REIOZGL.cjs.map} +1 -1
- package/dist/{chunk-O5ZCJEZ4.js → chunk-4TFAI3ED.js} +2 -2
- package/dist/{chunk-WVZSTMCZ.cjs → chunk-5DRJA7QR.cjs} +3 -3
- package/dist/{chunk-WVZSTMCZ.cjs.map → chunk-5DRJA7QR.cjs.map} +1 -1
- package/dist/{chunk-4OF7DHIT.js → chunk-6QRVXWR5.js} +4 -4
- package/dist/{chunk-BTBFKDPH.js → chunk-ABTMJUDG.js} +2 -2
- package/dist/{chunk-F4GZFIUJ.js → chunk-CC4NIJMB.js} +2 -2
- package/dist/{chunk-CPVXUEKF.js → chunk-D664D3FI.js} +2 -2
- package/dist/{chunk-WQC4XWVT.js → chunk-D72CU53J.js} +2 -2
- package/dist/{chunk-E6G4B457.js → chunk-GGRHL4YH.js} +2 -2
- package/dist/{chunk-B5M676H3.cjs → chunk-HA3YIEAS.cjs} +6 -6
- package/dist/{chunk-B5M676H3.cjs.map → chunk-HA3YIEAS.cjs.map} +1 -1
- package/dist/{chunk-BUFGW3UJ.cjs → chunk-I3SP3API.cjs} +212 -182
- package/dist/chunk-I3SP3API.cjs.map +1 -0
- package/dist/{chunk-MGCIQ43Y.js → chunk-JYYBXKZA.js} +3 -3
- package/dist/{chunk-BNEKESI4.js → chunk-KHTWVYXZ.js} +2 -2
- package/dist/{chunk-V7S36XCU.cjs → chunk-NFSD73DZ.cjs} +3 -3
- package/dist/{chunk-V7S36XCU.cjs.map → chunk-NFSD73DZ.cjs.map} +1 -1
- package/dist/{chunk-F6OHQLN7.js → chunk-OSA4N6SU.js} +37 -7
- package/dist/chunk-OSA4N6SU.js.map +1 -0
- package/dist/{chunk-BV2YG7M6.js → chunk-SGUJUZQO.js} +2 -2
- package/dist/{chunk-B3POEH7X.js → chunk-SWQRHUDA.js} +2 -2
- package/dist/{chunk-3RVASM4C.js → chunk-TR5VN742.js} +4 -4
- package/dist/{chunk-BMXWY36E.js → chunk-TWDML6TT.js} +38 -8
- package/dist/chunk-TWDML6TT.js.map +1 -0
- package/dist/{chunk-N45RCYBL.js → chunk-UD3HVA54.js} +3 -3
- package/dist/{chunk-NE75RO62.js → chunk-V3BF5CHZ.js} +2 -2
- package/dist/{chunk-IZN5BTCW.js → chunk-VEKQVNQB.js} +2 -2
- package/dist/{chunk-MYDHNNPA.js → chunk-VHOXQFOR.js} +36 -8
- package/dist/chunk-VHOXQFOR.js.map +1 -0
- package/dist/{chunk-L556KKBU.cjs → chunk-XQ3RVR6Q.cjs} +79 -79
- package/dist/{chunk-L556KKBU.cjs.map → chunk-XQ3RVR6Q.cjs.map} +1 -1
- package/dist/{chunk-MMZUWRH6.js → chunk-XQ5HPFAM.js} +11 -11
- package/dist/{chunk-UNYH6MTO.js → chunk-XQQBI2SA.js} +2 -2
- package/dist/chunks-ZLTYS4CR.js +10 -0
- package/dist/cli.js +30 -30
- package/dist/{formula-DHBBWQLC.js → formula-3EGYBYNE.js} +3 -3
- package/dist/{formula-G3FQTUOY.cjs → formula-PHF3UITO.cjs} +9 -9
- package/dist/{formula-G3FQTUOY.cjs.map → formula-PHF3UITO.cjs.map} +1 -1
- package/dist/{formula-I4EA7ULD.js → formula-WMAQ55VQ.js} +4 -4
- package/dist/{image-ocr-5YWVBRY6.js → image-ocr-B2NN5TAL.js} +6 -6
- package/dist/{image-ocr-QUVBGNWD.js → image-ocr-KVJD6GHL.js} +9 -9
- package/dist/{image-ocr-THUO6YRG.cjs → image-ocr-T6LIG5GS.cjs} +17 -17
- package/dist/{image-ocr-THUO6YRG.cjs.map → image-ocr-T6LIG5GS.cjs.map} +1 -1
- package/dist/index.cjs +393 -365
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +36 -8
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +23 -23
- package/dist/{model-bundle-6RG5PO3R.js → model-bundle-EXX3IODU.js} +5 -5
- package/dist/{models-CGYIGN6D.js → models-W2SESSYL.js} +5 -5
- package/dist/{parse-worker-v2-F5NXYBU6.js → parse-worker-v2-7BWE7KNP.js} +12 -12
- package/dist/{parser-G5QTRKII.js → parser-2PI6LJCI.js} +9 -9
- package/dist/{parser-I2C5DUXC.js → parser-CEAA577B.js} +12 -12
- package/dist/{parser-GJ4PKW7I.cjs → parser-YUINUJ4S.cjs} +159 -159
- package/dist/{parser-GJ4PKW7I.cjs.map → parser-YUINUJ4S.cjs.map} +1 -1
- package/dist/{pdf-ocr-TNW6YOPX.js → pdf-ocr-F3CIPEPL.js} +6 -6
- package/dist/pdf-ocr-OSTC5UJV.cjs +35 -0
- package/dist/{pdf-ocr-LJKCUXTE.cjs.map → pdf-ocr-OSTC5UJV.cjs.map} +1 -1
- package/dist/{pdf-ocr-U3I74Q4O.js → pdf-ocr-YGWCP4PR.js} +9 -9
- package/dist/{profile-io-5YZCFK7B.js → profile-io-SPV7R36C.js} +3 -3
- package/dist/{rasterize-7VRHPOQX.js → rasterize-LHEDECSI.js} +3 -3
- package/dist/{redact-doc-VK6VGBK3.js → redact-doc-IAO5G53U.js} +11 -11
- package/dist/{render-Y7J6DPRL.js → render-AUZ46UJ4.js} +7 -7
- package/dist/seal-V7X23PUW.js +10 -0
- package/dist/{setup-4XTUDU4X.js → setup-QSGBWJ6M.js} +3 -3
- package/dist/visual-DRB7R6X2.js +21 -0
- package/dist/{watch-SPZRLTKG.js → watch-GG4NB4MW.js} +12 -12
- package/package.json +1 -1
- package/dist/chunk-BMXWY36E.js.map +0 -1
- package/dist/chunk-BUFGW3UJ.cjs.map +0 -1
- package/dist/chunk-F6OHQLN7.js.map +0 -1
- package/dist/chunk-MYDHNNPA.js.map +0 -1
- package/dist/chunks-FYCQOIWO.js +0 -10
- package/dist/pdf-ocr-LJKCUXTE.cjs +0 -35
- package/dist/seal-4QIZ3ZNI.js +0 -10
- package/dist/visual-VEMQJ52W.js +0 -21
- /package/dist/{-IS4RXPEZ.js.map → -VCEFVSND.js.map} +0 -0
- /package/dist/{chunk-Z6ONQ63K.js.map → chunk-35PIJFN6.js.map} +0 -0
- /package/dist/{chunk-NRCG3ASU.js.map → chunk-3B7SMRWJ.js.map} +0 -0
- /package/dist/{chunk-PDOWSDNM.js.map → chunk-4F6KDOS5.js.map} +0 -0
- /package/dist/{chunk-O5ZCJEZ4.js.map → chunk-4TFAI3ED.js.map} +0 -0
- /package/dist/{chunk-4OF7DHIT.js.map → chunk-6QRVXWR5.js.map} +0 -0
- /package/dist/{chunk-BTBFKDPH.js.map → chunk-ABTMJUDG.js.map} +0 -0
- /package/dist/{chunk-F4GZFIUJ.js.map → chunk-CC4NIJMB.js.map} +0 -0
- /package/dist/{chunk-CPVXUEKF.js.map → chunk-D664D3FI.js.map} +0 -0
- /package/dist/{chunk-WQC4XWVT.js.map → chunk-D72CU53J.js.map} +0 -0
- /package/dist/{chunk-E6G4B457.js.map → chunk-GGRHL4YH.js.map} +0 -0
- /package/dist/{chunk-MGCIQ43Y.js.map → chunk-JYYBXKZA.js.map} +0 -0
- /package/dist/{chunk-BNEKESI4.js.map → chunk-KHTWVYXZ.js.map} +0 -0
- /package/dist/{chunk-BV2YG7M6.js.map → chunk-SGUJUZQO.js.map} +0 -0
- /package/dist/{chunk-B3POEH7X.js.map → chunk-SWQRHUDA.js.map} +0 -0
- /package/dist/{chunk-3RVASM4C.js.map → chunk-TR5VN742.js.map} +0 -0
- /package/dist/{chunk-N45RCYBL.js.map → chunk-UD3HVA54.js.map} +0 -0
- /package/dist/{chunk-NE75RO62.js.map → chunk-V3BF5CHZ.js.map} +0 -0
- /package/dist/{chunk-IZN5BTCW.js.map → chunk-VEKQVNQB.js.map} +0 -0
- /package/dist/{chunk-MMZUWRH6.js.map → chunk-XQ5HPFAM.js.map} +0 -0
- /package/dist/{chunk-UNYH6MTO.js.map → chunk-XQQBI2SA.js.map} +0 -0
- /package/dist/{chunks-FYCQOIWO.js.map → chunks-ZLTYS4CR.js.map} +0 -0
- /package/dist/{formula-DHBBWQLC.js.map → formula-3EGYBYNE.js.map} +0 -0
- /package/dist/{formula-I4EA7ULD.js.map → formula-WMAQ55VQ.js.map} +0 -0
- /package/dist/{image-ocr-5YWVBRY6.js.map → image-ocr-B2NN5TAL.js.map} +0 -0
- /package/dist/{image-ocr-QUVBGNWD.js.map → image-ocr-KVJD6GHL.js.map} +0 -0
- /package/dist/{model-bundle-6RG5PO3R.js.map → model-bundle-EXX3IODU.js.map} +0 -0
- /package/dist/{models-CGYIGN6D.js.map → models-W2SESSYL.js.map} +0 -0
- /package/dist/{parse-worker-v2-F5NXYBU6.js.map → parse-worker-v2-7BWE7KNP.js.map} +0 -0
- /package/dist/{parser-G5QTRKII.js.map → parser-2PI6LJCI.js.map} +0 -0
- /package/dist/{parser-I2C5DUXC.js.map → parser-CEAA577B.js.map} +0 -0
- /package/dist/{pdf-ocr-TNW6YOPX.js.map → pdf-ocr-F3CIPEPL.js.map} +0 -0
- /package/dist/{pdf-ocr-U3I74Q4O.js.map → pdf-ocr-YGWCP4PR.js.map} +0 -0
- /package/dist/{profile-io-5YZCFK7B.js.map → profile-io-SPV7R36C.js.map} +0 -0
- /package/dist/{rasterize-7VRHPOQX.js.map → rasterize-LHEDECSI.js.map} +0 -0
- /package/dist/{redact-doc-VK6VGBK3.js.map → redact-doc-IAO5G53U.js.map} +0 -0
- /package/dist/{render-Y7J6DPRL.js.map → render-AUZ46UJ4.js.map} +0 -0
- /package/dist/{seal-4QIZ3ZNI.js.map → seal-V7X23PUW.js.map} +0 -0
- /package/dist/{setup-4XTUDU4X.js.map → setup-QSGBWJ6M.js.map} +0 -0
- /package/dist/{visual-VEMQJ52W.js.map → visual-DRB7R6X2.js.map} +0 -0
- /package/dist/{watch-SPZRLTKG.js.map → watch-GG4NB4MW.js.map} +0 -0
|
@@ -5,15 +5,15 @@
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _chunkHA3YIEAScjs = require('./chunk-HA3YIEAS.cjs');
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _chunkNFSD73DZcjs = require('./chunk-NFSD73DZ.cjs');
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
|
|
16
|
-
var
|
|
16
|
+
var _chunk4REIOZGLcjs = require('./chunk-4REIOZGL.cjs');
|
|
17
17
|
|
|
18
18
|
// src/ocr/models.ts
|
|
19
19
|
var _path = require('path');
|
|
@@ -65,7 +65,7 @@ var OCR_REC_DICT = {
|
|
|
65
65
|
sizeMb: 1
|
|
66
66
|
};
|
|
67
67
|
function getOcrModelsDir() {
|
|
68
|
-
return
|
|
68
|
+
return _chunkNFSD73DZcjs.getModelsDir.call(void 0, "ppocr");
|
|
69
69
|
}
|
|
70
70
|
var DEFAULT_OCR_MODELS = Object.freeze({
|
|
71
71
|
det: { spec: OCR_DET_MODEL },
|
|
@@ -107,7 +107,7 @@ async function ensureOcrModelsFor(sel, onProgress) {
|
|
|
107
107
|
if (!stamp || verifiedInProcess.get(path) !== stamp) todo.push(s.spec);
|
|
108
108
|
}
|
|
109
109
|
if (!todo.length) return;
|
|
110
|
-
await
|
|
110
|
+
await _chunkNFSD73DZcjs.ensureModelsIn.call(void 0, dir, todo, onProgress);
|
|
111
111
|
for (const spec of todo) {
|
|
112
112
|
const path = _path.join.call(void 0, dir, spec.filename), stamp = await fileStamp(path);
|
|
113
113
|
if (stamp) verifiedInProcess.set(path, stamp);
|
|
@@ -1216,7 +1216,10 @@ function extractLines(fnArray, argsArray) {
|
|
|
1216
1216
|
classifyAndAdd(seg, effWidth, horizontals, verticals, fromFill, fromFill ? void 0 : { h: shortH, v: shortV });
|
|
1217
1217
|
});
|
|
1218
1218
|
if (from) outs.forEach((o, k) => {
|
|
1219
|
-
for (let n = from[k]; n < o.length; n++) if (white || k < 2 && !thinFill.has(o[n]))
|
|
1219
|
+
for (let n = from[k]; n < o.length; n++) if (white || k < 2 && !thinFill.has(o[n])) {
|
|
1220
|
+
nonRules.add(o[n]);
|
|
1221
|
+
if (white) WHITE_EDGES.add(o[n]);
|
|
1222
|
+
}
|
|
1220
1223
|
});
|
|
1221
1224
|
currentPath = [];
|
|
1222
1225
|
}
|
|
@@ -1543,8 +1546,15 @@ function preprocessLines(horizontals, verticals, nonRules) {
|
|
|
1543
1546
|
let v = verticals.filter((l) => l.lineWidth <= MAX_LINE_WIDTH);
|
|
1544
1547
|
h = dropShadingStacks(h, "h");
|
|
1545
1548
|
v = dropShadingStacks(v, "v");
|
|
1546
|
-
h = mergeParallelLines(h, "h", nonRules);
|
|
1549
|
+
h = mergeParallelLines(h, "h", nonRules, v);
|
|
1547
1550
|
v = mergeParallelLines(v, "v", nonRules);
|
|
1551
|
+
if (nonRules) {
|
|
1552
|
+
const visH = h.filter((l) => !nonRules.has(l)), visV = v.filter((l) => !nonRules.has(l));
|
|
1553
|
+
const crossH = (w) => visV.filter((c) => c.x1 > w.x1 + 1 && c.x1 < w.x2 - 1 && Math.min(c.y1, c.y2) < w.y1 - 2 && Math.max(c.y1, c.y2) > w.y1 + 2).length;
|
|
1554
|
+
const crossV = (w) => visH.filter((c) => c.y1 > Math.min(w.y1, w.y2) + 1 && c.y1 < Math.max(w.y1, w.y2) - 1 && Math.min(c.x1, c.x2) < w.x1 - 2 && Math.max(c.x1, c.x2) > w.x1 + 2).length;
|
|
1555
|
+
h = h.filter((l) => !(WHITE_EDGES.has(l) && nonRules.has(l) && crossH(l) >= 2));
|
|
1556
|
+
v = v.filter((l) => !(WHITE_EDGES.has(l) && nonRules.has(l) && crossV(l) >= 2));
|
|
1557
|
+
}
|
|
1548
1558
|
return { horizontals: h, verticals: v };
|
|
1549
1559
|
}
|
|
1550
1560
|
var STACK_GAP = 2;
|
|
@@ -1712,7 +1722,8 @@ function closeOpenTableEdges(horizontals, verticals) {
|
|
|
1712
1722
|
}
|
|
1713
1723
|
return synthesized.length ? [...verticals, ...synthesized] : verticals;
|
|
1714
1724
|
}
|
|
1715
|
-
|
|
1725
|
+
var WHITE_EDGES = /* @__PURE__ */ new WeakSet();
|
|
1726
|
+
function mergeParallelLines(lines, dir, nonRules, perp) {
|
|
1716
1727
|
if (lines.length <= 1) return lines;
|
|
1717
1728
|
const sorted = [...lines].sort((a, b) => {
|
|
1718
1729
|
const posA = dir === "h" ? a.y1 : a.x1;
|
|
@@ -1735,7 +1746,26 @@ function mergeParallelLines(lines, dir, nonRules) {
|
|
|
1735
1746
|
const overlap2 = Math.min(prevEnd, currEnd) - Math.max(prevStart, currStart);
|
|
1736
1747
|
const minLen = Math.min(prevEnd - prevStart, currEnd - currStart);
|
|
1737
1748
|
if (overlap2 > minLen * 0.3) {
|
|
1738
|
-
|
|
1749
|
+
const bgPrev = !!_optionalChain([nonRules, 'optionalAccess', _13 => _13.has, 'call', _14 => _14(prev)]) && !nonRules.has(curr), bgCurr = !!_optionalChain([nonRules, 'optionalAccess', _15 => _15.has, 'call', _16 => _16(curr)]) && !nonRules.has(prev);
|
|
1750
|
+
const whPrev = bgPrev && WHITE_EDGES.has(prev), whCurr = bgCurr && WHITE_EDGES.has(curr);
|
|
1751
|
+
if (bgPrev) nonRules.delete(prev);
|
|
1752
|
+
const clip = (w, o) => {
|
|
1753
|
+
if (dir !== "h" || !perp) return false;
|
|
1754
|
+
let n = 0;
|
|
1755
|
+
for (const c of perp) {
|
|
1756
|
+
if (nonRules.has(c) || Math.min(c.y1, c.y2) >= w.y1 - 2 || Math.max(c.y1, c.y2) <= w.y1 + 2) continue;
|
|
1757
|
+
if (c.x1 > w.x1 + 1 && c.x1 < o.x1 - 1 || c.x1 > o.x2 + 1 && c.x1 < w.x2 - 1) n++;
|
|
1758
|
+
}
|
|
1759
|
+
return n >= 2;
|
|
1760
|
+
};
|
|
1761
|
+
if (whPrev && clip(prev, curr)) {
|
|
1762
|
+
prev.x1 = curr.x1;
|
|
1763
|
+
prev.x2 = curr.x2;
|
|
1764
|
+
prev.y1 = prev.y2 = curr.y1;
|
|
1765
|
+
prev.lineWidth = curr.lineWidth;
|
|
1766
|
+
continue;
|
|
1767
|
+
}
|
|
1768
|
+
if (whCurr && clip(curr, prev)) continue;
|
|
1739
1769
|
if (dir === "h") {
|
|
1740
1770
|
prev.x1 = Math.min(prev.x1, curr.x1);
|
|
1741
1771
|
prev.x2 = Math.max(prev.x2, curr.x2);
|
|
@@ -1803,8 +1833,8 @@ function extractImageRegions(fnArray, argsArray, respectClip = false) {
|
|
|
1803
1833
|
break;
|
|
1804
1834
|
case _pdfmjs.OPS.restore: {
|
|
1805
1835
|
const state = stack.pop();
|
|
1806
|
-
ctm = _nullishCoalesce(_optionalChain([state, 'optionalAccess',
|
|
1807
|
-
clip = _nullishCoalesce(_optionalChain([state, 'optionalAccess',
|
|
1836
|
+
ctm = _nullishCoalesce(_optionalChain([state, 'optionalAccess', _17 => _17.ctm]), () => ( [1, 0, 0, 1, 0, 0]));
|
|
1837
|
+
clip = _nullishCoalesce(_optionalChain([state, 'optionalAccess', _18 => _18.clip]), () => ( null));
|
|
1808
1838
|
break;
|
|
1809
1839
|
}
|
|
1810
1840
|
case _pdfmjs.OPS.transform: {
|
|
@@ -1815,19 +1845,19 @@ function extractImageRegions(fnArray, argsArray, respectClip = false) {
|
|
|
1815
1845
|
// Form XObject 는 /Matrix 공간에서 그린다 — pdfjs 인자 [matrix, bbox], End 에서 복원 (line-extract.ts 와 같음)
|
|
1816
1846
|
case _pdfmjs.OPS.paintFormXObjectBegin: {
|
|
1817
1847
|
stack.push({ ctm, clip });
|
|
1818
|
-
const m = _optionalChain([argsArray, 'access',
|
|
1848
|
+
const m = _optionalChain([argsArray, 'access', _19 => _19[i], 'optionalAccess', _20 => _20[0]]);
|
|
1819
1849
|
if (Array.isArray(m) && m.length >= 6) ctm = multiplyTransform(ctm, m);
|
|
1820
1850
|
break;
|
|
1821
1851
|
}
|
|
1822
1852
|
case _pdfmjs.OPS.paintFormXObjectEnd: {
|
|
1823
1853
|
const state = stack.pop();
|
|
1824
|
-
ctm = _nullishCoalesce(_optionalChain([state, 'optionalAccess',
|
|
1825
|
-
clip = _nullishCoalesce(_optionalChain([state, 'optionalAccess',
|
|
1854
|
+
ctm = _nullishCoalesce(_optionalChain([state, 'optionalAccess', _21 => _21.ctm]), () => ( [1, 0, 0, 1, 0, 0]));
|
|
1855
|
+
clip = _nullishCoalesce(_optionalChain([state, 'optionalAccess', _22 => _22.clip]), () => ( null));
|
|
1826
1856
|
break;
|
|
1827
1857
|
}
|
|
1828
1858
|
case _pdfmjs.OPS.constructPath: {
|
|
1829
1859
|
const [ops, coords] = argsArray[i];
|
|
1830
|
-
pathRect = pathRect === void 0 && _optionalChain([ops, 'optionalAccess',
|
|
1860
|
+
pathRect = pathRect === void 0 && _optionalChain([ops, 'optionalAccess', _23 => _23.length]) === 1 && ops[0] === _pdfmjs.OPS.rectangle && _optionalChain([coords, 'optionalAccess', _24 => _24.length]) >= 4 ? transformedRect(ctm, coords[0], coords[1], coords[2], coords[3]) : null;
|
|
1831
1861
|
break;
|
|
1832
1862
|
}
|
|
1833
1863
|
case _pdfmjs.OPS.clip:
|
|
@@ -1980,7 +2010,7 @@ function hasShadedRowBands(host, clips, fills, verticals, horizontals) {
|
|
|
1980
2010
|
if (!host.colXs.slice(1, -1).every((x) => verticals.some((v) => !v.fromFill && near2(v.x1, x) && v.y1 <= host.bbox.y1 + tol && v.y2 >= host.bbox.y2 - tol))) return false;
|
|
1981
2011
|
const covered = /* @__PURE__ */ new Set();
|
|
1982
2012
|
for (const band of bands) {
|
|
1983
|
-
if (band.clipParent || !_optionalChain([band, 'access',
|
|
2013
|
+
if (band.clipParent || !_optionalChain([band, 'access', _25 => _25.cells, 'optionalAccess', _26 => _26.length]) || band.colXs.length !== host.colXs.length || !band.colXs.every((x, i) => near2(x, host.colXs[i]))) return false;
|
|
1984
2014
|
const start = host.rowYs.findIndex((y) => near2(y, band.rowYs[0]));
|
|
1985
2015
|
if (start < 0 || !band.rowYs.every((y, i) => near2(y, host.rowYs[start + i]))) return false;
|
|
1986
2016
|
if (!band.rowYs.every((y) => horizontals.some((h) => !h.fromFill && near2(h.y1, y) && h.x1 <= host.bbox.x1 + tol && h.x2 >= host.bbox.x2 - tol))) return false;
|
|
@@ -2082,7 +2112,7 @@ function mergeVertices(vertices) {
|
|
|
2082
2112
|
const candidates = [];
|
|
2083
2113
|
for (let dx = -1; dx <= 1; dx++) {
|
|
2084
2114
|
for (let dy = -1; dy <= 1; dy++) {
|
|
2085
|
-
const arr = _optionalChain([buckets, 'access',
|
|
2115
|
+
const arr = _optionalChain([buckets, 'access', _27 => _27.get, 'call', _28 => _28(cx + dx), 'optionalAccess', _29 => _29.get, 'call', _30 => _30(cy + dy)]);
|
|
2086
2116
|
if (!arr) continue;
|
|
2087
2117
|
for (const j of arr) {
|
|
2088
2118
|
if (j > i && !used[j]) candidates.push(j);
|
|
@@ -2209,7 +2239,7 @@ function dropShadingClipGrids(clipGrids, lineGrids, fillRects, verticals = [], h
|
|
|
2209
2239
|
const area = (b) => Math.max(0, b.x2 - b.x1) * Math.max(0, b.y2 - b.y1);
|
|
2210
2240
|
const inter = (a, b) => area({ x1: Math.max(a.x1, b.x1), y1: Math.max(a.y1, b.y1), x2: Math.min(a.x2, b.x2), y2: Math.min(a.y2, b.y2) });
|
|
2211
2241
|
return clipGrids.filter((c) => {
|
|
2212
|
-
if (!_optionalChain([c, 'access',
|
|
2242
|
+
if (!_optionalChain([c, 'access', _31 => _31.cells, 'optionalAccess', _32 => _32.length]) || c.clipParent) return true;
|
|
2213
2243
|
const sourceCells = c.cells.filter((cell) => !cell.filler);
|
|
2214
2244
|
if (sourceCells.length === 0) return true;
|
|
2215
2245
|
const shaded = sourceCells.every((cell) => fillRects.some((f) => near2(f.x1, cell.bbox.x1) && near2(f.x2, cell.bbox.x2) && near2(f.y1, cell.bbox.y1) && near2(f.y2, cell.bbox.y2)));
|
|
@@ -2219,7 +2249,7 @@ function dropShadingClipGrids(clipGrids, lineGrids, fillRects, verticals = [], h
|
|
|
2219
2249
|
const host = lineGrids.find((l) => (
|
|
2220
2250
|
// Inferred filler cells carry no boundary evidence. Replace their frame only
|
|
2221
2251
|
// with a finer ruled grid of the same extent, never a larger surrounding form.
|
|
2222
|
-
(!c.cells.some((cell) => cell.filler) || near2(c.bbox.x1, l.bbox.x1) && near2(c.bbox.x2, l.bbox.x2) && near2(c.bbox.y1, l.bbox.y1) && near2(c.bbox.y2, l.bbox.y2) && l.rowYs.length > c.rowYs.length && sourceCells.every((cell) => [cell.bbox.y1, cell.bbox.y2].every((y) => l.rowYs.some((ly) => near2(y, ly))))) && c.bbox.x1 >= l.bbox.x1 - SHADE_CLIP_TOL && c.bbox.x2 <= l.bbox.x2 + SHADE_CLIP_TOL && c.bbox.y1 >= l.bbox.y1 - SHADE_CLIP_TOL && c.bbox.y2 <= l.bbox.y2 + SHADE_CLIP_TOL && c.colXs.every((x) => l.colXs.some((lx) => near2(lx, x))) && (clipGrids.reduce((s, o) => s + (_optionalChain([o, 'access',
|
|
2252
|
+
(!c.cells.some((cell) => cell.filler) || near2(c.bbox.x1, l.bbox.x1) && near2(c.bbox.x2, l.bbox.x2) && near2(c.bbox.y1, l.bbox.y1) && near2(c.bbox.y2, l.bbox.y2) && l.rowYs.length > c.rowYs.length && sourceCells.every((cell) => [cell.bbox.y1, cell.bbox.y2].every((y) => l.rowYs.some((ly) => near2(y, ly))))) && c.bbox.x1 >= l.bbox.x1 - SHADE_CLIP_TOL && c.bbox.x2 <= l.bbox.x2 + SHADE_CLIP_TOL && c.bbox.y1 >= l.bbox.y1 - SHADE_CLIP_TOL && c.bbox.y2 <= l.bbox.y2 + SHADE_CLIP_TOL && c.colXs.every((x) => l.colXs.some((lx) => near2(lx, x))) && (clipGrids.reduce((s, o) => s + (_optionalChain([o, 'access', _33 => _33.cells, 'optionalAccess', _34 => _34.some, 'call', _35 => _35((cell) => cell.filler)]) ? o.cells.filter((cell) => !cell.filler).reduce((a, cell) => a + inter(cell.bbox, l.bbox), 0) : inter(o.bbox, l.bbox)), 0) <= area(l.bbox) * SHADE_CLIP_MAX_AREA || l.rowYs.length === c.rowYs.length + 1 && c.rowYs.every((y, i) => near2(y, l.rowYs[i])) && l.colXs.length === c.colXs.length && c.colXs.every((x, i) => near2(x, l.colXs[i])) && !clipGrids.some((o) => o !== c && inter(o.bbox, l.bbox) > 0) || hasShadedRowBands(l, clipGrids, fillRects, verticals, horizontals))
|
|
2223
2253
|
));
|
|
2224
2254
|
return !host;
|
|
2225
2255
|
});
|
|
@@ -2234,12 +2264,12 @@ function dropHeadBandClipGrids(clipGrids, lineGrids) {
|
|
|
2234
2264
|
if (clipGrids.length === 0 || lineGrids.length === 0) return clipGrids;
|
|
2235
2265
|
const near2 = (a, b) => Math.abs(a - b) <= SHADE_CLIP_TOL;
|
|
2236
2266
|
const overlaps = (a, b) => Math.min(a.x2, b.x2) > Math.max(a.x1, b.x1) && Math.min(a.y2, b.y2) > Math.max(a.y1, b.y1);
|
|
2237
|
-
const kept = clipGrids.filter((c) => c.clipParent || !_optionalChain([c, 'access',
|
|
2267
|
+
const kept = clipGrids.filter((c) => c.clipParent || !_optionalChain([c, 'access', _36 => _36.cells, 'optionalAccess', _37 => _37.length]) || !lineGrids.some((l) => l.rowYs.length > c.rowYs.length && l.colXs.length === c.colXs.length && c.colXs.every((x, k) => near2(x, l.colXs[k])) && c.rowYs.every((y, k) => near2(y, l.rowYs[k])) && !clipGrids.some((o) => o !== c && overlaps(o.bbox, l.bbox))));
|
|
2238
2268
|
return kept.filter((c) => !lineGrids.some((l) => headBandTiles(kept, l, near2, overlaps).includes(c)));
|
|
2239
2269
|
}
|
|
2240
2270
|
function headBandTiles(clips, l, near2, overlaps) {
|
|
2241
2271
|
const onRow = (y) => l.rowYs.some((r) => near2(r, y));
|
|
2242
|
-
const band = clips.filter((c) => !c.clipParent && _optionalChain([c, 'access',
|
|
2272
|
+
const band = clips.filter((c) => !c.clipParent && _optionalChain([c, 'access', _38 => _38.cells, 'optionalAccess', _39 => _39.length]) && near2(c.bbox.y2, l.bbox.y2) && c.bbox.y1 > l.bbox.y1 + SHADE_CLIP_TOL && c.bbox.x1 >= l.bbox.x1 - SHADE_CLIP_TOL && c.bbox.x2 <= l.bbox.x2 + SHADE_CLIP_TOL && c.rowYs.every(onRow)).sort((a, b) => a.bbox.x1 - b.bbox.x1);
|
|
2243
2273
|
if (band.length < 2 || !near2(band[0].bbox.x1, l.bbox.x1) || !near2(band[band.length - 1].bbox.x2, l.bbox.x2)) return [];
|
|
2244
2274
|
if (band.some((c, k) => k > 0 && c.bbox.x1 > band[k - 1].bbox.x2 + SHADE_CLIP_TOL)) return [];
|
|
2245
2275
|
const bottom = Math.min(...band.map((c) => c.bbox.y1));
|
|
@@ -2595,7 +2625,7 @@ function buildClipCellGrids(rects, strokedH, strokedV, pageWidth, pageHeight, te
|
|
|
2595
2625
|
for (let dx = -1; dx <= 1 && !duplicate; dx++) {
|
|
2596
2626
|
const ys2 = buckets.get(bx + dx);
|
|
2597
2627
|
for (let dy = -1; dy <= 1 && !duplicate; dy++) {
|
|
2598
|
-
duplicate = _nullishCoalesce(_optionalChain([ys2, 'optionalAccess',
|
|
2628
|
+
duplicate = _nullishCoalesce(_optionalChain([ys2, 'optionalAccess', _40 => _40.get, 'call', _41 => _41(by + dy), 'optionalAccess', _42 => _42.some, 'call', _43 => _43((c) => sameRect(c, r))]), () => ( false));
|
|
2599
2629
|
}
|
|
2600
2630
|
}
|
|
2601
2631
|
if (duplicate) continue;
|
|
@@ -2743,7 +2773,7 @@ function buildClipCellGrids(rects, strokedH, strokedV, pageWidth, pageHeight, te
|
|
|
2743
2773
|
else groups.set(r, [i]);
|
|
2744
2774
|
}
|
|
2745
2775
|
const containers = cells.filter((_, i) => isContainer[i]);
|
|
2746
|
-
const groupSize = (i) => _nullishCoalesce(_optionalChain([groups, 'access',
|
|
2776
|
+
const groupSize = (i) => _nullishCoalesce(_optionalChain([groups, 'access', _44 => _44.get, 'call', _45 => _45(find(i)), 'optionalAccess', _46 => _46.length]), () => ( 0));
|
|
2747
2777
|
const isGridMember = (i) => groupSize(i) >= CLIP_MIN_GROUP;
|
|
2748
2778
|
const framed = (r) => edgeStroked(strokedH, "h", r.y1, r.x1, r.x2) && edgeStroked(strokedH, "h", r.y2, r.x1, r.x2) && edgeStroked(strokedV, "v", r.x1, r.y1, r.y2) && edgeStroked(strokedV, "v", r.x2, r.y1, r.y2);
|
|
2749
2779
|
const titledFrame = (r) => r.y1 >= pageHeight * TITLED_FRAME_MIN_TOP && r.x2 - r.x1 >= pageWidth * TITLED_FRAME_MIN_WIDTH && textPoints.some((p) => p.y < r.y1 && p.y > pageHeight * HEADER_BAND && p.x >= r.x1 - CLIP_EDGE_TOL && p.x <= r.x2 + CLIP_EDGE_TOL) && textPoints.some((p) => p.x > r.x1 && p.x < r.x2 && p.y > r.y1 && p.y < r.y2);
|
|
@@ -3124,8 +3154,8 @@ function childRules(r, grid) {
|
|
|
3124
3154
|
}
|
|
3125
3155
|
function recordClipCellEdges(grids, horizontals, verticals, nonRules) {
|
|
3126
3156
|
if (!grids.some((g) => g.cells)) return;
|
|
3127
|
-
const h = rules(_optionalChain([nonRules, 'optionalAccess',
|
|
3128
|
-
const v = rules(_optionalChain([nonRules, 'optionalAccess',
|
|
3157
|
+
const h = rules(_optionalChain([nonRules, 'optionalAccess', _47 => _47.size]) ? horizontals.filter((l) => !nonRules.has(l)) : horizontals, "h");
|
|
3158
|
+
const v = rules(_optionalChain([nonRules, 'optionalAccess', _48 => _48.size]) ? verticals.filter((l) => !nonRules.has(l)) : verticals, "v");
|
|
3129
3159
|
for (const g of grids) {
|
|
3130
3160
|
if (!g.cells) continue;
|
|
3131
3161
|
const ownH = childRules(h, g), ownV = childRules(v, g);
|
|
@@ -3141,9 +3171,9 @@ function recordOpenEndCellEdges(grid, cells, horizontals) {
|
|
|
3141
3171
|
const end = horizontals.find((l) => OPEN_END_RULES.has(l) && Math.abs(l.y1 - b.y1) <= EDGE_NEAR2 && Math.abs(l.x1 - b.x1) <= EDGE_NEAR2 && Math.abs(l.x2 - b.x2) <= EDGE_NEAR2);
|
|
3142
3172
|
const raw = end && OPEN_END_RULES.get(end);
|
|
3143
3173
|
if (!raw) return;
|
|
3144
|
-
const hs = raw.horizontals.filter((l) => !_optionalChain([raw, 'access',
|
|
3174
|
+
const hs = raw.horizontals.filter((l) => !_optionalChain([raw, 'access', _49 => _49.nonRules, 'optionalAccess', _50 => _50.has, 'call', _51 => _51(l)]));
|
|
3145
3175
|
if (hs.some((l) => Math.abs(l.y1 - b.y1) <= EDGE_NEAR2 && Math.min(l.x2, b.x2) - Math.max(l.x1, b.x1) > TIP_MAX)) return;
|
|
3146
|
-
const h = rules(hs, "h"), v = rules(raw.verticals.filter((l) => !_optionalChain([raw, 'access',
|
|
3176
|
+
const h = rules(hs, "h"), v = rules(raw.verticals.filter((l) => !_optionalChain([raw, 'access', _52 => _52.nonRules, 'optionalAccess', _53 => _53.has, 'call', _54 => _54(l)])), "v");
|
|
3147
3177
|
const edges = cells.map((c) => edgesOf(c.bbox, h, v));
|
|
3148
3178
|
const last = grid.rowYs.length - 2;
|
|
3149
3179
|
if (!cells.every((c, i) => {
|
|
@@ -3154,16 +3184,16 @@ function recordOpenEndCellEdges(grid, cells, horizontals) {
|
|
|
3154
3184
|
}
|
|
3155
3185
|
function takeClipCellEdges(from, to) {
|
|
3156
3186
|
const e = CLIP_CELL_EDGES.get(from);
|
|
3157
|
-
if (e)
|
|
3187
|
+
if (e) _chunkHA3YIEAScjs.CELL_EDGES.set(to, e);
|
|
3158
3188
|
}
|
|
3159
3189
|
function hasOpenCellSeam(a, b) {
|
|
3160
|
-
const u =
|
|
3190
|
+
const u = _chunkHA3YIEAScjs.CELL_EDGES.get(a), d = _chunkHA3YIEAScjs.CELL_EDGES.get(b);
|
|
3161
3191
|
return !!u && !!d && u.t && !u.b && !d.t && d.b && u.l && u.r && d.l && d.r;
|
|
3162
3192
|
}
|
|
3163
3193
|
function joinCellEdges(a, b) {
|
|
3164
|
-
const u =
|
|
3194
|
+
const u = _chunkHA3YIEAScjs.CELL_EDGES.get(a), d = _chunkHA3YIEAScjs.CELL_EDGES.get(b);
|
|
3165
3195
|
if (!u || !d) return;
|
|
3166
|
-
|
|
3196
|
+
_chunkHA3YIEAScjs.CELL_EDGES.set(a, { t: u.t, b: d.b, l: u.l || d.l, r: u.r || d.r });
|
|
3167
3197
|
}
|
|
3168
3198
|
|
|
3169
3199
|
// src/pdf/cell-extract.ts
|
|
@@ -3339,7 +3369,7 @@ function tagScripts(text, lines) {
|
|
|
3339
3369
|
const [s, e, kind] = marks[m];
|
|
3340
3370
|
out = out.slice(0, s) + `<${kind}>` + out.slice(s, e) + `</${kind}>` + out.slice(e);
|
|
3341
3371
|
}
|
|
3342
|
-
return
|
|
3372
|
+
return _chunkHA3YIEAScjs.tidyScriptTags.call(void 0, out);
|
|
3343
3373
|
}
|
|
3344
3374
|
|
|
3345
3375
|
// src/pdf/line-wrap.ts
|
|
@@ -3386,12 +3416,12 @@ var WrapLexicon = (_class = class {constructor() { _class.prototype.__init.call(
|
|
|
3386
3416
|
const t = toks[i], n = t.length;
|
|
3387
3417
|
if (i > 0 && i < toks.length - 1) {
|
|
3388
3418
|
bump(this.words, t);
|
|
3389
|
-
const run = _nullishCoalesce(_optionalChain([t, 'access',
|
|
3419
|
+
const run = _nullishCoalesce(_optionalChain([t, 'access', _55 => _55.match, 'call', _56 => _56(/^[가-힣]+/), 'optionalAccess', _57 => _57[0]]), () => ( ""));
|
|
3390
3420
|
for (let j = 2; j <= Math.min(run.length, 6); j++) this.heads.add(run.slice(0, j));
|
|
3391
3421
|
}
|
|
3392
3422
|
if (i + 1 < toks.length) {
|
|
3393
3423
|
this.pairs.add(t + " " + toks[i + 1]);
|
|
3394
|
-
const tail = _optionalChain([t, 'access',
|
|
3424
|
+
const tail = _optionalChain([t, 'access', _58 => _58.match, 'call', _59 => _59(/[가-힣]+$/), 'optionalAccess', _60 => _60[0]]);
|
|
3395
3425
|
if (tail) this.spacedHeads.add(tail + " " + toks[i + 1].charAt(0));
|
|
3396
3426
|
}
|
|
3397
3427
|
for (let a = 0; a + 1 < n; a++) {
|
|
@@ -3428,14 +3458,14 @@ var WrapLexicon = (_class = class {constructor() { _class.prototype.__init.call(
|
|
|
3428
3458
|
const n = left.length;
|
|
3429
3459
|
if (n < 2 || right.length < 2) return null;
|
|
3430
3460
|
const k1 = pairKey(left.charCodeAt(n - 2), left.charCodeAt(n - 1)), k2 = pairKey(right.charCodeAt(0), right.charCodeAt(1));
|
|
3431
|
-
return decideCounts(_nullishCoalesce(_optionalChain([this, 'access',
|
|
3461
|
+
return decideCounts(_nullishCoalesce(_optionalChain([this, 'access', _61 => _61.joined2, 'access', _62 => _62.get, 'call', _63 => _63(k1), 'optionalAccess', _64 => _64.get, 'call', _65 => _65(k2)]), () => ( 0)), _nullishCoalesce(_optionalChain([this, 'access', _66 => _66.spaced2, 'access', _67 => _67.get, 'call', _68 => _68(k1), 'optionalAccess', _69 => _69.get, 'call', _70 => _70(k2)]), () => ( 0)));
|
|
3432
3462
|
}
|
|
3433
3463
|
/** 꺾인 자리 증거: "" 붙음 · " " 띄움 · null 모름 (두 글자 증거가 갈리거나 없으면 한 글자) */
|
|
3434
3464
|
evidence(left, right) {
|
|
3435
3465
|
const n = left.length;
|
|
3436
3466
|
if (n >= 2 && right.length >= 2) {
|
|
3437
3467
|
const k1 = pairKey(left.charCodeAt(n - 2), left.charCodeAt(n - 1)), k2 = pairKey(right.charCodeAt(0), right.charCodeAt(1));
|
|
3438
|
-
const v = decideCounts(_nullishCoalesce(_optionalChain([this, 'access',
|
|
3468
|
+
const v = decideCounts(_nullishCoalesce(_optionalChain([this, 'access', _71 => _71.joined2, 'access', _72 => _72.get, 'call', _73 => _73(k1), 'optionalAccess', _74 => _74.get, 'call', _75 => _75(k2)]), () => ( 0)), _nullishCoalesce(_optionalChain([this, 'access', _76 => _76.spaced2, 'access', _77 => _77.get, 'call', _78 => _78(k1), 'optionalAccess', _79 => _79.get, 'call', _80 => _80(k2)]), () => ( 0)));
|
|
3439
3469
|
if (v !== null) return v;
|
|
3440
3470
|
}
|
|
3441
3471
|
if (n && right.length) {
|
|
@@ -3510,11 +3540,11 @@ function wrapJoiner(prevText, nextText, lex, heads = true) {
|
|
|
3510
3540
|
if (particleContinues(left, right)) return "";
|
|
3511
3541
|
if (endsAsWord(left)) return " ";
|
|
3512
3542
|
if (/[A-Za-z]-$/.test(left) && /^[A-Za-z]/.test(right) && !/[가-힣]/.test(prev + next)) {
|
|
3513
|
-
return _optionalChain([lex, 'optionalAccess',
|
|
3543
|
+
return _optionalChain([lex, 'optionalAccess', _81 => _81.joinedWord, 'call', _82 => _82(left, right.replace(/[.,;:!?)]*$/, ""))]) ? "" : " ";
|
|
3514
3544
|
}
|
|
3515
3545
|
if (/[·ㆍ‧-]/.test(a) && !/[·ㆍ‧…]{2}$/.test(prev) && /[가-힣A-Za-z0-9]/.test(b)) return "";
|
|
3516
3546
|
if (/[A-Za-z]/.test(a) && /[A-Za-z]/.test(b) || /\d/.test(a) && /\d/.test(b)) return " ";
|
|
3517
|
-
const ev = _optionalChain([lex, 'optionalAccess',
|
|
3547
|
+
const ev = _optionalChain([lex, 'optionalAccess', _83 => _83.evidence, 'call', _84 => _84(left, right)]);
|
|
3518
3548
|
if (ev != null) return ev;
|
|
3519
3549
|
if (lex && /[가-힣A-Za-z0-9]$/.test(left) && /^[가-힣A-Za-z0-9]/.test(right) && lex.joinedWord(left, right.replace(/[.,)」』’”;:]+$/, ""))) return "";
|
|
3520
3550
|
if (/\d$/.test(left) && COUNTER.test(right)) return "";
|
|
@@ -3522,7 +3552,7 @@ function wrapJoiner(prevText, nextText, lex, heads = true) {
|
|
|
3522
3552
|
const r1 = right.replace(/[.,)」』’”]+$/, "");
|
|
3523
3553
|
if (lex && /[가-힣]$/.test(left) && /^[가-힣]$/.test(r1) && !STANDALONE_SYLLABLE.test(r1) && !lex.isWord(r1) && !lex.isWord(right)) return "";
|
|
3524
3554
|
if (lex && heads) {
|
|
3525
|
-
const tail = _optionalChain([left, 'access',
|
|
3555
|
+
const tail = _optionalChain([left, 'access', _85 => _85.match, 'call', _86 => _86(/[가-힣]+$/), 'optionalAccess', _87 => _87[0]]), run = _optionalChain([right, 'access', _88 => _88.match, 'call', _89 => _89(/^[가-힣]+/), 'optionalAccess', _90 => _90[0]]);
|
|
3526
3556
|
if (tail && run && !STANDALONE_SYLLABLE.test(tail) && lex.startsWord(tail + run.slice(0, 2)) && !lex.spacedHead(tail, run[0])) return "";
|
|
3527
3557
|
if (/[가-힣]{2}$/.test(left) && /^\([^()\s]*\)/.test(right) && !endsAsWord(left) && !/(?:함|음|됨|임|다)$/.test(left) && !BARE_UNIT_PAREN.test(right) && !/^\(\d/.test(right)) return "";
|
|
3528
3558
|
}
|
|
@@ -3557,14 +3587,14 @@ function joinPageBreakWraps(blocks, lex) {
|
|
|
3557
3587
|
if (a.type !== "paragraph" && a.type !== "list" || b.type !== "paragraph") continue;
|
|
3558
3588
|
const last = a.bbox && PARA_LAST_LINE.get(a.bbox), fs = last ? last.fontSize : 0;
|
|
3559
3589
|
if (!last || fs <= 0 || (_nullishCoalesce(pageRight.get(a.pageNumber), () => ( Infinity))) - last.right >= BODY_FULL_TOL * fs) continue;
|
|
3560
|
-
if (last.width < BODY_MIN_WIDTH_EM * fs || Math.abs((_nullishCoalesce(_optionalChain([b, 'access',
|
|
3590
|
+
if (last.width < BODY_MIN_WIDTH_EM * fs || Math.abs((_nullishCoalesce(_optionalChain([b, 'access', _91 => _91.style, 'optionalAccess', _92 => _92.fontSize]), () => ( 0))) - fs) > 0.15 * fs) continue;
|
|
3561
3591
|
const bt = b.text.replace(MARKUP, "");
|
|
3562
3592
|
if (startsNewItem(a.text, b.text) || PAGE_REF_TAIL.test(a.text) || PAGE_ITEM_HEAD.test(bt)) continue;
|
|
3563
3593
|
if (PAGE_HEAD_MARK.test(bt) && !(/^[\u25a0-\u25ff]/.test(bt) && a.text.includes(bt[0]))) continue;
|
|
3564
3594
|
const firstLeft = b.bbox && PARA_FIRST_LEFT.get(b.bbox);
|
|
3565
3595
|
const indented = firstLeft === void 0 || firstLeft - (_nullishCoalesce(pageLeft.get(b.pageNumber), () => ( firstLeft))) >= 0.3 * fs;
|
|
3566
3596
|
if (indented && SENTENCE_END.test(a.text.replace(MARKUP, "").trimEnd())) continue;
|
|
3567
|
-
if (Math.round(_nullishCoalesce(_optionalChain([b, 'access',
|
|
3597
|
+
if (Math.round(_nullishCoalesce(_optionalChain([b, 'access', _93 => _93.style, 'optionalAccess', _94 => _94.fontSize]), () => ( 0))) !== Math.round(fs) && titleLike(b.text)) continue;
|
|
3568
3598
|
if (/\t/.test(a.text.slice(a.text.lastIndexOf("\n") + 1).replace(/^\S{1,8}\t/, "")) && titleLike(bt.trim().split("\n")[0])) continue;
|
|
3569
3599
|
const joined = wrapJoiner(a.text, b.text, lex);
|
|
3570
3600
|
const head = a.text, joiner = joined === "" && last.spaceAfter ? " " : joined;
|
|
@@ -3613,7 +3643,7 @@ function bodyLineJoins(lines, lex) {
|
|
|
3613
3643
|
for (const l of lines) if (!HANGING.test(l.text) && l.right > inner) inner = l.right;
|
|
3614
3644
|
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;
|
|
3615
3645
|
const nextWordNoRoom = (a, b) => {
|
|
3616
|
-
const w = _optionalChain([b, 'access',
|
|
3646
|
+
const w = _optionalChain([b, 'access', _95 => _95.text, 'access', _96 => _96.trim, 'call', _97 => _97(), 'access', _98 => _98.match, 'call', _99 => _99(/^\S+/), 'optionalAccess', _100 => _100[0]]);
|
|
3617
3647
|
const n = [...b.text.trim()].length;
|
|
3618
3648
|
if (!w || n === 0) return false;
|
|
3619
3649
|
const em = (b.right - b.left) / n;
|
|
@@ -3639,7 +3669,7 @@ function bodyLineJoins(lines, lex) {
|
|
|
3639
3669
|
const a = lines[i], b = lines[i + 1];
|
|
3640
3670
|
const fs = a.fontSize;
|
|
3641
3671
|
const own = i === i1 ? p2 : p1;
|
|
3642
|
-
const others = Number.isFinite(own) ? own : _nullishCoalesce(_optionalChain([lex, 'optionalAccess',
|
|
3672
|
+
const others = Number.isFinite(own) ? own : _nullishCoalesce(_optionalChain([lex, 'optionalAccess', _101 => _101.bodyPitch, 'call', _102 => _102(fs)]), () => ( Infinity));
|
|
3643
3673
|
const maxPitch = Number.isFinite(others) ? Math.min(BODY_MAX_PITCH_ABS_EM * fs, Math.max(BODY_MAX_PITCH_EM * fs, others * BODY_PITCH_REL)) : BODY_MAX_PITCH_EM * fs;
|
|
3644
3674
|
const wordWrap = ragged && !full(a) && nextWordNoRoom(a, b) && !MULTI_LEVEL_NUMBER.test(b.text.trimStart());
|
|
3645
3675
|
const wraps = fs > 0 && (full(a) || wordWrap) && a.right - a.left >= BODY_MIN_WIDTH_EM * fs && a.y - b.y > 0 && a.y - b.y < maxPitch && Math.abs(b.fontSize - fs) <= 0.15 * fs && !startsNewItem(a.text, b.text);
|
|
@@ -3810,7 +3840,7 @@ function cellTextToString(items, wrap) {
|
|
|
3810
3840
|
const merged = mergeSuperscriptRows(lines).map((line) => sortLineByX(line));
|
|
3811
3841
|
const textLines = merged.map((s) => {
|
|
3812
3842
|
if (s.length === 1) return s[0].text;
|
|
3813
|
-
if (s.length === 2 && /^[가-힣]$/.test(s[0].text) && /^[가-힣]$/.test(s[1].text) && !!_optionalChain([wrap, 'optionalAccess',
|
|
3843
|
+
if (s.length === 2 && /^[가-힣]$/.test(s[0].text) && /^[가-힣]$/.test(s[1].text) && !!_optionalChain([wrap, 'optionalAccess', _103 => _103.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;
|
|
3814
3844
|
const evenSpaced = detectEvenSpacedItems(s, true);
|
|
3815
3845
|
const hangulLine = s.some((it) => /[가-힣]/.test(it.text));
|
|
3816
3846
|
let result = s[0].text;
|
|
@@ -3957,12 +3987,12 @@ function markEvenRun(items, visible, result, start, end) {
|
|
|
3957
3987
|
}
|
|
3958
3988
|
function mergeCellTextLines(textLines, wrap) {
|
|
3959
3989
|
if (textLines.length <= 1) return textLines[0] || "";
|
|
3960
|
-
const numberWrapped = (k) => !!_optionalChain([wrap, 'optionalAccess',
|
|
3990
|
+
const numberWrapped = (k) => !!_optionalChain([wrap, 'optionalAccess', _104 => _104.wraps, 'access', _105 => _105[k]]) && (_nullishCoalesce(_optionalChain([wrap, 'access', _106 => _106.wide, 'optionalAccess', _107 => _107[k]]), () => ( true)));
|
|
3961
3991
|
const merged = [textLines[0]];
|
|
3962
3992
|
for (let i = 1; i < textLines.length; i++) {
|
|
3963
3993
|
const prev = merged[merged.length - 1];
|
|
3964
3994
|
const curr = textLines[i];
|
|
3965
|
-
if (wrap ? wrap.wraps[i - 1] && !_optionalChain([wrap, 'access',
|
|
3995
|
+
if (wrap ? wrap.wraps[i - 1] && !_optionalChain([wrap, 'access', _108 => _108.spaced, 'optionalAccess', _109 => _109[i - 1]]) && !startsNewItem(prev, curr) && wrapJoiner(prev, curr, wrap.lex, false) === "" : /[가-힣]$/.test(prev) && /^[가-힣]+$/.test(curr) && curr.length <= 8 && !curr.includes(" ")) {
|
|
3966
3996
|
merged[merged.length - 1] = prev + curr;
|
|
3967
3997
|
} else if (curr.trim().length <= 3 && /^[)\]%}]/.test(curr.trim())) {
|
|
3968
3998
|
merged[merged.length - 1] = prev + curr.trim();
|
|
@@ -4057,7 +4087,7 @@ function normalizeUndersegmentedTable(originalCells, colXs, items, rowYs) {
|
|
|
4057
4087
|
if (numRows > MAX_UNDERSEGMENTED_ROWS || numCols < MIN_UNDERSEGMENTED_COLUMNS) return null;
|
|
4058
4088
|
if (items.length === 0) return null;
|
|
4059
4089
|
if (numRows >= 3) {
|
|
4060
|
-
if (_optionalChain([rowYs, 'optionalAccess',
|
|
4090
|
+
if (_optionalChain([rowYs, 'optionalAccess', _110 => _110.length]) !== numRows + 1) return null;
|
|
4061
4091
|
const rebuilt2 = [];
|
|
4062
4092
|
let expanded = 0;
|
|
4063
4093
|
for (let r = 0; r < numRows; r++) {
|
|
@@ -4151,7 +4181,7 @@ function sortLineByX(items) {
|
|
|
4151
4181
|
e++;
|
|
4152
4182
|
}
|
|
4153
4183
|
const run = items.slice(s, e), seqs = run.map((i) => i.seq);
|
|
4154
|
-
const ok = !wide ? !run.some((i) => _optionalChain([i, 'access',
|
|
4184
|
+
const ok = !wide ? !run.some((i) => _optionalChain([i, 'access', _111 => _111.text, 'optionalAccess', _112 => _112.startsWith, 'call', _113 => _113("$")])) : Math.max(...seqs) - Math.min(...seqs) <= 2 * (e - s - 1) && run.every((i) => Math.abs((_nullishCoalesce(i.fontSize, () => ( 0))) - (_nullishCoalesce(run[0].fontSize, () => ( 0)))) <= 0.5);
|
|
4155
4185
|
if (e - s > 1 && seqs.every((q) => q !== void 0) && ok) {
|
|
4156
4186
|
run.sort((a, b) => a.seq - b.seq);
|
|
4157
4187
|
for (let k = 0; k < run.length; k++) items[s + k] = run[k];
|
|
@@ -4221,7 +4251,7 @@ function dominantStyle(items) {
|
|
|
4221
4251
|
let maxCount = 0, dominantSize = 0;
|
|
4222
4252
|
for (const i of items) {
|
|
4223
4253
|
if (i.fontSize <= 0) continue;
|
|
4224
|
-
const count = (freq.get(i.fontSize) || 0) + Math.max(1, _nullishCoalesce(_optionalChain([i, 'access',
|
|
4254
|
+
const count = (freq.get(i.fontSize) || 0) + Math.max(1, _nullishCoalesce(_optionalChain([i, 'access', _114 => _114.text, 'access', _115 => _115.match, 'call', _116 => _116(/[\p{L}\p{N}]/gu), 'optionalAccess', _117 => _117.length]), () => ( 0)));
|
|
4225
4255
|
freq.set(i.fontSize, count);
|
|
4226
4256
|
if (count > maxCount) {
|
|
4227
4257
|
maxCount = count;
|
|
@@ -4229,7 +4259,7 @@ function dominantStyle(items) {
|
|
|
4229
4259
|
}
|
|
4230
4260
|
}
|
|
4231
4261
|
if (dominantSize === 0) return void 0;
|
|
4232
|
-
const fontName = _optionalChain([items, 'access',
|
|
4262
|
+
const fontName = _optionalChain([items, 'access', _118 => _118.find, 'call', _119 => _119((i) => i.fontSize === dominantSize), 'optionalAccess', _120 => _120.fontName]) || void 0;
|
|
4233
4263
|
return fontName ? { fontSize: dominantSize, fontName } : { fontSize: dominantSize };
|
|
4234
4264
|
}
|
|
4235
4265
|
function normalizeItems(rawItems) {
|
|
@@ -4374,7 +4404,7 @@ function splitAroundOverlays(c, overlays) {
|
|
|
4374
4404
|
const ov = overlays.filter((o) => {
|
|
4375
4405
|
for (let at = c.text.indexOf(o.text); at >= 0; at = c.text.indexOf(o.text, at + 1)) {
|
|
4376
4406
|
const prefix = c.text.slice(0, at);
|
|
4377
|
-
const est = c.x + glyphUnits(prefix.replace(/\s+/g, "")) * a0 + (_nullishCoalesce(_optionalChain([prefix, 'access',
|
|
4407
|
+
const est = c.x + glyphUnits(prefix.replace(/\s+/g, "")) * a0 + (_nullishCoalesce(_optionalChain([prefix, 'access', _121 => _121.match, 'call', _122 => _122(/\s+/g), 'optionalAccess', _123 => _123.length]), () => ( 0))) * ws;
|
|
4378
4408
|
if (Math.abs(est - o.x) <= OVERLAY_DUP_EM * fs) return false;
|
|
4379
4409
|
}
|
|
4380
4410
|
return true;
|
|
@@ -4499,7 +4529,7 @@ function mergeSuperscriptLines(lines) {
|
|
|
4499
4529
|
return result;
|
|
4500
4530
|
}
|
|
4501
4531
|
function mergeLineSimple(items) {
|
|
4502
|
-
if (items.length <= 1) return _optionalChain([items, 'access',
|
|
4532
|
+
if (items.length <= 1) return _optionalChain([items, 'access', _124 => _124[0], 'optionalAccess', _125 => _125.text]) || "";
|
|
4503
4533
|
const sorted = sortLineByX([...items]);
|
|
4504
4534
|
const isEvenSpaced = detectEvenSpacedItems(sorted);
|
|
4505
4535
|
const hangulLine = sorted.some((it) => /[가-힣]/.test(it.text));
|
|
@@ -4588,7 +4618,7 @@ function isProseTable(table) {
|
|
|
4588
4618
|
if (!(long > 0 && long >= total * 0.5 && longRows >= rows * 0.4)) return false;
|
|
4589
4619
|
for (let c = 0; c < table.cols; c++) {
|
|
4590
4620
|
const filled = table.cells.map((row) => row[c]).filter((cell) => cell && cell.colSpan < table.cols && cell.text.trim()).map((cell) => cell.text.trim());
|
|
4591
|
-
if (filled.length >= 3 && filled.length >= rows * 0.6 && filled.every((text) => text.length <= 30 && (_nullishCoalesce(_optionalChain([text, 'access',
|
|
4621
|
+
if (filled.length >= 3 && filled.length >= rows * 0.6 && filled.every((text) => text.length <= 30 && (_nullishCoalesce(_optionalChain([text, 'access', _126 => _126.match, 'call', _127 => _127(/\p{L}/gu), 'optionalAccess', _128 => _128.length]), () => ( 0))) >= 2)) return false;
|
|
4592
4622
|
}
|
|
4593
4623
|
return true;
|
|
4594
4624
|
}
|
|
@@ -4617,7 +4647,7 @@ var TICK = /^-?[\d,]+(?:\.\d+)?%?$/;
|
|
|
4617
4647
|
var QUANTITY = /^[-−–]?[\d,]*\.?\d+%?$/;
|
|
4618
4648
|
var quantity = (token) => Number(token.replace(/^[−–]/, "-").replace(/[,%]/g, ""));
|
|
4619
4649
|
function isValueAxisColumn(table, c) {
|
|
4620
|
-
const lines = table.cells.flatMap((row) => (_nullishCoalesce(_optionalChain([row, 'access',
|
|
4650
|
+
const lines = table.cells.flatMap((row) => (_nullishCoalesce(_optionalChain([row, 'access', _129 => _129[c], 'optionalAccess', _130 => _130.text]), () => ( ""))).split("\n").map((line) => line.trim().split(/\s+/)));
|
|
4621
4651
|
const others = table.cells.flatMap((row) => row.filter((_, k) => k !== c).map((cell) => cell.text.trim().split(/\s+/))).filter((tokens) => tokens.every((token) => QUANTITY.test(token))).flat().map(quantity).filter((v) => !(Number.isInteger(v) && v >= 1900 && v <= 2100));
|
|
4622
4652
|
for (const ticks of [lines.flat().filter((t) => TICK.test(t)).map(quantity), lines.map((tokens) => tokens[0]).filter((t) => TICK.test(t)).map(quantity)]) {
|
|
4623
4653
|
const run = fallingRun(ticks);
|
|
@@ -4649,7 +4679,7 @@ function isChartTable(table, ocr = false) {
|
|
|
4649
4679
|
const numeric = texts.filter((text) => NUMERIC_CELL.test(text)).length;
|
|
4650
4680
|
if (numeric < texts.length * 0.5) return false;
|
|
4651
4681
|
for (let c = 0; c < table.cols; c++) {
|
|
4652
|
-
if (!ocr ? isValueAxisColumn(table, c) : hasValueAxis(table.cells.flatMap((row) => (_nullishCoalesce(_optionalChain([row, 'access',
|
|
4682
|
+
if (!ocr ? isValueAxisColumn(table, c) : hasValueAxis(table.cells.flatMap((row) => (_nullishCoalesce(_optionalChain([row, 'access', _131 => _131[c], 'optionalAccess', _132 => _132.text]), () => ( ""))).split(/\s+/)).filter((t) => TICK.test(t)).map((t) => Number(t.replace(/[,%]/g, ""))))) return true;
|
|
4653
4683
|
}
|
|
4654
4684
|
const values = texts.filter((text) => text.split(/\s+/).every((token) => QUANTITY.test(token))).length;
|
|
4655
4685
|
const cells = table.rows * table.cols;
|
|
@@ -4703,7 +4733,7 @@ function clusterCellLines(items) {
|
|
|
4703
4733
|
}
|
|
4704
4734
|
var WRAP_INDENT_MAX = 3;
|
|
4705
4735
|
function joinClusterCellLines(lines, box, lex) {
|
|
4706
|
-
let out = _nullishCoalesce(_optionalChain([lines, 'access',
|
|
4736
|
+
let out = _nullishCoalesce(_optionalChain([lines, 'access', _133 => _133[0], 'optionalAccess', _134 => _134.text]), () => ( ""));
|
|
4707
4737
|
for (let i = 1; i < lines.length; i++) {
|
|
4708
4738
|
const a = lines[i - 1], b = lines[i];
|
|
4709
4739
|
const join2 = !a.spaceAfter && cellLineWraps(box, box.x1, a.right, a.fontSize, b.firstCharW) && a.left - box.x1 <= WRAP_INDENT_MAX * a.fontSize && b.left - box.x1 <= WRAP_INDENT_MAX * b.fontSize && /<\/u>$/.test(a.text) === /^<u>/.test(b.text) && !startsNewItem(out, b.text) && wrapJoiner(out, b.text, lex, false) === "";
|
|
@@ -4975,7 +5005,7 @@ function detectAlignedTwoColumnTables(rows, pageNum) {
|
|
|
4975
5005
|
continue;
|
|
4976
5006
|
}
|
|
4977
5007
|
const top = rows[i - 1];
|
|
4978
|
-
const title = _optionalChain([top, 'optionalAccess',
|
|
5008
|
+
const title = _optionalChain([top, 'optionalAccess', _135 => _135.items, 'access', _136 => _136.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;
|
|
4979
5009
|
const tableRows = title ? [title, ...body] : body;
|
|
4980
5010
|
const cells = tableRows.map((row, idx) => {
|
|
4981
5011
|
if (title && idx === 0) return [{ text: row.items[0].text, colSpan: 2, rowSpan: 1 }, { text: "", colSpan: 1, rowSpan: 1 }];
|
|
@@ -5031,12 +5061,12 @@ function isTwoColumnProse(r) {
|
|
|
5031
5061
|
if (t.rows < 8) return false;
|
|
5032
5062
|
const dense = [];
|
|
5033
5063
|
for (let c = 0; c < t.cols; c++) {
|
|
5034
|
-
const filled = t.cells.filter((row) => _optionalChain([row, 'access',
|
|
5064
|
+
const filled = t.cells.filter((row) => _optionalChain([row, 'access', _137 => _137[c], 'optionalAccess', _138 => _138.text, 'access', _139 => _139.trim, 'call', _140 => _140()])).length;
|
|
5035
5065
|
if (filled / t.rows >= 0.3) dense.push(c);
|
|
5036
5066
|
}
|
|
5037
5067
|
if (dense.length !== 2) return false;
|
|
5038
5068
|
for (const c of dense) {
|
|
5039
|
-
const lens = t.cells.map((row) => _nullishCoalesce(_optionalChain([row, 'access',
|
|
5069
|
+
const lens = t.cells.map((row) => _nullishCoalesce(_optionalChain([row, 'access', _141 => _141[c], 'optionalAccess', _142 => _142.text, 'access', _143 => _143.replace, 'call', _144 => _144(/\s+/g, ""), 'access', _145 => _145.length]), () => ( 0))).filter((n) => n > 0);
|
|
5040
5070
|
const avg = lens.reduce((s, v) => s + v, 0) / (lens.length || 1);
|
|
5041
5071
|
if (avg < 12) return false;
|
|
5042
5072
|
}
|
|
@@ -5495,7 +5525,7 @@ function assignRowItems(items, columns, numCols, headerFace) {
|
|
|
5495
5525
|
const runs = [];
|
|
5496
5526
|
for (const it of sorted) {
|
|
5497
5527
|
const last = runs[runs.length - 1];
|
|
5498
|
-
const prev = _optionalChain([last, 'optionalAccess',
|
|
5528
|
+
const prev = _optionalChain([last, 'optionalAccess', _146 => _146[last.length - 1]]);
|
|
5499
5529
|
if (prev && it.x - (prev.x + prev.w) <= Math.max(0.5, it.fontSize * 0.05) && !it.hasSpaceBefore) last.push(it);
|
|
5500
5530
|
else runs.push([it]);
|
|
5501
5531
|
}
|
|
@@ -5546,7 +5576,7 @@ function assignRowItems(items, columns, numCols, headerFace) {
|
|
|
5546
5576
|
assignedGroups.add(gi);
|
|
5547
5577
|
usedCols.add(ci);
|
|
5548
5578
|
}
|
|
5549
|
-
const colOf = groups.map((g) => _nullishCoalesce(_optionalChain([result, 'access',
|
|
5579
|
+
const colOf = groups.map((g) => _nullishCoalesce(_optionalChain([result, 'access', _147 => _147.find, 'call', _148 => _148((a) => a.items === g), 'optionalAccess', _149 => _149.col]), () => ( -1)));
|
|
5550
5580
|
if (groups.length <= numCols && colOf.some((c, g) => g > 0 && c < colOf[g - 1])) {
|
|
5551
5581
|
const G = groups.length, cost = (g, c2) => Math.abs(groupCenters[g] - colCenters[c2]);
|
|
5552
5582
|
const best = groups.map(() => new Array(numCols).fill(Infinity)), from = groups.map(() => new Array(numCols).fill(-1));
|
|
@@ -5583,7 +5613,7 @@ function assignRowItems(items, columns, numCols, headerFace) {
|
|
|
5583
5613
|
function buildClusterTable(rows, columns, pageNum, lex) {
|
|
5584
5614
|
const numRows = rows.length;
|
|
5585
5615
|
if (numRows < MIN_ROWS || columns.length < MIN_COLS) return null;
|
|
5586
|
-
const headFaces = new Set(_optionalChain([rows, 'access',
|
|
5616
|
+
const headFaces = new Set(_optionalChain([rows, 'access', _150 => _150[0], 'optionalAccess', _151 => _151.items, 'access', _152 => _152.map, 'call', _153 => _153((i) => i.fontName)]));
|
|
5587
5617
|
const headerFace = headFaces.size === 1 && rows.slice(1).every((row) => row.items.every((i) => !headFaces.has(i.fontName))) ? [...headFaces][0] : void 0;
|
|
5588
5618
|
const assigned = rows.map((row, r) => assignRowItems(row.items, columns, columns.length, r === 0 ? headerFace : void 0));
|
|
5589
5619
|
const cuts = supportedOcrColumnCuts(assigned);
|
|
@@ -5654,7 +5684,7 @@ function buildClusterTable(rows, columns, pageNum, lex) {
|
|
|
5654
5684
|
const nonEmptyCols = cells[r].filter((c) => c.text.trim()).length;
|
|
5655
5685
|
if (nonEmptyCols !== 1) continue;
|
|
5656
5686
|
if (cells[r][0].text.trim() !== "") continue;
|
|
5657
|
-
const contentText = _optionalChain([cells, 'access',
|
|
5687
|
+
const contentText = _optionalChain([cells, 'access', _154 => _154[r], 'access', _155 => _155.find, 'call', _156 => _156((c) => c.text.trim()), 'optionalAccess', _157 => _157.text, 'access', _158 => _158.trim, 'call', _159 => _159()]) || "";
|
|
5658
5688
|
if (/^[○●▶\-·]/.test(contentText)) continue;
|
|
5659
5689
|
for (let pr = r - 1; pr >= 0; pr--) {
|
|
5660
5690
|
if (cells[pr].some((c) => c.text.trim())) {
|
|
@@ -5887,7 +5917,7 @@ function stackedTableBands(items) {
|
|
|
5887
5917
|
const caption = (start, end) => lines.slice(start, end).some((line) => /^Table\s+\d+\s*[:.]/i.test(mergeLineSimple(line).trim()));
|
|
5888
5918
|
while (runs.length > 0 && !caption(runs[runs.length - 1].end, lines.length)) runs.pop();
|
|
5889
5919
|
if (runs.length < 2) return null;
|
|
5890
|
-
if (runs.some((run, i) => !caption(run.end, _nullishCoalesce(_optionalChain([runs, 'access',
|
|
5920
|
+
if (runs.some((run, i) => !caption(run.end, _nullishCoalesce(_optionalChain([runs, 'access', _160 => _160[i + 1], 'optionalAccess', _161 => _161.start]), () => ( lines.length))))) return null;
|
|
5891
5921
|
const tables = runs.map((run) => lines.slice(run.start, run.end).flat());
|
|
5892
5922
|
const between = runs.slice(0, -1).map((run, i) => lines.slice(run.end, runs[i + 1].start).flat());
|
|
5893
5923
|
const tail = lines.slice(runs[runs.length - 1].end);
|
|
@@ -6155,7 +6185,7 @@ function splitTrailingColumnRegion(items) {
|
|
|
6155
6185
|
}
|
|
6156
6186
|
function panelBlocks(items, panel, pageNum) {
|
|
6157
6187
|
const lines = groupByY([...items].sort((a, b) => b.y - a.y || a.x - b.x));
|
|
6158
|
-
const faceOf = (line) => _nullishCoalesce(_optionalChain([dominantStyle, 'call',
|
|
6188
|
+
const faceOf = (line) => _nullishCoalesce(_optionalChain([dominantStyle, 'call', _162 => _162(line), 'optionalAccess', _163 => _163.fontName]), () => ( ""));
|
|
6159
6189
|
const runs = [];
|
|
6160
6190
|
for (const line of lines) {
|
|
6161
6191
|
const last = runs[runs.length - 1];
|
|
@@ -6337,7 +6367,7 @@ function validWrapBands(items, bands) {
|
|
|
6337
6367
|
}
|
|
6338
6368
|
function inheritedWrapBands(items) {
|
|
6339
6369
|
const source = XY_WRAP_ITEMS.get(items[0]);
|
|
6340
|
-
const present = _optionalChain([source, 'optionalAccess',
|
|
6370
|
+
const present = _optionalChain([source, 'optionalAccess', _164 => _164.length]) === items.length ? new Set(items) : null;
|
|
6341
6371
|
const sameLeaf = present && source.every((item) => present.has(item));
|
|
6342
6372
|
return sameLeaf ? validWrapBands(items, _nullishCoalesce(XY_WRAP_BANDS.get(items[0]), () => ( []))) : [];
|
|
6343
6373
|
}
|
|
@@ -6376,7 +6406,7 @@ function wrappedLineBands(items, inherited) {
|
|
|
6376
6406
|
left: box.x,
|
|
6377
6407
|
right: box.x + box.width,
|
|
6378
6408
|
y: row.reduce((n, i) => n + i.y, 0) / row.length,
|
|
6379
|
-
fontSize: _nullishCoalesce(_optionalChain([dominantStyle, 'call',
|
|
6409
|
+
fontSize: _nullishCoalesce(_optionalChain([dominantStyle, 'call', _165 => _165(row), 'optionalAccess', _166 => _166.fontSize]), () => ( 0)),
|
|
6380
6410
|
sources: row.map((item) => ({ item, state: { ...item } }))
|
|
6381
6411
|
};
|
|
6382
6412
|
});
|
|
@@ -6512,10 +6542,10 @@ function pushLineParagraphs(out, yLines, pageNum, lex) {
|
|
|
6512
6542
|
const lines = attachDropCaps(yLines).map((items) => ({ items, text: mergeLineSimple(items) })).filter((l) => l.text.trim());
|
|
6513
6543
|
const geo = lines.map((l) => {
|
|
6514
6544
|
const b = computeBBox(l.items, pageNum);
|
|
6515
|
-
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',
|
|
6545
|
+
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', _167 => _167(l.items), 'optionalAccess', _168 => _168.fontSize]), () => ( 0)) };
|
|
6516
6546
|
});
|
|
6517
6547
|
const joins = bodyLineJoins(geo, lex);
|
|
6518
|
-
const first = _optionalChain([lines, 'access',
|
|
6548
|
+
const first = _optionalChain([lines, 'access', _169 => _169[0], 'optionalAccess', _170 => _170.items, 'access', _171 => _171[0]]);
|
|
6519
6549
|
const bands = first ? _nullishCoalesce(XY_WRAP_BANDS.get(first), () => ( [])) : [];
|
|
6520
6550
|
const hasBand = (top, bottom) => {
|
|
6521
6551
|
let lo = 0, hi = bands.length;
|
|
@@ -6592,15 +6622,15 @@ function computeMedianFontSizeFromFreq(freq) {
|
|
|
6592
6622
|
function detectHeadings(blocks, medianFontSize) {
|
|
6593
6623
|
for (let bi = 0; bi < blocks.length; bi++) {
|
|
6594
6624
|
const block = blocks[bi];
|
|
6595
|
-
if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access',
|
|
6625
|
+
if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access', _172 => _172.style, 'optionalAccess', _173 => _173.fontSize])) continue;
|
|
6596
6626
|
const text = block.text.trim();
|
|
6597
6627
|
if (text.length === 0 || text.length > 200) continue;
|
|
6598
6628
|
if (/^\d+$/.test(text) && !isChapterNumber(block, blocks[bi + 1], medianFontSize)) continue;
|
|
6599
6629
|
const ratio = block.style.fontSize / medianFontSize;
|
|
6600
6630
|
let level = 0;
|
|
6601
|
-
if (ratio >=
|
|
6602
|
-
else if (ratio >=
|
|
6603
|
-
else if (ratio >=
|
|
6631
|
+
if (ratio >= _chunkHA3YIEAScjs.HEADING_RATIO_H1) level = 1;
|
|
6632
|
+
else if (ratio >= _chunkHA3YIEAScjs.HEADING_RATIO_H2) level = 2;
|
|
6633
|
+
else if (ratio >= _chunkHA3YIEAScjs.HEADING_RATIO_H3) level = 3;
|
|
6604
6634
|
if (level > 0) {
|
|
6605
6635
|
block.type = "heading";
|
|
6606
6636
|
block.level = level;
|
|
@@ -6609,21 +6639,21 @@ function detectHeadings(blocks, medianFontSize) {
|
|
|
6609
6639
|
}
|
|
6610
6640
|
}
|
|
6611
6641
|
function isChapterNumber(block, next, medianFontSize) {
|
|
6612
|
-
const size = _nullishCoalesce(_optionalChain([block, 'access',
|
|
6613
|
-
const nextSize = _nullishCoalesce(_optionalChain([next, 'optionalAccess',
|
|
6614
|
-
const text = _nullishCoalesce(_optionalChain([next, 'optionalAccess',
|
|
6615
|
-
const a = block.bbox, b = _optionalChain([next, 'optionalAccess',
|
|
6616
|
-
return /^\d{1,2}$/.test(_nullishCoalesce(_optionalChain([block, 'access',
|
|
6642
|
+
const size = _nullishCoalesce(_optionalChain([block, 'access', _174 => _174.style, 'optionalAccess', _175 => _175.fontSize]), () => ( 0));
|
|
6643
|
+
const nextSize = _nullishCoalesce(_optionalChain([next, 'optionalAccess', _176 => _176.style, 'optionalAccess', _177 => _177.fontSize]), () => ( 0));
|
|
6644
|
+
const text = _nullishCoalesce(_optionalChain([next, 'optionalAccess', _178 => _178.text, 'optionalAccess', _179 => _179.trim, 'call', _180 => _180()]), () => ( ""));
|
|
6645
|
+
const a = block.bbox, b = _optionalChain([next, 'optionalAccess', _181 => _181.bbox]);
|
|
6646
|
+
return /^\d{1,2}$/.test(_nullishCoalesce(_optionalChain([block, 'access', _182 => _182.text, 'optionalAccess', _183 => _183.trim, 'call', _184 => _184()]), () => ( ""))) && size >= medianFontSize * 2.5 && !!next && (next.type === "paragraph" || next.type === "heading") && next.pageNumber === block.pageNumber && nextSize >= medianFontSize * _chunkHA3YIEAScjs.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;
|
|
6617
6647
|
}
|
|
6618
6648
|
function mergeStackedHeadingLines(blocks, medianFontSize) {
|
|
6619
6649
|
for (let i = 0; i < blocks.length - 1; ) {
|
|
6620
6650
|
const a = blocks[i], b = blocks[i + 1];
|
|
6621
6651
|
const ab = a.bbox, bb = b.bbox;
|
|
6622
|
-
const af = _nullishCoalesce(_optionalChain([a, 'access',
|
|
6652
|
+
const af = _nullishCoalesce(_optionalChain([a, 'access', _185 => _185.style, 'optionalAccess', _186 => _186.fontSize]), () => ( 0)), bf = _nullishCoalesce(_optionalChain([b, 'access', _187 => _187.style, 'optionalAccess', _188 => _188.fontSize]), () => ( 0));
|
|
6623
6653
|
const gap = ab && bb ? ab.y - (bb.y + bb.height) : Infinity;
|
|
6624
|
-
const centered = ab && bb && _optionalChain([a, 'access',
|
|
6654
|
+
const centered = ab && bb && _optionalChain([a, 'access', _189 => _189.style, 'optionalAccess', _190 => _190.fontName]) === _optionalChain([b, 'access', _191 => _191.style, 'optionalAccess', _192 => _192.fontName]) && Math.abs(ab.x + ab.width / 2 - (bb.x + bb.width / 2)) <= Math.max(5, af * 0.5);
|
|
6625
6655
|
const sameAnchor = ab && bb && Math.abs(ab.x - bb.x) <= 5;
|
|
6626
|
-
const wrapped = sameAnchor && _optionalChain([a, 'access',
|
|
6656
|
+
const wrapped = sameAnchor && _optionalChain([a, 'access', _193 => _193.style, 'optionalAccess', _194 => _194.fontName]) === _optionalChain([b, 'access', _195 => _195.style, 'optionalAccess', _196 => _196.fontName]) && af === bf && ab.width >= bb.width * 0.95 && (_nullishCoalesce(_optionalChain([a, 'access', _197 => _197.text, 'optionalAccess', _198 => _198.trim, 'call', _199 => _199(), 'access', _200 => _200.split, 'call', _201 => _201(/\s+/), 'access', _202 => _202.length]), () => ( 0))) >= 3;
|
|
6627
6657
|
const displayStack = centered && gap <= Math.min(af, bf) * 0.3 && Math.max(af, bf) <= Math.min(af, bf) * 1.45;
|
|
6628
6658
|
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)) {
|
|
6629
6659
|
i++;
|
|
@@ -6652,25 +6682,25 @@ function detectTypographyHeadings(blocks) {
|
|
|
6652
6682
|
if (page.some((block) => block.type === "heading")) continue;
|
|
6653
6683
|
const faceWeight = /* @__PURE__ */ new Map();
|
|
6654
6684
|
for (const block of page) {
|
|
6655
|
-
if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access',
|
|
6685
|
+
if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access', _203 => _203.style, 'optionalAccess', _204 => _204.fontName])) continue;
|
|
6656
6686
|
const faces = FACE_CHARS.get(block);
|
|
6657
6687
|
if (faces) for (const [face, n] of faces) faceWeight.set(face, (_nullishCoalesce(faceWeight.get(face), () => ( 0))) + n);
|
|
6658
6688
|
else faceWeight.set(block.style.fontName, (_nullishCoalesce(faceWeight.get(block.style.fontName), () => ( 0))) + block.text.length);
|
|
6659
6689
|
}
|
|
6660
|
-
const bodyFace = _optionalChain([[...faceWeight], 'access',
|
|
6690
|
+
const bodyFace = _optionalChain([[...faceWeight], 'access', _205 => _205.sort, 'call', _206 => _206((a, b) => b[1] - a[1]), 'access', _207 => _207[0], 'optionalAccess', _208 => _208[0]]);
|
|
6661
6691
|
if (!bodyFace || (_nullishCoalesce(faceWeight.get(bodyFace), () => ( 0))) < 250) continue;
|
|
6662
6692
|
const sizeWeight = /* @__PURE__ */ new Map();
|
|
6663
6693
|
for (const block of page) {
|
|
6664
|
-
if (block.type !== "paragraph" || !_optionalChain([block, 'access',
|
|
6694
|
+
if (block.type !== "paragraph" || !_optionalChain([block, 'access', _209 => _209.style, 'optionalAccess', _210 => _210.fontSize])) continue;
|
|
6665
6695
|
const faces = FACE_CHARS.get(block);
|
|
6666
|
-
const chars = faces ? _nullishCoalesce(faces.get(bodyFace), () => ( 0)) : block.style.fontName === bodyFace ? _nullishCoalesce(_optionalChain([block, 'access',
|
|
6696
|
+
const chars = faces ? _nullishCoalesce(faces.get(bodyFace), () => ( 0)) : block.style.fontName === bodyFace ? _nullishCoalesce(_optionalChain([block, 'access', _211 => _211.text, 'optionalAccess', _212 => _212.length]), () => ( 0)) : 0;
|
|
6667
6697
|
if (chars) sizeWeight.set(block.style.fontSize, (_nullishCoalesce(sizeWeight.get(block.style.fontSize), () => ( 0))) + chars);
|
|
6668
6698
|
}
|
|
6669
|
-
const bodySize = _nullishCoalesce(_optionalChain([[...sizeWeight], 'access',
|
|
6699
|
+
const bodySize = _nullishCoalesce(_optionalChain([[...sizeWeight], 'access', _213 => _213.sort, 'call', _214 => _214((a, b) => b[1] - a[1]), 'access', _215 => _215[0], 'optionalAccess', _216 => _216[0]]), () => ( 0));
|
|
6670
6700
|
for (let i = 0; i < page.length; i++) {
|
|
6671
6701
|
const block = page[i];
|
|
6672
6702
|
const { text, bbox, style } = block;
|
|
6673
|
-
if (block.type !== "paragraph" || !text || !bbox || !_optionalChain([style, 'optionalAccess',
|
|
6703
|
+
if (block.type !== "paragraph" || !text || !bbox || !_optionalChain([style, 'optionalAccess', _217 => _217.fontName]) || !style.fontSize) continue;
|
|
6674
6704
|
const title = text.trim();
|
|
6675
6705
|
const numbered = /^\d+(?:\.\d+)*\.?\s+[A-Z가-힣]/.test(title);
|
|
6676
6706
|
const faces = FACE_CHARS.get(block);
|
|
@@ -6700,16 +6730,16 @@ function detectDocumentStyleHeadings(blocks) {
|
|
|
6700
6730
|
for (const page of byPage.values()) {
|
|
6701
6731
|
const faceChars = /* @__PURE__ */ new Map();
|
|
6702
6732
|
for (const block of page) {
|
|
6703
|
-
if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access',
|
|
6733
|
+
if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access', _218 => _218.style, 'optionalAccess', _219 => _219.fontName])) continue;
|
|
6704
6734
|
faceChars.set(block.style.fontName, (_nullishCoalesce(faceChars.get(block.style.fontName), () => ( 0))) + block.text.length);
|
|
6705
6735
|
}
|
|
6706
|
-
const bodyFace = _optionalChain([[...faceChars], 'access',
|
|
6736
|
+
const bodyFace = _optionalChain([[...faceChars], 'access', _220 => _220.sort, 'call', _221 => _221((a, b) => b[1] - a[1]), 'access', _222 => _222[0], 'optionalAccess', _223 => _223[0]]);
|
|
6707
6737
|
if (!bodyFace || (_nullishCoalesce(faceChars.get(bodyFace), () => ( 0))) < 100) continue;
|
|
6708
|
-
const labels = page.filter((b) => b.type === "paragraph" && b.text && b.bbox && _optionalChain([b, 'access',
|
|
6738
|
+
const labels = page.filter((b) => b.type === "paragraph" && b.text && b.bbox && _optionalChain([b, 'access', _224 => _224.style, 'optionalAccess', _225 => _225.fontName]) && b.style.fontName !== bodyFace && b.text.trim().length >= 3 && b.text.trim().length <= 40);
|
|
6709
6739
|
for (const label of labels) {
|
|
6710
|
-
const peers = labels.filter((b) => _optionalChain([b, 'access',
|
|
6740
|
+
const peers = labels.filter((b) => _optionalChain([b, 'access', _226 => _226.style, 'optionalAccess', _227 => _227.fontName]) === _optionalChain([label, 'access', _228 => _228.style, 'optionalAccess', _229 => _229.fontName]) && Math.abs(b.bbox.y - label.bbox.y) <= 3 && Math.abs(b.bbox.x - label.bbox.x) >= 60);
|
|
6711
6741
|
if (peers.length < 2) continue;
|
|
6712
|
-
const value = page.find((b) => b.type === "paragraph" && b.bbox && _optionalChain([b, 'access',
|
|
6742
|
+
const value = page.find((b) => b.type === "paragraph" && b.bbox && _optionalChain([b, 'access', _230 => _230.style, 'optionalAccess', _231 => _231.fontName]) !== _optionalChain([label, 'access', _232 => _232.style, 'optionalAccess', _233 => _233.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);
|
|
6713
6743
|
if (value) {
|
|
6714
6744
|
label.type = "heading";
|
|
6715
6745
|
label.level = 2;
|
|
@@ -6718,7 +6748,7 @@ function detectDocumentStyleHeadings(blocks) {
|
|
|
6718
6748
|
const first = page.find((b) => b.type !== "image" && b.type !== "separator");
|
|
6719
6749
|
const second = page[page.indexOf(first) + 1];
|
|
6720
6750
|
const third = page[page.indexOf(first) + 2];
|
|
6721
|
-
if (!first || !second || !third || first.type !== "list" && first.type !== "paragraph" || second.type !== "paragraph" || !first.text || !second.text || !first.bbox || !second.bbox || !_optionalChain([first, 'access',
|
|
6751
|
+
if (!first || !second || !third || first.type !== "list" && first.type !== "paragraph" || second.type !== "paragraph" || !first.text || !second.text || !first.bbox || !second.bbox || !_optionalChain([first, 'access', _234 => _234.style, 'optionalAccess', _235 => _235.fontName]) || !_optionalChain([second, 'access', _236 => _236.style, 'optionalAccess', _237 => _237.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', _238 => _238.style, 'optionalAccess', _239 => _239.fontName]) !== bodyFace) continue;
|
|
6722
6752
|
first.type = "heading";
|
|
6723
6753
|
first.level = 1;
|
|
6724
6754
|
first.text = `${first.text.trim()} ${second.text.trim()}`;
|
|
@@ -6742,18 +6772,18 @@ function detectSiblingStyleHeadings(blocks) {
|
|
|
6742
6772
|
for (const page of byPage.values()) {
|
|
6743
6773
|
const bodyChars = /* @__PURE__ */ new Map();
|
|
6744
6774
|
for (const block of page) {
|
|
6745
|
-
if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access',
|
|
6775
|
+
if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access', _240 => _240.style, 'optionalAccess', _241 => _241.fontName])) continue;
|
|
6746
6776
|
const face = block.style.fontName;
|
|
6747
6777
|
bodyChars.set(face, (_nullishCoalesce(bodyChars.get(face), () => ( 0))) + block.text.length);
|
|
6748
6778
|
}
|
|
6749
|
-
const bodyFace = _optionalChain([[...bodyChars], 'access',
|
|
6750
|
-
const anchors = page.filter((b) => b.type === "heading" && b.text && _optionalChain([b, 'access',
|
|
6779
|
+
const bodyFace = _optionalChain([[...bodyChars], 'access', _242 => _242.sort, 'call', _243 => _243((a, b) => b[1] - a[1]), 'access', _244 => _244[0], 'optionalAccess', _245 => _245[0]]);
|
|
6780
|
+
const anchors = page.filter((b) => b.type === "heading" && b.text && _optionalChain([b, 'access', _246 => _246.style, 'optionalAccess', _247 => _247.fontName]) && b.style.fontName !== bodyFace);
|
|
6751
6781
|
for (const anchor of anchors) {
|
|
6752
6782
|
const numbered = /^([A-Z])\.\d+\s+/.exec(anchor.text.trim());
|
|
6753
6783
|
const lettered = /^([A-Z])\s+/.exec(anchor.text.trim());
|
|
6754
|
-
const peers = anchors.filter((b) => _optionalChain([b, 'access',
|
|
6784
|
+
const peers = anchors.filter((b) => _optionalChain([b, 'access', _248 => _248.style, 'optionalAccess', _249 => _249.fontName]) === _optionalChain([anchor, 'access', _250 => _250.style, 'optionalAccess', _251 => _251.fontName]) && Math.abs((_nullishCoalesce(_optionalChain([b, 'access', _252 => _252.style, 'optionalAccess', _253 => _253.fontSize]), () => ( 0))) - (_nullishCoalesce(_optionalChain([anchor, 'access', _254 => _254.style, 'optionalAccess', _255 => _255.fontSize]), () => ( 0)))) < 0.5);
|
|
6755
6785
|
if (peers.length < 2 && !numbered && !lettered) continue;
|
|
6756
|
-
const candidates = page.filter((b) => b.type === "paragraph" && b.text && b.bbox && _optionalChain([b, 'access',
|
|
6786
|
+
const candidates = page.filter((b) => b.type === "paragraph" && b.text && b.bbox && _optionalChain([b, 'access', _256 => _256.style, 'optionalAccess', _257 => _257.fontName]) === _optionalChain([anchor, 'access', _258 => _258.style, 'optionalAccess', _259 => _259.fontName]) && Math.abs((_nullishCoalesce(_optionalChain([b, 'access', _260 => _260.style, 'optionalAccess', _261 => _261.fontSize]), () => ( 0))) - (_nullishCoalesce(_optionalChain([anchor, 'access', _262 => _262.style, 'optionalAccess', _263 => _263.fontSize]), () => ( 0)))) < 0.5 && b.text.trim().length >= 3 && b.text.trim().length <= 80 && b.bbox.height <= (_nullishCoalesce(_optionalChain([b, 'access', _264 => _264.style, 'optionalAccess', _265 => _265.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()));
|
|
6757
6787
|
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));
|
|
6758
6788
|
if (siblings.length < (numbered || lettered ? 1 : 2)) continue;
|
|
6759
6789
|
for (const sibling of siblings) {
|
|
@@ -6772,13 +6802,13 @@ function detectRepeatedPageLabels(blocks) {
|
|
|
6772
6802
|
}
|
|
6773
6803
|
for (const page of byPage.values()) {
|
|
6774
6804
|
const bodyChars = /* @__PURE__ */ new Map();
|
|
6775
|
-
for (const b of page) if (b.type === "paragraph" && b.text && _optionalChain([b, 'access',
|
|
6805
|
+
for (const b of page) if (b.type === "paragraph" && b.text && _optionalChain([b, 'access', _266 => _266.style, 'optionalAccess', _267 => _267.fontName])) {
|
|
6776
6806
|
const faces = FACE_CHARS.get(b);
|
|
6777
6807
|
if (faces) for (const [face, n] of faces) bodyChars.set(face, (_nullishCoalesce(bodyChars.get(face), () => ( 0))) + n);
|
|
6778
6808
|
else bodyChars.set(b.style.fontName, (_nullishCoalesce(bodyChars.get(b.style.fontName), () => ( 0))) + b.text.length);
|
|
6779
6809
|
}
|
|
6780
|
-
const bodyFace = _optionalChain([[...bodyChars], 'access',
|
|
6781
|
-
const candidates = page.filter((b) => b.type === "paragraph" && b.text && b.bbox && _optionalChain([b, 'access',
|
|
6810
|
+
const bodyFace = _optionalChain([[...bodyChars], 'access', _268 => _268.sort, 'call', _269 => _269((a, b) => b[1] - a[1]), 'access', _270 => _270[0], 'optionalAccess', _271 => _271[0]]);
|
|
6811
|
+
const candidates = page.filter((b) => b.type === "paragraph" && b.text && b.bbox && _optionalChain([b, 'access', _272 => _272.style, 'optionalAccess', _273 => _273.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);
|
|
6782
6812
|
const groups = /* @__PURE__ */ new Map();
|
|
6783
6813
|
for (const b of candidates) {
|
|
6784
6814
|
const key = `${b.style.fontName}:${b.style.fontSize}`;
|
|
@@ -6814,19 +6844,19 @@ function detectPageLeadHeadings(blocks) {
|
|
|
6814
6844
|
for (const page of byPage.values()) {
|
|
6815
6845
|
const content = page.filter((b) => b.type !== "image" && b.type !== "separator" && !(b.type === "paragraph" && !b.style));
|
|
6816
6846
|
const [first, second, third] = content;
|
|
6817
|
-
if (!_optionalChain([first, 'optionalAccess',
|
|
6847
|
+
if (!_optionalChain([first, 'optionalAccess', _274 => _274.bbox]) || !first.text || !_optionalChain([first, 'access', _275 => _275.style, 'optionalAccess', _276 => _276.fontSize]) || !second) continue;
|
|
6818
6848
|
const firstText = first.text.trim();
|
|
6819
6849
|
const captionLike = /^(?:Figure|Fig\.?|Table|표|그림)\s*\d/i;
|
|
6820
6850
|
const hasImage = page.some((b) => b.type === "image");
|
|
6821
|
-
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',
|
|
6851
|
+
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', _277 => _277.text, 'optionalAccess', _278 => _278.trim, 'call', _279 => _279()]), () => ( ""))) && (_nullishCoalesce(_optionalChain([second, 'access', _280 => _280.text, 'optionalAccess', _281 => _281.length]), () => ( 0))) >= 100 && second.bbox && first.bbox.y - (second.bbox.y + second.bbox.height) >= first.style.fontSize);
|
|
6822
6852
|
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);
|
|
6823
|
-
const firstIsSection = first.type === "list" && /^\d+\.\s+[A-Z][A-Z\s]{12,}$/.test(firstText) && second.type === "paragraph" && (_nullishCoalesce(_optionalChain([second, 'access',
|
|
6853
|
+
const firstIsSection = first.type === "list" && /^\d+\.\s+[A-Z][A-Z\s]{12,}$/.test(firstText) && second.type === "paragraph" && (_nullishCoalesce(_optionalChain([second, 'access', _282 => _282.text, 'optionalAccess', _283 => _283.length]), () => ( 0))) >= 100;
|
|
6824
6854
|
if (firstIsTitle || firstAboveProse || firstIsSection) {
|
|
6825
6855
|
first.type = "heading";
|
|
6826
6856
|
first.level = 1;
|
|
6827
6857
|
}
|
|
6828
|
-
if (first.type !== "heading" || captionLike.test(firstText) || second.type !== "paragraph" || !second.text || !second.bbox || !_optionalChain([second, 'access',
|
|
6829
|
-
const distinctFace = _optionalChain([third, 'access',
|
|
6858
|
+
if (first.type !== "heading" || captionLike.test(firstText) || second.type !== "paragraph" || !second.text || !second.bbox || !_optionalChain([second, 'access', _284 => _284.style, 'optionalAccess', _285 => _285.fontName]) || !second.style.fontSize || !_optionalChain([third, 'optionalAccess', _286 => _286.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;
|
|
6859
|
+
const distinctFace = _optionalChain([third, 'access', _287 => _287.style, 'optionalAccess', _288 => _288.fontName]) !== second.style.fontName;
|
|
6830
6860
|
const namedContents = /^Table of Contents$/i.test(second.text.trim());
|
|
6831
6861
|
if (distinctFace && third.text.length >= 60 || namedContents) {
|
|
6832
6862
|
second.type = "heading";
|
|
@@ -6837,24 +6867,24 @@ function detectPageLeadHeadings(blocks) {
|
|
|
6837
6867
|
function refineDocumentStyleHeadings(blocks) {
|
|
6838
6868
|
const faceChars = /* @__PURE__ */ new Map();
|
|
6839
6869
|
for (const block of blocks) {
|
|
6840
|
-
if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access',
|
|
6870
|
+
if (block.type !== "paragraph" || !block.text || !_optionalChain([block, 'access', _289 => _289.style, 'optionalAccess', _290 => _290.fontName])) continue;
|
|
6841
6871
|
faceChars.set(block.style.fontName, (_nullishCoalesce(faceChars.get(block.style.fontName), () => ( 0))) + block.text.length);
|
|
6842
6872
|
}
|
|
6843
6873
|
const [bodyFace, bodyChars] = _nullishCoalesce([...faceChars].sort((a, b) => b[1] - a[1])[0], () => ( []));
|
|
6844
6874
|
if (!bodyFace || !bodyChars || bodyChars < 300) return;
|
|
6845
6875
|
for (let i = 0; i < blocks.length; i++) {
|
|
6846
6876
|
const block = blocks[i];
|
|
6847
|
-
const text = _nullishCoalesce(_optionalChain([block, 'access',
|
|
6877
|
+
const text = _nullishCoalesce(_optionalChain([block, 'access', _291 => _291.text, 'optionalAccess', _292 => _292.trim, 'call', _293 => _293()]), () => ( ""));
|
|
6848
6878
|
if (block.type === "heading" && /(?:https?:\/\/|www\.|^arxiv:|^doi:)/i.test(text)) {
|
|
6849
6879
|
block.type = "paragraph";
|
|
6850
6880
|
block.level = void 0;
|
|
6851
6881
|
continue;
|
|
6852
6882
|
}
|
|
6853
6883
|
const box = block.bbox, style = block.style;
|
|
6854
|
-
if (block.type !== "paragraph" || !box || !_optionalChain([style, 'optionalAccess',
|
|
6884
|
+
if (block.type !== "paragraph" || !box || !_optionalChain([style, 'optionalAccess', _294 => _294.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;
|
|
6855
6885
|
const previous = blocks[i - 1], next = blocks[i + 1];
|
|
6856
|
-
const pb = _optionalChain([previous, 'optionalAccess',
|
|
6857
|
-
if (!pb || !nb || previous.pageNumber !== block.pageNumber || next.pageNumber !== block.pageNumber || previous.type !== "paragraph" && previous.type !== "heading" || next.type !== "paragraph" || _optionalChain([next, 'access',
|
|
6886
|
+
const pb = _optionalChain([previous, 'optionalAccess', _295 => _295.bbox]), nb = _optionalChain([next, 'optionalAccess', _296 => _296.bbox]);
|
|
6887
|
+
if (!pb || !nb || previous.pageNumber !== block.pageNumber || next.pageNumber !== block.pageNumber || previous.type !== "paragraph" && previous.type !== "heading" || next.type !== "paragraph" || _optionalChain([next, 'access', _297 => _297.style, 'optionalAccess', _298 => _298.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;
|
|
6858
6888
|
block.type = "heading";
|
|
6859
6889
|
block.level = 2;
|
|
6860
6890
|
}
|
|
@@ -6904,7 +6934,7 @@ function detectMarkerHeadings(blocks) {
|
|
|
6904
6934
|
block.level = 4;
|
|
6905
6935
|
continue;
|
|
6906
6936
|
}
|
|
6907
|
-
if (/^[가-힣]{2,6}$/.test(text) && _optionalChain([block, 'access',
|
|
6937
|
+
if (/^[가-힣]{2,6}$/.test(text) && _optionalChain([block, 'access', _299 => _299.style, 'optionalAccess', _300 => _300.fontSize])) {
|
|
6908
6938
|
const prev = blocks[i - 1];
|
|
6909
6939
|
const next = blocks[i + 1];
|
|
6910
6940
|
const prevIsStructural = !prev || prev.type === "table" || prev.type === "heading" || prev.type === "separator";
|
|
@@ -6945,7 +6975,7 @@ function detectTableCaptions(blocks) {
|
|
|
6945
6975
|
block.table.caption = blocks[i - 1].text.trim();
|
|
6946
6976
|
blocks.splice(i - 1, 1);
|
|
6947
6977
|
i--;
|
|
6948
|
-
} else if (isCaptionCandidate(blocks[i + 1], block) && _optionalChain([blocks, 'access',
|
|
6978
|
+
} else if (isCaptionCandidate(blocks[i + 1], block) && _optionalChain([blocks, 'access', _301 => _301[i + 2], 'optionalAccess', _302 => _302.type]) !== "table") {
|
|
6949
6979
|
const cap = blocks[i + 1].bbox, tbl = block.bbox;
|
|
6950
6980
|
block.table.caption = blocks[i + 1].text.trim();
|
|
6951
6981
|
if (cap && tbl && cap.y + cap.height <= tbl.y + 1) block.table.captionBelow = true;
|
|
@@ -7183,7 +7213,7 @@ function removeHeaderFooterBlocks(blocks, pageHeights, warnings, notes, tables =
|
|
|
7183
7213
|
const bottomEntries = [];
|
|
7184
7214
|
for (let bi = 0; bi < blocks.length; bi++) {
|
|
7185
7215
|
const b = blocks[bi];
|
|
7186
|
-
const text = !tables ? _optionalChain([b, 'access',
|
|
7216
|
+
const text = !tables ? _optionalChain([b, 'access', _303 => _303.text, 'optionalAccess', _304 => _304.trim, 'call', _305 => _305()]) : b.type === "table" && b.table ? b.table.cells.flat().map((c) => c.text.trim()).filter(Boolean).join(" | ") : void 0;
|
|
7187
7217
|
if (!b.bbox || !b.pageNumber || !text) continue;
|
|
7188
7218
|
const ph = pageHeights.get(b.bbox.page) || pageHeights.get(b.pageNumber);
|
|
7189
7219
|
if (!ph) continue;
|
|
@@ -7216,7 +7246,7 @@ function removeHeaderFooterBlocks(blocks, pageHeights, warnings, notes, tables =
|
|
|
7216
7246
|
for (const [p, count] of patternCount) {
|
|
7217
7247
|
const pages = [..._nullishCoalesce(patternPages.get(p), () => ( []))];
|
|
7218
7248
|
const span2 = pages.length ? Math.max(...pages) - Math.min(...pages) + 1 : 0;
|
|
7219
|
-
const varying = !tables && (_nullishCoalesce(_optionalChain([patternNumbers, 'access',
|
|
7249
|
+
const varying = !tables && (_nullishCoalesce(_optionalChain([patternNumbers, 'access', _306 => _306.get, 'call', _307 => _307(p), 'optionalAccess', _308 => _308.size]), () => ( 0))) > 1;
|
|
7220
7250
|
const occ = _nullishCoalesce(patternOcc.get(p), () => ( []));
|
|
7221
7251
|
const dense = pages.length >= span2 * 0.4;
|
|
7222
7252
|
const loose = looseVaryingNumber(occ, entries === topEntries) && (entries === bottomEntries || dense || tracksPages(occ));
|
|
@@ -7228,8 +7258,8 @@ function removeHeaderFooterBlocks(blocks, pageHeights, warnings, notes, tables =
|
|
|
7228
7258
|
for (const e of entries) {
|
|
7229
7259
|
const norm = e.text.replace(/\d+/g, "#");
|
|
7230
7260
|
if (!repeatedPatterns.has(norm)) continue;
|
|
7231
|
-
const noteMark = _optionalChain([e, 'access',
|
|
7232
|
-
if (noteMark && _optionalChain([notes, 'optionalAccess',
|
|
7261
|
+
const noteMark = _optionalChain([e, 'access', _309 => _309.text, 'access', _310 => _310.match, 'call', _311 => _311(/^\d{1,3}\)/), 'optionalAccess', _312 => _312[0]]);
|
|
7262
|
+
if (noteMark && _optionalChain([notes, 'optionalAccess', _313 => _313.get, 'call', _314 => _314(e.page), 'optionalAccess', _315 => _315.marks, 'access', _316 => _316.some, 'call', _317 => _317((m) => m.mark === noteMark)])) continue;
|
|
7233
7263
|
const cand = blocks[e.blockIdx];
|
|
7234
7264
|
const cb = cand.bbox;
|
|
7235
7265
|
const tableNote = /^(?:주\s*(?:\d+\s*[).:]|[::])|(?:자료|출처)\s*[::]|\*\s+\S)/.test(e.text.replace(/ \| /g, " ")) && blocks.some((o) => {
|
|
@@ -7243,7 +7273,7 @@ function removeHeaderFooterBlocks(blocks, pageHeights, warnings, notes, tables =
|
|
|
7243
7273
|
if (bi === e.blockIdx) continue;
|
|
7244
7274
|
const o = blocks[bi];
|
|
7245
7275
|
if (!o.bbox || o.bbox.page !== cb.page) continue;
|
|
7246
|
-
const oNorm = _optionalChain([o, 'access',
|
|
7276
|
+
const oNorm = _optionalChain([o, 'access', _318 => _318.text, 'optionalAccess', _319 => _319.trim, 'call', _320 => _320(), 'access', _321 => _321.replace, 'call', _322 => _322(/\d+/g, "#")]);
|
|
7247
7277
|
if (oNorm && repeatedPatterns.has(oNorm)) continue;
|
|
7248
7278
|
const overlap2 = Math.min(cb.y + cb.height, o.bbox.y + o.bbox.height) - Math.max(cb.y, o.bbox.y);
|
|
7249
7279
|
if (overlap2 >= cb.height * 0.5) {
|
|
@@ -7371,7 +7401,7 @@ function recordRowRules(table, cells, bbox, hs) {
|
|
|
7371
7401
|
function markImageCell(cell) {
|
|
7372
7402
|
IMAGE_CELLS.add(cell);
|
|
7373
7403
|
}
|
|
7374
|
-
var emptyCell = (cell) => !cell || !_optionalChain([cell, 'access',
|
|
7404
|
+
var emptyCell = (cell) => !cell || !_optionalChain([cell, 'access', _323 => _323.text, 'optionalAccess', _324 => _324.trim, 'call', _325 => _325()]) && !_optionalChain([cell, 'access', _326 => _326.blocks, 'optionalAccess', _327 => _327.length]) && !IMAGE_CELLS.has(cell);
|
|
7375
7405
|
function trimTable(table) {
|
|
7376
7406
|
let cols = table.cols;
|
|
7377
7407
|
while (cols > 0 && table.cells.every((row) => emptyCell(row[cols - 1]))) cols--;
|
|
@@ -7387,7 +7417,7 @@ function trimTable(table) {
|
|
|
7387
7417
|
function trimTrailingEmptyTableCols(blocks) {
|
|
7388
7418
|
for (const b of blocks) {
|
|
7389
7419
|
if (b.type !== "table" || !b.table) continue;
|
|
7390
|
-
for (const row of b.table.cells) for (const cell of row) if (_optionalChain([cell, 'access',
|
|
7420
|
+
for (const row of b.table.cells) for (const cell of row) if (_optionalChain([cell, 'access', _328 => _328.blocks, 'optionalAccess', _329 => _329.length])) trimTrailingEmptyTableCols(cell.blocks);
|
|
7391
7421
|
trimTable(b.table);
|
|
7392
7422
|
}
|
|
7393
7423
|
}
|
|
@@ -7407,7 +7437,7 @@ function mergeSliverColumns(grid, colXs, maxWidth) {
|
|
|
7407
7437
|
}
|
|
7408
7438
|
const ok = owner.every((row) => {
|
|
7409
7439
|
const o = row[c];
|
|
7410
|
-
return !!o && (o.colSpan > 1 || !o.text.trim() && !_optionalChain([o, 'access',
|
|
7440
|
+
return !!o && (o.colSpan > 1 || !o.text.trim() && !_optionalChain([o, 'access', _330 => _330.blocks, 'optionalAccess', _331 => _331.length]));
|
|
7411
7441
|
});
|
|
7412
7442
|
if (!ok) continue;
|
|
7413
7443
|
const spanning = /* @__PURE__ */ new Set();
|
|
@@ -7434,7 +7464,7 @@ var multiply = (m, t) => [
|
|
|
7434
7464
|
m[1] * t[4] + m[3] * t[5] + m[5]
|
|
7435
7465
|
];
|
|
7436
7466
|
function hollowCircle(image) {
|
|
7437
|
-
if (!_optionalChain([image, 'optionalAccess',
|
|
7467
|
+
if (!_optionalChain([image, 'optionalAccess', _332 => _332.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;
|
|
7438
7468
|
const stride = image.kind === _pdfmjs.ImageKind.RGB_24BPP ? 3 : image.kind === _pdfmjs.ImageKind.RGBA_32BPP ? 4 : 0;
|
|
7439
7469
|
const { width, height, data } = image;
|
|
7440
7470
|
if (!stride || data.length < width * height * stride) return false;
|
|
@@ -7499,9 +7529,9 @@ function smallVisibleImagePaints(fnArray, argsArray) {
|
|
|
7499
7529
|
const op = fnArray[i], args = argsArray[i];
|
|
7500
7530
|
if (op === _pdfmjs.OPS.save || op === _pdfmjs.OPS.paintFormXObjectBegin) {
|
|
7501
7531
|
stack.push({ ctm, alpha, clip, unknownClip });
|
|
7502
|
-
const matrix = op === _pdfmjs.OPS.paintFormXObjectBegin ? _optionalChain([args, 'optionalAccess',
|
|
7532
|
+
const matrix = op === _pdfmjs.OPS.paintFormXObjectBegin ? _optionalChain([args, 'optionalAccess', _333 => _333[0]]) : void 0;
|
|
7503
7533
|
if (Array.isArray(matrix) && matrix.length >= 6) ctm = multiply(ctm, matrix);
|
|
7504
|
-
const bounds = op === _pdfmjs.OPS.paintFormXObjectBegin ? _optionalChain([args, 'optionalAccess',
|
|
7534
|
+
const bounds = op === _pdfmjs.OPS.paintFormXObjectBegin ? _optionalChain([args, 'optionalAccess', _334 => _334[1]]) : void 0;
|
|
7505
7535
|
if (Array.isArray(bounds) && bounds.length === 4) {
|
|
7506
7536
|
const box = rectangle(bounds[0], bounds[1], bounds[2] - bounds[0], bounds[3] - bounds[1]);
|
|
7507
7537
|
if (box && ctm[1] === 0 && ctm[2] === 0) intersectClip(box);
|
|
@@ -7509,17 +7539,17 @@ function smallVisibleImagePaints(fnArray, argsArray) {
|
|
|
7509
7539
|
}
|
|
7510
7540
|
} else if (op === _pdfmjs.OPS.restore || op === _pdfmjs.OPS.paintFormXObjectEnd) {
|
|
7511
7541
|
const state = stack.pop();
|
|
7512
|
-
ctm = _nullishCoalesce(_optionalChain([state, 'optionalAccess',
|
|
7513
|
-
alpha = _nullishCoalesce(_optionalChain([state, 'optionalAccess',
|
|
7514
|
-
clip = _nullishCoalesce(_optionalChain([state, 'optionalAccess',
|
|
7515
|
-
unknownClip = _nullishCoalesce(_optionalChain([state, 'optionalAccess',
|
|
7542
|
+
ctm = _nullishCoalesce(_optionalChain([state, 'optionalAccess', _335 => _335.ctm]), () => ( [1, 0, 0, 1, 0, 0]));
|
|
7543
|
+
alpha = _nullishCoalesce(_optionalChain([state, 'optionalAccess', _336 => _336.alpha]), () => ( 1));
|
|
7544
|
+
clip = _nullishCoalesce(_optionalChain([state, 'optionalAccess', _337 => _337.clip]), () => ( null));
|
|
7545
|
+
unknownClip = _nullishCoalesce(_optionalChain([state, 'optionalAccess', _338 => _338.unknownClip]), () => ( false));
|
|
7516
7546
|
} else if (op === _pdfmjs.OPS.setGState) {
|
|
7517
|
-
for (const [key, value] of _nullishCoalesce(_optionalChain([args, 'optionalAccess',
|
|
7547
|
+
for (const [key, value] of _nullishCoalesce(_optionalChain([args, 'optionalAccess', _339 => _339[0]]), () => ( []))) {
|
|
7518
7548
|
if (key === "ca") alpha = typeof value === "number" ? value : 0;
|
|
7519
7549
|
}
|
|
7520
7550
|
} else if (op === _pdfmjs.OPS.constructPath) {
|
|
7521
7551
|
const [operations, coordinates] = args;
|
|
7522
|
-
pathRect = pathRect === void 0 && _optionalChain([operations, 'optionalAccess',
|
|
7552
|
+
pathRect = pathRect === void 0 && _optionalChain([operations, 'optionalAccess', _340 => _340.length]) === 1 && operations[0] === _pdfmjs.OPS.rectangle && _optionalChain([coordinates, 'optionalAccess', _341 => _341.length]) >= 4 && ctm[1] === 0 && ctm[2] === 0 ? rectangle(coordinates[0], coordinates[1], coordinates[2], coordinates[3]) : null;
|
|
7523
7553
|
} else if (op === _pdfmjs.OPS.clip || op === _pdfmjs.OPS.eoClip) pendingClip = true;
|
|
7524
7554
|
else if ([
|
|
7525
7555
|
_pdfmjs.OPS.endPath,
|
|
@@ -7539,7 +7569,7 @@ function smallVisibleImagePaints(fnArray, argsArray) {
|
|
|
7539
7569
|
pendingClip = false;
|
|
7540
7570
|
pathRect = void 0;
|
|
7541
7571
|
} else if (op === _pdfmjs.OPS.transform && Array.isArray(args) && args.length >= 6) ctm = multiply(ctm, args);
|
|
7542
|
-
else if (op === _pdfmjs.OPS.paintImageXObject && typeof _optionalChain([args, 'optionalAccess',
|
|
7572
|
+
else if (op === _pdfmjs.OPS.paintImageXObject && typeof _optionalChain([args, 'optionalAccess', _342 => _342[0]]) === "string") {
|
|
7543
7573
|
if (typeof args[1] !== "number" || typeof args[2] !== "number" || args[1] < 16 || args[1] > 128 || args[2] < 16 || args[2] > 128) continue;
|
|
7544
7574
|
const box = extractImageRegions([_pdfmjs.OPS.transform, _pdfmjs.OPS.paintImageXObject], [ctm, args])[0];
|
|
7545
7575
|
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;
|
|
@@ -7558,14 +7588,14 @@ async function restoreImageBullets(items, page, fnArray, argsArray, shapes = /*
|
|
|
7558
7588
|
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];
|
|
7559
7589
|
if (!line || /^[○●•◦□■∙]/.test(line.text.trim()) || !/\p{L}/u.test(line.text)) continue;
|
|
7560
7590
|
const row = items.filter((item) => Math.abs(item.y - line.y) <= 2 && item.x >= line.x);
|
|
7561
|
-
if (row.reduce((n, item) => n + (_nullishCoalesce(_optionalChain([item, 'access',
|
|
7591
|
+
if (row.reduce((n, item) => n + (_nullishCoalesce(_optionalChain([item, 'access', _343 => _343.text, 'access', _344 => _344.match, 'call', _345 => _345(/\p{L}/gu), 'optionalAccess', _346 => _346.length]), () => ( 0))), 0) < 12 || items.some((item) => item !== line && Math.abs(item.y - line.y) <= 2 && item.x < line.x)) continue;
|
|
7562
7592
|
candidates.push({ id, x: box.x1, width, line });
|
|
7563
7593
|
}
|
|
7564
7594
|
let restored = 0;
|
|
7565
7595
|
const used = /* @__PURE__ */ new Set();
|
|
7566
7596
|
for (const candidate of candidates) {
|
|
7567
7597
|
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);
|
|
7568
|
-
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',
|
|
7598
|
+
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', _347 => _347.text, 'access', _348 => _348.match, 'call', _349 => _349(/\p{L}/gu), 'optionalAccess', _350 => _350.length]), () => ( 0))) >= 12).sort((a, b) => b.y - a.y);
|
|
7569
7599
|
const numberedList = numbered.some((item, index) => index > 0 && item.text.trim().charCodeAt(0) === numbered[index - 1].text.trim().charCodeAt(0) + 1);
|
|
7570
7600
|
if (!same.length && !numberedList || used.has(candidate.line)) continue;
|
|
7571
7601
|
if (!shapes.has(candidate.id)) shapes.set(candidate.id, hollowCircle(await resolveImagePixels(page, candidate.id)));
|
|
@@ -7631,7 +7661,7 @@ function groupFlowBoxUnits(blocks, grids, hs, vs, images) {
|
|
|
7631
7661
|
return units;
|
|
7632
7662
|
}
|
|
7633
7663
|
function arrowDirection(image) {
|
|
7634
|
-
if (!_optionalChain([image, 'optionalAccess',
|
|
7664
|
+
if (!_optionalChain([image, 'optionalAccess', _351 => _351.data]) || image.width < 16 || image.width > 128 || image.height < 16 || image.height > 128) return 0;
|
|
7635
7665
|
const { width, height, data } = image;
|
|
7636
7666
|
const stride = image.kind === _pdfmjs.ImageKind.RGB_24BPP ? 3 : image.kind === _pdfmjs.ImageKind.RGBA_32BPP ? 4 : 0;
|
|
7637
7667
|
if (!stride || data.length < width * height * stride) return 0;
|
|
@@ -7699,7 +7729,7 @@ function isSideTabTable(box, table, others, pageWidth, pageHeight) {
|
|
|
7699
7729
|
function removeSideTabs(blocks, pageWidths) {
|
|
7700
7730
|
const edges = /* @__PURE__ */ new Map();
|
|
7701
7731
|
for (const b of blocks) {
|
|
7702
|
-
if (!b.bbox || b.pageNumber === void 0 || [..._nullishCoalesce(_optionalChain([b, 'access',
|
|
7732
|
+
if (!b.bbox || b.pageNumber === void 0 || [..._nullishCoalesce(_optionalChain([b, 'access', _352 => _352.text, 'optionalAccess', _353 => _353.trim, 'call', _354 => _354()]), () => ( ""))].length <= MAX_CHARS) continue;
|
|
7703
7733
|
const e = _nullishCoalesce(edges.get(b.pageNumber), () => ( { lefts: [], rights: [] }));
|
|
7704
7734
|
e.lefts.push(b.bbox.x);
|
|
7705
7735
|
e.rights.push(b.bbox.x + b.bbox.width);
|
|
@@ -7715,7 +7745,7 @@ function removeSideTabs(blocks, pageWidths) {
|
|
|
7715
7745
|
const fallback = all.length ? { left: q(all.map((e) => e.left), 0.5), right: q(all.map((e) => e.right), 0.5) } : void 0;
|
|
7716
7746
|
const key = (b) => {
|
|
7717
7747
|
const w = b.pageNumber !== void 0 ? pageWidths.get(b.pageNumber) : void 0;
|
|
7718
|
-
const text = _optionalChain([b, 'access',
|
|
7748
|
+
const text = _optionalChain([b, 'access', _355 => _355.text, 'optionalAccess', _356 => _356.trim, 'call', _357 => _357()]);
|
|
7719
7749
|
const area = _nullishCoalesce((b.pageNumber !== void 0 ? body.get(b.pageNumber) : void 0), () => ( fallback));
|
|
7720
7750
|
if (b.type === "table") {
|
|
7721
7751
|
if (!w || !b.bbox || !b.table || !SIDE_TAB_TABLES.has(b.table)) return null;
|
|
@@ -8151,16 +8181,16 @@ function isProseSpread(items) {
|
|
|
8151
8181
|
for (let i = 1; i < sorted.length; i++) {
|
|
8152
8182
|
gaps.push(sorted[i].x - (sorted[i - 1].x + sorted[i - 1].w));
|
|
8153
8183
|
}
|
|
8154
|
-
const maxGap =
|
|
8184
|
+
const maxGap = _chunk4REIOZGLcjs.safeMax.call(void 0, gaps);
|
|
8155
8185
|
const avgLen = items.reduce((s, i) => s + i.text.length, 0) / items.length;
|
|
8156
8186
|
if (items.length >= 4 && maxGap < 40 && avgLen < 5) return true;
|
|
8157
|
-
const minGap =
|
|
8187
|
+
const minGap = _chunk4REIOZGLcjs.safeMin.call(void 0, gaps);
|
|
8158
8188
|
return minGap > 0 && maxGap - minGap <= Math.max(2, maxGap * 0.15) && (items.filter((i) => /^\P{L}*\p{Ll}/u.test(i.text)).length * 2 >= items.length || items.some((i) => /\p{L}[,.;:]["”’)]?$/u.test(i.text)));
|
|
8159
8189
|
}
|
|
8160
8190
|
function detectColumns(yLines) {
|
|
8161
8191
|
const allItems = yLines.flat();
|
|
8162
8192
|
if (allItems.length === 0) return null;
|
|
8163
|
-
const pageWidth =
|
|
8193
|
+
const pageWidth = _chunk4REIOZGLcjs.safeMax.call(void 0, allItems.map((i) => i.x + i.w)) - _chunk4REIOZGLcjs.safeMin.call(void 0, allItems.map((i) => i.x));
|
|
8164
8194
|
if (pageWidth < 100) return null;
|
|
8165
8195
|
let bigoLineIdx = -1;
|
|
8166
8196
|
for (let i = 0; i < yLines.length; i++) {
|
|
@@ -8385,7 +8415,7 @@ var UNDER_BOX_PAIR_MAX_EM = 2.2;
|
|
|
8385
8415
|
var UNDER_BOX_PAIR_OVERLAP = 0.8;
|
|
8386
8416
|
function markUnderlineItems(items, horizontals, verticals, nonRules) {
|
|
8387
8417
|
const underlines = [];
|
|
8388
|
-
if (_optionalChain([nonRules, 'optionalAccess',
|
|
8418
|
+
if (_optionalChain([nonRules, 'optionalAccess', _358 => _358.size])) horizontals = horizontals.filter((line) => !nonRules.has(line));
|
|
8389
8419
|
if (items.length === 0 || horizontals.length === 0) return underlines;
|
|
8390
8420
|
const tightOwners = /* @__PURE__ */ new Map();
|
|
8391
8421
|
const tightlyOwned = (line) => {
|
|
@@ -8491,7 +8521,7 @@ function hasBoxTopPair(line, maxH, horizontals, cellItems) {
|
|
|
8491
8521
|
if (ow <= 0) continue;
|
|
8492
8522
|
const overlap2 = Math.min(line.x2, o.x2) - Math.max(line.x1, o.x1);
|
|
8493
8523
|
if (overlap2 / Math.max(w, ow) < UNDER_BOX_PAIR_OVERLAP) continue;
|
|
8494
|
-
const covered = _nullishCoalesce(_optionalChain([cellItems, 'optionalAccess',
|
|
8524
|
+
const covered = _nullishCoalesce(_optionalChain([cellItems, 'optionalAccess', _359 => _359.reduce, 'call', _360 => _360((sum, item) => {
|
|
8495
8525
|
const below = item.y - o.y1;
|
|
8496
8526
|
if (below < 0.5 || below > 3 || !item.text.trim()) return sum;
|
|
8497
8527
|
return sum + Math.max(0, Math.min(o.x2, item.x + item.w) - Math.max(o.x1, item.x));
|
|
@@ -8558,13 +8588,13 @@ function partTex(group) {
|
|
|
8558
8588
|
const base = Math.min(...g.filter((i) => i.fontSize >= size * SCRIPT_SIZE_RATIO).map((i) => i.y));
|
|
8559
8589
|
let s = "", run = "";
|
|
8560
8590
|
const flush = () => {
|
|
8561
|
-
if (run) s +=
|
|
8591
|
+
if (run) s += _chunkHA3YIEAScjs.toTex.call(void 0, run);
|
|
8562
8592
|
run = "";
|
|
8563
8593
|
};
|
|
8564
8594
|
g.forEach((it, k) => {
|
|
8565
8595
|
if (it.fontSize < size * SCRIPT_SIZE_RATIO && it.y - base >= size * SCRIPT_RISE_EM) {
|
|
8566
8596
|
flush();
|
|
8567
|
-
s += `^{${
|
|
8597
|
+
s += `^{${_chunkHA3YIEAScjs.toTex.call(void 0, it.text)}}`;
|
|
8568
8598
|
return;
|
|
8569
8599
|
}
|
|
8570
8600
|
if (k && it.x - (g[k - 1].x + g[k - 1].w) > spaceGapThreshold(it.fontSize)) run += " ";
|
|
@@ -8736,12 +8766,12 @@ function rebuildUnitLine(items, grid) {
|
|
|
8736
8766
|
function prependUnitRow(cells, cols, line, usedItems) {
|
|
8737
8767
|
const text = cleanCellText(line.map((item) => item.text).join(""));
|
|
8738
8768
|
cells.unshift(Array.from({ length: cols }, (_, c) => ({ text: c === 0 ? text : "", colSpan: c === 0 ? cols : 1, rowSpan: 1 })));
|
|
8739
|
-
for (const cell of cells[0])
|
|
8769
|
+
for (const cell of cells[0]) _chunkHA3YIEAScjs.CELL_EDGES.set(cell, NO_EDGES);
|
|
8740
8770
|
for (const item of line) usedItems.add(item);
|
|
8741
8771
|
}
|
|
8742
8772
|
function attachUnitRow(items, grid, cells, cols, usedItems) {
|
|
8743
8773
|
const all = cells.flat();
|
|
8744
|
-
if (all.filter((c) => c.text.trim()).length * 2 < all.length || UNIT.test(_nullishCoalesce(_optionalChain([cells, 'access',
|
|
8774
|
+
if (all.filter((c) => c.text.trim()).length * 2 < all.length || UNIT.test(_nullishCoalesce(_optionalChain([cells, 'access', _361 => _361[0], 'optionalAccess', _362 => _362[0], 'optionalAccess', _363 => _363.text]), () => ( "")))) return false;
|
|
8745
8775
|
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);
|
|
8746
8776
|
let nearest = Infinity;
|
|
8747
8777
|
for (const it of above) nearest = Math.min(nearest, it.y);
|
|
@@ -8776,7 +8806,7 @@ function closeShadedTableEdges(clipGrids, horizontals, verticals, fillRects) {
|
|
|
8776
8806
|
let hs = horizontals, vs = verticals;
|
|
8777
8807
|
const restored = [];
|
|
8778
8808
|
for (const grid of clipGrids) {
|
|
8779
|
-
if (grid.clipParent || grid.rowYs.length !== 2 || grid.colXs.length < 3 || !_optionalChain([grid, 'access',
|
|
8809
|
+
if (grid.clipParent || grid.rowYs.length !== 2 || grid.colXs.length < 3 || !_optionalChain([grid, 'access', _364 => _364.cells, 'optionalAccess', _365 => _365.length]) || grid.cells.some((c) => c.filler || c.rowSpan !== 1 || c.colSpan !== 1)) continue;
|
|
8780
8810
|
const { x1, x2, y1: mid, y2: top } = grid.bbox;
|
|
8781
8811
|
if (!grid.cells.every((c) => fillRects.some((f) => near2(f.x1, c.bbox.x1) && near2(f.x2, c.bbox.x2) && near2(f.y1, c.bbox.y1) && near2(f.y2, c.bbox.y2)))) continue;
|
|
8782
8812
|
const topRule = hs.find((h) => near2(h.y1, top) && near2(h.x1, x1) && near2(h.x2, x2));
|
|
@@ -9240,7 +9270,7 @@ function takeFrameSpanningText(items, cutX, pageNum, lex) {
|
|
|
9240
9270
|
const rows = groupByY([...items].sort((a, b) => b.y - a.y || a.x - b.x)).map((line) => {
|
|
9241
9271
|
const runs = [];
|
|
9242
9272
|
for (const item of [...line].sort((a, b) => a.x - b.x)) {
|
|
9243
|
-
const run = runs[runs.length - 1], prev = _optionalChain([run, 'optionalAccess',
|
|
9273
|
+
const run = runs[runs.length - 1], prev = _optionalChain([run, 'optionalAccess', _366 => _366[run.length - 1]]);
|
|
9244
9274
|
if (prev && item.x - (prev.x + prev.w) <= Math.max(prev.fontSize, item.fontSize) * 0.6) run.push(item);
|
|
9245
9275
|
else runs.push([item]);
|
|
9246
9276
|
}
|
|
@@ -9284,7 +9314,7 @@ function groupFrameParagraphUnits(units, frames) {
|
|
|
9284
9314
|
for (const unit of units) for (const block of unit) source.set(block, unit);
|
|
9285
9315
|
const members = /* @__PURE__ */ new Map(), emitted = /* @__PURE__ */ new Set();
|
|
9286
9316
|
for (const frame of frames) {
|
|
9287
|
-
if (frame.length < 2 || frame.some((block) => block.type !== "paragraph" || _optionalChain([source, 'access',
|
|
9317
|
+
if (frame.length < 2 || frame.some((block) => block.type !== "paragraph" || _optionalChain([source, 'access', _367 => _367.get, 'call', _368 => _368(block), 'optionalAccess', _369 => _369.length]) !== 1)) continue;
|
|
9288
9318
|
for (const block of frame) members.set(block, frame);
|
|
9289
9319
|
}
|
|
9290
9320
|
const out = [];
|
|
@@ -9297,7 +9327,7 @@ function groupFrameParagraphUnits(units, frames) {
|
|
|
9297
9327
|
}
|
|
9298
9328
|
}
|
|
9299
9329
|
for (const unit of out) {
|
|
9300
|
-
if (unit.length < 2 || _optionalChain([FRAME_READING_UNITS, 'access',
|
|
9330
|
+
if (unit.length < 2 || _optionalChain([FRAME_READING_UNITS, 'access', _370 => _370.get, 'call', _371 => _371(unit[0]), 'optionalAccess', _372 => _372.blocks]) === unit) continue;
|
|
9301
9331
|
const bs = unit.map((b) => b.bbox).filter((b) => !!b);
|
|
9302
9332
|
if (bs.length !== unit.length) continue;
|
|
9303
9333
|
const x = Math.min(...bs.map((b) => b.x)), y = Math.min(...bs.map((b) => b.y));
|
|
@@ -9314,14 +9344,14 @@ function groupFrameParagraphUnits(units, frames) {
|
|
|
9314
9344
|
function recordFrameTitle(table, source, pageNum) {
|
|
9315
9345
|
if (!CLIP_TABLES.has(table) || table.rows !== 1 || table.cols !== 3 || source.length < 2) return;
|
|
9316
9346
|
const cells = table.cells[0];
|
|
9317
|
-
if (cells.length !== 3 || cells.some((c) => c.colSpan !== 1 || c.rowSpan !== 1 || _optionalChain([c, 'access',
|
|
9347
|
+
if (cells.length !== 3 || cells.some((c) => c.colSpan !== 1 || c.rowSpan !== 1 || _optionalChain([c, 'access', _373 => _373.blocks, 'optionalAccess', _374 => _374.length]) || c.text.includes("\n"))) return;
|
|
9318
9348
|
const [label, spacer, title] = cells;
|
|
9319
9349
|
if (!/^(?:붙임|별첨|첨부|부록)\s*\d{1,3}$/.test(label.text.trim()) || spacer.text.trim() || !title.text.trim()) return;
|
|
9320
9350
|
if (cells.some((c) => {
|
|
9321
|
-
const e =
|
|
9351
|
+
const e = _chunkHA3YIEAScjs.CELL_EDGES.get(c);
|
|
9322
9352
|
return !e || e.t || e.b || e.l || e.r;
|
|
9323
9353
|
})) return;
|
|
9324
|
-
const xs = TABLE_COLXS.get(table), style = dominantStyle(source), fs = _nullishCoalesce(_optionalChain([style, 'optionalAccess',
|
|
9354
|
+
const xs = TABLE_COLXS.get(table), style = dominantStyle(source), fs = _nullishCoalesce(_optionalChain([style, 'optionalAccess', _375 => _375.fontSize]), () => ( 0));
|
|
9325
9355
|
if (!xs || xs.length !== 4 || fs <= 0) return;
|
|
9326
9356
|
const width = xs[3] - xs[0], gap = xs[2] - xs[1];
|
|
9327
9357
|
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;
|
|
@@ -9379,7 +9409,7 @@ function extendNestedShadedHeaders(clipGrids, lineGrids, horizontals, verticals,
|
|
|
9379
9409
|
const extended = [];
|
|
9380
9410
|
for (let i = 0; i < clipGrids.length; i++) {
|
|
9381
9411
|
const c = clipGrids[i], parent = c.clipParent;
|
|
9382
|
-
if (!parent || c.rowYs.length !== 2 || c.colXs.length < 3 || !_optionalChain([c, 'access',
|
|
9412
|
+
if (!parent || c.rowYs.length !== 2 || c.colXs.length < 3 || !_optionalChain([c, 'access', _376 => _376.cells, 'optionalAccess', _377 => _377.length]) || c.cells.some((cell) => cell.filler || cell.rowSpan !== 1 || cell.colSpan !== 1)) continue;
|
|
9383
9413
|
if (!clipGrids.some((g) => g.rowYs.length === 2 && g.colXs.length === 2 && near2(g.bbox.x1, parent.x1) && near2(g.bbox.x2, parent.x2) && near2(g.bbox.y1, parent.y1) && near2(g.bbox.y2, parent.y2))) continue;
|
|
9384
9414
|
if (!c.cells.every((cell) => fills.some((f) => near2(f.x1, cell.bbox.x1) && near2(f.x2, cell.bbox.x2) && near2(f.y1, cell.bbox.y1) && near2(f.y2, cell.bbox.y2)))) continue;
|
|
9385
9415
|
const host = lineGrids.find((l) => l.rowYs.length > 2 && l.colXs.length === c.colXs.length && c.colXs.every((x, k) => near2(x, l.colXs[k])) && c.rowYs.every((y, k) => near2(y, l.rowYs[k])) && contains4(parent, l.bbox) && l.rowYs.every((y) => horizontals.some((h) => near2(h.y1, y) && near2(h.x1, l.bbox.x1) && near2(h.x2, l.bbox.x2))) && l.colXs.every((x) => verticals.some((v) => near2(v.x1, x) && v.y1 <= l.bbox.y1 + 1.5 && v.y2 >= l.bbox.y2 - 1.5)) && !clipGrids.some((o) => o !== c && !contains4(o.bbox, l.bbox) && Math.min(o.bbox.x2, l.bbox.x2) > Math.max(o.bbox.x1, l.bbox.x1) && Math.min(o.bbox.y2, l.bbox.y2) > Math.max(o.bbox.y1, l.bbox.y1)));
|
|
@@ -9402,7 +9432,7 @@ function attachSideTabBlocks(tab, body, pageNum) {
|
|
|
9402
9432
|
bbox: computeBBox(items, pageNum),
|
|
9403
9433
|
style: dominantStyle(items)
|
|
9404
9434
|
});
|
|
9405
|
-
const prefix = ordered.filter((g) => !_optionalChain([caps, 'optionalAccess',
|
|
9435
|
+
const prefix = ordered.filter((g) => !_optionalChain([caps, 'optionalAccess', _378 => _378.has, 'call', _379 => _379(g)])).map((g) => ({
|
|
9406
9436
|
type: "paragraph",
|
|
9407
9437
|
text: g.text.trim(),
|
|
9408
9438
|
pageNumber: pageNum,
|
|
@@ -9411,7 +9441,7 @@ function attachSideTabBlocks(tab, body, pageNum) {
|
|
|
9411
9441
|
}));
|
|
9412
9442
|
const groups = /* @__PURE__ */ new Map();
|
|
9413
9443
|
for (const g of ordered) {
|
|
9414
|
-
const cap = _optionalChain([caps, 'optionalAccess',
|
|
9444
|
+
const cap = _optionalChain([caps, 'optionalAccess', _380 => _380.get, 'call', _381 => _381(g)]);
|
|
9415
9445
|
if (cap) groups.set(cap, [..._nullishCoalesce(groups.get(cap), () => ( [])), g]);
|
|
9416
9446
|
}
|
|
9417
9447
|
for (const [cap, glyphs] of groups) {
|
|
@@ -9442,7 +9472,7 @@ function extractPageBlocksWithLines(items, pageNum, opList, pageWidth, pageHeigh
|
|
|
9442
9472
|
let prev = null;
|
|
9443
9473
|
for (const line of streamLines(items)) {
|
|
9444
9474
|
lex.addLine(mergeLineSimple(line));
|
|
9445
|
-
const fs = _nullishCoalesce(_optionalChain([dominantStyle, 'call',
|
|
9475
|
+
const fs = _nullishCoalesce(_optionalChain([dominantStyle, 'call', _382 => _382(line), 'optionalAccess', _383 => _383.fontSize]), () => ( 0));
|
|
9446
9476
|
const left = Math.min(...line.map((i) => i.x)), right = Math.max(...line.map((i) => i.x + i.w));
|
|
9447
9477
|
const y = line.reduce((n, i) => n + i.y, 0) / line.length;
|
|
9448
9478
|
const wide = fs > 0 && right - left >= 12 * fs;
|
|
@@ -9456,7 +9486,7 @@ function extractPageBlocksWithLines(items, pageNum, opList, pageWidth, pageHeigh
|
|
|
9456
9486
|
const filled = fillBlanks(items, horizontals, verticals);
|
|
9457
9487
|
items = filled.items;
|
|
9458
9488
|
horizontals = filled.horizontals;
|
|
9459
|
-
const prevPage = _optionalChain([carry, 'optionalAccess',
|
|
9489
|
+
const prevPage = _optionalChain([carry, 'optionalAccess', _384 => _384.page]) === pageNum - 1 ? carry.clip : void 0;
|
|
9460
9490
|
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 };
|
|
9461
9491
|
if (carry) {
|
|
9462
9492
|
carry.page = pageNum;
|
|
@@ -9713,14 +9743,14 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
|
|
|
9713
9743
|
if (!assignedItems.has(textItems[ti])) usedItems.delete(owners[ti]);
|
|
9714
9744
|
}
|
|
9715
9745
|
}
|
|
9716
|
-
if (unitLine.length > 0 && rebuiltUsed && !/^\s*\(\s*단위\s*[::]/.test(_nullishCoalesce(_optionalChain([finalGrid, 'access',
|
|
9746
|
+
if (unitLine.length > 0 && rebuiltUsed && !/^\s*\(\s*단위\s*[::]/.test(_nullishCoalesce(_optionalChain([finalGrid, 'access', _385 => _385[0], 'optionalAccess', _386 => _386[0], 'optionalAccess', _387 => _387.text]), () => ( "")))) {
|
|
9717
9747
|
prependUnitRow(finalGrid, numCols, unitLine, usedItems);
|
|
9718
9748
|
finalRows++;
|
|
9719
9749
|
}
|
|
9720
9750
|
if (!rebuiltUsed && attachUnitRow(items, grid, finalGrid, numCols, usedItems)) finalRows++;
|
|
9721
9751
|
let semanticOneColumn = false;
|
|
9722
9752
|
if (!grid.cells && !nestedAttached && numCols === 1 && numGridRows >= 2) {
|
|
9723
|
-
const populatedRows = finalGrid.filter((row) => _optionalChain([row, 'access',
|
|
9753
|
+
const populatedRows = finalGrid.filter((row) => _optionalChain([row, 'access', _388 => _388[0], 'optionalAccess', _389 => _389.text, 'access', _390 => _390.trim, 'call', _391 => _391()]));
|
|
9724
9754
|
if (populatedRows.length >= 4) {
|
|
9725
9755
|
const fontSizes = tableItems.map((item) => item.fontSize).filter((size) => size > 0).sort((a, b) => a - b);
|
|
9726
9756
|
const medianFont = _nullishCoalesce(fontSizes[Math.floor(fontSizes.length / 2)], () => ( 0));
|
|
@@ -9816,7 +9846,7 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
|
|
|
9816
9846
|
height: grid.bbox.y2 - grid.bbox.y1
|
|
9817
9847
|
};
|
|
9818
9848
|
if (numRows === 1 && numCols === 1 && gridW < pageWidth * 0.35) {
|
|
9819
|
-
const prose = _nullishCoalesce(_optionalChain([finalGrid, 'access',
|
|
9849
|
+
const prose = _nullishCoalesce(_optionalChain([finalGrid, 'access', _392 => _392[0], 'optionalAccess', _393 => _393[0], 'optionalAccess', _394 => _394.text]), () => ( ""));
|
|
9820
9850
|
const besideLines = (side) => new Set(side.map((it) => Math.round(it.y / 3))).size;
|
|
9821
9851
|
const rightLines = items.filter((it) => it.x >= grid.bbox.x2 + 3 && it.y >= grid.bbox.y1 && it.y <= grid.bbox.y2);
|
|
9822
9852
|
const leftLines = items.filter((it) => it.x + it.w <= grid.bbox.x1 - 3 && it.y >= grid.bbox.y1 && it.y <= grid.bbox.y2);
|
|
@@ -9835,8 +9865,8 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
|
|
|
9835
9865
|
}
|
|
9836
9866
|
}
|
|
9837
9867
|
if (!grid.cells && !nestedAttached && shouldDemoteTable(irTable)) {
|
|
9838
|
-
const paragraphs = numRows === 1 && numCols === 1 ? _optionalChain([irTable, 'access',
|
|
9839
|
-
if (_optionalChain([paragraphs, 'optionalAccess',
|
|
9868
|
+
const paragraphs = numRows === 1 && numCols === 1 ? _optionalChain([irTable, 'access', _395 => _395.cells, 'access', _396 => _396[0], 'optionalAccess', _397 => _397[0], 'optionalAccess', _398 => _398.blocks]) : void 0;
|
|
9869
|
+
if (_optionalChain([paragraphs, 'optionalAccess', _399 => _399.length])) {
|
|
9840
9870
|
blocks.push(...paragraphs);
|
|
9841
9871
|
frameParagraphUnits.push(paragraphs);
|
|
9842
9872
|
recordFrameReadingUnit(paragraphs, tableBbox);
|
|
@@ -9883,7 +9913,7 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
|
|
|
9883
9913
|
const clusterResults = (proseColumns ? [] : detectClusterTables(clusterItems, pageNum, void 0, lex)).filter((cr) => {
|
|
9884
9914
|
const b = cr.bbox;
|
|
9885
9915
|
const overlapX = (x) => Math.min(x.x + x.width, b.x + b.width) - Math.max(x.x, b.x);
|
|
9886
|
-
return !blocks.some((x) => x.bbox && x.bbox.y >= b.y - 2 && x.bbox.y + x.bbox.height <= b.y + b.height + 2 && (x.type === "paragraph" ? (_nullishCoalesce(_optionalChain([x, 'access',
|
|
9916
|
+
return !blocks.some((x) => x.bbox && x.bbox.y >= b.y - 2 && x.bbox.y + x.bbox.height <= b.y + b.height + 2 && (x.type === "paragraph" ? (_nullishCoalesce(_optionalChain([x, 'access', _400 => _400.text, 'optionalAccess', _401 => _401.match, 'call', _402 => _402(/\p{L}/gu), 'optionalAccess', _403 => _403.length]), () => ( 0))) >= 10 && overlapX(x.bbox) >= 0.8 * b.width : x.type === "table" && !ocrPage && _optionalChain([x, 'access', _404 => _404.table, 'optionalAccess', _405 => _405.cols]) === cr.table.cols && overlapX(x.bbox) >= 0.5 * Math.min(x.bbox.width, b.width)));
|
|
9887
9917
|
});
|
|
9888
9918
|
if (clusterResults.length > 0) {
|
|
9889
9919
|
const ciToIdx = /* @__PURE__ */ new Map();
|
|
@@ -9920,7 +9950,7 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
|
|
|
9920
9950
|
groupSizes.push(1);
|
|
9921
9951
|
}
|
|
9922
9952
|
const allY = remaining.map((i) => i.y);
|
|
9923
|
-
const pageH =
|
|
9953
|
+
const pageH = _chunk4REIOZGLcjs.safeMax.call(void 0, allY) - _chunk4REIOZGLcjs.safeMin.call(void 0, allY);
|
|
9924
9954
|
const gapThreshold = Math.max(15, pageH * 0.03);
|
|
9925
9955
|
const sides = frameColumnTextBands(remaining, spanning, gx);
|
|
9926
9956
|
const textBlocks = [];
|
|
@@ -9936,7 +9966,7 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
|
|
|
9936
9966
|
finalTextBlocks.push(...detectListBlocks(textBlocks));
|
|
9937
9967
|
} else {
|
|
9938
9968
|
const allY = remaining.map((i) => i.y);
|
|
9939
|
-
const pageH =
|
|
9969
|
+
const pageH = _chunk4REIOZGLcjs.safeMax.call(void 0, allY) - _chunk4REIOZGLcjs.safeMin.call(void 0, allY);
|
|
9940
9970
|
const gapThreshold = Math.max(15, pageH * 0.03);
|
|
9941
9971
|
const groups = xyCutOrder(remaining, gapThreshold);
|
|
9942
9972
|
const textBlocks = [];
|
|
@@ -10268,7 +10298,7 @@ function extractPageBlocksFallback(items, pageNum, fullPage = false, detectTable
|
|
|
10268
10298
|
blocks.push(...columnTextToBlocks(tableText, pageNum, bbox, dominantStyle(items)));
|
|
10269
10299
|
} else {
|
|
10270
10300
|
const allY = items.map((i) => i.y);
|
|
10271
|
-
const pageHeight =
|
|
10301
|
+
const pageHeight = _chunk4REIOZGLcjs.safeMax.call(void 0, allY) - _chunk4REIOZGLcjs.safeMin.call(void 0, allY);
|
|
10272
10302
|
const gapThreshold = Math.max(15, pageHeight * 0.03);
|
|
10273
10303
|
const orderedGroups = proseCutX !== null ? splitTwoColumnProse(items, proseCutX) : xyCutOrder(items, gapThreshold, 0, void 0, minGap);
|
|
10274
10304
|
for (const group of orderedGroups) {
|
|
@@ -10300,19 +10330,19 @@ function mergeOcrImageRegions(blocks, page, regions, ocrBlocks) {
|
|
|
10300
10330
|
const overlapH = Math.max(0, Math.min(b.y + b.height, region.y2) - Math.max(b.y, region.y1));
|
|
10301
10331
|
return overlapW * overlapH >= b.width * b.height * 0.8;
|
|
10302
10332
|
});
|
|
10303
|
-
const labels = candidates.filter((b) => b.type === "paragraph" && b.bbox.height <= 24 && (_nullishCoalesce(_optionalChain([b, 'access',
|
|
10333
|
+
const labels = candidates.filter((b) => b.type === "paragraph" && b.bbox.height <= 24 && (_nullishCoalesce(_optionalChain([b, 'access', _406 => _406.text, 'optionalAccess', _407 => _407.match, 'call', _408 => _408(/[\p{L}\p{N}]/gu), 'optionalAccess', _409 => _409.length]), () => ( 0))) >= 2);
|
|
10304
10334
|
const axisFragments = rotatedAxisFragments(candidates);
|
|
10305
10335
|
const accepted = candidates.filter((b) => {
|
|
10306
|
-
if (b.type === "paragraph") return (_nullishCoalesce(_optionalChain([b, 'access',
|
|
10336
|
+
if (b.type === "paragraph") return (_nullishCoalesce(_optionalChain([b, 'access', _410 => _410.text, 'optionalAccess', _411 => _411.match, 'call', _412 => _412(/[\p{L}\p{N}]/gu), 'optionalAccess', _413 => _413.length]), () => ( 0))) >= 2 || !axisFragments.has(b) && (supportedDiagramLabel(b, labels, region) || axisTick(b, candidates));
|
|
10307
10337
|
const t = b.table;
|
|
10308
10338
|
if (b.type !== "table" || !t || UNRULED_REGION_TABLES.has(b)) return false;
|
|
10309
10339
|
const lone = t.cells.filter((row) => row.filter((c) => c.text.trim()).length === 1 && row.some((c) => c.colSpan === t.cols)).length;
|
|
10310
10340
|
if (t.rows >= 2 && lone * 2 >= t.rows) return false;
|
|
10311
10341
|
if (t.rows === 1 && t.cols === 1) {
|
|
10312
|
-
const text = _nullishCoalesce(_optionalChain([t, 'access',
|
|
10313
|
-
return (_nullishCoalesce(_optionalChain([text, 'access',
|
|
10342
|
+
const text = _nullishCoalesce(_optionalChain([t, 'access', _414 => _414.cells, 'access', _415 => _415[0], 'optionalAccess', _416 => _416[0], 'optionalAccess', _417 => _417.text]), () => ( ""));
|
|
10343
|
+
return (_nullishCoalesce(_optionalChain([text, 'access', _418 => _418.match, 'call', _419 => _419(/\n/g), 'optionalAccess', _420 => _420.length]), () => ( 0))) >= 5 && (_nullishCoalesce(_optionalChain([text, 'access', _421 => _421.match, 'call', _422 => _422(/\d/g), 'optionalAccess', _423 => _423.length]), () => ( 0))) >= text.length * 0.25;
|
|
10314
10344
|
}
|
|
10315
|
-
const headerLabels = _nullishCoalesce(_optionalChain([t, 'access',
|
|
10345
|
+
const headerLabels = _nullishCoalesce(_optionalChain([t, 'access', _424 => _424.cells, 'access', _425 => _425[0], 'optionalAccess', _426 => _426.filter, 'call', _427 => _427((c) => c.text.replace(/[^A-Za-z가-힣]/g, "").length >= 2), 'access', _428 => _428.length]), () => ( 0));
|
|
10316
10346
|
return t.rows >= 2 && t.cols >= 2 && headerLabels >= t.cols * 0.75 && t.cells.slice(1).some((row) => row.filter((c) => c.text.trim()).length >= 2);
|
|
10317
10347
|
});
|
|
10318
10348
|
const selected = candidates.flatMap((b) => accepted.includes(b) ? [b] : b.type === "table" && b.table ? rowParagraphs(b).filter((p) => /[\p{L}\p{N}]{2}/u.test(_nullishCoalesce(p.text, () => ( "")))) : []);
|
|
@@ -10329,14 +10359,14 @@ function mergeOcrImageRegions(blocks, page, regions, ocrBlocks) {
|
|
|
10329
10359
|
for (const block of selected) {
|
|
10330
10360
|
if (seen2.has(block)) continue;
|
|
10331
10361
|
const frame = FRAME_READING_UNITS.get(block);
|
|
10332
|
-
const source = _optionalChain([frame, 'optionalAccess',
|
|
10362
|
+
const source = _optionalChain([frame, 'optionalAccess', _429 => _429.blocks, 'access', _430 => _430.every, 'call', _431 => _431((member) => selectedSet.has(member))]) ? frame.blocks : [block];
|
|
10333
10363
|
source.forEach((member) => seen2.add(member));
|
|
10334
10364
|
const available = source.filter((member) => !hasOriginal(member));
|
|
10335
10365
|
const units = frame && available.length === source.length && source === frame.blocks ? [{ blocks: available, bbox: frame.bbox, atomic: true }] : available.map((member) => ({ blocks: [member], bbox: member.bbox, atomic: false }));
|
|
10336
10366
|
for (const unit of units) {
|
|
10337
10367
|
const b = unit.bbox;
|
|
10338
10368
|
const index = blocks.findIndex((existing) => {
|
|
10339
|
-
const e = _nullishCoalesce(_optionalChain([FRAME_READING_UNITS, 'access',
|
|
10369
|
+
const e = _nullishCoalesce(_optionalChain([FRAME_READING_UNITS, 'access', _432 => _432.get, 'call', _433 => _433(existing), 'optionalAccess', _434 => _434.bbox]), () => ( existing.bbox));
|
|
10340
10370
|
if (existing.pageNumber !== page || !e) return false;
|
|
10341
10371
|
const beside = e.y < region.y2 && e.y + e.height > region.y1 && e.x >= region.x2 - 1;
|
|
10342
10372
|
if (placedHere.has(existing) && Math.abs(e.y + e.height / 2 - b.y - b.height / 2) <= Math.min(e.height, b.height) * 0.25) return e.x > b.x;
|
|
@@ -10354,16 +10384,16 @@ function mergeOcrImageRegions(blocks, page, regions, ocrBlocks) {
|
|
|
10354
10384
|
}
|
|
10355
10385
|
function axisTick(block, candidates) {
|
|
10356
10386
|
const b = block.bbox;
|
|
10357
|
-
if (!/^\d$/u.test(_nullishCoalesce(_optionalChain([block, 'access',
|
|
10358
|
-
const numeric = candidates.filter((o) => o !== block && o.type === "paragraph" && o.bbox && /^[\d\s.,%+−-]+$/u.test(_nullishCoalesce(_optionalChain([o, 'access',
|
|
10387
|
+
if (!/^\d$/u.test(_nullishCoalesce(_optionalChain([block, 'access', _435 => _435.text, 'optionalAccess', _436 => _436.trim, 'call', _437 => _437()]), () => ( "")))) return false;
|
|
10388
|
+
const numeric = candidates.filter((o) => o !== block && o.type === "paragraph" && o.bbox && /^[\d\s.,%+−-]+$/u.test(_nullishCoalesce(_optionalChain([o, 'access', _438 => _438.text, 'optionalAccess', _439 => _439.trim, 'call', _440 => _440()]), () => ( ""))) && /\d/u.test(_nullishCoalesce(o.text, () => ( ""))) && Math.max(o.bbox.height, b.height) <= Math.min(o.bbox.height, b.height) * 2);
|
|
10359
10389
|
const cy = b.y + b.height / 2, right = b.x + b.width;
|
|
10360
10390
|
const row = numeric.filter((o) => Math.abs(o.bbox.y + o.bbox.height / 2 - cy) <= Math.min(o.bbox.height, b.height) * 0.35);
|
|
10361
10391
|
const column = numeric.filter((o) => Math.abs(o.bbox.x + o.bbox.width - right) <= Math.max(o.bbox.height, b.height) * 0.5);
|
|
10362
10392
|
return row.length >= 2 || column.length >= 2;
|
|
10363
10393
|
}
|
|
10364
10394
|
function supportedDiagramLabel(block, labels, region) {
|
|
10365
|
-
const b = block.bbox, text = _nullishCoalesce(_optionalChain([block, 'access',
|
|
10366
|
-
if (!b || !/^[\p{L}\p{N}]$/u.test(text) || b.height < 4 || b.width < 1 || b.width > b.height * 2 || b.x < region.x1 || b.y < region.y1 || b.x + b.width > region.x2 || b.y + b.height > region.y2 || b.width * b.height > (region.x2 - region.x1) * (region.y2 - region.y1) * 5e-3 || labels.length < 3 || !labels.some((l) => /\p{L}{3}/u.test(_nullishCoalesce(l.text, () => ( "")))) || labels.filter((l) => !/\p{L}/u.test(_nullishCoalesce(l.text, () => ( ""))) && (_nullishCoalesce(_optionalChain([l, 'access',
|
|
10395
|
+
const b = block.bbox, text = _nullishCoalesce(_optionalChain([block, 'access', _441 => _441.text, 'optionalAccess', _442 => _442.trim, 'call', _443 => _443()]), () => ( ""));
|
|
10396
|
+
if (!b || !/^[\p{L}\p{N}]$/u.test(text) || b.height < 4 || b.width < 1 || b.width > b.height * 2 || b.x < region.x1 || b.y < region.y1 || b.x + b.width > region.x2 || b.y + b.height > region.y2 || b.width * b.height > (region.x2 - region.x1) * (region.y2 - region.y1) * 5e-3 || labels.length < 3 || !labels.some((l) => /\p{L}{3}/u.test(_nullishCoalesce(l.text, () => ( "")))) || labels.filter((l) => !/\p{L}/u.test(_nullishCoalesce(l.text, () => ( ""))) && (_nullishCoalesce(_optionalChain([l, 'access', _444 => _444.text, 'optionalAccess', _445 => _445.match, 'call', _446 => _446(/\p{N}/gu), 'optionalAccess', _447 => _447.length]), () => ( 0))) >= 2).length < 2) return false;
|
|
10367
10397
|
let above = false, below = false;
|
|
10368
10398
|
for (const label of labels) {
|
|
10369
10399
|
const a = label.bbox, em = Math.max(b.height, a.height);
|
|
@@ -10378,7 +10408,7 @@ function rotatedAxisFragments(candidates) {
|
|
|
10378
10408
|
const paragraphs = candidates.filter((b) => b.type === "paragraph" && b.bbox.height <= 24);
|
|
10379
10409
|
const axes = [];
|
|
10380
10410
|
for (const block of paragraphs) {
|
|
10381
|
-
const b = block.bbox, text = _nullishCoalesce(_optionalChain([block, 'access',
|
|
10411
|
+
const b = block.bbox, text = _nullishCoalesce(_optionalChain([block, 'access', _448 => _448.text, 'optionalAccess', _449 => _449.trim, 'call', _450 => _450()]), () => ( ""));
|
|
10382
10412
|
if (!/^[\d\s.,%+−-]+$/u.test(text) || !/\d/u.test(text) || b.width > b.height * 6) continue;
|
|
10383
10413
|
const axis = axes.find((a) => Math.abs(a[0].bbox.x + a[0].bbox.width - b.x - b.width) <= Math.max(a[0].bbox.height, b.height) * 0.5);
|
|
10384
10414
|
if (axis) axis.push(block);
|
|
@@ -10395,8 +10425,8 @@ function rotatedAxisFragments(candidates) {
|
|
|
10395
10425
|
const em = Math.max(...axis.map((a) => a.bbox.height)), right = axis[0].bbox.x + axis[0].bbox.width;
|
|
10396
10426
|
if (top - bottom < em * 6) continue;
|
|
10397
10427
|
const left = paragraphs.filter((block) => {
|
|
10398
|
-
const b = block.bbox, text = _nullishCoalesce(_optionalChain([block, 'access',
|
|
10399
|
-
return /\p{Script=Latin}/u.test(text) && (_nullishCoalesce(_optionalChain([text, 'access',
|
|
10428
|
+
const b = block.bbox, text = _nullishCoalesce(_optionalChain([block, 'access', _451 => _451.text, 'optionalAccess', _452 => _452.trim, 'call', _453 => _453()]), () => ( ""));
|
|
10429
|
+
return /\p{Script=Latin}/u.test(text) && (_nullishCoalesce(_optionalChain([text, 'access', _454 => _454.match, 'call', _455 => _455(/[\p{L}\p{N}]/gu), 'optionalAccess', _456 => _456.length]), () => ( 0))) <= 3 && b.width <= b.height * 3 && b.x + b.width >= right - em * 6 && b.x + b.width <= right - Math.max(em, b.height) && b.y >= bottom && b.y + b.height <= top;
|
|
10400
10430
|
});
|
|
10401
10431
|
const stack = left.filter((a) => left.some((b) => {
|
|
10402
10432
|
if (a === b || !aligned(a, b)) return false;
|
|
@@ -10406,7 +10436,7 @@ function rotatedAxisFragments(candidates) {
|
|
|
10406
10436
|
if (stack.length < 2) continue;
|
|
10407
10437
|
for (const block of paragraphs) {
|
|
10408
10438
|
const b = block.bbox;
|
|
10409
|
-
if (b.y >= bottom && b.y + b.height <= top && b.x + b.width >= right - em * 6 && b.x + b.width <= right - Math.max(em, b.height) && /^[\p{L}\p{N}]$/u.test(_nullishCoalesce(_optionalChain([block, 'access',
|
|
10439
|
+
if (b.y >= bottom && b.y + b.height <= top && b.x + b.width >= right - em * 6 && b.x + b.width <= right - Math.max(em, b.height) && /^[\p{L}\p{N}]$/u.test(_nullishCoalesce(_optionalChain([block, 'access', _457 => _457.text, 'optionalAccess', _458 => _458.trim, 'call', _459 => _459()]), () => ( ""))) && stack.some((s) => aligned(s, block))) fragments.add(block);
|
|
10410
10440
|
}
|
|
10411
10441
|
}
|
|
10412
10442
|
return fragments;
|
|
@@ -10510,4 +10540,4 @@ function rowParagraphs(block) {
|
|
|
10510
10540
|
|
|
10511
10541
|
|
|
10512
10542
|
exports.DEFAULT_OCR_MODELS = DEFAULT_OCR_MODELS; exports.resolveOcrModels = resolveOcrModels; exports.ocrSelectionKey = ocrSelectionKey; exports.ocrSourcePath = ocrSourcePath; exports.ensureOcrModelsFor = ensureOcrModelsFor; exports.ocrModelsCached = ocrModelsCached; exports.parseCharacterDict = parseCharacterDict; exports.grayCrop = grayCrop; exports.inkStats = inkStats; exports.splitRowBands = splitRowBands; exports.leadingTriangle = leadingTriangle; exports.arrowGlyph = arrowGlyph; exports.leaderRuns = leaderRuns; exports.inkBounds = inkBounds; exports.bracketFeatures = bracketFeatures; exports.slantedPair = slantedPair; exports.romanStems = romanStems; exports.circledAt = circledAt; exports.quoteHead = quoteHead; exports.edgeTrim = edgeTrim; exports.tallInkCount = tallInkCount; exports.gapGlyphs = gapGlyphs; exports.ringBullet = ringBullet; exports.dashRatio = dashRatio; exports.leadingRing = leadingRing; exports.discAt = discAt; exports.serifOne = serifOne; exports.starRun = starRun; exports.bracketShape = bracketShape; exports.leadingBullet = leadingBullet; exports.rememberOcrTextGaps = rememberOcrTextGaps; exports.copyOcrTextGaps = copyOcrTextGaps; exports.findOcrTextGaps = findOcrTextGaps; exports.extractLines = extractLines; exports.extractImageRegions = extractImageRegions; exports.NO_EDGES = NO_EDGES; exports.hasOpenCellSeam = hasOpenCellSeam; exports.joinCellEdges = joinCellEdges; exports.filterHiddenText = filterHiddenText; exports.collapseEvenSpacing = collapseEvenSpacing; exports.computeBBox = computeBBox; exports.dominantStyle = dominantStyle; exports.normalizeItems = normalizeItems; exports.groupByY = groupByY; exports.mergeLineSimple = mergeLineSimple; exports.WrapLexicon = WrapLexicon; exports.startsNewItem = startsNewItem; exports.wrapJoiner = wrapJoiner; exports.joinPageBreakWraps = joinPageBreakWraps; exports.splitPageBreakWraps = splitPageBreakWraps; exports.latinSoftWrap = latinSoftWrap; exports.TOC_BLOCKS = TOC_BLOCKS; exports.computeMedianFontSizeFromFreq = computeMedianFontSizeFromFreq; exports.detectHeadings = detectHeadings; exports.mergeStackedHeadingLines = mergeStackedHeadingLines; exports.detectTypographyHeadings = detectTypographyHeadings; exports.detectDocumentStyleHeadings = detectDocumentStyleHeadings; exports.detectSiblingStyleHeadings = detectSiblingStyleHeadings; exports.detectRepeatedPageLabels = detectRepeatedPageLabels; exports.detectPageLeadHeadings = detectPageLeadHeadings; exports.refineDocumentStyleHeadings = refineDocumentStyleHeadings; exports.detectMarkerHeadings = detectMarkerHeadings; exports.detectTableCaptions = detectTableCaptions; exports.detectKoreanListBlocks = detectKoreanListBlocks; exports.removeHeaderFooterBlocks = removeHeaderFooterBlocks; exports.runningLinePatterns = runningLinePatterns; exports.stripAbsorbedRunningLines = stripAbsorbedRunningLines; exports.CLIP_TABLES = CLIP_TABLES; exports.FRAME_TITLE_BLOCKS = FRAME_TITLE_BLOCKS; exports.TABLE_COLXS = TABLE_COLXS; exports.TABLE_ROWYS = TABLE_ROWYS; exports.TABLE_TAIL = TABLE_TAIL; exports.PART_COLXS = PART_COLXS; exports.EMPTY_PARTS = EMPTY_PARTS; exports.IMAGE_CELLS = IMAGE_CELLS; exports.FILLER_CELLS = FILLER_CELLS; exports.CONT_PARTS = CONT_PARTS; exports.CELL_LINES = CELL_LINES; exports.ROW_RULES = ROW_RULES; exports.trimTrailingEmptyTableCols = trimTrailingEmptyTableCols; exports.restoreImageBullets = restoreImageBullets; exports.detectRightArrowRegions = detectRightArrowRegions; exports.removeSideTabs = removeSideTabs; exports.extractPageBlocksWithLines = extractPageBlocksWithLines; exports.UNRULED_REGION_TABLES = UNRULED_REGION_TABLES; exports.mergeOcrImageRegions = mergeOcrImageRegions;
|
|
10513
|
-
//# sourceMappingURL=chunk-
|
|
10543
|
+
//# sourceMappingURL=chunk-I3SP3API.cjs.map
|