kordoc 4.6.0 → 4.6.1
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/LICENSE +21 -21
- package/NOTICE +176 -176
- package/README.md +962 -958
- package/THIRD_PARTY/apache-2.0.LICENSE +201 -201
- package/THIRD_PARTY/claw-hwp.LICENSE +21 -21
- package/THIRD_PARTY/hml-equation-parser.LICENSE +201 -201
- package/THIRD_PARTY/hml-equation-parser.txt +35 -35
- package/THIRD_PARTY/opendataloader-pdf.txt +32 -32
- package/THIRD_PARTY/pix2text.txt +17 -17
- package/THIRD_PARTY/rhwp-forms.txt +35 -35
- package/dist/{-DEVLQKIT.js → -6XJ6MCQG.js} +12 -12
- package/dist/{chunk-3FFPHTXD.js → chunk-3H5X63BQ.js} +1 -1
- package/dist/chunk-3H5X63BQ.js.map +1 -0
- package/dist/{chunk-IBVMJIHR.js → chunk-3VTMSSDW.js} +2 -2
- package/dist/chunk-3VTMSSDW.js.map +1 -0
- package/dist/{chunk-6GBLFQMA.js → chunk-5RPYBC2Q.js} +1 -1
- package/dist/chunk-5RPYBC2Q.js.map +1 -0
- package/dist/{chunk-W34QSJFF.js → chunk-7FCNOKOR.js} +1 -1
- package/dist/chunk-7FCNOKOR.js.map +1 -0
- package/dist/{chunk-HPRGVU6A.cjs → chunk-AC3K3FZJ.cjs} +6 -6
- package/dist/chunk-AC3K3FZJ.cjs.map +1 -0
- package/dist/{chunk-KC63W72C.js → chunk-AFPD74JJ.js} +2 -2
- package/dist/chunk-AFPD74JJ.js.map +1 -0
- package/dist/{chunk-2CENWSAW.js → chunk-B2OQOTRT.js} +216 -22
- package/dist/chunk-B2OQOTRT.js.map +1 -0
- package/dist/{chunk-IHK5LCYX.js → chunk-BCG2PKQU.js} +2 -2
- package/dist/chunk-BCG2PKQU.js.map +1 -0
- package/dist/{chunk-PQDNCWAZ.js → chunk-BGSGUONP.js} +217 -23
- package/dist/chunk-BGSGUONP.js.map +1 -0
- package/dist/{chunk-X34YWRL5.cjs → chunk-DCZVOIEO.cjs} +1 -1
- package/dist/chunk-DCZVOIEO.cjs.map +1 -0
- package/dist/{chunk-O5EK52TG.js → chunk-DZIXKL7E.js} +1 -1
- package/dist/chunk-DZIXKL7E.js.map +1 -0
- package/dist/{chunk-MSMSHU2F.js → chunk-EACTUWYE.js} +3 -3
- package/dist/chunk-EACTUWYE.js.map +1 -0
- package/dist/{chunk-AIQ3ISQU.js → chunk-GE43BE46.js} +1 -1
- package/dist/chunk-GE43BE46.js.map +1 -0
- package/dist/chunk-GS7T56RP.cjs.map +1 -1
- package/dist/{chunk-6XPXIG57.js → chunk-GZDOWYJM.js} +2 -2
- package/dist/chunk-GZDOWYJM.js.map +1 -0
- package/dist/{chunk-OPL22SYF.js → chunk-IDHBO6AG.js} +3 -3
- package/dist/chunk-IDHBO6AG.js.map +1 -0
- package/dist/{chunk-3TBUDJDE.js → chunk-MOL7MDBG.js} +1 -1
- package/dist/chunk-MOL7MDBG.js.map +1 -0
- package/dist/{chunk-PSAHY5XW.js → chunk-MVTX6ODZ.js} +1 -1
- package/dist/chunk-MVTX6ODZ.js.map +1 -0
- package/dist/{chunk-UQ4NSK66.js → chunk-PV2EXXGI.js} +3 -3
- package/dist/chunk-PV2EXXGI.js.map +1 -0
- package/dist/{chunk-I42DND3B.cjs → chunk-SHYF2BB2.cjs} +223 -29
- package/dist/chunk-SHYF2BB2.cjs.map +1 -0
- package/dist/{chunk-WX7WQTOT.cjs → chunk-TUU535RB.cjs} +2 -2
- package/dist/chunk-TUU535RB.cjs.map +1 -0
- package/dist/{chunk-YNJDNP44.js → chunk-UAFSPWU7.js} +1 -1
- package/dist/chunk-UAFSPWU7.js.map +1 -0
- package/dist/{chunk-2CABQYTT.js → chunk-VCA4SZ2D.js} +3 -3
- package/dist/chunk-VCA4SZ2D.js.map +1 -0
- package/dist/{chunk-7BTO44Q7.js → chunk-VO24F4BJ.js} +13 -13
- package/dist/chunk-VO24F4BJ.js.map +1 -0
- package/dist/{chunk-CARNWWGI.cjs → chunk-W5KRKBYR.cjs} +4 -4
- package/dist/chunk-W5KRKBYR.cjs.map +1 -0
- package/dist/{chunk-VNEV6VKD.js → chunk-XZDJXYUC.js} +2 -2
- package/dist/chunk-XZDJXYUC.js.map +1 -0
- package/dist/{chunk-UGKXJA3W.js → chunk-YUVKU5CW.js} +2 -2
- package/dist/chunk-YUVKU5CW.js.map +1 -0
- package/dist/{chunk-KQOTL4WI.js → chunk-YXXHH6WC.js} +2 -2
- package/dist/chunk-YXXHH6WC.js.map +1 -0
- package/dist/{chunk-MGGU3ZRK.cjs → chunk-ZV5OKQ3Z.cjs} +1 -1
- package/dist/chunk-ZV5OKQ3Z.cjs.map +1 -0
- package/dist/{chunk-ZYQ5X6PG.js → chunk-ZYVULRYF.js} +2 -2
- package/dist/chunk-ZYVULRYF.js.map +1 -0
- package/dist/chunks-4HEG6ZPG.js +10 -0
- package/dist/cli.js +24 -24
- package/dist/cli.js.map +1 -1
- package/dist/{formula-WKGP3D3Y.cjs → formula-CG4S7TWO.cjs} +8 -8
- package/dist/formula-CG4S7TWO.cjs.map +1 -0
- package/dist/{formula-ETB6MESN.js → formula-JLYS73QL.js} +2 -2
- package/dist/formula-JLYS73QL.js.map +1 -0
- package/dist/{formula-KW4NI5IO.js → formula-LIVQSCMM.js} +2 -2
- package/dist/formula-LIVQSCMM.js.map +1 -0
- package/dist/{image-ocr-C6U7YHRC.js → image-ocr-7VYYQH5F.js} +5 -5
- package/dist/image-ocr-7VYYQH5F.js.map +1 -0
- package/dist/{image-ocr-YID6TDN5.cjs → image-ocr-MLUPV4FM.cjs} +11 -11
- package/dist/image-ocr-MLUPV4FM.cjs.map +1 -0
- package/dist/{image-ocr-YIBJCOUQ.js → image-ocr-Y3WDYG4I.js} +7 -7
- package/dist/image-ocr-Y3WDYG4I.js.map +1 -0
- package/dist/index.cjs +185 -185
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +7 -7
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +20 -20
- package/dist/mcp.js.map +1 -1
- package/dist/{models-6VMAVZR6.js → models-6SIKLKRH.js} +3 -3
- package/dist/page-range-737B4EZW.js +8 -0
- package/dist/page-range-LNMXJU6W.js +7 -0
- package/dist/page-range-P7SDW6LR.cjs +8 -0
- package/dist/page-range-P7SDW6LR.cjs.map +1 -0
- package/dist/{parser-GFXZV2VJ.js → parser-FMYUF4DT.js} +9 -9
- package/dist/parser-FMYUF4DT.js.map +1 -0
- package/dist/{parser-EYCVDUJA.cjs → parser-QOFG3K3Y.cjs} +27 -27
- package/dist/parser-QOFG3K3Y.cjs.map +1 -0
- package/dist/{parser-SHM3JEH6.js → parser-ZDJ7QTLL.js} +7 -7
- package/dist/parser-ZDJ7QTLL.js.map +1 -0
- package/dist/pdf-ocr-BFWPYON4.js +15 -0
- package/dist/pdf-ocr-CBJAL5DC.js +12 -0
- package/dist/pdf-ocr-MYZNSEK4.cjs +13 -0
- package/dist/pdf-ocr-MYZNSEK4.cjs.map +1 -0
- package/dist/{profile-io-FQZNNA3O.js → profile-io-L5EH4JAD.js} +3 -3
- package/dist/{rasterize-QGKFNTXO.js → rasterize-7AR662AL.js} +2 -2
- package/dist/rasterize-7AR662AL.js.map +1 -0
- package/dist/{redact-W5K3ILQH.js → redact-7ILEAUTS.js} +2 -2
- package/dist/render-CAFQT7S4.js +10 -0
- package/dist/seal-ESAC3IZR.js +10 -0
- package/dist/{setup-I4I75QJU.js → setup-GUQT5ELJ.js} +1 -1
- package/dist/setup-GUQT5ELJ.js.map +1 -0
- package/dist/{watch-OIVXH2RN.js → watch-ZPKLNQTD.js} +12 -12
- package/dist/watch-ZPKLNQTD.js.map +1 -0
- package/package.json +103 -103
- package/templates//352/260/204/354/235/264/352/270/260/354/225/210/353/254/270_/354/230/210/354/213/234/352/260/222.json +9 -9
- package/templates//354/235/274/353/260/230/352/270/260/354/225/210/353/254/270_/354/230/210/354/213/234/352/260/222.json +24 -24
- package/dist/chunk-2CABQYTT.js.map +0 -1
- package/dist/chunk-2CENWSAW.js.map +0 -1
- package/dist/chunk-3FFPHTXD.js.map +0 -1
- package/dist/chunk-3TBUDJDE.js.map +0 -1
- package/dist/chunk-6GBLFQMA.js.map +0 -1
- package/dist/chunk-6XPXIG57.js.map +0 -1
- package/dist/chunk-7BTO44Q7.js.map +0 -1
- package/dist/chunk-AIQ3ISQU.js.map +0 -1
- package/dist/chunk-CARNWWGI.cjs.map +0 -1
- package/dist/chunk-HPRGVU6A.cjs.map +0 -1
- package/dist/chunk-I42DND3B.cjs.map +0 -1
- package/dist/chunk-IBVMJIHR.js.map +0 -1
- package/dist/chunk-IHK5LCYX.js.map +0 -1
- package/dist/chunk-KC63W72C.js.map +0 -1
- package/dist/chunk-KQOTL4WI.js.map +0 -1
- package/dist/chunk-MGGU3ZRK.cjs.map +0 -1
- package/dist/chunk-MSMSHU2F.js.map +0 -1
- package/dist/chunk-O5EK52TG.js.map +0 -1
- package/dist/chunk-OPL22SYF.js.map +0 -1
- package/dist/chunk-PQDNCWAZ.js.map +0 -1
- package/dist/chunk-PSAHY5XW.js.map +0 -1
- package/dist/chunk-UGKXJA3W.js.map +0 -1
- package/dist/chunk-UQ4NSK66.js.map +0 -1
- package/dist/chunk-VNEV6VKD.js.map +0 -1
- package/dist/chunk-W34QSJFF.js.map +0 -1
- package/dist/chunk-WX7WQTOT.cjs.map +0 -1
- package/dist/chunk-X34YWRL5.cjs.map +0 -1
- package/dist/chunk-YNJDNP44.js.map +0 -1
- package/dist/chunk-ZYQ5X6PG.js.map +0 -1
- package/dist/chunks-Y2VE2WCJ.js +0 -10
- package/dist/formula-ETB6MESN.js.map +0 -1
- package/dist/formula-KW4NI5IO.js.map +0 -1
- package/dist/formula-WKGP3D3Y.cjs.map +0 -1
- package/dist/image-ocr-C6U7YHRC.js.map +0 -1
- package/dist/image-ocr-YIBJCOUQ.js.map +0 -1
- package/dist/image-ocr-YID6TDN5.cjs.map +0 -1
- package/dist/page-range-CIRRJPXJ.js +0 -7
- package/dist/page-range-OF5I4PQY.js +0 -8
- package/dist/page-range-TPIRSA3J.cjs +0 -8
- package/dist/page-range-TPIRSA3J.cjs.map +0 -1
- package/dist/parser-EYCVDUJA.cjs.map +0 -1
- package/dist/parser-GFXZV2VJ.js.map +0 -1
- package/dist/parser-SHM3JEH6.js.map +0 -1
- package/dist/pdf-ocr-TMAWPOHC.cjs +0 -13
- package/dist/pdf-ocr-TMAWPOHC.cjs.map +0 -1
- package/dist/pdf-ocr-UKFYODLP.js +0 -15
- package/dist/pdf-ocr-ZG4UVUIT.js +0 -12
- package/dist/rasterize-QGKFNTXO.js.map +0 -1
- package/dist/render-YFIWQYVB.js +0 -10
- package/dist/seal-GZ7NDWLR.js +0 -10
- package/dist/setup-I4I75QJU.js.map +0 -1
- package/dist/watch-OIVXH2RN.js.map +0 -1
- /package/dist/{-DEVLQKIT.js.map → -6XJ6MCQG.js.map} +0 -0
- /package/dist/{chunks-Y2VE2WCJ.js.map → chunks-4HEG6ZPG.js.map} +0 -0
- /package/dist/{models-6VMAVZR6.js.map → models-6SIKLKRH.js.map} +0 -0
- /package/dist/{page-range-CIRRJPXJ.js.map → page-range-737B4EZW.js.map} +0 -0
- /package/dist/{page-range-OF5I4PQY.js.map → page-range-LNMXJU6W.js.map} +0 -0
- /package/dist/{pdf-ocr-UKFYODLP.js.map → pdf-ocr-BFWPYON4.js.map} +0 -0
- /package/dist/{pdf-ocr-ZG4UVUIT.js.map → pdf-ocr-CBJAL5DC.js.map} +0 -0
- /package/dist/{profile-io-FQZNNA3O.js.map → profile-io-L5EH4JAD.js.map} +0 -0
- /package/dist/{redact-W5K3ILQH.js.map → redact-7ILEAUTS.js.map} +0 -0
- /package/dist/{render-YFIWQYVB.js.map → render-CAFQT7S4.js.map} +0 -0
- /package/dist/{seal-GZ7NDWLR.js.map → seal-ESAC3IZR.js.map} +0 -0
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunkTUU535RBcjs = require('./chunk-TUU535RB.cjs');
|
|
8
8
|
|
|
9
9
|
// src/pdf/image-regions.ts
|
|
10
10
|
var _pdfmjs = require('pdfjs-dist/legacy/build/pdf.mjs');
|
|
@@ -1567,9 +1567,9 @@ function detectHeadings(blocks, medianFontSize) {
|
|
|
1567
1567
|
if (/^\d+$/.test(text)) continue;
|
|
1568
1568
|
const ratio = block.style.fontSize / medianFontSize;
|
|
1569
1569
|
let level = 0;
|
|
1570
|
-
if (ratio >=
|
|
1571
|
-
else if (ratio >=
|
|
1572
|
-
else if (ratio >=
|
|
1570
|
+
if (ratio >= _chunkTUU535RBcjs.HEADING_RATIO_H1) level = 1;
|
|
1571
|
+
else if (ratio >= _chunkTUU535RBcjs.HEADING_RATIO_H2) level = 2;
|
|
1572
|
+
else if (ratio >= _chunkTUU535RBcjs.HEADING_RATIO_H3) level = 3;
|
|
1573
1573
|
if (level > 0) {
|
|
1574
1574
|
block.type = "heading";
|
|
1575
1575
|
block.level = level;
|
|
@@ -2681,6 +2681,149 @@ function findVerticalCut(items) {
|
|
|
2681
2681
|
return { position, gap: largestGap };
|
|
2682
2682
|
}
|
|
2683
2683
|
|
|
2684
|
+
// src/pdf/two-column.ts
|
|
2685
|
+
var GUTTER_SCAN_LO = 0.3;
|
|
2686
|
+
var GUTTER_SCAN_HI = 0.7;
|
|
2687
|
+
var GUTTER_MAX_SAMPLES = 400;
|
|
2688
|
+
var WIDE_RECT_RATIO = 0.55;
|
|
2689
|
+
var GUTTER_MAX_COVER_RATIO = 0.06;
|
|
2690
|
+
var SIDE_MIN_COUNT = 5;
|
|
2691
|
+
var SIDE_MIN_HEIGHT_RATIO = 0.3;
|
|
2692
|
+
var SIDE_MIN_VSPAN_RATIO = 0.45;
|
|
2693
|
+
var SIDE_MIN_WIDTH_SYMMETRY = 0.5;
|
|
2694
|
+
var MIN_CONTENT_SPAN = 300;
|
|
2695
|
+
var TEXT_RECT_MAX_H = 20;
|
|
2696
|
+
var ROW_Y_TOL = 2;
|
|
2697
|
+
var SIDE_MIN_TEXT_ROWS = 12;
|
|
2698
|
+
var CROSS_ROW_TINY_GAP = 12;
|
|
2699
|
+
var MAX_TINY_GAP_ROWS = 1;
|
|
2700
|
+
var MAX_BOTH_SIDE_ROW_RATIO = 0.65;
|
|
2701
|
+
var BLOCK_DOMINANT_TEXT_RECTS = 10;
|
|
2702
|
+
function detectColumnGutter(rects) {
|
|
2703
|
+
if (rects.length < 8) return null;
|
|
2704
|
+
let minX = Infinity;
|
|
2705
|
+
let maxX = -Infinity;
|
|
2706
|
+
for (const r of rects) {
|
|
2707
|
+
if (r.x < minX) minX = r.x;
|
|
2708
|
+
if (r.x + r.w > maxX) maxX = r.x + r.w;
|
|
2709
|
+
}
|
|
2710
|
+
const span = maxX - minX;
|
|
2711
|
+
if (!Number.isFinite(span) || span < MIN_CONTENT_SPAN) return null;
|
|
2712
|
+
const narrow = rects.filter((r) => r.w < span * WIDE_RECT_RATIO && r.w > 0 && r.h > 0);
|
|
2713
|
+
if (narrow.length < SIDE_MIN_COUNT * 2) return null;
|
|
2714
|
+
let totalH = 0;
|
|
2715
|
+
for (const r of narrow) totalH += r.h;
|
|
2716
|
+
if (totalH <= 0) return null;
|
|
2717
|
+
const lo = minX + span * GUTTER_SCAN_LO;
|
|
2718
|
+
const hi = minX + span * GUTTER_SCAN_HI;
|
|
2719
|
+
const step = Math.max(2, (hi - lo) / GUTTER_MAX_SAMPLES);
|
|
2720
|
+
let gutterX = 0;
|
|
2721
|
+
let bestCover = Infinity;
|
|
2722
|
+
for (let x = lo; x <= hi; x += step) {
|
|
2723
|
+
let cover = 0;
|
|
2724
|
+
for (const r of narrow) {
|
|
2725
|
+
if (r.x < x && r.x + r.w > x) cover += r.h;
|
|
2726
|
+
}
|
|
2727
|
+
if (cover < bestCover) {
|
|
2728
|
+
bestCover = cover;
|
|
2729
|
+
gutterX = x;
|
|
2730
|
+
}
|
|
2731
|
+
}
|
|
2732
|
+
if (bestCover > totalH * GUTTER_MAX_COVER_RATIO) return null;
|
|
2733
|
+
const left = [];
|
|
2734
|
+
const right = [];
|
|
2735
|
+
for (const r of narrow) {
|
|
2736
|
+
if (r.x + r.w <= gutterX) left.push(r);
|
|
2737
|
+
else if (r.x >= gutterX) right.push(r);
|
|
2738
|
+
}
|
|
2739
|
+
if (left.length < SIDE_MIN_COUNT || right.length < SIDE_MIN_COUNT) return null;
|
|
2740
|
+
const sideStats = (side) => {
|
|
2741
|
+
let sMinX = Infinity, sMaxR = -Infinity, sMinY = Infinity, sMaxT = -Infinity, hSum = 0;
|
|
2742
|
+
for (const r of side) {
|
|
2743
|
+
if (r.x < sMinX) sMinX = r.x;
|
|
2744
|
+
if (r.x + r.w > sMaxR) sMaxR = r.x + r.w;
|
|
2745
|
+
if (r.y < sMinY) sMinY = r.y;
|
|
2746
|
+
if (r.y + r.h > sMaxT) sMaxT = r.y + r.h;
|
|
2747
|
+
hSum += r.h;
|
|
2748
|
+
}
|
|
2749
|
+
return { width: sMaxR - sMinX, vspan: sMaxT - sMinY, minY: sMinY, maxT: sMaxT, hSum };
|
|
2750
|
+
};
|
|
2751
|
+
const L = sideStats(left);
|
|
2752
|
+
const R = sideStats(right);
|
|
2753
|
+
if (Math.min(L.hSum, R.hSum) / Math.max(L.hSum, R.hSum) < SIDE_MIN_HEIGHT_RATIO) return null;
|
|
2754
|
+
const unionVspan = Math.max(L.maxT, R.maxT) - Math.min(L.minY, R.minY);
|
|
2755
|
+
if (unionVspan <= 0) return null;
|
|
2756
|
+
if (L.vspan / unionVspan < SIDE_MIN_VSPAN_RATIO) return null;
|
|
2757
|
+
if (R.vspan / unionVspan < SIDE_MIN_VSPAN_RATIO) return null;
|
|
2758
|
+
if (Math.min(L.width, R.width) / Math.max(L.width, R.width) < SIDE_MIN_WIDTH_SYMMETRY) return null;
|
|
2759
|
+
const textRects = (side) => side.filter((r) => r.h <= TEXT_RECT_MAX_H);
|
|
2760
|
+
const lText = textRects(left);
|
|
2761
|
+
const rText = textRects(right);
|
|
2762
|
+
if (lText.length + rText.length >= BLOCK_DOMINANT_TEXT_RECTS) {
|
|
2763
|
+
const rows = /* @__PURE__ */ new Map();
|
|
2764
|
+
const rowKey = (y) => Math.round(y / ROW_Y_TOL);
|
|
2765
|
+
for (const r of lText) {
|
|
2766
|
+
const k = rowKey(r.y);
|
|
2767
|
+
const e = _nullishCoalesce(rows.get(k), () => ( { lEnd: -Infinity, rStart: Infinity }));
|
|
2768
|
+
if (r.x + r.w > e.lEnd) e.lEnd = r.x + r.w;
|
|
2769
|
+
rows.set(k, e);
|
|
2770
|
+
}
|
|
2771
|
+
const lRowCount = rows.size;
|
|
2772
|
+
for (const r of rText) {
|
|
2773
|
+
const k = rowKey(r.y);
|
|
2774
|
+
const e = _nullishCoalesce(rows.get(k), () => ( { lEnd: -Infinity, rStart: Infinity }));
|
|
2775
|
+
if (r.x < e.rStart) e.rStart = r.x;
|
|
2776
|
+
rows.set(k, e);
|
|
2777
|
+
}
|
|
2778
|
+
let rRowCount = 0;
|
|
2779
|
+
let bothRows = 0;
|
|
2780
|
+
let tinyGapRows = 0;
|
|
2781
|
+
for (const e of rows.values()) {
|
|
2782
|
+
if (e.rStart < Infinity) rRowCount++;
|
|
2783
|
+
if (e.lEnd > -Infinity && e.rStart < Infinity) {
|
|
2784
|
+
bothRows++;
|
|
2785
|
+
if (e.rStart - e.lEnd < CROSS_ROW_TINY_GAP) tinyGapRows++;
|
|
2786
|
+
}
|
|
2787
|
+
}
|
|
2788
|
+
if (lRowCount < SIDE_MIN_TEXT_ROWS || rRowCount < SIDE_MIN_TEXT_ROWS) return null;
|
|
2789
|
+
if (tinyGapRows > MAX_TINY_GAP_ROWS) return null;
|
|
2790
|
+
if (bothRows / Math.min(lRowCount, rRowCount) > MAX_BOTH_SIDE_ROW_RATIO) return null;
|
|
2791
|
+
}
|
|
2792
|
+
return gutterX;
|
|
2793
|
+
}
|
|
2794
|
+
function orderByGutter(units, rectOf, gutterX) {
|
|
2795
|
+
const left = [];
|
|
2796
|
+
const right = [];
|
|
2797
|
+
const cross = [];
|
|
2798
|
+
for (const u of units) {
|
|
2799
|
+
const r = rectOf(u);
|
|
2800
|
+
const top = r.y + r.h;
|
|
2801
|
+
if (r.x < gutterX && r.x + r.w > gutterX) cross.push({ u, top });
|
|
2802
|
+
else if (r.x + r.w <= gutterX) left.push({ u, top });
|
|
2803
|
+
else right.push({ u, top });
|
|
2804
|
+
}
|
|
2805
|
+
const byTopDesc = (a, b) => b.top - a.top;
|
|
2806
|
+
cross.sort(byTopDesc);
|
|
2807
|
+
left.sort(byTopDesc);
|
|
2808
|
+
right.sort(byTopDesc);
|
|
2809
|
+
const bandOf = (top) => {
|
|
2810
|
+
let k = 0;
|
|
2811
|
+
while (k < cross.length && cross[k].top > top) k++;
|
|
2812
|
+
return k;
|
|
2813
|
+
};
|
|
2814
|
+
const ordered = [];
|
|
2815
|
+
for (let k = 0; k <= cross.length; k++) {
|
|
2816
|
+
for (const t of left) {
|
|
2817
|
+
if (bandOf(t.top) === k) ordered.push(t.u);
|
|
2818
|
+
}
|
|
2819
|
+
for (const t of right) {
|
|
2820
|
+
if (bandOf(t.top) === k) ordered.push(t.u);
|
|
2821
|
+
}
|
|
2822
|
+
if (k < cross.length) ordered.push(cross[k].u);
|
|
2823
|
+
}
|
|
2824
|
+
return ordered;
|
|
2825
|
+
}
|
|
2826
|
+
|
|
2684
2827
|
// src/pdf/columns.ts
|
|
2685
2828
|
function isProseSpread(items) {
|
|
2686
2829
|
if (items.length < 4) return false;
|
|
@@ -2689,14 +2832,14 @@ function isProseSpread(items) {
|
|
|
2689
2832
|
for (let i = 1; i < sorted.length; i++) {
|
|
2690
2833
|
gaps.push(sorted[i].x - (sorted[i - 1].x + sorted[i - 1].w));
|
|
2691
2834
|
}
|
|
2692
|
-
const maxGap =
|
|
2835
|
+
const maxGap = _chunkTUU535RBcjs.safeMax.call(void 0, gaps);
|
|
2693
2836
|
const avgLen = items.reduce((s, i) => s + i.text.length, 0) / items.length;
|
|
2694
2837
|
return maxGap < 40 && avgLen < 5;
|
|
2695
2838
|
}
|
|
2696
2839
|
function detectColumns(yLines) {
|
|
2697
2840
|
const allItems = yLines.flat();
|
|
2698
2841
|
if (allItems.length === 0) return null;
|
|
2699
|
-
const pageWidth =
|
|
2842
|
+
const pageWidth = _chunkTUU535RBcjs.safeMax.call(void 0, allItems.map((i) => i.x + i.w)) - _chunkTUU535RBcjs.safeMin.call(void 0, allItems.map((i) => i.x));
|
|
2700
2843
|
if (pageWidth < 100) return null;
|
|
2701
2844
|
let bigoLineIdx = -1;
|
|
2702
2845
|
for (let i = 0; i < yLines.length; i++) {
|
|
@@ -3114,6 +3257,9 @@ function extractBlocksWithGrids(items, pageNum, grids, horizontals, verticals) {
|
|
|
3114
3257
|
blocks.push({ type: "table", table: irTable, pageNumber: pageNum, bbox: tableBbox });
|
|
3115
3258
|
}
|
|
3116
3259
|
let remaining = items.filter((i) => !usedItems.has(i));
|
|
3260
|
+
const groupSizes = [];
|
|
3261
|
+
let finalTextBlocks = [];
|
|
3262
|
+
let gutterX = null;
|
|
3117
3263
|
if (remaining.length > 0) {
|
|
3118
3264
|
remaining.sort((a, b) => b.y - a.y || a.x - b.x);
|
|
3119
3265
|
const clusterItems = remaining.map((i) => ({
|
|
@@ -3140,11 +3286,39 @@ function extractBlocksWithGrids(items, pageNum, grids, horizontals, verticals) {
|
|
|
3140
3286
|
}
|
|
3141
3287
|
remaining = remaining.filter((_, idx) => !usedClusterIndices.has(idx));
|
|
3142
3288
|
}
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
|
|
3289
|
+
}
|
|
3290
|
+
{
|
|
3291
|
+
const rects = remaining.map((i) => ({ x: i.x, y: i.y, w: i.w, h: i.h > 0 ? i.h : i.fontSize }));
|
|
3292
|
+
for (const b of blocks) {
|
|
3293
|
+
if (b.bbox) rects.push({ x: b.bbox.x, y: b.bbox.y, w: b.bbox.width, h: b.bbox.height });
|
|
3294
|
+
}
|
|
3295
|
+
gutterX = detectColumnGutter(rects);
|
|
3296
|
+
}
|
|
3297
|
+
if (remaining.length > 0) {
|
|
3298
|
+
if (gutterX !== null) {
|
|
3299
|
+
const gx = gutterX;
|
|
3146
3300
|
const allY = remaining.map((i) => i.y);
|
|
3147
|
-
const pageH =
|
|
3301
|
+
const pageH = _chunkTUU535RBcjs.safeMax.call(void 0, allY) - _chunkTUU535RBcjs.safeMin.call(void 0, allY);
|
|
3302
|
+
const gapThreshold = Math.max(15, pageH * 0.03);
|
|
3303
|
+
const sides = [
|
|
3304
|
+
remaining.filter((i) => i.x + i.w <= gx),
|
|
3305
|
+
remaining.filter((i) => i.x < gx && i.x + i.w > gx),
|
|
3306
|
+
remaining.filter((i) => i.x >= gx)
|
|
3307
|
+
];
|
|
3308
|
+
const textBlocks = [];
|
|
3309
|
+
for (const side of sides) {
|
|
3310
|
+
if (side.length === 0) continue;
|
|
3311
|
+
for (const group of xyCutOrder(side, gapThreshold)) {
|
|
3312
|
+
if (group.length === 0) continue;
|
|
3313
|
+
const groupBlocks = extractPageBlocksFallback(group, pageNum);
|
|
3314
|
+
for (const b of groupBlocks) textBlocks.push(b);
|
|
3315
|
+
groupSizes.push(groupBlocks.length);
|
|
3316
|
+
}
|
|
3317
|
+
}
|
|
3318
|
+
finalTextBlocks = detectListBlocks(textBlocks);
|
|
3319
|
+
} else {
|
|
3320
|
+
const allY = remaining.map((i) => i.y);
|
|
3321
|
+
const pageH = _chunkTUU535RBcjs.safeMax.call(void 0, allY) - _chunkTUU535RBcjs.safeMin.call(void 0, allY);
|
|
3148
3322
|
const groups = xyCutOrder(remaining, Math.max(15, pageH * 0.03));
|
|
3149
3323
|
const textBlocks = [];
|
|
3150
3324
|
for (const group of groups) {
|
|
@@ -3155,26 +3329,43 @@ function extractBlocksWithGrids(items, pageNum, grids, horizontals, verticals) {
|
|
|
3155
3329
|
}
|
|
3156
3330
|
finalTextBlocks = detectListBlocks(textBlocks);
|
|
3157
3331
|
}
|
|
3158
|
-
|
|
3159
|
-
|
|
3160
|
-
|
|
3161
|
-
|
|
3162
|
-
|
|
3163
|
-
|
|
3332
|
+
}
|
|
3333
|
+
const units = blocks.map((b) => [b]);
|
|
3334
|
+
let off = 0;
|
|
3335
|
+
for (const size of groupSizes) {
|
|
3336
|
+
const unit = finalTextBlocks.slice(off, off + size);
|
|
3337
|
+
off += size;
|
|
3338
|
+
if (unit.length > 0) units.push(unit);
|
|
3339
|
+
}
|
|
3340
|
+
const unitTopY = (u) => {
|
|
3341
|
+
let top = 0;
|
|
3342
|
+
for (const b of u) {
|
|
3343
|
+
if (b.bbox && b.bbox.y + b.bbox.height > top) top = b.bbox.y + b.bbox.height;
|
|
3164
3344
|
}
|
|
3165
|
-
|
|
3166
|
-
|
|
3345
|
+
return top;
|
|
3346
|
+
};
|
|
3347
|
+
if (gutterX !== null && units.length > 1) {
|
|
3348
|
+
const gx = gutterX;
|
|
3349
|
+
const unitRect = (u) => {
|
|
3350
|
+
let minX = Infinity, minY = Infinity, maxR = -Infinity, maxT = -Infinity;
|
|
3167
3351
|
for (const b of u) {
|
|
3168
|
-
if (b.bbox
|
|
3169
|
-
|
|
3170
|
-
|
|
3352
|
+
if (!b.bbox) continue;
|
|
3353
|
+
if (b.bbox.x < minX) minX = b.bbox.x;
|
|
3354
|
+
if (b.bbox.y < minY) minY = b.bbox.y;
|
|
3355
|
+
if (b.bbox.x + b.bbox.width > maxR) maxR = b.bbox.x + b.bbox.width;
|
|
3356
|
+
if (b.bbox.y + b.bbox.height > maxT) maxT = b.bbox.y + b.bbox.height;
|
|
3357
|
+
}
|
|
3358
|
+
if (!Number.isFinite(minX)) return { x: gx - 1, y: 0, w: 2, h: 0 };
|
|
3359
|
+
return { x: minX, y: minY, w: maxR - minX, h: maxT - minY };
|
|
3171
3360
|
};
|
|
3172
|
-
|
|
3173
|
-
const
|
|
3174
|
-
|
|
3175
|
-
return mergeAdjacentTableBlocks(ordered);
|
|
3361
|
+
const ordered2 = [];
|
|
3362
|
+
for (const u of orderByGutter(units, unitRect, gx)) for (const b of u) ordered2.push(b);
|
|
3363
|
+
return mergeAdjacentTableBlocks(ordered2);
|
|
3176
3364
|
}
|
|
3177
|
-
|
|
3365
|
+
units.sort((a, b) => unitTopY(b) - unitTopY(a));
|
|
3366
|
+
const ordered = [];
|
|
3367
|
+
for (const u of units) for (const b of u) ordered.push(b);
|
|
3368
|
+
return mergeAdjacentTableBlocks(ordered);
|
|
3178
3369
|
}
|
|
3179
3370
|
var NEIGHBOR_TABLE_EPSILON = 0.2;
|
|
3180
3371
|
function mergeCrossPageTables(blocks) {
|
|
@@ -3323,7 +3514,10 @@ function extractPageBlocksFallback(items, pageNum, fullPage = false, detectTable
|
|
|
3323
3514
|
return by - ay;
|
|
3324
3515
|
});
|
|
3325
3516
|
} else {
|
|
3326
|
-
|
|
3517
|
+
let proseCutX = fullPage ? findTwoColumnProseCutX(items) : null;
|
|
3518
|
+
if (proseCutX === null && fullPage) {
|
|
3519
|
+
proseCutX = detectColumnGutter(items.map((i) => ({ x: i.x, y: i.y, w: i.w, h: i.h > 0 ? i.h : i.fontSize })));
|
|
3520
|
+
}
|
|
3327
3521
|
const allYLines = mergeSuperscriptLines(groupByY(items));
|
|
3328
3522
|
const columns = proseCutX !== null || !detectTables ? null : detectColumns(allYLines);
|
|
3329
3523
|
if (columns && columns.length >= 3) {
|
|
@@ -3332,7 +3526,7 @@ function extractPageBlocksFallback(items, pageNum, fullPage = false, detectTable
|
|
|
3332
3526
|
blocks.push({ type: "paragraph", text: tableText, pageNumber: pageNum, bbox, style: dominantStyle(items) });
|
|
3333
3527
|
} else {
|
|
3334
3528
|
const allY = items.map((i) => i.y);
|
|
3335
|
-
const pageHeight =
|
|
3529
|
+
const pageHeight = _chunkTUU535RBcjs.safeMax.call(void 0, allY) - _chunkTUU535RBcjs.safeMin.call(void 0, allY);
|
|
3336
3530
|
const gapThreshold = Math.max(15, pageHeight * 0.03);
|
|
3337
3531
|
const orderedGroups = proseCutX !== null ? splitTwoColumnProse(items, proseCutX) : xyCutOrder(items, gapThreshold);
|
|
3338
3532
|
for (const group of orderedGroups) {
|
|
@@ -3371,4 +3565,4 @@ function extractPageBlocksFallback(items, pageNum, fullPage = false, detectTable
|
|
|
3371
3565
|
|
|
3372
3566
|
|
|
3373
3567
|
exports.extractImageRegions = extractImageRegions; exports.filterHiddenText = filterHiddenText; exports.collapseEvenSpacing = collapseEvenSpacing; exports.normalizeItems = normalizeItems; exports.computeMedianFontSizeFromFreq = computeMedianFontSizeFromFreq; exports.detectHeadings = detectHeadings; exports.detectMarkerHeadings = detectMarkerHeadings; exports.detectTableCaptions = detectTableCaptions; exports.detectKoreanListBlocks = detectKoreanListBlocks; exports.removeHeaderFooterBlocks = removeHeaderFooterBlocks; exports.extractPageBlocksWithLines = extractPageBlocksWithLines; exports.mergeCrossPageTables = mergeCrossPageTables;
|
|
3374
|
-
//# sourceMappingURL=chunk-
|
|
3568
|
+
//# sourceMappingURL=chunk-SHYF2BB2.cjs.map
|