ureca_document_parser 0.0.1__tar.gz
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.
- ureca_document_parser-0.0.1/.github/workflows/ci.yml +53 -0
- ureca_document_parser-0.0.1/.github/workflows/docs.yml +27 -0
- ureca_document_parser-0.0.1/.github/workflows/publish.yml +36 -0
- ureca_document_parser-0.0.1/.gitignore +10 -0
- ureca_document_parser-0.0.1/.python-version +1 -0
- ureca_document_parser-0.0.1/CLAUDE.md +143 -0
- ureca_document_parser-0.0.1/PKG-INFO +45 -0
- ureca_document_parser-0.0.1/README.md +0 -0
- ureca_document_parser-0.0.1/docs/api-reference.md +247 -0
- ureca_document_parser-0.0.1/docs/formats/hwp.md +145 -0
- ureca_document_parser-0.0.1/docs/formats/hwpx.md +168 -0
- ureca_document_parser-0.0.1/docs/guides/advanced.md +378 -0
- ureca_document_parser-0.0.1/docs/guides/cli.md +136 -0
- ureca_document_parser-0.0.1/docs/guides/langchain.md +252 -0
- ureca_document_parser-0.0.1/docs/guides/python-api.md +237 -0
- ureca_document_parser-0.0.1/docs/index.md +68 -0
- ureca_document_parser-0.0.1/docs/installation.md +82 -0
- ureca_document_parser-0.0.1/docs/reference/architecture.md +323 -0
- ureca_document_parser-0.0.1/docs/reference/extending.md +208 -0
- ureca_document_parser-0.0.1/document.hwp +0 -0
- ureca_document_parser-0.0.1/mkdocs.yml +71 -0
- ureca_document_parser-0.0.1/output.md +597 -0
- ureca_document_parser-0.0.1/pyproject.toml +71 -0
- ureca_document_parser-0.0.1/src/ureca_document_parser/__init__.py +111 -0
- ureca_document_parser-0.0.1/src/ureca_document_parser/__main__.py +6 -0
- ureca_document_parser-0.0.1/src/ureca_document_parser/cli.py +82 -0
- ureca_document_parser-0.0.1/src/ureca_document_parser/hwp/__init__.py +14 -0
- ureca_document_parser-0.0.1/src/ureca_document_parser/hwp/parser.py +251 -0
- ureca_document_parser-0.0.1/src/ureca_document_parser/hwp/records.py +101 -0
- ureca_document_parser-0.0.1/src/ureca_document_parser/hwp/tables.py +136 -0
- ureca_document_parser-0.0.1/src/ureca_document_parser/hwp/text.py +80 -0
- ureca_document_parser-0.0.1/src/ureca_document_parser/hwpx/__init__.py +3 -0
- ureca_document_parser-0.0.1/src/ureca_document_parser/hwpx/parser.py +273 -0
- ureca_document_parser-0.0.1/src/ureca_document_parser/models.py +77 -0
- ureca_document_parser-0.0.1/src/ureca_document_parser/protocols.py +45 -0
- ureca_document_parser-0.0.1/src/ureca_document_parser/py.typed +0 -0
- ureca_document_parser-0.0.1/src/ureca_document_parser/registry.py +105 -0
- ureca_document_parser-0.0.1/src/ureca_document_parser/styles.py +38 -0
- ureca_document_parser-0.0.1/src/ureca_document_parser/writers/__init__.py +3 -0
- ureca_document_parser-0.0.1/src/ureca_document_parser/writers/markdown.py +178 -0
- ureca_document_parser-0.0.1/tests/__init__.py +0 -0
- ureca_document_parser-0.0.1/tests/conftest.py +91 -0
- ureca_document_parser-0.0.1/tests/test_cli.py +50 -0
- ureca_document_parser-0.0.1/tests/test_hwp_parser.py +132 -0
- ureca_document_parser-0.0.1/tests/test_hwpx_parser.py +76 -0
- ureca_document_parser-0.0.1/tests/test_markdown_writer.py +132 -0
- ureca_document_parser-0.0.1/tests/test_models.py +65 -0
- ureca_document_parser-0.0.1/tests/test_registry.py +113 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [main]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
test:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
strategy:
|
|
13
|
+
matrix:
|
|
14
|
+
python-version: ["3.12", "3.13"]
|
|
15
|
+
|
|
16
|
+
steps:
|
|
17
|
+
- uses: actions/checkout@v4
|
|
18
|
+
|
|
19
|
+
- name: Install uv
|
|
20
|
+
uses: astral-sh/setup-uv@v5
|
|
21
|
+
|
|
22
|
+
- name: Set up Python ${{ matrix.python-version }}
|
|
23
|
+
run: uv python install ${{ matrix.python-version }}
|
|
24
|
+
|
|
25
|
+
- name: Install dependencies
|
|
26
|
+
run: uv sync --extra dev
|
|
27
|
+
|
|
28
|
+
- name: Run tests
|
|
29
|
+
run: uv run pytest tests/ -v --tb=short
|
|
30
|
+
|
|
31
|
+
- name: Run tests with coverage
|
|
32
|
+
run: uv run pytest tests/ --cov=ureca_document_parser --cov-report=term-missing
|
|
33
|
+
|
|
34
|
+
lint:
|
|
35
|
+
runs-on: ubuntu-latest
|
|
36
|
+
|
|
37
|
+
steps:
|
|
38
|
+
- uses: actions/checkout@v4
|
|
39
|
+
|
|
40
|
+
- name: Install uv
|
|
41
|
+
uses: astral-sh/setup-uv@v5
|
|
42
|
+
|
|
43
|
+
- name: Set up Python
|
|
44
|
+
run: uv python install 3.12
|
|
45
|
+
|
|
46
|
+
- name: Install dependencies
|
|
47
|
+
run: uv sync --extra dev
|
|
48
|
+
|
|
49
|
+
- name: Run ruff check
|
|
50
|
+
run: uv run ruff check src/
|
|
51
|
+
|
|
52
|
+
- name: Run ruff format check
|
|
53
|
+
run: uv run ruff format --check src/
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
name: Deploy Docs
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
|
|
7
|
+
permissions:
|
|
8
|
+
contents: write
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
deploy:
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@v4
|
|
16
|
+
|
|
17
|
+
- name: Install uv
|
|
18
|
+
uses: astral-sh/setup-uv@v5
|
|
19
|
+
|
|
20
|
+
- name: Set up Python
|
|
21
|
+
run: uv python install 3.12
|
|
22
|
+
|
|
23
|
+
- name: Install dependencies
|
|
24
|
+
run: uv sync --extra docs
|
|
25
|
+
|
|
26
|
+
- name: Build and deploy docs
|
|
27
|
+
run: uv run mkdocs gh-deploy --force
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [published]
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
publish:
|
|
9
|
+
runs-on: ubuntu-latest
|
|
10
|
+
permissions:
|
|
11
|
+
id-token: write # OIDC for trusted publishing
|
|
12
|
+
|
|
13
|
+
steps:
|
|
14
|
+
- uses: actions/checkout@v4
|
|
15
|
+
|
|
16
|
+
- name: Install uv
|
|
17
|
+
uses: astral-sh/setup-uv@v5
|
|
18
|
+
with:
|
|
19
|
+
enable-cache: true
|
|
20
|
+
|
|
21
|
+
- name: Set up Python
|
|
22
|
+
run: uv python install 3.12
|
|
23
|
+
|
|
24
|
+
- name: Install dependencies
|
|
25
|
+
run: uv sync
|
|
26
|
+
|
|
27
|
+
- name: Run tests
|
|
28
|
+
run: uv run pytest tests/ -v
|
|
29
|
+
|
|
30
|
+
- name: Build package
|
|
31
|
+
run: uv build
|
|
32
|
+
|
|
33
|
+
- name: Publish to PyPI
|
|
34
|
+
run: uv publish
|
|
35
|
+
env:
|
|
36
|
+
UV_PUBLISH_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.12
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
# CLAUDE.md
|
|
2
|
+
|
|
3
|
+
## 프로젝트 개요
|
|
4
|
+
|
|
5
|
+
`ureca_document_parser` — 한국어 워드프로세서(아래한글) HWP/HWPX 파일을 Markdown 또는 LangChain Document 청크로 변환하는 다중 포맷 문서 파서. PyPI 배포 가능한 패키지로, 클린 아키텍처 기반으로 새 포맷 확장이 용이하다.
|
|
6
|
+
|
|
7
|
+
## 명령어
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
uv sync
|
|
11
|
+
uv run ureca_document_parser <file.hwp|file.hwpx> -o <output.md>
|
|
12
|
+
uv run ureca_document_parser --list-formats
|
|
13
|
+
uv run python -m ureca_document_parser <file.hwp> -o <output.md>
|
|
14
|
+
uv run pytest tests/ -v
|
|
15
|
+
uv build
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## 아키텍처
|
|
19
|
+
|
|
20
|
+
**파이프라인**: 입력 파일 → 포맷 레지스트리 → 파서 → Document 모델 → Writer → 출력 (또는 → TextSplitter → LangChain Documents)
|
|
21
|
+
|
|
22
|
+
```
|
|
23
|
+
src/ureca_document_parser/
|
|
24
|
+
├── __init__.py # 공개 API (convert, convert_to_chunks, get_registry)
|
|
25
|
+
├── __main__.py # python -m ureca_document_parser
|
|
26
|
+
├── cli.py # CLI (argparse, 레지스트리 기반 자동 라우팅)
|
|
27
|
+
├── models.py # Document 모델 (Paragraph, Table, Image, ListItem, ...)
|
|
28
|
+
├── protocols.py # Parser / Writer Protocol (구조적 서브타이핑)
|
|
29
|
+
├── registry.py # FormatRegistry (확장자→파서, 포맷명→Writer 매핑, 스레드 안전 싱글톤)
|
|
30
|
+
├── styles.py # 공유 헤딩 패턴
|
|
31
|
+
├── hwp/
|
|
32
|
+
│ ├── __init__.py # HwpParser 및 저수준 타입 re-export
|
|
33
|
+
│ ├── parser.py # HWP v5 바이너리 파서 (olefile) — 오케스트레이션
|
|
34
|
+
│ ├── records.py # 바이너리 레코드 파싱 (Record, RecordCursor, 상수)
|
|
35
|
+
│ ├── text.py # 문자 스캐닝 및 텍스트 추출 (CharInfo, BSTR)
|
|
36
|
+
│ └── tables.py # 3단계 테이블 추출
|
|
37
|
+
├── hwpx/
|
|
38
|
+
│ ├── __init__.py # HwpxParser re-export
|
|
39
|
+
│ └── parser.py # HWPX 파서 (zipfile + xml.etree)
|
|
40
|
+
└── writers/
|
|
41
|
+
└── markdown.py # Markdown 작성기
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### 주요 모듈
|
|
45
|
+
|
|
46
|
+
- **`protocols.py`** — `Parser` / `Writer` Protocol. 상속 없이 정적 메서드 시그니처만 맞추면 된다.
|
|
47
|
+
- **`registry.py`** — `FormatRegistry`가 확장자→파서, 포맷명→Writer를 매핑. `get_registry()`로 스레드 안전 싱글톤 접근.
|
|
48
|
+
- **`models.py`** — 공유 문서 모델. `Document` = `list[DocumentElement]` + `Metadata`. 파싱 실패 시 `ParseError`.
|
|
49
|
+
- **`hwp/`** — HWP v5 바이너리 파서. `records.py`(레코드 스트림), `text.py`(문자 추출), `tables.py`(테이블 파싱), `parser.py`(오케스트레이션)로 분리.
|
|
50
|
+
- **`hwpx/parser.py`** — HWPX (ZIP+XML) 파서. 표준 라이브러리 `xml.etree` 사용.
|
|
51
|
+
- **`writers/markdown.py`** — `Document`를 Markdown으로 변환. 연속 `ListItem`을 하나의 블록으로 그룹핑.
|
|
52
|
+
|
|
53
|
+
### 라이브러리 사용 예시
|
|
54
|
+
|
|
55
|
+
```python
|
|
56
|
+
from ureca_document_parser import convert
|
|
57
|
+
convert("보고서.hwp", "보고서.md")
|
|
58
|
+
|
|
59
|
+
from ureca_document_parser import convert_to_chunks
|
|
60
|
+
chunks = convert_to_chunks("보고서.hwp", chunk_size=1000, chunk_overlap=200)
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## 테스트
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
uv run pytest tests/ -v # 전체 테스트
|
|
67
|
+
uv run pytest tests/ --cov # 커버리지 포함
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
테스트 범위: 모델, 레지스트리, CLI, HWP 파서 (단위 + 통합), HWPX 파서, Markdown 작성기.
|
|
71
|
+
|
|
72
|
+
## 포맷 확장
|
|
73
|
+
|
|
74
|
+
`docs/reference/extending.md` 참고. Protocol에 맞는 파서/Writer 클래스를 작성하고 `registry.py:_auto_register()`에 등록한다.
|
|
75
|
+
|
|
76
|
+
## 의존성
|
|
77
|
+
|
|
78
|
+
필수: `olefile`. 선택: `langchain-text-splitters`+`langchain-core` (청크 분할), `pymupdf` (PDF), `pillow`+`pytesseract` (OCR). 개발: `pytest`, `pytest-cov`, `mypy`, `ruff`.
|
|
79
|
+
|
|
80
|
+
## 문서
|
|
81
|
+
|
|
82
|
+
### 구조
|
|
83
|
+
|
|
84
|
+
```
|
|
85
|
+
docs/
|
|
86
|
+
├── index.md # 홈 — 퀵스타트, 주요 기능
|
|
87
|
+
├── installation.md # 설치 방법 (기본 + 선택적 의존성)
|
|
88
|
+
├── formats/ # 포맷별 상세 가이드
|
|
89
|
+
│ ├── hwp.md # HWP 포맷 (개요 + 파일 구조 + 사용 예시)
|
|
90
|
+
│ └── hwpx.md # HWPX 포맷 (개요 + 파일 구조 + 사용 예시)
|
|
91
|
+
├── guides/ # 사용 가이드
|
|
92
|
+
│ ├── cli.md # CLI 사용법
|
|
93
|
+
│ ├── python-api.md # Python API 기본 사용법
|
|
94
|
+
│ ├── langchain.md # LangChain 연동 (RAG)
|
|
95
|
+
│ └── advanced.md # 고급 사용법 (Document 모델 직접 다루기)
|
|
96
|
+
├── api-reference.md # API 레퍼런스 (convert, convert_to_chunks, get_registry 등, mkdocstrings 자동 생성)
|
|
97
|
+
└── reference/ # 기술 참조 (기여자용)
|
|
98
|
+
├── architecture.md # 내부 아키텍처 (파이프라인, 모듈 의존성, 구현 세부사항)
|
|
99
|
+
└── extending.md # 새 파서/Writer 추가 가이드
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### 작성 규칙
|
|
103
|
+
|
|
104
|
+
- 말투: es-toolkit 스타일 친근한 존댓말 (`~예요`, `~해요`, `~돼요`)
|
|
105
|
+
- 코드와 전용 용어를 제외한 모든 텍스트는 한글로 작성한다.
|
|
106
|
+
- 관점: **외부 프로젝트에 설치해서 쓰는 사용자** 기준. 내부 소스코드를 복붙하지 않는다.
|
|
107
|
+
- CLI 예제는 반드시 `uv run ureca_document_parser ...` 형태로 작성한다.
|
|
108
|
+
- 예제 파일명은 실제 사용 시나리오 기반 (예: `보고서.hwp`, `제안서.hwpx`)
|
|
109
|
+
- 외부 의존성을 언급할 때는 **이름에 공식문서 링크**를 걸고, 바로 아래에 `uv add` 코드블록을 넣는다.
|
|
110
|
+
- `api-reference.md`는 `mkdocstrings`가 docstring에서 자동 생성하므로 최소한의 설명만 작성한다.
|
|
111
|
+
- `docs/reference/` 하위 문서는 기여자(contributor) 또는 깊이 있는 이해가 필요한 사용자 관점으로 작성한다.
|
|
112
|
+
- Mermaid 다이어그램 사용 가능 (mkdocs.yml에 설정 완료)
|
|
113
|
+
- MkDocs admonition 사용 가능: `!!! note`, `!!! info`, `!!! warning`
|
|
114
|
+
|
|
115
|
+
### 빌드 및 미리보기
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
uv sync --extra docs # 문서 의존성 설치
|
|
119
|
+
uv run mkdocs serve # http://127.0.0.1:8000 로컬 미리보기
|
|
120
|
+
uv run mkdocs build # site/ 디렉토리에 정적 파일 빌드
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### 배포
|
|
124
|
+
|
|
125
|
+
배포는 자동이다. `main` 브랜치에 push하면 `.github/workflows/docs.yml`이 실행되어 GitHub Pages에 배포된다.
|
|
126
|
+
|
|
127
|
+
- 워크플로우: `mkdocs gh-deploy --force` → `gh-pages` 브랜치에 push
|
|
128
|
+
- Pages 설정: Source = `gh-pages` 브랜치 (GitHub Settings → Pages)
|
|
129
|
+
- URL: https://ureca-corp.github.io/document_parser/
|
|
130
|
+
|
|
131
|
+
수동 배포가 필요한 경우:
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
uv run mkdocs gh-deploy --force
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### 네비게이션
|
|
138
|
+
|
|
139
|
+
페이지를 추가/삭제하면 `mkdocs.yml`의 `nav:` 섹션을 함께 수정해야 한다.
|
|
140
|
+
|
|
141
|
+
## CI
|
|
142
|
+
|
|
143
|
+
GitHub Actions (`.github/workflows/ci.yml`) — `main` 브랜치 push/PR 시 실행. Python 3.12 + 3.13 테스트 매트릭스, ruff 린트/포맷 검사.
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ureca_document_parser
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: Multi-format document parser and converter (HWP, HWPX, PDF, Image)
|
|
5
|
+
Project-URL: Homepage, https://ureca-corp.github.io/document_parser/
|
|
6
|
+
Project-URL: Documentation, https://ureca-corp.github.io/document_parser/
|
|
7
|
+
Project-URL: Repository, https://github.com/ureca-corp/document_parser
|
|
8
|
+
Project-URL: Issues, https://github.com/ureca-corp/document_parser/issues
|
|
9
|
+
Author-email: Ureca Enterprise Corp <andy@ureca.im>
|
|
10
|
+
License: MIT
|
|
11
|
+
Keywords: converter,document,hwp,hwpx,markdown,parser
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
17
|
+
Classifier: Topic :: Text Processing :: Markup
|
|
18
|
+
Requires-Python: >=3.12
|
|
19
|
+
Requires-Dist: olefile>=0.47
|
|
20
|
+
Provides-Extra: all
|
|
21
|
+
Requires-Dist: langchain-core>=0.2; extra == 'all'
|
|
22
|
+
Requires-Dist: langchain-text-splitters>=0.2; extra == 'all'
|
|
23
|
+
Requires-Dist: mkdocs-material>=9.5; extra == 'all'
|
|
24
|
+
Requires-Dist: mkdocs>=1.6; extra == 'all'
|
|
25
|
+
Requires-Dist: mkdocstrings[python]>=0.27; extra == 'all'
|
|
26
|
+
Requires-Dist: pillow>=10.0; extra == 'all'
|
|
27
|
+
Requires-Dist: pymupdf>=1.24; extra == 'all'
|
|
28
|
+
Requires-Dist: pytesseract>=0.3; extra == 'all'
|
|
29
|
+
Provides-Extra: dev
|
|
30
|
+
Requires-Dist: mypy>=1.10; extra == 'dev'
|
|
31
|
+
Requires-Dist: pytest-cov>=5.0; extra == 'dev'
|
|
32
|
+
Requires-Dist: pytest>=8.0; extra == 'dev'
|
|
33
|
+
Requires-Dist: ruff>=0.4; extra == 'dev'
|
|
34
|
+
Provides-Extra: docs
|
|
35
|
+
Requires-Dist: mkdocs-material>=9.5; extra == 'docs'
|
|
36
|
+
Requires-Dist: mkdocs>=1.6; extra == 'docs'
|
|
37
|
+
Requires-Dist: mkdocstrings[python]>=0.27; extra == 'docs'
|
|
38
|
+
Provides-Extra: langchain
|
|
39
|
+
Requires-Dist: langchain-core>=0.2; extra == 'langchain'
|
|
40
|
+
Requires-Dist: langchain-text-splitters>=0.2; extra == 'langchain'
|
|
41
|
+
Provides-Extra: ocr
|
|
42
|
+
Requires-Dist: pillow>=10.0; extra == 'ocr'
|
|
43
|
+
Requires-Dist: pytesseract>=0.3; extra == 'ocr'
|
|
44
|
+
Provides-Extra: pdf
|
|
45
|
+
Requires-Dist: pymupdf>=1.24; extra == 'pdf'
|
|
File without changes
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
# API 레퍼런스
|
|
2
|
+
|
|
3
|
+
`ureca_document_parser`의 공개 API 문서예요.
|
|
4
|
+
|
|
5
|
+
## 최상위 함수
|
|
6
|
+
|
|
7
|
+
패키지에서 직접 import해서 사용하는 주요 함수들이에요.
|
|
8
|
+
|
|
9
|
+
### convert()
|
|
10
|
+
|
|
11
|
+
파일을 변환해서 저장해요.
|
|
12
|
+
|
|
13
|
+
::: ureca_document_parser.convert
|
|
14
|
+
options:
|
|
15
|
+
heading_level: 3
|
|
16
|
+
show_source: false
|
|
17
|
+
|
|
18
|
+
**예시:**
|
|
19
|
+
|
|
20
|
+
```python
|
|
21
|
+
from ureca_document_parser import convert
|
|
22
|
+
|
|
23
|
+
convert("보고서.hwp", "보고서.md")
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
### convert_to_chunks()
|
|
29
|
+
|
|
30
|
+
파일을 파싱하고 LangChain 청크로 분할해요.
|
|
31
|
+
|
|
32
|
+
!!! note "선택적 의존성 필요"
|
|
33
|
+
이 함수를 사용하려면 `langchain` 추가 의존성이 필요해요.
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
uv add "ureca_document_parser[langchain]"
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
::: ureca_document_parser.convert_to_chunks
|
|
40
|
+
options:
|
|
41
|
+
heading_level: 3
|
|
42
|
+
show_source: false
|
|
43
|
+
|
|
44
|
+
**예시:**
|
|
45
|
+
|
|
46
|
+
```python
|
|
47
|
+
from ureca_document_parser import convert_to_chunks
|
|
48
|
+
|
|
49
|
+
chunks = convert_to_chunks("보고서.hwp", chunk_size=1000, chunk_overlap=200)
|
|
50
|
+
|
|
51
|
+
for chunk in chunks:
|
|
52
|
+
print(chunk.page_content)
|
|
53
|
+
print(chunk.metadata)
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
### get_registry()
|
|
59
|
+
|
|
60
|
+
포맷 레지스트리 싱글톤을 반환해요.
|
|
61
|
+
|
|
62
|
+
::: ureca_document_parser.get_registry
|
|
63
|
+
options:
|
|
64
|
+
heading_level: 3
|
|
65
|
+
show_source: false
|
|
66
|
+
|
|
67
|
+
**예시:**
|
|
68
|
+
|
|
69
|
+
```python
|
|
70
|
+
from ureca_document_parser import get_registry
|
|
71
|
+
|
|
72
|
+
registry = get_registry()
|
|
73
|
+
doc = registry.parse("보고서.hwp")
|
|
74
|
+
markdown = registry.write(doc, "markdown")
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
## Document 모델
|
|
80
|
+
|
|
81
|
+
파싱 결과를 표현하는 데이터 모델이에요.
|
|
82
|
+
|
|
83
|
+
### Document
|
|
84
|
+
|
|
85
|
+
문서 전체를 나타내요.
|
|
86
|
+
|
|
87
|
+
::: ureca_document_parser.Document
|
|
88
|
+
options:
|
|
89
|
+
heading_level: 3
|
|
90
|
+
show_source: false
|
|
91
|
+
members:
|
|
92
|
+
- elements
|
|
93
|
+
- metadata
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
### Metadata
|
|
98
|
+
|
|
99
|
+
문서 메타데이터를 담고 있어요.
|
|
100
|
+
|
|
101
|
+
::: ureca_document_parser.Metadata
|
|
102
|
+
options:
|
|
103
|
+
heading_level: 3
|
|
104
|
+
show_source: false
|
|
105
|
+
|
|
106
|
+
---
|
|
107
|
+
|
|
108
|
+
### Paragraph
|
|
109
|
+
|
|
110
|
+
문단 요소를 나타내요.
|
|
111
|
+
|
|
112
|
+
::: ureca_document_parser.Paragraph
|
|
113
|
+
options:
|
|
114
|
+
heading_level: 3
|
|
115
|
+
show_source: false
|
|
116
|
+
|
|
117
|
+
---
|
|
118
|
+
|
|
119
|
+
### Table
|
|
120
|
+
|
|
121
|
+
표 요소를 나타내요.
|
|
122
|
+
|
|
123
|
+
::: ureca_document_parser.Table
|
|
124
|
+
options:
|
|
125
|
+
heading_level: 3
|
|
126
|
+
show_source: false
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
### TableRow
|
|
131
|
+
|
|
132
|
+
표의 행을 나타내요.
|
|
133
|
+
|
|
134
|
+
::: ureca_document_parser.TableRow
|
|
135
|
+
options:
|
|
136
|
+
heading_level: 3
|
|
137
|
+
show_source: false
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
### TableCell
|
|
142
|
+
|
|
143
|
+
표의 셀을 나타내요.
|
|
144
|
+
|
|
145
|
+
::: ureca_document_parser.TableCell
|
|
146
|
+
options:
|
|
147
|
+
heading_level: 3
|
|
148
|
+
show_source: false
|
|
149
|
+
|
|
150
|
+
---
|
|
151
|
+
|
|
152
|
+
### ListItem
|
|
153
|
+
|
|
154
|
+
리스트 아이템을 나타내요.
|
|
155
|
+
|
|
156
|
+
::: ureca_document_parser.ListItem
|
|
157
|
+
options:
|
|
158
|
+
heading_level: 3
|
|
159
|
+
show_source: false
|
|
160
|
+
|
|
161
|
+
---
|
|
162
|
+
|
|
163
|
+
### Image
|
|
164
|
+
|
|
165
|
+
이미지 요소를 나타내요.
|
|
166
|
+
|
|
167
|
+
::: ureca_document_parser.Image
|
|
168
|
+
options:
|
|
169
|
+
heading_level: 3
|
|
170
|
+
show_source: false
|
|
171
|
+
|
|
172
|
+
---
|
|
173
|
+
|
|
174
|
+
### Link
|
|
175
|
+
|
|
176
|
+
링크 요소를 나타내요.
|
|
177
|
+
|
|
178
|
+
::: ureca_document_parser.Link
|
|
179
|
+
options:
|
|
180
|
+
heading_level: 3
|
|
181
|
+
show_source: false
|
|
182
|
+
|
|
183
|
+
---
|
|
184
|
+
|
|
185
|
+
### HorizontalRule
|
|
186
|
+
|
|
187
|
+
구분선 요소를 나타내요.
|
|
188
|
+
|
|
189
|
+
::: ureca_document_parser.HorizontalRule
|
|
190
|
+
options:
|
|
191
|
+
heading_level: 3
|
|
192
|
+
show_source: false
|
|
193
|
+
|
|
194
|
+
---
|
|
195
|
+
|
|
196
|
+
## 예외
|
|
197
|
+
|
|
198
|
+
### ParseError
|
|
199
|
+
|
|
200
|
+
파싱 실패 시 발생하는 예외예요.
|
|
201
|
+
|
|
202
|
+
::: ureca_document_parser.ParseError
|
|
203
|
+
options:
|
|
204
|
+
heading_level: 3
|
|
205
|
+
show_source: false
|
|
206
|
+
|
|
207
|
+
**예시:**
|
|
208
|
+
|
|
209
|
+
```python
|
|
210
|
+
from ureca_document_parser import get_registry, ParseError
|
|
211
|
+
|
|
212
|
+
registry = get_registry()
|
|
213
|
+
|
|
214
|
+
try:
|
|
215
|
+
doc = registry.parse("손상된파일.hwp")
|
|
216
|
+
except ParseError as e:
|
|
217
|
+
print(f"파싱 실패: {e}")
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
---
|
|
221
|
+
|
|
222
|
+
## Protocol
|
|
223
|
+
|
|
224
|
+
새 파서나 Writer를 추가할 때 구현해야 하는 인터페이스예요. 자세한 내용은 [포맷 확장 가이드](reference/extending.md)를 참고하세요.
|
|
225
|
+
|
|
226
|
+
### Parser
|
|
227
|
+
|
|
228
|
+
::: ureca_document_parser.Parser
|
|
229
|
+
options:
|
|
230
|
+
heading_level: 3
|
|
231
|
+
show_source: false
|
|
232
|
+
|
|
233
|
+
---
|
|
234
|
+
|
|
235
|
+
### Writer
|
|
236
|
+
|
|
237
|
+
::: ureca_document_parser.Writer
|
|
238
|
+
options:
|
|
239
|
+
heading_level: 3
|
|
240
|
+
show_source: false
|
|
241
|
+
|
|
242
|
+
---
|
|
243
|
+
|
|
244
|
+
## 더 알아보기
|
|
245
|
+
|
|
246
|
+
- [고급 사용법](guides/advanced.md) — Document 모델 직접 다루기
|
|
247
|
+
- [포맷 확장하기](reference/extending.md) — 새 파서/Writer 추가하기
|