kordoc 4.21.20 → 4.21.21
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 +6 -5
- package/dist/{-QHQ2QKM7.js → -ZYF6HX4M.js} +11 -11
- package/dist/{chunk-FU3SCGE7.js → chunk-2ZGP7A5T.js} +2 -2
- package/dist/{chunk-TYYKK5DX.js → chunk-3TCF5HPP.js} +2 -2
- package/dist/{chunk-WWMHVDRG.cjs → chunk-57VNFMMS.cjs} +3 -3
- package/dist/{chunk-WWMHVDRG.cjs.map → chunk-57VNFMMS.cjs.map} +1 -1
- package/dist/{chunk-75INFYVC.js → chunk-5HTFWUJE.js} +2 -2
- package/dist/{chunk-G6G25HUO.js → chunk-7YAJCXCD.js} +2 -2
- package/dist/{chunk-DBFAQJCX.js → chunk-BC54LBST.js} +3 -3
- package/dist/{chunk-PALYDA3M.js → chunk-BG6LUCQL.js} +2 -2
- package/dist/{chunk-42XYVZ2B.js → chunk-CY4QM2KQ.js} +2 -2
- package/dist/{chunk-2FALZL3E.cjs → chunk-DTZIZ5PP.cjs} +13 -13
- package/dist/{chunk-2FALZL3E.cjs.map → chunk-DTZIZ5PP.cjs.map} +1 -1
- package/dist/{chunk-AINZICPE.js → chunk-FBJVDBMO.js} +2 -2
- package/dist/{chunk-7ITWGPNB.js → chunk-FZMGF6XU.js} +2 -2
- package/dist/{chunk-CKEO54YN.cjs → chunk-H2MS4VG3.cjs} +3 -3
- package/dist/{chunk-CKEO54YN.cjs.map → chunk-H2MS4VG3.cjs.map} +1 -1
- package/dist/{chunk-KBL24ZCP.js → chunk-HWIW3WK2.js} +3 -3
- package/dist/{chunk-E5L6DUOE.js → chunk-J5PBI3ZC.js} +3 -3
- package/dist/{chunk-LY4ITNAL.js → chunk-KBV4WFZ6.js} +80 -5
- package/dist/chunk-KBV4WFZ6.js.map +1 -0
- package/dist/{chunk-JDVOYDIA.js → chunk-KTLHADU4.js} +2 -2
- package/dist/{chunk-M37GOXT5.cjs → chunk-MCUX2Y2C.cjs} +2 -2
- package/dist/{chunk-M37GOXT5.cjs.map → chunk-MCUX2Y2C.cjs.map} +1 -1
- package/dist/{chunk-ZMGWKGSC.js → chunk-PTF4NCFM.js} +2 -2
- package/dist/{chunk-N47I6OS7.js → chunk-QHNVH4TC.js} +6 -6
- package/dist/{chunk-LO5A36FU.js → chunk-RBRHO7WL.js} +2 -2
- package/dist/{chunk-6HIDMA5O.js → chunk-T3DTTK23.js} +2 -2
- package/dist/{chunk-KS2SASZH.cjs → chunk-T7PN5D4D.cjs} +6 -6
- package/dist/{chunk-KS2SASZH.cjs.map → chunk-T7PN5D4D.cjs.map} +1 -1
- package/dist/{chunk-MOT7WOP5.cjs → chunk-TMUUDMDH.cjs} +100 -25
- package/dist/chunk-TMUUDMDH.cjs.map +1 -0
- package/dist/{chunk-I4HF4UCA.js → chunk-TRO4CQHJ.js} +4 -4
- package/dist/{chunk-WINHSKFD.js → chunk-WGMYVRSA.js} +2 -2
- package/dist/{chunk-LQSF4JSV.js → chunk-YHPJTLCA.js} +2 -2
- package/dist/{chunk-BLKAJD2G.js → chunk-YM3K3LCD.js} +10 -10
- package/dist/{chunk-F5KWC7I3.js → chunk-YQZOPT3A.js} +81 -6
- package/dist/chunk-YQZOPT3A.js.map +1 -0
- package/dist/{chunk-F5PISJEI.js → chunk-ZZIQWSGC.js} +2 -2
- package/dist/chunks-MDMJRCJ7.js +10 -0
- package/dist/cli.js +30 -30
- package/dist/{formula-XAPMN6HX.js → formula-6XNIXZ5L.js} +3 -3
- package/dist/{formula-G5LTBMGC.cjs → formula-A3I5VAP7.cjs} +9 -9
- package/dist/{formula-G5LTBMGC.cjs.map → formula-A3I5VAP7.cjs.map} +1 -1
- package/dist/{formula-KHPAZKOK.js → formula-P7M7IH2L.js} +4 -4
- package/dist/{image-ocr-RNPHQ4C2.js → image-ocr-3C6W3KZO.js} +6 -6
- package/dist/{image-ocr-N5LAIHRV.js → image-ocr-ITNY454I.js} +9 -9
- package/dist/{image-ocr-MHPVAYOB.cjs → image-ocr-UJRSQ2T3.cjs} +15 -15
- package/dist/{image-ocr-MHPVAYOB.cjs.map → image-ocr-UJRSQ2T3.cjs.map} +1 -1
- package/dist/index.cjs +276 -276
- package/dist/index.js +5 -5
- package/dist/mcp.js +22 -22
- package/dist/{model-bundle-XP4AHFLT.js → model-bundle-LAWQH75O.js} +5 -5
- package/dist/{models-AD2KAUNC.js → models-6QTD2CFM.js} +5 -5
- package/dist/{parse-worker-v2-7UHOQ2TK.js → parse-worker-v2-FEPJG3ER.js} +12 -12
- package/dist/{parser-5WGRQKPI.js → parser-56I364YM.js} +16 -8
- package/dist/{parser-2RN5WNPJ.js.map → parser-56I364YM.js.map} +1 -1
- package/dist/{parser-2RN5WNPJ.js → parser-KFCY3NIN.js} +19 -11
- package/dist/{parser-5WGRQKPI.js.map → parser-KFCY3NIN.js.map} +1 -1
- package/dist/{parser-ZPCCXCVO.cjs → parser-VKWUMUML.cjs} +142 -134
- package/dist/parser-VKWUMUML.cjs.map +1 -0
- package/dist/pdf-ocr-MME37BL4.js +18 -0
- package/dist/pdf-ocr-OKAHNEJA.cjs +19 -0
- package/dist/{pdf-ocr-SFIWMJQL.cjs.map → pdf-ocr-OKAHNEJA.cjs.map} +1 -1
- package/dist/pdf-ocr-ZZ6AJL6Z.js +22 -0
- package/dist/{profile-io-UP7H2J6I.js → profile-io-OCITHUQF.js} +3 -3
- package/dist/{rasterize-XBCDG4MD.js → rasterize-SFCG4YOI.js} +3 -3
- package/dist/{redact-doc-CJ6W6YNR.js → redact-doc-5SMPXIGG.js} +11 -11
- package/dist/{render-K5UDHXRI.js → render-FGPG5A2N.js} +7 -7
- package/dist/seal-GA7NZDTG.js +10 -0
- package/dist/{setup-S66RLBBM.js → setup-JQVYZO7I.js} +3 -3
- package/dist/visual-YMG644YW.js +20 -0
- package/dist/{watch-PB7IOD73.js → watch-C77BUSP7.js} +12 -12
- package/package.json +1 -1
- package/dist/chunk-F5KWC7I3.js.map +0 -1
- package/dist/chunk-LY4ITNAL.js.map +0 -1
- package/dist/chunk-MOT7WOP5.cjs.map +0 -1
- package/dist/chunks-BJRBKGKZ.js +0 -10
- package/dist/parser-ZPCCXCVO.cjs.map +0 -1
- package/dist/pdf-ocr-KHY3P4EP.js +0 -18
- package/dist/pdf-ocr-LFDH6DFD.js +0 -22
- package/dist/pdf-ocr-SFIWMJQL.cjs +0 -19
- package/dist/seal-YCK6TM5I.js +0 -10
- package/dist/visual-S5ZNFWFH.js +0 -20
- /package/dist/{-QHQ2QKM7.js.map → -ZYF6HX4M.js.map} +0 -0
- /package/dist/{chunk-FU3SCGE7.js.map → chunk-2ZGP7A5T.js.map} +0 -0
- /package/dist/{chunk-TYYKK5DX.js.map → chunk-3TCF5HPP.js.map} +0 -0
- /package/dist/{chunk-75INFYVC.js.map → chunk-5HTFWUJE.js.map} +0 -0
- /package/dist/{chunk-G6G25HUO.js.map → chunk-7YAJCXCD.js.map} +0 -0
- /package/dist/{chunk-DBFAQJCX.js.map → chunk-BC54LBST.js.map} +0 -0
- /package/dist/{chunk-PALYDA3M.js.map → chunk-BG6LUCQL.js.map} +0 -0
- /package/dist/{chunk-42XYVZ2B.js.map → chunk-CY4QM2KQ.js.map} +0 -0
- /package/dist/{chunk-AINZICPE.js.map → chunk-FBJVDBMO.js.map} +0 -0
- /package/dist/{chunk-7ITWGPNB.js.map → chunk-FZMGF6XU.js.map} +0 -0
- /package/dist/{chunk-KBL24ZCP.js.map → chunk-HWIW3WK2.js.map} +0 -0
- /package/dist/{chunk-E5L6DUOE.js.map → chunk-J5PBI3ZC.js.map} +0 -0
- /package/dist/{chunk-JDVOYDIA.js.map → chunk-KTLHADU4.js.map} +0 -0
- /package/dist/{chunk-ZMGWKGSC.js.map → chunk-PTF4NCFM.js.map} +0 -0
- /package/dist/{chunk-N47I6OS7.js.map → chunk-QHNVH4TC.js.map} +0 -0
- /package/dist/{chunk-LO5A36FU.js.map → chunk-RBRHO7WL.js.map} +0 -0
- /package/dist/{chunk-6HIDMA5O.js.map → chunk-T3DTTK23.js.map} +0 -0
- /package/dist/{chunk-I4HF4UCA.js.map → chunk-TRO4CQHJ.js.map} +0 -0
- /package/dist/{chunk-WINHSKFD.js.map → chunk-WGMYVRSA.js.map} +0 -0
- /package/dist/{chunk-LQSF4JSV.js.map → chunk-YHPJTLCA.js.map} +0 -0
- /package/dist/{chunk-BLKAJD2G.js.map → chunk-YM3K3LCD.js.map} +0 -0
- /package/dist/{chunk-F5PISJEI.js.map → chunk-ZZIQWSGC.js.map} +0 -0
- /package/dist/{chunks-BJRBKGKZ.js.map → chunks-MDMJRCJ7.js.map} +0 -0
- /package/dist/{formula-XAPMN6HX.js.map → formula-6XNIXZ5L.js.map} +0 -0
- /package/dist/{formula-KHPAZKOK.js.map → formula-P7M7IH2L.js.map} +0 -0
- /package/dist/{image-ocr-RNPHQ4C2.js.map → image-ocr-3C6W3KZO.js.map} +0 -0
- /package/dist/{image-ocr-N5LAIHRV.js.map → image-ocr-ITNY454I.js.map} +0 -0
- /package/dist/{model-bundle-XP4AHFLT.js.map → model-bundle-LAWQH75O.js.map} +0 -0
- /package/dist/{models-AD2KAUNC.js.map → models-6QTD2CFM.js.map} +0 -0
- /package/dist/{parse-worker-v2-7UHOQ2TK.js.map → parse-worker-v2-FEPJG3ER.js.map} +0 -0
- /package/dist/{pdf-ocr-KHY3P4EP.js.map → pdf-ocr-MME37BL4.js.map} +0 -0
- /package/dist/{pdf-ocr-LFDH6DFD.js.map → pdf-ocr-ZZ6AJL6Z.js.map} +0 -0
- /package/dist/{profile-io-UP7H2J6I.js.map → profile-io-OCITHUQF.js.map} +0 -0
- /package/dist/{rasterize-XBCDG4MD.js.map → rasterize-SFCG4YOI.js.map} +0 -0
- /package/dist/{redact-doc-CJ6W6YNR.js.map → redact-doc-5SMPXIGG.js.map} +0 -0
- /package/dist/{render-K5UDHXRI.js.map → render-FGPG5A2N.js.map} +0 -0
- /package/dist/{seal-YCK6TM5I.js.map → seal-GA7NZDTG.js.map} +0 -0
- /package/dist/{setup-S66RLBBM.js.map → setup-JQVYZO7I.js.map} +0 -0
- /package/dist/{visual-S5ZNFWFH.js.map → visual-YMG644YW.js.map} +0 -0
- /package/dist/{watch-PB7IOD73.js.map → watch-C77BUSP7.js.map} +0 -0
|
@@ -4,15 +4,15 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunkT7PN5D4Dcjs = require('./chunk-T7PN5D4D.cjs');
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
var
|
|
11
|
+
var _chunkH2MS4VG3cjs = require('./chunk-H2MS4VG3.cjs');
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
var
|
|
15
|
+
var _chunkMCUX2Y2Ccjs = require('./chunk-MCUX2Y2C.cjs');
|
|
16
16
|
|
|
17
17
|
// src/ocr/models.ts
|
|
18
18
|
var _path = require('path');
|
|
@@ -40,10 +40,10 @@ var OCR_REC_DICT = {
|
|
|
40
40
|
};
|
|
41
41
|
var ALL_OCR_MODELS = [OCR_DET_MODEL, OCR_REC_MODEL, OCR_REC_DICT];
|
|
42
42
|
function getOcrModelsDir() {
|
|
43
|
-
return
|
|
43
|
+
return _chunkH2MS4VG3cjs.getModelsDir.call(void 0, "ppocr");
|
|
44
44
|
}
|
|
45
45
|
async function ensureOcrModels(onProgress) {
|
|
46
|
-
return
|
|
46
|
+
return _chunkH2MS4VG3cjs.ensureModelsIn.call(void 0, getOcrModelsDir(), ALL_OCR_MODELS, onProgress);
|
|
47
47
|
}
|
|
48
48
|
async function ocrModelsCached() {
|
|
49
49
|
const dir = getOcrModelsDir();
|
|
@@ -2135,7 +2135,7 @@ function tagScripts(text, lines) {
|
|
|
2135
2135
|
const [s, e, kind] = marks[m];
|
|
2136
2136
|
out = out.slice(0, s) + `<${kind}>` + out.slice(s, e) + `</${kind}>` + out.slice(e);
|
|
2137
2137
|
}
|
|
2138
|
-
return
|
|
2138
|
+
return _chunkT7PN5D4Dcjs.tidyScriptTags.call(void 0, out);
|
|
2139
2139
|
}
|
|
2140
2140
|
|
|
2141
2141
|
// src/pdf/line-wrap.ts
|
|
@@ -5190,9 +5190,9 @@ function detectHeadings(blocks, medianFontSize) {
|
|
|
5190
5190
|
if (/^\d+$/.test(text) && !isChapterNumber(block, blocks[bi + 1], medianFontSize)) continue;
|
|
5191
5191
|
const ratio = block.style.fontSize / medianFontSize;
|
|
5192
5192
|
let level = 0;
|
|
5193
|
-
if (ratio >=
|
|
5194
|
-
else if (ratio >=
|
|
5195
|
-
else if (ratio >=
|
|
5193
|
+
if (ratio >= _chunkT7PN5D4Dcjs.HEADING_RATIO_H1) level = 1;
|
|
5194
|
+
else if (ratio >= _chunkT7PN5D4Dcjs.HEADING_RATIO_H2) level = 2;
|
|
5195
|
+
else if (ratio >= _chunkT7PN5D4Dcjs.HEADING_RATIO_H3) level = 3;
|
|
5196
5196
|
if (level > 0) {
|
|
5197
5197
|
block.type = "heading";
|
|
5198
5198
|
block.level = level;
|
|
@@ -5205,7 +5205,7 @@ function isChapterNumber(block, next, medianFontSize) {
|
|
|
5205
5205
|
const nextSize = _nullishCoalesce(_optionalChain([next, 'optionalAccess', _145 => _145.style, 'optionalAccess', _146 => _146.fontSize]), () => ( 0));
|
|
5206
5206
|
const text = _nullishCoalesce(_optionalChain([next, 'optionalAccess', _147 => _147.text, 'optionalAccess', _148 => _148.trim, 'call', _149 => _149()]), () => ( ""));
|
|
5207
5207
|
const a = block.bbox, b = _optionalChain([next, 'optionalAccess', _150 => _150.bbox]);
|
|
5208
|
-
return /^\d{1,2}$/.test(_nullishCoalesce(_optionalChain([block, 'access', _151 => _151.text, 'optionalAccess', _152 => _152.trim, 'call', _153 => _153()]), () => ( ""))) && size >= medianFontSize * 2.5 && !!next && (next.type === "paragraph" || next.type === "heading") && next.pageNumber === block.pageNumber && nextSize >= medianFontSize *
|
|
5208
|
+
return /^\d{1,2}$/.test(_nullishCoalesce(_optionalChain([block, 'access', _151 => _151.text, 'optionalAccess', _152 => _152.trim, 'call', _153 => _153()]), () => ( ""))) && size >= medianFontSize * 2.5 && !!next && (next.type === "paragraph" || next.type === "heading") && next.pageNumber === block.pageNumber && nextSize >= medianFontSize * _chunkT7PN5D4Dcjs.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;
|
|
5209
5209
|
}
|
|
5210
5210
|
function mergeStackedHeadingLines(blocks, medianFontSize) {
|
|
5211
5211
|
for (let i = 0; i < blocks.length - 1; ) {
|
|
@@ -5744,6 +5744,20 @@ function detectSpecialKoreanTables(blocks) {
|
|
|
5744
5744
|
flushKvTable();
|
|
5745
5745
|
return result;
|
|
5746
5746
|
}
|
|
5747
|
+
function tracksPages(occ) {
|
|
5748
|
+
const nums = occ.map((o) => [...o.text.matchAll(/\d+/g)].map((m) => +m[0]));
|
|
5749
|
+
if (!nums.length || nums.some((n) => n.length !== nums[0].length)) return false;
|
|
5750
|
+
return nums[0].some((_, j) => new Set(occ.map((o, k) => o.page - nums[k][j])).size === 1);
|
|
5751
|
+
}
|
|
5752
|
+
function looseVaryingNumber(occ) {
|
|
5753
|
+
const nums = occ.map((o) => [...o.text.matchAll(/\d+/g)]);
|
|
5754
|
+
if (!nums.length || nums.some((n) => n.length !== nums[0].length)) return false;
|
|
5755
|
+
const loose = (text, m) => !/\p{L}/u.test(_nullishCoalesce(text[m.index - 1], () => ( " "))) && !/\p{L}/u.test(_nullishCoalesce(text[m.index + m[0].length], () => ( " ")));
|
|
5756
|
+
for (let j = 0; j < nums[0].length; j++) {
|
|
5757
|
+
if (new Set(nums.map((n) => n[j][0])).size > 1 && occ.every((o, k) => loose(o.text, nums[k][j]))) return true;
|
|
5758
|
+
}
|
|
5759
|
+
return false;
|
|
5760
|
+
}
|
|
5747
5761
|
function removeHeaderFooterBlocks(blocks, pageHeights, warnings, notes, tables = false, context = []) {
|
|
5748
5762
|
if (context.length && !tables) {
|
|
5749
5763
|
const removed = removeHeaderFooterBlocks([...blocks, ...context], pageHeights, [], notes).filter((index) => index < blocks.length);
|
|
@@ -5773,6 +5787,7 @@ function removeHeaderFooterBlocks(blocks, pageHeights, warnings, notes, tables =
|
|
|
5773
5787
|
const patternCount = /* @__PURE__ */ new Map();
|
|
5774
5788
|
const patternPages = /* @__PURE__ */ new Map();
|
|
5775
5789
|
const patternNumbers = /* @__PURE__ */ new Map();
|
|
5790
|
+
const patternOcc = /* @__PURE__ */ new Map();
|
|
5776
5791
|
for (const e of entries) {
|
|
5777
5792
|
const norm = e.text.replace(/\d+/g, "#");
|
|
5778
5793
|
patternCount.set(norm, (patternCount.get(norm) || 0) + 1);
|
|
@@ -5782,13 +5797,18 @@ function removeHeaderFooterBlocks(blocks, pageHeights, warnings, notes, tables =
|
|
|
5782
5797
|
const pages = patternPages.get(norm) || /* @__PURE__ */ new Set();
|
|
5783
5798
|
pages.add(e.page);
|
|
5784
5799
|
patternPages.set(norm, pages);
|
|
5800
|
+
patternOcc.set(norm, [..._nullishCoalesce(patternOcc.get(norm), () => ( [])), e]);
|
|
5785
5801
|
}
|
|
5786
5802
|
const repeatedPatterns = /* @__PURE__ */ new Set();
|
|
5787
5803
|
for (const [p, count] of patternCount) {
|
|
5788
5804
|
const pages = [..._nullishCoalesce(patternPages.get(p), () => ( []))];
|
|
5789
5805
|
const span2 = pages.length ? Math.max(...pages) - Math.min(...pages) + 1 : 0;
|
|
5790
|
-
const
|
|
5791
|
-
|
|
5806
|
+
const varying = !tables && (_nullishCoalesce(_optionalChain([patternNumbers, 'access', _275 => _275.get, 'call', _276 => _276(p), 'optionalAccess', _277 => _277.size]), () => ( 0))) > 1;
|
|
5807
|
+
const occ = _nullishCoalesce(patternOcc.get(p), () => ( []));
|
|
5808
|
+
const dense = pages.length >= span2 * 0.4;
|
|
5809
|
+
const loose = looseVaryingNumber(occ) && (entries === bottomEntries || dense || tracksPages(occ));
|
|
5810
|
+
const pageNumbered = varying && (loose || dense && new Set(occ.map((o) => o.text)).size * 2 <= occ.length);
|
|
5811
|
+
if (count >= MIN_REPEAT2 && pages.length >= MIN_REPEAT2 && (varying ? pageNumbered : dense)) {
|
|
5792
5812
|
repeatedPatterns.add(p);
|
|
5793
5813
|
}
|
|
5794
5814
|
}
|
|
@@ -5826,6 +5846,59 @@ function removeHeaderFooterBlocks(blocks, pageHeights, warnings, notes, tables =
|
|
|
5826
5846
|
}
|
|
5827
5847
|
return [...removeSet].sort((a, b) => a - b);
|
|
5828
5848
|
}
|
|
5849
|
+
function runningLinePatterns(removed, pageHeights) {
|
|
5850
|
+
const occ = /* @__PURE__ */ new Map();
|
|
5851
|
+
for (const b of removed) {
|
|
5852
|
+
const ph = b.bbox && b.pageNumber ? pageHeights.get(b.bbox.page) || pageHeights.get(b.pageNumber) : void 0;
|
|
5853
|
+
const key = b.text ? runningKey(b.text) : "";
|
|
5854
|
+
if (!ph || !b.bbox || !b.pageNumber || !/\p{L}/u.test(key) || ph - b.bbox.y <= ph * 0.5) continue;
|
|
5855
|
+
(_nullishCoalesce(occ.get(key), () => ( occ.set(key, []).get(key)))).push({ page: b.pageNumber, nums: (_nullishCoalesce(b.text.match(/\d+/g), () => ( []))).join(",") });
|
|
5856
|
+
}
|
|
5857
|
+
const out = /* @__PURE__ */ new Map();
|
|
5858
|
+
for (const [key, list] of occ) {
|
|
5859
|
+
if (!pageNumberAtEnd(key)) continue;
|
|
5860
|
+
const offsets = new Set(list.map((o) => o.page - +o.nums));
|
|
5861
|
+
if (offsets.size === 1) out.set(key, [...offsets][0]);
|
|
5862
|
+
}
|
|
5863
|
+
return out;
|
|
5864
|
+
}
|
|
5865
|
+
var runningKey = (s) => s.replace(/\d+/g, "#").replace(/\s+/g, " ").trim();
|
|
5866
|
+
var pageNumberAtEnd = (key) => (_nullishCoalesce(key.match(/#/g), () => ( []))).length === 1 && /#\s*[)\]]?$/.test(key);
|
|
5867
|
+
function stripAbsorbedRunningLines(blocks, pageHeights, running) {
|
|
5868
|
+
if (!running.size) return blocks;
|
|
5869
|
+
const matches = (line, page) => {
|
|
5870
|
+
const offset = running.get(runningKey(line));
|
|
5871
|
+
return offset !== void 0 && page - +(_nullishCoalesce(line.match(/\d+/g), () => ( []))).pop() === offset;
|
|
5872
|
+
};
|
|
5873
|
+
const out = [];
|
|
5874
|
+
for (const b of blocks) {
|
|
5875
|
+
const ph = b.bbox && b.pageNumber ? pageHeights.get(b.bbox.page) || pageHeights.get(b.pageNumber) : void 0;
|
|
5876
|
+
if (!ph || !b.bbox || !b.pageNumber || b.bbox.y > ph * 0.12) {
|
|
5877
|
+
out.push(b);
|
|
5878
|
+
continue;
|
|
5879
|
+
}
|
|
5880
|
+
if (b.type === "paragraph" && b.text) {
|
|
5881
|
+
const lines = b.text.split("\n");
|
|
5882
|
+
let hi = lines.length;
|
|
5883
|
+
while (hi > 0 && !lines[hi - 1].trim()) hi--;
|
|
5884
|
+
if (hi > 0 && matches(lines[hi - 1], b.pageNumber)) {
|
|
5885
|
+
const text = lines.slice(0, hi - 1).join("\n").trim();
|
|
5886
|
+
if (!text) continue;
|
|
5887
|
+
b.text = text;
|
|
5888
|
+
}
|
|
5889
|
+
} else if (b.type === "table" && b.table && b.table.cells.length) {
|
|
5890
|
+
const t = b.table, last = t.cells.length - 1;
|
|
5891
|
+
if (matches(t.cells[last].map((c) => c.text.trim()).filter(Boolean).join(" "), b.pageNumber) && !t.cells.slice(0, last).some((row, i) => row.some((c) => i + (c.rowSpan || 1) - 1 >= last))) {
|
|
5892
|
+
t.cells.pop();
|
|
5893
|
+
if (!t.cells.length) continue;
|
|
5894
|
+
t.rows = t.cells.length;
|
|
5895
|
+
t.hasHeader = t.hasHeader && t.rows > 1;
|
|
5896
|
+
}
|
|
5897
|
+
}
|
|
5898
|
+
out.push(b);
|
|
5899
|
+
}
|
|
5900
|
+
return out;
|
|
5901
|
+
}
|
|
5829
5902
|
|
|
5830
5903
|
// src/pdf/table-meta.ts
|
|
5831
5904
|
var CLIP_TABLES = /* @__PURE__ */ new WeakSet();
|
|
@@ -6578,16 +6651,16 @@ function isProseSpread(items) {
|
|
|
6578
6651
|
for (let i = 1; i < sorted.length; i++) {
|
|
6579
6652
|
gaps.push(sorted[i].x - (sorted[i - 1].x + sorted[i - 1].w));
|
|
6580
6653
|
}
|
|
6581
|
-
const maxGap =
|
|
6654
|
+
const maxGap = _chunkMCUX2Y2Ccjs.safeMax.call(void 0, gaps);
|
|
6582
6655
|
const avgLen = items.reduce((s, i) => s + i.text.length, 0) / items.length;
|
|
6583
6656
|
if (items.length >= 4 && maxGap < 40 && avgLen < 5) return true;
|
|
6584
|
-
const minGap =
|
|
6657
|
+
const minGap = _chunkMCUX2Y2Ccjs.safeMin.call(void 0, gaps);
|
|
6585
6658
|
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;
|
|
6586
6659
|
}
|
|
6587
6660
|
function detectColumns(yLines) {
|
|
6588
6661
|
const allItems = yLines.flat();
|
|
6589
6662
|
if (allItems.length === 0) return null;
|
|
6590
|
-
const pageWidth =
|
|
6663
|
+
const pageWidth = _chunkMCUX2Y2Ccjs.safeMax.call(void 0, allItems.map((i) => i.x + i.w)) - _chunkMCUX2Y2Ccjs.safeMin.call(void 0, allItems.map((i) => i.x));
|
|
6591
6664
|
if (pageWidth < 100) return null;
|
|
6592
6665
|
let bigoLineIdx = -1;
|
|
6593
6666
|
for (let i = 0; i < yLines.length; i++) {
|
|
@@ -7131,12 +7204,12 @@ function recordClipCellEdges(grids, horizontals, verticals, nonRules) {
|
|
|
7131
7204
|
}
|
|
7132
7205
|
function takeClipCellEdges(from, to) {
|
|
7133
7206
|
const e = CLIP_CELL_EDGES.get(from);
|
|
7134
|
-
if (e)
|
|
7207
|
+
if (e) _chunkT7PN5D4Dcjs.CELL_EDGES.set(to, e);
|
|
7135
7208
|
}
|
|
7136
7209
|
function joinCellEdges(a, b) {
|
|
7137
|
-
const u =
|
|
7210
|
+
const u = _chunkT7PN5D4Dcjs.CELL_EDGES.get(a), d = _chunkT7PN5D4Dcjs.CELL_EDGES.get(b);
|
|
7138
7211
|
if (!u || !d) return;
|
|
7139
|
-
|
|
7212
|
+
_chunkT7PN5D4Dcjs.CELL_EDGES.set(a, { t: u.t, b: d.b, l: u.l || d.l, r: u.r || d.r });
|
|
7140
7213
|
}
|
|
7141
7214
|
|
|
7142
7215
|
// src/pdf/table-unit-row.ts
|
|
@@ -7152,7 +7225,7 @@ function rebuildUnitLine(items, grid) {
|
|
|
7152
7225
|
function prependUnitRow(cells, cols, line, usedItems) {
|
|
7153
7226
|
const text = cleanCellText(line.map((item) => item.text).join(""));
|
|
7154
7227
|
cells.unshift(Array.from({ length: cols }, (_, c) => ({ text: c === 0 ? text : "", colSpan: c === 0 ? cols : 1, rowSpan: 1 })));
|
|
7155
|
-
for (const cell of cells[0])
|
|
7228
|
+
for (const cell of cells[0]) _chunkT7PN5D4Dcjs.CELL_EDGES.set(cell, NO_EDGES);
|
|
7156
7229
|
for (const item of line) usedItems.add(item);
|
|
7157
7230
|
}
|
|
7158
7231
|
function attachUnitRow(items, grid, cells, cols, usedItems) {
|
|
@@ -7682,7 +7755,7 @@ function recordFrameTitle(table, source, pageNum) {
|
|
|
7682
7755
|
const [label, spacer, title] = cells;
|
|
7683
7756
|
if (!/^(?:붙임|별첨|첨부|부록)\s*\d{1,3}$/.test(label.text.trim()) || spacer.text.trim() || !title.text.trim()) return;
|
|
7684
7757
|
if (cells.some((c) => {
|
|
7685
|
-
const e =
|
|
7758
|
+
const e = _chunkT7PN5D4Dcjs.CELL_EDGES.get(c);
|
|
7686
7759
|
return !e || e.t || e.b || e.l || e.r;
|
|
7687
7760
|
})) return;
|
|
7688
7761
|
const xs = TABLE_COLXS.get(table), style = dominantStyle(source), fs = _nullishCoalesce(_optionalChain([style, 'optionalAccess', _346 => _346.fontSize]), () => ( 0));
|
|
@@ -8341,7 +8414,7 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
|
|
|
8341
8414
|
groupSizes.push(1);
|
|
8342
8415
|
}
|
|
8343
8416
|
const allY = remaining.map((i) => i.y);
|
|
8344
|
-
const pageH =
|
|
8417
|
+
const pageH = _chunkMCUX2Y2Ccjs.safeMax.call(void 0, allY) - _chunkMCUX2Y2Ccjs.safeMin.call(void 0, allY);
|
|
8345
8418
|
const gapThreshold = Math.max(15, pageH * 0.03);
|
|
8346
8419
|
const sides = frameColumnTextBands(remaining, spanning, gx);
|
|
8347
8420
|
const textBlocks = [];
|
|
@@ -8357,7 +8430,7 @@ function extractBlocksWithGrids(items, pageNum, pageWidth, pageHeight, grids, ho
|
|
|
8357
8430
|
finalTextBlocks.push(...detectListBlocks(textBlocks));
|
|
8358
8431
|
} else {
|
|
8359
8432
|
const allY = remaining.map((i) => i.y);
|
|
8360
|
-
const pageH =
|
|
8433
|
+
const pageH = _chunkMCUX2Y2Ccjs.safeMax.call(void 0, allY) - _chunkMCUX2Y2Ccjs.safeMin.call(void 0, allY);
|
|
8361
8434
|
const gapThreshold = Math.max(15, pageH * 0.03);
|
|
8362
8435
|
const groups = xyCutOrder(remaining, gapThreshold);
|
|
8363
8436
|
const textBlocks = [];
|
|
@@ -8685,7 +8758,7 @@ function extractPageBlocksFallback(items, pageNum, fullPage = false, detectTable
|
|
|
8685
8758
|
blocks.push(...columnTextToBlocks(tableText, pageNum, bbox, dominantStyle(items)));
|
|
8686
8759
|
} else {
|
|
8687
8760
|
const allY = items.map((i) => i.y);
|
|
8688
|
-
const pageHeight =
|
|
8761
|
+
const pageHeight = _chunkMCUX2Y2Ccjs.safeMax.call(void 0, allY) - _chunkMCUX2Y2Ccjs.safeMin.call(void 0, allY);
|
|
8689
8762
|
const gapThreshold = Math.max(15, pageHeight * 0.03);
|
|
8690
8763
|
const orderedGroups = proseCutX !== null ? splitTwoColumnProse(items, proseCutX) : xyCutOrder(items, gapThreshold, 0, void 0, minGap);
|
|
8691
8764
|
for (const group of orderedGroups) {
|
|
@@ -8895,5 +8968,7 @@ function rowParagraphs(block) {
|
|
|
8895
8968
|
|
|
8896
8969
|
|
|
8897
8970
|
|
|
8898
|
-
|
|
8899
|
-
|
|
8971
|
+
|
|
8972
|
+
|
|
8973
|
+
exports.OCR_DET_MODEL = OCR_DET_MODEL; exports.OCR_REC_MODEL = OCR_REC_MODEL; exports.OCR_REC_DICT = OCR_REC_DICT; exports.getOcrModelsDir = getOcrModelsDir; exports.ensureOcrModels = ensureOcrModels; exports.ocrModelsCached = ocrModelsCached; exports.parseCharacterDict = parseCharacterDict; exports.extractLines = extractLines; exports.extractImageRegions = extractImageRegions; exports.filterHiddenText = filterHiddenText; exports.collapseEvenSpacing = collapseEvenSpacing; exports.computeBBox = computeBBox; exports.dominantStyle = dominantStyle; exports.normalizeItems = normalizeItems; exports.groupByY = groupByY; exports.mergeLineSimple = mergeLineSimple; exports.WrapLexicon = WrapLexicon; exports.startsNewItem = startsNewItem; exports.wrapJoiner = wrapJoiner; exports.joinPageBreakWraps = joinPageBreakWraps; exports.splitPageBreakWraps = splitPageBreakWraps; exports.latinSoftWrap = latinSoftWrap; exports.TOC_BLOCKS = TOC_BLOCKS; exports.computeMedianFontSizeFromFreq = computeMedianFontSizeFromFreq; exports.detectHeadings = detectHeadings; exports.mergeStackedHeadingLines = mergeStackedHeadingLines; exports.detectTypographyHeadings = detectTypographyHeadings; exports.detectDocumentStyleHeadings = detectDocumentStyleHeadings; exports.detectSiblingStyleHeadings = detectSiblingStyleHeadings; exports.detectRepeatedPageLabels = detectRepeatedPageLabels; exports.detectPageLeadHeadings = detectPageLeadHeadings; exports.refineDocumentStyleHeadings = refineDocumentStyleHeadings; exports.detectMarkerHeadings = detectMarkerHeadings; exports.detectTableCaptions = detectTableCaptions; exports.detectKoreanListBlocks = detectKoreanListBlocks; exports.removeHeaderFooterBlocks = removeHeaderFooterBlocks; exports.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.NO_EDGES = NO_EDGES; exports.joinCellEdges = joinCellEdges; exports.restoreImageBullets = restoreImageBullets; exports.detectRightArrowRegions = detectRightArrowRegions; exports.removeSideTabs = removeSideTabs; exports.extractPageBlocksWithLines = extractPageBlocksWithLines; exports.UNRULED_REGION_TABLES = UNRULED_REGION_TABLES; exports.mergeOcrImageRegions = mergeOcrImageRegions;
|
|
8974
|
+
//# sourceMappingURL=chunk-TMUUDMDH.cjs.map
|