@claritylabs/cl-sdk 3.1.6 → 3.1.7
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/dist/index.js +7 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +7 -10
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -11387,7 +11387,6 @@ Return JSON for the operational profile.`;
|
|
|
11387
11387
|
var VISUAL_TABLE_REPAIR_MAX_TABLES = 4;
|
|
11388
11388
|
var VISUAL_TABLE_REPAIR_MAX_ROWS = 28;
|
|
11389
11389
|
var VISUAL_TABLE_REPAIR_MAX_CELLS = 140;
|
|
11390
|
-
var VISUAL_TABLE_REPAIR_KEYWORDS = /\b(coverage|limit|limits?|deductible|retroactive|premium|tax|fee|sublimit|sub-limit|aggregate|claim|occurrence|retention|declarations?)\b/i;
|
|
11391
11390
|
function isSourceTreeHeaderRow(row) {
|
|
11392
11391
|
return row.metadata?.isHeader === true || row.metadata?.isHeader === "true";
|
|
11393
11392
|
}
|
|
@@ -11433,13 +11432,11 @@ function primaryHeaderColumnCount(rows) {
|
|
|
11433
11432
|
if (header) return header.cells.length;
|
|
11434
11433
|
return Math.max(0, ...rows.map(({ cells }) => cells.length));
|
|
11435
11434
|
}
|
|
11436
|
-
function
|
|
11435
|
+
function visualTableRepairScore(candidate) {
|
|
11437
11436
|
const rows = candidate.rows;
|
|
11438
|
-
if (rows.length < 3) return
|
|
11439
|
-
const tableText = rows.map(({ row, cells }) => tableRowTextForPrompt(row, cells)).join(" ");
|
|
11440
|
-
if (!VISUAL_TABLE_REPAIR_KEYWORDS.test(tableText)) return false;
|
|
11437
|
+
if (rows.length < 3) return 0;
|
|
11441
11438
|
const headerCount = primaryHeaderColumnCount(rows);
|
|
11442
|
-
if (headerCount < 2) return
|
|
11439
|
+
if (headerCount < 2) return 0;
|
|
11443
11440
|
const firstHeaderIndex = rows.findIndex(({ row, cells }) => isSourceTreeHeaderRow(row) && cells.length > 1);
|
|
11444
11441
|
const repeatedHeader = firstHeaderIndex >= 0 && rows.some(({ row }, index) => index > firstHeaderIndex && isSourceTreeHeaderRow(row));
|
|
11445
11442
|
const shortContinuation = rows.some(
|
|
@@ -11451,7 +11448,7 @@ function shouldRepairVisualTable(candidate) {
|
|
|
11451
11448
|
const danglingSlash = rows.some(
|
|
11452
11449
|
({ row, cells }) => !isSourceTreeHeaderRow(row) && /\/\s*$/.test(tableRowTextForPrompt(row, cells))
|
|
11453
11450
|
);
|
|
11454
|
-
return repeatedHeader
|
|
11451
|
+
return (repeatedHeader ? 4 : 0) + (danglingSlash ? 3 : 0) + (shortContinuation ? 3 : 0) + (genericDataLabels ? 2 : 0);
|
|
11455
11452
|
}
|
|
11456
11453
|
function visualTableCandidates(sourceTree) {
|
|
11457
11454
|
const byParent = nodesByParent(sourceTree);
|
|
@@ -11459,9 +11456,9 @@ function visualTableCandidates(sourceTree) {
|
|
|
11459
11456
|
table,
|
|
11460
11457
|
page: table.pageStart,
|
|
11461
11458
|
rows: tableRowsWithCells(table, byParent)
|
|
11462
|
-
})).filter(
|
|
11463
|
-
(left, right) => left.page - right.page || left.table.order - right.table.order || left.table.id.localeCompare(right.table.id)
|
|
11464
|
-
).slice(0, VISUAL_TABLE_REPAIR_MAX_TABLES);
|
|
11459
|
+
})).map((candidate) => ({ ...candidate, repairScore: visualTableRepairScore(candidate) })).filter((candidate) => candidate.repairScore > 0).sort(
|
|
11460
|
+
(left, right) => right.repairScore - left.repairScore || left.page - right.page || left.table.order - right.table.order || left.table.id.localeCompare(right.table.id)
|
|
11461
|
+
).slice(0, VISUAL_TABLE_REPAIR_MAX_TABLES).map(({ repairScore: _repairScore, ...candidate }) => candidate);
|
|
11465
11462
|
}
|
|
11466
11463
|
function compactVisualTableCandidate(candidate) {
|
|
11467
11464
|
let cellCount = 0;
|