012. 튜토리얼: 첫 문서 처리하기 (Tutorial: Process your first document)
- 원문: English
- 위치: Amazon Textract Insights › Getting started with Amazon Textract Insights › Tutorial: Process your first document
한 줄 요약
AWS CLI로 프로젝트 생성(추출 + 공개 W-2 블루프린트) → S3 업로드 → 작업 시작 → 상태 폴링 → job_metadata.json → 추출 결과 → 커스텀 추출 결과까지 7단계로 한 번 돌려 보는 튜토리얼입니다.
🇰🇷 한국어 지원
- ❌ 미지원. Insights는 6개 언어(영어, 프랑스어, 독일어, 이탈리아어, 포르투갈어, 스페인어)만 처리합니다. 근거: 003
쉽게 말하면
“설정 만들기 → 파일 올리기 → 시작 → 끝났나 확인 → 결과 목록 파일 읽기 → 결과 파일 읽기” 순서입니다.
핵심 내용
단계별 요약
| 단계 | 명령/API | 포인트 |
|---|---|---|
| 1. 프로젝트 생성 | create-project | --extraction-configuration 필수: BoundingBox, 비어 있지 않은 Granularity.Types, OutputFormat 지정. 동기 호출, ProjectArn + Status: COMPLETED 반환 |
| 2. 업로드 | aws s3 cp | 입력 버킷에 문서 업로드 |
| 3. 작업 시작 | start-document-insights | 입력 S3 URI, 출력 S3 접두사(prefix), 프로젝트 ARN. JobArn 반환 |
| 4. 폴링 | get-document-insights | IN_PROGRESS / SUCCEEDED / FAILED. 실패 시 ErrorType, ErrorMessage |
| 5. 메타데이터 | job_metadata.json | 위치: s3://<bucket>/<prefix>/<job-id>/job_metadata.json. 문서별 extraction_path, custom_path, custom_status |
| 6. 추출 결과 | extraction/0/result.json | 문서 메타데이터, 텍스트 표현, 통계, granularity별 섹션 |
| 7. 커스텀 결과 | custom/0/result.json | matched_blueprint, document_class, inference_result(값), explainability_info(필드별 신뢰도·위치) |
1단계 예시 (핵심 부분)
aws textract create-project --region us-east-1 \
--project-name "my-first-project" \
--custom-configuration '{"Blueprints": [{"BlueprintArn": "arn:aws:textract:us-east-1:aws:blueprint/public-w2-form"}]}' \
--extraction-configuration '{"BoundingBox": {"State": "ENABLED"}, "Granularity": {"Types": ["PAGE", "ELEMENT"]}, "OutputFormat": {"TextFormat": {"Types": ["MARKDOWN"]}, "AdditionalFileFormat": {"State": "DISABLED"}}}'
커스텀 결과 읽는 법
inference_result: 스키마 키 그대로 값이 들어 있음(예:employee_general_info.first_name)explainability_info:inference_result와 같은 모양. 필드마다success,confidence(0~1),geometry(bounding box, page, word_references),type,value- ⚠️ 못 찾은 필드는 빈 문자열
""로 반환됩니다. - 💡 신뢰도로 자동 승인 필드와 사람 검토 필드를 나눕니다.
SA 관점
- 결과 파일 경로는 직접 조합하지 말고 항상
job_metadata.json에서 읽는 방식으로 구현하는 것이 안전합니다(분할·매칭 결과에 따라 문서 수가 달라짐). - 폴링 대신 이벤트 기반 처리가 가능한지는 061에서 확인하세요.