@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 CHANGED
@@ -35,7 +35,7 @@
35
35
  ## 주요 기능
36
36
 
37
37
  - **고품질 OCR**: Docling SDK를 활용한 문서 인식 (ocrmac / Apple Vision Framework)
38
- - **혼합 문자 자동 감지 및 보정**: 한글·한자 혼용 페이지를 자동 감지하여 VLM으로 보정
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
- **그러나 ocrmac은 혼합 문자 체계를 처리하지 못합니다.** 한글·한자 혼용 문서(그리고 잠재적으로 다른 혼합 문자 조합)에서 보조 문자가 깨진 텍스트로 변환됩니다. 전체 파이프라인을 비용이 높은 VLM으로 전환하는 대신, **문제가 있는 페이지만 타겟팅**하여 VLM으로 보정합니다.
236
+ **그러나 한국어 고고학 보고서는 문자 체계 인식 보정이 자주 필요합니다.** 한자 복원, CJK mojibake, 음독 치환, 기관명 등은 표준 OCR만으로 안정적으로 처리하기 어렵습니다. VLM을 기본 OCR 엔진으로 쓰는 대신, 빠른 ocrmac 파이프라인을 먼저 실행한 뒤 한국어 보고서에 VLM 텍스트 보정을 적용합니다.
237
237
 
238
- ### 2단계 감지 (`OcrStrategySampler`)
238
+ ### 2단계 한국어 감지 (`OcrStrategySampler`)
239
239
 
240
- 1. **텍스트 레이어 사전 검사** (비용 없음): `pdftotext`로 문서의 텍스트 레이어를 추출하여 한글과 CJK 문자가 모두 존재하는지 확인합니다. 둘 다 존재하면 즉시 혼합 문자 문서로 판별합니다.
241
- 2. **VLM 샘플링** (필요 시에만): 최대 15페이지를 샘플링(앞뒤 10%는 표지·부록으로 제외)하여 Vision LLM으로 분석합니다. 최초 한글·한자 혼용 감지 시 즉시 종료하여 API 비용을 최소화합니다.
240
+ 1. **텍스트 레이어 사전 검사** (비용 없음): `pdftotext`로 문서의 텍스트 레이어를 추출하여 한글을 확인합니다. 한글이 있으면 즉시 한국어 문서로 판별합니다.
241
+ 2. **VLM 샘플링** (필요 시에만): 최대 15페이지를 샘플링(앞뒤 10%는 표지·부록으로 제외)하여 Vision LLM으로 언어를 판정합니다. `ko-KR` 감지 시 즉시 종료합니다.
242
242
 
243
- ### 페이지별 보정 (`VlmTextCorrector`)
243
+ ### 전체 문서 보정 (`VlmTextCorrector`)
244
244
 
245
- 혼합 문자 페이지가 감지되면, 해당 페이지만 VLM에 전송하여 보정합니다:
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
- - **Mixed Script Auto-Detection & Correction**: Automatically detects Korean-Hanja mixed pages and corrects them via VLM
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, ocrmac cannot handle mixed character systems.** Documents containing Korean-Hanja combinations (and potentially other mixed scripts) produce garbled text for the non-primary script. Rather than switching the entire pipeline to a costly VLM, the system **targets only the affected pages** for VLM correction, minimizing cost and processing time.
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 both Hangul and CJK characters. If both are present, the document is immediately flagged as mixed-script.
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 on first Korean-Hanja mix detection to minimize API costs.
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
- ### Per-Page Correction (`VlmTextCorrector`)
243
+ ### Full-Document Correction (`VlmTextCorrector`)
244
244
 
245
- When mixed-script pages are detected, only those pages are sent to the VLM for correction:
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 mixed-script is detected)
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)