Skip to content

Commit 5c223e0

Browse files
committed
feat: add korean readme
1 parent f3ccd1c commit 5c223e0

File tree

2 files changed

+366
-1
lines changed

2 files changed

+366
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
# TOON (Token-Oriented Object Notation)
66

7-
[English](README.md) | [中文](README.zh-CN.md)
7+
[English](README.md) | [中文](assets/README.zh-CN.md) | [한국어](assets/README.ko.md)
88

99
A compact, human-readable serialization format designed for passing structured data to Large Language Models with significantly reduced token usage.
1010

assets/README.ko.md

Lines changed: 365 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,365 @@
1+
<p align="center">
2+
<img src="toonify.png" alt="Toonify Logo" width="400">
3+
</p>
4+
5+
# TOON (Token-Oriented Object Notation)
6+
7+
[English](../README.md) | [中文](README.zh-CN.md) | [한국어](README.ko.md)
8+
9+
구조화된 데이터를 대규모 언어 모델에 전달할 때 토큰 사용량을 크게 줄이도록 설계된 간결하고 사람이 읽을 수 있는 직렬화 형식입니다.
10+
11+
[![Python Version](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/)
12+
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
13+
14+
## 개요
15+
16+
TOON은 **CSV 수준의 간결함**을 달성하면서 **명시적인 구조**를 추가하여 다음과 같은 용도에 이상적입니다:
17+
- LLM API 호출 시 토큰 비용 절감
18+
- 컨텍스트 윈도우 효율성 향상
19+
- 사람이 읽을 수 있는 형식 유지
20+
- 데이터 구조 및 타입 보존
21+
22+
### 주요 기능
23+
24+
-**간결함**: 구조화된 데이터의 경우 JSON보다 30-60% 작음
25+
-**가독성**: 깔끔하고 들여쓰기 기반의 구문
26+
-**구조화**: 중첩된 객체와 배열 보존
27+
-**타입 안전성**: 문자열, 숫자, 불리언, null 지원
28+
-**유연성**: 다양한 구분자 옵션 (쉼표, 탭, 파이프)
29+
-**스마트**: 균일한 배열을 위한 자동 테이블 형식
30+
-**효율성**: 깊게 중첩된 객체를 위한 키 폴딩
31+
32+
## 설치
33+
34+
```bash
35+
pip install toonify
36+
```
37+
38+
개발 환경:
39+
```bash
40+
pip install toonify[dev]
41+
```
42+
43+
## 빠른 시작
44+
45+
### Python API
46+
47+
```python
48+
from toon import encode, decode
49+
50+
# Python dict를 TOON으로 인코딩
51+
data = {
52+
'products': [
53+
{'sku': 'LAP-001', 'name': 'Gaming Laptop', 'price': 1299.99},
54+
{'sku': 'MOU-042', 'name': 'Wireless Mouse', 'price': 29.99}
55+
]
56+
}
57+
58+
toon_string = encode(data)
59+
print(toon_string)
60+
# 출력:
61+
# products[2]{sku,name,price}:
62+
# LAP-001,Gaming Laptop,1299.99
63+
# MOU-042,Wireless Mouse,29.99
64+
65+
# TOON을 다시 Python으로 디코딩
66+
result = decode(toon_string)
67+
assert result == data
68+
```
69+
70+
### 명령줄
71+
72+
```bash
73+
# JSON을 TOON으로 인코딩
74+
toon input.json -o output.toon
75+
76+
# TOON을 JSON으로 디코딩
77+
toon input.toon -o output.json
78+
79+
# 파이프 사용
80+
cat data.json | toon -e > data.toon
81+
82+
# 토큰 통계 표시
83+
toon data.json --stats
84+
```
85+
86+
## TOON 형식 사양
87+
88+
### 기본 구문
89+
90+
```toon
91+
# 간단한 키-값 쌍
92+
title: Machine Learning Basics
93+
chapters: 12
94+
published: true
95+
```
96+
97+
### 배열
98+
99+
**기본 배열** (인라인):
100+
```toon
101+
temperatures: [72.5,68.3,75.1,70.8,73.2]
102+
categories: [electronics,computers,accessories]
103+
```
104+
105+
**테이블 배열** (헤더가 있는 균일한 객체):
106+
```toon
107+
inventory[3]{sku,product,stock}:
108+
KB-789,Mechanical Keyboard,45
109+
MS-456,RGB Mouse Pad,128
110+
HD-234,USB Headset,67
111+
```
112+
113+
**리스트 배열** (불균일하거나 중첩된):
114+
```toon
115+
tasks[2]:
116+
Complete documentation
117+
Review pull requests
118+
```
119+
120+
### 중첩 객체
121+
122+
```toon
123+
server:
124+
hostname: api-prod-01
125+
config:
126+
port: 8080
127+
region: us-east
128+
```
129+
130+
### 따옴표 규칙
131+
132+
문자열은 필요한 경우에만 따옴표로 묶습니다:
133+
- 특수 문자 포함 (`,`, `:`, `"`, 줄바꿈)
134+
- 앞/뒤 공백 있음
135+
- 리터럴처럼 보임 (`true`, `false`, `null`)
136+
- 비어있음
137+
138+
```toon
139+
simple: ProductName
140+
quoted: "Product, Description"
141+
escaped: "Size: 15\" display"
142+
multiline: "First feature\nSecond feature"
143+
```
144+
145+
## API 레퍼런스
146+
147+
### `encode(data, options=None)`
148+
149+
Python 객체를 TOON 문자열로 변환합니다.
150+
151+
**매개변수:**
152+
- `data`: Python dict 또는 list
153+
- `options`: 선택적 dict:
154+
- `delimiter`: `'comma'` (기본값), `'tab'`, 또는 `'pipe'`
155+
- `indent`: 레벨당 공백 수 (기본값: 2)
156+
- `key_folding`: `'off'` (기본값) 또는 `'safe'`
157+
- `flatten_depth`: 키 폴딩의 최대 깊이 (기본값: None)
158+
159+
**예제:**
160+
```python
161+
toon = encode(data, {
162+
'delimiter': 'tab',
163+
'indent': 4,
164+
'key_folding': 'safe'
165+
})
166+
```
167+
168+
### `decode(toon_string, options=None)`
169+
170+
TOON 문자열을 Python 객체로 변환합니다.
171+
172+
**매개변수:**
173+
- `toon_string`: TOON 형식 문자열
174+
- `options`: 선택적 dict:
175+
- `strict`: 구조를 엄격하게 검증 (기본값: True)
176+
- `expand_paths`: `'off'` (기본값) 또는 `'safe'`
177+
- `default_delimiter`: 기본 구분자 (기본값: `','`)
178+
179+
**예제:**
180+
```python
181+
data = decode(toon_string, {
182+
'expand_paths': 'safe',
183+
'strict': False
184+
})
185+
```
186+
187+
## CLI 사용법
188+
189+
```
190+
usage: toon [-h] [-o OUTPUT] [-e] [-d] [--delimiter {comma,tab,pipe}]
191+
[--indent INDENT] [--stats] [--no-strict]
192+
[--key-folding {off,safe}] [--flatten-depth DEPTH]
193+
[--expand-paths {off,safe}]
194+
[input]
195+
196+
TOON (Token-Oriented Object Notation) - JSON과 TOON 형식 간 변환
197+
198+
positional arguments:
199+
input 입력 파일 경로 (또는 stdin의 경우 "-")
200+
201+
optional arguments:
202+
-h, --help 도움말 메시지 표시
203+
-o, --output OUTPUT 출력 파일 경로 (기본값: stdout)
204+
-e, --encode 인코딩 모드 강제 (JSON에서 TOON으로)
205+
-d, --decode 디코딩 모드 강제 (TOON에서 JSON으로)
206+
--delimiter {comma,tab,pipe}
207+
배열 구분자 (기본값: comma)
208+
--indent INDENT 들여쓰기 크기 (기본값: 2)
209+
--stats 토큰 통계 표시
210+
--no-strict 엄격한 검증 비활성화 (디코딩만)
211+
--key-folding {off,safe}
212+
키 폴딩 모드 (인코딩만)
213+
--flatten-depth DEPTH 최대 키 폴딩 깊이 (인코딩만)
214+
--expand-paths {off,safe}
215+
경로 확장 모드 (디코딩만)
216+
```
217+
218+
## 고급 기능
219+
220+
### 키 폴딩
221+
222+
단일 키 체인을 점으로 구분된 경로로 축소합니다:
223+
224+
```python
225+
data = {
226+
'api': {
227+
'response': {
228+
'product': {
229+
'title': 'Wireless Keyboard'
230+
}
231+
}
232+
}
233+
}
234+
235+
# key_folding='safe' 사용
236+
toon = encode(data, {'key_folding': 'safe'})
237+
# 출력: api.response.product.title: Wireless Keyboard
238+
```
239+
240+
### 경로 확장
241+
242+
점으로 구분된 키를 중첩 객체로 확장합니다:
243+
244+
```python
245+
toon = 'store.location.zipcode: 10001'
246+
247+
# expand_paths='safe' 사용
248+
data = decode(toon, {'expand_paths': 'safe'})
249+
# 결과: {'store': {'location': {'zipcode': 10001}}}
250+
```
251+
252+
### 사용자 정의 구분자
253+
254+
데이터에 가장 적합한 구분자를 선택하세요:
255+
256+
```python
257+
# 탭 구분자 (스프레드시트 같은 데이터에 더 좋음)
258+
toon = encode(data, {'delimiter': 'tab'})
259+
260+
# 파이프 구분자 (데이터에 쉼표가 포함된 경우)
261+
toon = encode(data, {'delimiter': 'pipe'})
262+
```
263+
264+
## 형식 비교
265+
266+
### JSON vs TOON
267+
268+
**JSON** (247 바이트):
269+
```json
270+
{
271+
"products": [
272+
{"id": 101, "name": "Laptop Pro", "price": 1299},
273+
{"id": 102, "name": "Magic Mouse", "price": 79},
274+
{"id": 103, "name": "USB-C Cable", "price": 19}
275+
]
276+
}
277+
```
278+
279+
**TOON** (98 바이트, **60% 감소**):
280+
```toon
281+
products[3]{id,name,price}:
282+
101,Laptop Pro,1299
283+
102,Magic Mouse,79
284+
103,USB-C Cable,19
285+
```
286+
287+
### TOON 사용 시기
288+
289+
**TOON 사용:**
290+
- ✅ LLM API에 데이터 전달 시 (토큰 비용 절감)
291+
- ✅ 균일한 테이블 데이터 작업
292+
- ✅ 컨텍스트 윈도우가 제한적일 때
293+
- ✅ 사람이 읽을 수 있어야 할 때
294+
295+
**JSON 사용:**
296+
- ❌ 최대 호환성이 필요할 때
297+
- ❌ 데이터가 매우 불규칙하거나 중첩될 때
298+
- ❌ 기존 JSON 전용 도구와 작업할 때
299+
300+
## 개발
301+
302+
### 설정
303+
304+
```bash
305+
git clone https://github.com/ScrapeGraphAI/toonify.git
306+
cd toonify
307+
pip install -e .[dev]
308+
```
309+
310+
### 테스트 실행
311+
312+
```bash
313+
pytest
314+
pytest --cov=toon --cov-report=term-missing
315+
```
316+
317+
### 예제 실행
318+
319+
```bash
320+
python examples/basic_usage.py
321+
python examples/advanced_features.py
322+
```
323+
324+
## 성능
325+
326+
TOON은 일반적으로 다음을 달성합니다:
327+
- 구조화된 데이터의 경우 JSON 대비 **30-60% 크기 감소**
328+
- 테이블 데이터의 경우 **40-70% 토큰 감소**
329+
- 인코딩/디코딩 시 **최소 오버헤드** (일반적인 페이로드의 경우 <1ms)
330+
331+
## 기여
332+
333+
기여를 환영합니다! 다음 단계를 따라주세요:
334+
335+
1. 저장소 포크
336+
2. 기능 브랜치 생성 (`git checkout -b feature/amazing-feature`)
337+
3. 테스트와 함께 변경 사항 작성
338+
4. 테스트 실행 (`pytest`)
339+
5. 변경 사항 커밋 (`git commit -m 'Add amazing feature'`)
340+
6. 브랜치에 푸시 (`git push origin feature/amazing-feature`)
341+
7. Pull Request 열기
342+
343+
## 라이선스
344+
345+
MIT 라이선스 - 자세한 내용은 [LICENSE](../LICENSE) 파일을 참조하세요.
346+
347+
## 크레딧
348+
349+
Python 구현은 [toon-format/toon](https://github.com/toon-format/toon)의 TypeScript TOON 라이브러리에서 영감을 받았습니다.
350+
351+
## 링크
352+
353+
- **GitHub**: https://github.com/ScrapeGraphAI/toonify
354+
- **PyPI**: https://pypi.org/project/toonify/
355+
- **문서**: https://github.com/ScrapeGraphAI/toonify#readme
356+
- **형식 사양**: https://github.com/toon-format/toon
357+
358+
---
359+
360+
[ScrapeGraph 팀](https://scrapegraphai.com)이 ❤️으로 만들었습니다
361+
362+
<p align="center">
363+
<img src="https://github.com/ScrapeGraphAI/Scrapegraph-ai/blob/main/docs/assets/scrapegraphai_logo.png" alt="ScrapeGraphAI Logo" width="250">
364+
</p>
365+

0 commit comments

Comments
 (0)