@heripo/document-processor 0.1.4 → 0.1.6
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.cjs +514 -44
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +131 -10
- package/dist/index.d.ts +131 -10
- package/dist/index.js +513 -44
- package/dist/index.js.map +1 -1
- package/package.json +8 -8
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { LoggerMethods } from '@heripo/logger';
|
|
2
|
-
import { DoclingDocument, DocumentProcessResult, Caption, PageRange, DoclingTextItem, DoclingPictureItem, DoclingTableItem, DoclingGroupItem, ProcessedImage, ProcessedTable, ProcessedFootnote, Chapter } from '@heripo/model';
|
|
2
|
+
import { DoclingDocument, HanjaAssessment, DocumentProcessResult, Caption, PageRange, DoclingTextItem, DoclingPictureItem, DoclingTableItem, DoclingGroupItem, ProcessedImage, ProcessedTable, ProcessedFootnote, Chapter } from '@heripo/model';
|
|
3
3
|
import { LanguageModel } from 'ai';
|
|
4
4
|
import { LLMTokenUsageAggregator, ExtendedTokenUsage } from '@heripo/shared';
|
|
5
5
|
import { z } from 'zod';
|
|
@@ -43,6 +43,11 @@ interface DocumentProcessorOptions {
|
|
|
43
43
|
* Falls back to 'fallbackModel' if not provided.
|
|
44
44
|
*/
|
|
45
45
|
captionParserModel?: LanguageModel;
|
|
46
|
+
/**
|
|
47
|
+
* Model for HanjaQualitySampler - evaluates KCJ character quality in OCR output.
|
|
48
|
+
* Requires vision capabilities. Falls back to 'fallbackModel' if not provided.
|
|
49
|
+
*/
|
|
50
|
+
hanjaQualitySamplerModel?: LanguageModel;
|
|
46
51
|
/**
|
|
47
52
|
* Batch size for TextCleaner text normalization (synchronous processing)
|
|
48
53
|
*/
|
|
@@ -132,6 +137,7 @@ declare class DocumentProcessor {
|
|
|
132
137
|
private readonly validatorModel;
|
|
133
138
|
private readonly visionTocExtractorModel;
|
|
134
139
|
private readonly captionParserModel;
|
|
140
|
+
private readonly hanjaQualitySamplerModel;
|
|
135
141
|
private readonly textCleanerBatchSize;
|
|
136
142
|
private readonly captionParserBatchSize;
|
|
137
143
|
private readonly captionValidatorBatchSize;
|
|
@@ -157,6 +163,18 @@ declare class DocumentProcessor {
|
|
|
157
163
|
* @throws {Error} with name 'AbortError' if aborted
|
|
158
164
|
*/
|
|
159
165
|
private checkAborted;
|
|
166
|
+
/**
|
|
167
|
+
* Assess the quality of KCJ (Hanja) character recognition in the OCR output.
|
|
168
|
+
*
|
|
169
|
+
* Samples pages containing KCJ characters and uses Vision LLM to compare
|
|
170
|
+
* the OCR text against the original page images. Returns an assessment
|
|
171
|
+
* indicating whether the document should be re-parsed with VLM pipeline.
|
|
172
|
+
*
|
|
173
|
+
* @param doclingDoc - Original document extracted from Docling SDK
|
|
174
|
+
* @param outputPath - Path containing pages subdirectory (pages/page_0.png, etc.)
|
|
175
|
+
* @returns Assessment result with severity and recommendation
|
|
176
|
+
*/
|
|
177
|
+
assessHanjaQuality(doclingDoc: DoclingDocument, outputPath: string): Promise<HanjaAssessment>;
|
|
160
178
|
/**
|
|
161
179
|
* Converts DoclingDocument to ProcessedDocument with token usage tracking.
|
|
162
180
|
*
|
|
@@ -722,6 +740,27 @@ declare class PageRangeParser extends VisionLLMComponent {
|
|
|
722
740
|
protected buildUserPrompt(pageNos: number[]): string;
|
|
723
741
|
}
|
|
724
742
|
|
|
743
|
+
/**
|
|
744
|
+
* Single validation issue detected during TOC validation
|
|
745
|
+
*/
|
|
746
|
+
interface TocValidationIssue {
|
|
747
|
+
/**
|
|
748
|
+
* Issue code (V001, V002, etc.)
|
|
749
|
+
*/
|
|
750
|
+
code: string;
|
|
751
|
+
/**
|
|
752
|
+
* Human-readable error message
|
|
753
|
+
*/
|
|
754
|
+
message: string;
|
|
755
|
+
/**
|
|
756
|
+
* Path to the problematic entry (e.g., "[0].children[2]")
|
|
757
|
+
*/
|
|
758
|
+
path: string;
|
|
759
|
+
/**
|
|
760
|
+
* The problematic entry
|
|
761
|
+
*/
|
|
762
|
+
entry: TocEntry;
|
|
763
|
+
}
|
|
725
764
|
/**
|
|
726
765
|
* TocExtractError
|
|
727
766
|
*
|
|
@@ -768,6 +807,12 @@ interface TocValidationOptions {
|
|
|
768
807
|
* Maximum allowed title length (default: 200)
|
|
769
808
|
*/
|
|
770
809
|
maxTitleLength?: number;
|
|
810
|
+
/**
|
|
811
|
+
* Maximum ratio of the first entry's page to total pages (default: 0.3)
|
|
812
|
+
* Used for V007 completeness check - if the first level-1 entry
|
|
813
|
+
* starts beyond max(50, totalPages * ratio), the TOC may be incomplete.
|
|
814
|
+
*/
|
|
815
|
+
maxFirstEntryPageRatio?: number;
|
|
771
816
|
}
|
|
772
817
|
|
|
773
818
|
/**
|
|
@@ -956,7 +1001,7 @@ declare class TocFinder {
|
|
|
956
1001
|
*/
|
|
957
1002
|
private isTableTocLike;
|
|
958
1003
|
/**
|
|
959
|
-
* Expand TOC area to consecutive pages
|
|
1004
|
+
* Expand TOC area to consecutive pages (both backward and forward)
|
|
960
1005
|
*/
|
|
961
1006
|
private expandToConsecutivePages;
|
|
962
1007
|
/**
|
|
@@ -1016,6 +1061,9 @@ interface TocExtractorOptions extends BaseLLMComponentOptions {
|
|
|
1016
1061
|
*
|
|
1017
1062
|
* Uses high-performance LLM to extract structured TOC from Markdown representation.
|
|
1018
1063
|
* Extends TextLLMComponent for standardized LLM call handling.
|
|
1064
|
+
*
|
|
1065
|
+
* When validation fails, automatically retries with correction feedback
|
|
1066
|
+
* up to MAX_VALIDATION_RETRIES times before throwing.
|
|
1019
1067
|
*/
|
|
1020
1068
|
declare class TocExtractor extends TextLLMComponent {
|
|
1021
1069
|
private readonly validationOptions?;
|
|
@@ -1024,21 +1072,34 @@ declare class TocExtractor extends TextLLMComponent {
|
|
|
1024
1072
|
/**
|
|
1025
1073
|
* Extract TOC structure from Markdown
|
|
1026
1074
|
*
|
|
1075
|
+
* When validation fails, retries with correction feedback up to MAX_VALIDATION_RETRIES times.
|
|
1076
|
+
*
|
|
1027
1077
|
* @param markdown - Markdown representation of TOC area
|
|
1028
|
-
* @
|
|
1078
|
+
* @param validationOverrides - Optional overrides for validation options (merged with constructor options)
|
|
1079
|
+
* @returns Object with entries array and token usage array (initial extraction + any corrections)
|
|
1029
1080
|
* @throws {TocParseError} When LLM fails to parse structure
|
|
1030
|
-
* @throws {TocValidationError} When validation fails
|
|
1081
|
+
* @throws {TocValidationError} When validation fails after all retries
|
|
1031
1082
|
*/
|
|
1032
|
-
extract(markdown: string): Promise<{
|
|
1083
|
+
extract(markdown: string, validationOverrides?: Partial<TocValidationOptions>): Promise<{
|
|
1033
1084
|
entries: TocEntry[];
|
|
1034
|
-
|
|
1085
|
+
usages: ExtendedTokenUsage[];
|
|
1035
1086
|
}>;
|
|
1036
1087
|
/**
|
|
1037
|
-
* Validate extracted entries
|
|
1088
|
+
* Validate extracted entries and return error or null
|
|
1089
|
+
*
|
|
1090
|
+
* Unlike validateOrThrow, this returns the error instead of throwing,
|
|
1091
|
+
* allowing the retry loop to handle it.
|
|
1092
|
+
*
|
|
1093
|
+
* @returns TocValidationError if validation fails, null if valid
|
|
1094
|
+
*/
|
|
1095
|
+
private tryValidateEntries;
|
|
1096
|
+
/**
|
|
1097
|
+
* Build correction prompt with validation error feedback
|
|
1038
1098
|
*
|
|
1039
|
-
*
|
|
1099
|
+
* Includes the original markdown, previous extraction result,
|
|
1100
|
+
* validation errors, and guidance for fixing common mistakes.
|
|
1040
1101
|
*/
|
|
1041
|
-
|
|
1102
|
+
protected buildCorrectionPrompt(markdown: string, previousEntries: TocEntry[], issues: TocValidationIssue[]): string;
|
|
1042
1103
|
/**
|
|
1043
1104
|
* Build system prompt for TOC extraction
|
|
1044
1105
|
*/
|
|
@@ -1439,4 +1500,64 @@ declare class ChapterConverter {
|
|
|
1439
1500
|
private buildChapterMap;
|
|
1440
1501
|
}
|
|
1441
1502
|
|
|
1442
|
-
|
|
1503
|
+
/**
|
|
1504
|
+
* HanjaQualitySampler
|
|
1505
|
+
*
|
|
1506
|
+
* Evaluates the quality of KCJ (Chinese/Japanese/Korean) character recognition
|
|
1507
|
+
* in OCR-processed documents. Samples a subset of pages containing KCJ text and
|
|
1508
|
+
* uses Vision LLM to compare the OCR output against the original page images.
|
|
1509
|
+
*
|
|
1510
|
+
* This is used to determine whether a document should be re-parsed using the
|
|
1511
|
+
* VLM pipeline for better KCJ character accuracy.
|
|
1512
|
+
*/
|
|
1513
|
+
declare class HanjaQualitySampler extends VisionLLMComponent {
|
|
1514
|
+
constructor(logger: LoggerMethods, model: LanguageModel, outputPath: string, maxRetries?: number, fallbackModel?: LanguageModel, aggregator?: LLMTokenUsageAggregator, abortSignal?: AbortSignal);
|
|
1515
|
+
/**
|
|
1516
|
+
* Assess the quality of KCJ character recognition in the document
|
|
1517
|
+
*
|
|
1518
|
+
* @param doclingDoc - DoclingDocument to assess
|
|
1519
|
+
* @returns Assessment result indicating whether VLM re-parse is needed
|
|
1520
|
+
*/
|
|
1521
|
+
assess(doclingDoc: DoclingDocument): Promise<HanjaAssessment>;
|
|
1522
|
+
/**
|
|
1523
|
+
* Get the eligible page range after trimming front/back edges.
|
|
1524
|
+
* Returns cutoff values where eligible pages satisfy: pageNo > frontCutoff && pageNo <= backCutoff
|
|
1525
|
+
*/
|
|
1526
|
+
private getEligiblePageRange;
|
|
1527
|
+
/**
|
|
1528
|
+
* Get page numbers that are "image-only" (contain pictures but minimal text).
|
|
1529
|
+
* These pages (e.g., photo plates/도판) are unsuitable for KCJ quality assessment.
|
|
1530
|
+
*/
|
|
1531
|
+
private getImageOnlyPages;
|
|
1532
|
+
/**
|
|
1533
|
+
* Get all pages with substantial text content.
|
|
1534
|
+
* Pages with fewer characters than MIN_TEXT_LENGTH (e.g., page numbers, headers only) are excluded.
|
|
1535
|
+
*/
|
|
1536
|
+
private getTextPages;
|
|
1537
|
+
/**
|
|
1538
|
+
* Select sample pages with highest text density.
|
|
1539
|
+
* Prefers pages in the eligible range (not edge-trimmed) and not image-only.
|
|
1540
|
+
* Falls back to all text pages if filtering leaves too few candidates.
|
|
1541
|
+
*/
|
|
1542
|
+
private selectSamplePages;
|
|
1543
|
+
/**
|
|
1544
|
+
* Evaluate sampled pages using Vision LLM
|
|
1545
|
+
*/
|
|
1546
|
+
private evaluatePages;
|
|
1547
|
+
/**
|
|
1548
|
+
* Evaluate a single page by comparing OCR text against the page image
|
|
1549
|
+
*/
|
|
1550
|
+
private evaluateSinglePage;
|
|
1551
|
+
/**
|
|
1552
|
+
* Aggregate individual page results into final assessment
|
|
1553
|
+
*/
|
|
1554
|
+
private aggregateResults;
|
|
1555
|
+
/**
|
|
1556
|
+
* Get page number from a text item
|
|
1557
|
+
*/
|
|
1558
|
+
private getPageNo;
|
|
1559
|
+
protected buildSystemPrompt(): string;
|
|
1560
|
+
protected buildUserPrompt(ocrText: string): string;
|
|
1561
|
+
}
|
|
1562
|
+
|
|
1563
|
+
export { BaseLLMComponent, type BaseLLMComponentOptions, BaseValidator, type BaseValidatorOptions, CONTINUATION_MARKERS, CaptionParseError, CaptionParser, type CaptionParserOptions, CaptionValidationError, CaptionValidator, type CaptionValidatorOptions, ChapterConverter, DocumentProcessor, type DocumentProcessorOptions, HanjaQualitySampler, type ImageContent, PAGE_NUMBER_PATTERN, PagePattern, PageRangeParseError, PageRangeParser, type PageSizeGroup, TOC_KEYWORDS, TextLLMComponent, type TocAreaResult, type TocContentValidationResult, TocContentValidationSchema, TocContentValidator, type TocContentValidatorOptions, type TocEntry, TocEntrySchema, TocExtractError, TocExtractor, type TocExtractorOptions, TocFinder, type TocFinderOptions, TocNotFoundError, TocParseError, type TocResponse, TocResponseSchema, VisionLLMComponent, type VisionLLMComponentOptions, type VisionTocExtractionResult, VisionTocExtractionSchema, VisionTocExtractor, type VisionTocExtractorOptions };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { LoggerMethods } from '@heripo/logger';
|
|
2
|
-
import { DoclingDocument, DocumentProcessResult, Caption, PageRange, DoclingTextItem, DoclingPictureItem, DoclingTableItem, DoclingGroupItem, ProcessedImage, ProcessedTable, ProcessedFootnote, Chapter } from '@heripo/model';
|
|
2
|
+
import { DoclingDocument, HanjaAssessment, DocumentProcessResult, Caption, PageRange, DoclingTextItem, DoclingPictureItem, DoclingTableItem, DoclingGroupItem, ProcessedImage, ProcessedTable, ProcessedFootnote, Chapter } from '@heripo/model';
|
|
3
3
|
import { LanguageModel } from 'ai';
|
|
4
4
|
import { LLMTokenUsageAggregator, ExtendedTokenUsage } from '@heripo/shared';
|
|
5
5
|
import { z } from 'zod';
|
|
@@ -43,6 +43,11 @@ interface DocumentProcessorOptions {
|
|
|
43
43
|
* Falls back to 'fallbackModel' if not provided.
|
|
44
44
|
*/
|
|
45
45
|
captionParserModel?: LanguageModel;
|
|
46
|
+
/**
|
|
47
|
+
* Model for HanjaQualitySampler - evaluates KCJ character quality in OCR output.
|
|
48
|
+
* Requires vision capabilities. Falls back to 'fallbackModel' if not provided.
|
|
49
|
+
*/
|
|
50
|
+
hanjaQualitySamplerModel?: LanguageModel;
|
|
46
51
|
/**
|
|
47
52
|
* Batch size for TextCleaner text normalization (synchronous processing)
|
|
48
53
|
*/
|
|
@@ -132,6 +137,7 @@ declare class DocumentProcessor {
|
|
|
132
137
|
private readonly validatorModel;
|
|
133
138
|
private readonly visionTocExtractorModel;
|
|
134
139
|
private readonly captionParserModel;
|
|
140
|
+
private readonly hanjaQualitySamplerModel;
|
|
135
141
|
private readonly textCleanerBatchSize;
|
|
136
142
|
private readonly captionParserBatchSize;
|
|
137
143
|
private readonly captionValidatorBatchSize;
|
|
@@ -157,6 +163,18 @@ declare class DocumentProcessor {
|
|
|
157
163
|
* @throws {Error} with name 'AbortError' if aborted
|
|
158
164
|
*/
|
|
159
165
|
private checkAborted;
|
|
166
|
+
/**
|
|
167
|
+
* Assess the quality of KCJ (Hanja) character recognition in the OCR output.
|
|
168
|
+
*
|
|
169
|
+
* Samples pages containing KCJ characters and uses Vision LLM to compare
|
|
170
|
+
* the OCR text against the original page images. Returns an assessment
|
|
171
|
+
* indicating whether the document should be re-parsed with VLM pipeline.
|
|
172
|
+
*
|
|
173
|
+
* @param doclingDoc - Original document extracted from Docling SDK
|
|
174
|
+
* @param outputPath - Path containing pages subdirectory (pages/page_0.png, etc.)
|
|
175
|
+
* @returns Assessment result with severity and recommendation
|
|
176
|
+
*/
|
|
177
|
+
assessHanjaQuality(doclingDoc: DoclingDocument, outputPath: string): Promise<HanjaAssessment>;
|
|
160
178
|
/**
|
|
161
179
|
* Converts DoclingDocument to ProcessedDocument with token usage tracking.
|
|
162
180
|
*
|
|
@@ -722,6 +740,27 @@ declare class PageRangeParser extends VisionLLMComponent {
|
|
|
722
740
|
protected buildUserPrompt(pageNos: number[]): string;
|
|
723
741
|
}
|
|
724
742
|
|
|
743
|
+
/**
|
|
744
|
+
* Single validation issue detected during TOC validation
|
|
745
|
+
*/
|
|
746
|
+
interface TocValidationIssue {
|
|
747
|
+
/**
|
|
748
|
+
* Issue code (V001, V002, etc.)
|
|
749
|
+
*/
|
|
750
|
+
code: string;
|
|
751
|
+
/**
|
|
752
|
+
* Human-readable error message
|
|
753
|
+
*/
|
|
754
|
+
message: string;
|
|
755
|
+
/**
|
|
756
|
+
* Path to the problematic entry (e.g., "[0].children[2]")
|
|
757
|
+
*/
|
|
758
|
+
path: string;
|
|
759
|
+
/**
|
|
760
|
+
* The problematic entry
|
|
761
|
+
*/
|
|
762
|
+
entry: TocEntry;
|
|
763
|
+
}
|
|
725
764
|
/**
|
|
726
765
|
* TocExtractError
|
|
727
766
|
*
|
|
@@ -768,6 +807,12 @@ interface TocValidationOptions {
|
|
|
768
807
|
* Maximum allowed title length (default: 200)
|
|
769
808
|
*/
|
|
770
809
|
maxTitleLength?: number;
|
|
810
|
+
/**
|
|
811
|
+
* Maximum ratio of the first entry's page to total pages (default: 0.3)
|
|
812
|
+
* Used for V007 completeness check - if the first level-1 entry
|
|
813
|
+
* starts beyond max(50, totalPages * ratio), the TOC may be incomplete.
|
|
814
|
+
*/
|
|
815
|
+
maxFirstEntryPageRatio?: number;
|
|
771
816
|
}
|
|
772
817
|
|
|
773
818
|
/**
|
|
@@ -956,7 +1001,7 @@ declare class TocFinder {
|
|
|
956
1001
|
*/
|
|
957
1002
|
private isTableTocLike;
|
|
958
1003
|
/**
|
|
959
|
-
* Expand TOC area to consecutive pages
|
|
1004
|
+
* Expand TOC area to consecutive pages (both backward and forward)
|
|
960
1005
|
*/
|
|
961
1006
|
private expandToConsecutivePages;
|
|
962
1007
|
/**
|
|
@@ -1016,6 +1061,9 @@ interface TocExtractorOptions extends BaseLLMComponentOptions {
|
|
|
1016
1061
|
*
|
|
1017
1062
|
* Uses high-performance LLM to extract structured TOC from Markdown representation.
|
|
1018
1063
|
* Extends TextLLMComponent for standardized LLM call handling.
|
|
1064
|
+
*
|
|
1065
|
+
* When validation fails, automatically retries with correction feedback
|
|
1066
|
+
* up to MAX_VALIDATION_RETRIES times before throwing.
|
|
1019
1067
|
*/
|
|
1020
1068
|
declare class TocExtractor extends TextLLMComponent {
|
|
1021
1069
|
private readonly validationOptions?;
|
|
@@ -1024,21 +1072,34 @@ declare class TocExtractor extends TextLLMComponent {
|
|
|
1024
1072
|
/**
|
|
1025
1073
|
* Extract TOC structure from Markdown
|
|
1026
1074
|
*
|
|
1075
|
+
* When validation fails, retries with correction feedback up to MAX_VALIDATION_RETRIES times.
|
|
1076
|
+
*
|
|
1027
1077
|
* @param markdown - Markdown representation of TOC area
|
|
1028
|
-
* @
|
|
1078
|
+
* @param validationOverrides - Optional overrides for validation options (merged with constructor options)
|
|
1079
|
+
* @returns Object with entries array and token usage array (initial extraction + any corrections)
|
|
1029
1080
|
* @throws {TocParseError} When LLM fails to parse structure
|
|
1030
|
-
* @throws {TocValidationError} When validation fails
|
|
1081
|
+
* @throws {TocValidationError} When validation fails after all retries
|
|
1031
1082
|
*/
|
|
1032
|
-
extract(markdown: string): Promise<{
|
|
1083
|
+
extract(markdown: string, validationOverrides?: Partial<TocValidationOptions>): Promise<{
|
|
1033
1084
|
entries: TocEntry[];
|
|
1034
|
-
|
|
1085
|
+
usages: ExtendedTokenUsage[];
|
|
1035
1086
|
}>;
|
|
1036
1087
|
/**
|
|
1037
|
-
* Validate extracted entries
|
|
1088
|
+
* Validate extracted entries and return error or null
|
|
1089
|
+
*
|
|
1090
|
+
* Unlike validateOrThrow, this returns the error instead of throwing,
|
|
1091
|
+
* allowing the retry loop to handle it.
|
|
1092
|
+
*
|
|
1093
|
+
* @returns TocValidationError if validation fails, null if valid
|
|
1094
|
+
*/
|
|
1095
|
+
private tryValidateEntries;
|
|
1096
|
+
/**
|
|
1097
|
+
* Build correction prompt with validation error feedback
|
|
1038
1098
|
*
|
|
1039
|
-
*
|
|
1099
|
+
* Includes the original markdown, previous extraction result,
|
|
1100
|
+
* validation errors, and guidance for fixing common mistakes.
|
|
1040
1101
|
*/
|
|
1041
|
-
|
|
1102
|
+
protected buildCorrectionPrompt(markdown: string, previousEntries: TocEntry[], issues: TocValidationIssue[]): string;
|
|
1042
1103
|
/**
|
|
1043
1104
|
* Build system prompt for TOC extraction
|
|
1044
1105
|
*/
|
|
@@ -1439,4 +1500,64 @@ declare class ChapterConverter {
|
|
|
1439
1500
|
private buildChapterMap;
|
|
1440
1501
|
}
|
|
1441
1502
|
|
|
1442
|
-
|
|
1503
|
+
/**
|
|
1504
|
+
* HanjaQualitySampler
|
|
1505
|
+
*
|
|
1506
|
+
* Evaluates the quality of KCJ (Chinese/Japanese/Korean) character recognition
|
|
1507
|
+
* in OCR-processed documents. Samples a subset of pages containing KCJ text and
|
|
1508
|
+
* uses Vision LLM to compare the OCR output against the original page images.
|
|
1509
|
+
*
|
|
1510
|
+
* This is used to determine whether a document should be re-parsed using the
|
|
1511
|
+
* VLM pipeline for better KCJ character accuracy.
|
|
1512
|
+
*/
|
|
1513
|
+
declare class HanjaQualitySampler extends VisionLLMComponent {
|
|
1514
|
+
constructor(logger: LoggerMethods, model: LanguageModel, outputPath: string, maxRetries?: number, fallbackModel?: LanguageModel, aggregator?: LLMTokenUsageAggregator, abortSignal?: AbortSignal);
|
|
1515
|
+
/**
|
|
1516
|
+
* Assess the quality of KCJ character recognition in the document
|
|
1517
|
+
*
|
|
1518
|
+
* @param doclingDoc - DoclingDocument to assess
|
|
1519
|
+
* @returns Assessment result indicating whether VLM re-parse is needed
|
|
1520
|
+
*/
|
|
1521
|
+
assess(doclingDoc: DoclingDocument): Promise<HanjaAssessment>;
|
|
1522
|
+
/**
|
|
1523
|
+
* Get the eligible page range after trimming front/back edges.
|
|
1524
|
+
* Returns cutoff values where eligible pages satisfy: pageNo > frontCutoff && pageNo <= backCutoff
|
|
1525
|
+
*/
|
|
1526
|
+
private getEligiblePageRange;
|
|
1527
|
+
/**
|
|
1528
|
+
* Get page numbers that are "image-only" (contain pictures but minimal text).
|
|
1529
|
+
* These pages (e.g., photo plates/도판) are unsuitable for KCJ quality assessment.
|
|
1530
|
+
*/
|
|
1531
|
+
private getImageOnlyPages;
|
|
1532
|
+
/**
|
|
1533
|
+
* Get all pages with substantial text content.
|
|
1534
|
+
* Pages with fewer characters than MIN_TEXT_LENGTH (e.g., page numbers, headers only) are excluded.
|
|
1535
|
+
*/
|
|
1536
|
+
private getTextPages;
|
|
1537
|
+
/**
|
|
1538
|
+
* Select sample pages with highest text density.
|
|
1539
|
+
* Prefers pages in the eligible range (not edge-trimmed) and not image-only.
|
|
1540
|
+
* Falls back to all text pages if filtering leaves too few candidates.
|
|
1541
|
+
*/
|
|
1542
|
+
private selectSamplePages;
|
|
1543
|
+
/**
|
|
1544
|
+
* Evaluate sampled pages using Vision LLM
|
|
1545
|
+
*/
|
|
1546
|
+
private evaluatePages;
|
|
1547
|
+
/**
|
|
1548
|
+
* Evaluate a single page by comparing OCR text against the page image
|
|
1549
|
+
*/
|
|
1550
|
+
private evaluateSinglePage;
|
|
1551
|
+
/**
|
|
1552
|
+
* Aggregate individual page results into final assessment
|
|
1553
|
+
*/
|
|
1554
|
+
private aggregateResults;
|
|
1555
|
+
/**
|
|
1556
|
+
* Get page number from a text item
|
|
1557
|
+
*/
|
|
1558
|
+
private getPageNo;
|
|
1559
|
+
protected buildSystemPrompt(): string;
|
|
1560
|
+
protected buildUserPrompt(ocrText: string): string;
|
|
1561
|
+
}
|
|
1562
|
+
|
|
1563
|
+
export { BaseLLMComponent, type BaseLLMComponentOptions, BaseValidator, type BaseValidatorOptions, CONTINUATION_MARKERS, CaptionParseError, CaptionParser, type CaptionParserOptions, CaptionValidationError, CaptionValidator, type CaptionValidatorOptions, ChapterConverter, DocumentProcessor, type DocumentProcessorOptions, HanjaQualitySampler, type ImageContent, PAGE_NUMBER_PATTERN, PagePattern, PageRangeParseError, PageRangeParser, type PageSizeGroup, TOC_KEYWORDS, TextLLMComponent, type TocAreaResult, type TocContentValidationResult, TocContentValidationSchema, TocContentValidator, type TocContentValidatorOptions, type TocEntry, TocEntrySchema, TocExtractError, TocExtractor, type TocExtractorOptions, TocFinder, type TocFinderOptions, TocNotFoundError, TocParseError, type TocResponse, TocResponseSchema, VisionLLMComponent, type VisionLLMComponentOptions, type VisionTocExtractionResult, VisionTocExtractionSchema, VisionTocExtractor, type VisionTocExtractorOptions };
|