@claritylabs/cl-sdk 3.0.14 → 3.0.15
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 +23 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +23 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2700,7 +2700,7 @@ function isDiscardableBoilerplate(text, unit) {
|
|
|
2700
2700
|
}
|
|
2701
2701
|
function isBoilerplateLine(line) {
|
|
2702
2702
|
const cleaned = normalizeWhitespace(line.replace(/\bColumn\s+\d+:\s*/gi, ""));
|
|
2703
|
-
return isDiscardableBoilerplate(cleaned) || /^
|
|
2703
|
+
return isDiscardableBoilerplate(cleaned) || /^THIS IS A CLAIMS-MADE AND REPORTED POLICY\.? PLEASE READ IT CAREFULLY\.?$/i.test(cleaned);
|
|
2704
2704
|
}
|
|
2705
2705
|
function removedBoilerplateLines(text) {
|
|
2706
2706
|
return text.split(/\s{2,}|\r?\n/).map(normalizeWhitespace).filter((line) => line && isBoilerplateLine(line));
|
|
@@ -2999,7 +2999,18 @@ function metadataString(metadata, key) {
|
|
|
2999
2999
|
}
|
|
3000
3000
|
function isTitleContentNode(node) {
|
|
3001
3001
|
if (node.kind !== "text") return false;
|
|
3002
|
-
|
|
3002
|
+
const isMarkedTitle = metadataString(node.metadata, "elementType") === "title" || metadataString(node.metadata, "sourceUnit") === "title";
|
|
3003
|
+
if (!isMarkedTitle) return false;
|
|
3004
|
+
const text = normalizeWhitespace2(node.textExcerpt ?? node.title);
|
|
3005
|
+
if (!text || text.length > 140) return false;
|
|
3006
|
+
const words = text.split(/\s+/);
|
|
3007
|
+
if (words.length > 14) return false;
|
|
3008
|
+
const startsWithStructuredHeading = /^(section|item|part|coverage part|endorsement|schedule|article)\b|^[A-Z]\.\s|\b[IVX]+\.\s/i.test(text);
|
|
3009
|
+
const uppercaseLetters = [...text].filter((char) => /[A-Z]/.test(char)).length;
|
|
3010
|
+
const lowercaseLetters = [...text].filter((char) => /[a-z]/.test(char)).length;
|
|
3011
|
+
const mostlyUppercase = uppercaseLetters > 0 && uppercaseLetters >= lowercaseLetters * 1.6;
|
|
3012
|
+
const sentenceLike = /\b(is|are|was|were|will|shall|may|must|means|includes|provided|subject|available|attached|remain|constitutes)\b/i.test(text) && /[a-z]/.test(text);
|
|
3013
|
+
return startsWithStructuredHeading || mostlyUppercase && !sentenceLike;
|
|
3003
3014
|
}
|
|
3004
3015
|
function nodePageEnd(node) {
|
|
3005
3016
|
return node.pageEnd ?? node.pageStart;
|
|
@@ -3039,10 +3050,10 @@ function groupPageContentByTitles(nodes) {
|
|
|
3039
3050
|
const bbox = evidenceNodes.flatMap((node) => node.bbox ?? []).slice(0, 12);
|
|
3040
3051
|
byId.set(activeTitle.id, {
|
|
3041
3052
|
...activeTitle,
|
|
3042
|
-
kind: "
|
|
3053
|
+
kind: "text",
|
|
3043
3054
|
title,
|
|
3044
3055
|
description: nodeTextDescription({
|
|
3045
|
-
kind: "
|
|
3056
|
+
kind: "text",
|
|
3046
3057
|
title,
|
|
3047
3058
|
text: evidenceNodes.map((node) => node.textExcerpt).filter(Boolean).join("\n\n"),
|
|
3048
3059
|
page: activeTitle.pageStart
|
|
@@ -9599,6 +9610,7 @@ function looksLikeDeclarationsContinuation(node) {
|
|
|
9599
9610
|
function looksLikePolicyFormStart(node) {
|
|
9600
9611
|
const text = sourceNodeText(node);
|
|
9601
9612
|
const excerpt = cleanText(node.textExcerpt, "");
|
|
9613
|
+
if (isAdministrativeNoticeNode(node) || looksLikeDeclarationsStart(node)) return false;
|
|
9602
9614
|
return /\bpolicy form\b/i.test(node.title) || /^policy\s+form\b/i.test(excerpt) || /\btechnology errors?\s*&?\s*omissions\b/i.test(text) && /\bplease read this entire policy carefully\b/i.test(text) || /\bform\s+[A-Z]{2,}-[A-Z0-9-]+\s+\d{2}\s+\d{2}\b/i.test(text);
|
|
9603
9615
|
}
|
|
9604
9616
|
function looksLikePolicyFormContinuation(node) {
|
|
@@ -9607,9 +9619,9 @@ function looksLikePolicyFormContinuation(node) {
|
|
|
9607
9619
|
return /\b(insuring agreement|definitions?|exclusions?|conditions?|claim means|insured means|wrongful act means|limits of liability|notice of claim|cancellation by|action against the company)\b/i.test(text);
|
|
9608
9620
|
}
|
|
9609
9621
|
function groupAdjacentChildren(params) {
|
|
9610
|
-
if (params.childIds.length <
|
|
9622
|
+
if (params.childIds.length < 1) return params.sourceTree;
|
|
9611
9623
|
const children = params.childIds.map((id2) => params.children.find((child) => child.id === id2)).filter((child) => Boolean(child));
|
|
9612
|
-
if (children.length <
|
|
9624
|
+
if (children.length < 1) return params.sourceTree;
|
|
9613
9625
|
const parentId = children[0].parentId;
|
|
9614
9626
|
if (!children.every((child) => child.parentId === parentId)) return params.sourceTree;
|
|
9615
9627
|
const documentId = children[0].documentId;
|
|
@@ -9718,6 +9730,11 @@ function applySemanticPageGrouping(sourceTree) {
|
|
|
9718
9730
|
for (let index = policyStartIndex; index < children.length; index += 1) {
|
|
9719
9731
|
const child = children[index];
|
|
9720
9732
|
if (index > policyStartIndex && looksLikeEndorsementStart(child)) break;
|
|
9733
|
+
if (isAdministrativeNoticeNode(child) || looksLikeDeclarationsStart(child)) break;
|
|
9734
|
+
if (index > policyStartIndex && child.kind === "page") {
|
|
9735
|
+
policyIds.push(child.id);
|
|
9736
|
+
continue;
|
|
9737
|
+
}
|
|
9721
9738
|
if (!looksLikePolicyFormContinuation(child)) break;
|
|
9722
9739
|
policyIds.push(child.id);
|
|
9723
9740
|
}
|