@heripo/pdf-parser 0.1.26 → 0.1.28
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.ko.md +8 -8
- package/README.md +8 -8
- package/dist/index.cjs +4115 -385
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +42 -4
- package/dist/index.d.ts +42 -4
- package/dist/index.js +4098 -371
- package/dist/index.js.map +1 -1
- package/package.json +11 -11
package/README.ko.md
CHANGED
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
## 주요 기능
|
|
36
36
|
|
|
37
37
|
- **고품질 OCR**: Docling SDK를 활용한 문서 인식 (ocrmac / Apple Vision Framework)
|
|
38
|
-
-
|
|
38
|
+
- **한국어 보고서 VLM 보정**: 한국어 보고서를 자동 감지하고 모든 페이지에 VLM 텍스트 보정을 적용
|
|
39
39
|
- **Apple Silicon 최적화**: M1/M2/M3/M4/M5 칩에서 GPU 가속 지원
|
|
40
40
|
- **자동 환경 설정**: Python 가상환경 및 docling-serve 자동 설치
|
|
41
41
|
- **이미지 추출**: PDF 내 이미지 자동 추출 및 저장
|
|
@@ -233,16 +233,16 @@ await pdfParser.dispose();
|
|
|
233
233
|
|
|
234
234
|
**ocrmac(Apple Vision Framework)은 매우 우수한 OCR 엔진입니다** -- 무료이고, GPU 가속을 지원하며, 고품질 결과를 제공합니다. 수천~수백만 권의 고고학 보고서를 처리할 때 이만한 솔루션이 없습니다.
|
|
235
235
|
|
|
236
|
-
**그러나
|
|
236
|
+
**그러나 한국어 고고학 보고서는 문자 체계 인식 보정이 자주 필요합니다.** 한자 복원, CJK mojibake, 음독 치환, 기관명 등은 표준 OCR만으로 안정적으로 처리하기 어렵습니다. VLM을 기본 OCR 엔진으로 쓰는 대신, 빠른 ocrmac 파이프라인을 먼저 실행한 뒤 한국어 보고서에 VLM 텍스트 보정을 적용합니다.
|
|
237
237
|
|
|
238
|
-
### 2단계 감지 (`OcrStrategySampler`)
|
|
238
|
+
### 2단계 한국어 감지 (`OcrStrategySampler`)
|
|
239
239
|
|
|
240
|
-
1. **텍스트 레이어 사전 검사** (비용 없음): `pdftotext`로 문서의 텍스트 레이어를 추출하여
|
|
241
|
-
2. **VLM 샘플링** (필요 시에만): 최대 15페이지를 샘플링(앞뒤 10%는 표지·부록으로 제외)하여 Vision LLM으로
|
|
240
|
+
1. **텍스트 레이어 사전 검사** (비용 없음): `pdftotext`로 문서의 텍스트 레이어를 추출하여 한글을 확인합니다. 한글이 있으면 즉시 한국어 문서로 판별합니다.
|
|
241
|
+
2. **VLM 샘플링** (필요 시에만): 최대 15페이지를 샘플링(앞뒤 10%는 표지·부록으로 제외)하여 Vision LLM으로 언어를 판정합니다. `ko-KR` 감지 시 즉시 종료합니다.
|
|
242
242
|
|
|
243
|
-
###
|
|
243
|
+
### 전체 문서 보정 (`VlmTextCorrector`)
|
|
244
244
|
|
|
245
|
-
|
|
245
|
+
한국어 보고서가 감지되면, 모든 페이지를 VLM에 전송하여 보정합니다:
|
|
246
246
|
|
|
247
247
|
- 각 페이지의 OCR 텍스트 요소와 표 셀을 추출
|
|
248
248
|
- `pdftotext` 참조 텍스트를 품질 기준으로 활용
|
|
@@ -261,7 +261,7 @@ const tokenUsageReport = await pdfParser.parse(
|
|
|
261
261
|
// OCR 전략 샘플링 활성화 (Vision LLM 모델 제공)
|
|
262
262
|
strategySamplerModel: openai('gpt-5.1'),
|
|
263
263
|
|
|
264
|
-
// VLM 텍스트 보정 모델 (
|
|
264
|
+
// VLM 텍스트 보정 모델 (한국어 보고서 감지 시 필요)
|
|
265
265
|
vlmProcessorModel: openai('gpt-5.1'),
|
|
266
266
|
|
|
267
267
|
// VLM 페이지 처리 동시성 (기본값: 1)
|
package/README.md
CHANGED
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
## Key Features
|
|
36
36
|
|
|
37
37
|
- **High-Quality OCR**: Document recognition using Docling SDK (ocrmac / Apple Vision Framework)
|
|
38
|
-
- **
|
|
38
|
+
- **Korean Report VLM Correction**: Automatically detects Korean reports and applies VLM text correction to all pages
|
|
39
39
|
- **Apple Silicon Optimized**: GPU acceleration on M1/M2/M3/M4/M5 chips
|
|
40
40
|
- **Automatic Environment Setup**: Automatic Python virtual environment and docling-serve installation
|
|
41
41
|
- **Image Extraction**: Automatic extraction and saving of images from PDFs
|
|
@@ -233,16 +233,16 @@ await pdfParser.dispose();
|
|
|
233
233
|
|
|
234
234
|
**ocrmac (Apple Vision Framework) is an excellent OCR engine** -- it's free, GPU-accelerated, and delivers high-quality results. For processing thousands to millions of archaeological reports, there's no better solution.
|
|
235
235
|
|
|
236
|
-
**However,
|
|
236
|
+
**However, Korean archaeological reports often need script-aware correction.** Hanja restoration, CJK mojibake, phonetic substitutions, and institution names can be unreliable with standard OCR alone. Rather than using VLM as the primary OCR engine, the system runs the fast ocrmac pipeline first and then applies VLM text correction to Korean reports.
|
|
237
237
|
|
|
238
|
-
### Two-Stage Detection (`OcrStrategySampler`)
|
|
238
|
+
### Two-Stage Korean Detection (`OcrStrategySampler`)
|
|
239
239
|
|
|
240
|
-
1. **Text Layer Pre-Check** (zero cost): Extracts the document's text layer using `pdftotext` and checks for
|
|
241
|
-
2. **VLM Sampling** (only when needed): Samples up to 15 pages (trimming 10% from front/back to skip covers and appendices) and analyzes them with a Vision LLM. Uses early exit
|
|
240
|
+
1. **Text Layer Pre-Check** (zero cost): Extracts the document's text layer using `pdftotext` and checks for Hangul. If Hangul is present, the document is immediately treated as Korean.
|
|
241
|
+
2. **VLM Sampling** (only when needed): Samples up to 15 pages (trimming 10% from front/back to skip covers and appendices) and analyzes them with a Vision LLM. Uses early exit when `ko-KR` is detected.
|
|
242
242
|
|
|
243
|
-
###
|
|
243
|
+
### Full-Document Correction (`VlmTextCorrector`)
|
|
244
244
|
|
|
245
|
-
When
|
|
245
|
+
When a Korean report is detected, every page is sent to the VLM for correction:
|
|
246
246
|
|
|
247
247
|
- Extracts OCR text elements and table cells from each page
|
|
248
248
|
- Uses `pdftotext` reference text as a quality anchor
|
|
@@ -261,7 +261,7 @@ const tokenUsageReport = await pdfParser.parse(
|
|
|
261
261
|
// Enable OCR strategy sampling (provide a Vision LLM model)
|
|
262
262
|
strategySamplerModel: openai('gpt-5.1'),
|
|
263
263
|
|
|
264
|
-
// VLM model for text correction (required when
|
|
264
|
+
// VLM model for text correction (required when Korean reports are detected)
|
|
265
265
|
vlmProcessorModel: openai('gpt-5.1'),
|
|
266
266
|
|
|
267
267
|
// Concurrency for VLM page processing (default: 1)
|