Keyboard shortcuts

Press ← or → to navigate between chapters

Press ? to show this help

Press Esc to hide this help

DICOM, 스프레드시트, 이메일과 혼합 미디어 API

아래 함수의 미디어 입력과 출력은 실제 변환에 주입된 핸들입니다. 단일 항목을 지정할 수 있는 메서드의 media_item_rid: Optional[str]는 기본 None이며 집합 전체를 처리합니다.

render_dicom_layer

DICOM의 한 layer를 이미지로 렌더링하고 MediaSetInputTransform을 반환합니다.

인자자료형기본값과 조건
media_item_ridOptional[str]None
layer_numberOptional[int]생략하면 가운데 layer
widthOptional[int]height를 지정하지 않으면 필요. 한쪽만 지정하면 비율 유지
heightOptional[int]width를 지정하지 않으면 필요. 한쪽만 지정하면 비율 유지
output_formatstr기본 PNG. JPEG 등의 이미지 형식 선택

다음 예제는 layer_number 2와 목표 폭 1024를 명시합니다.

def render_layer(dicom, image_output):
    operation = dicom.transform().render_dicom_layer(layer_number=2, width=1024)
    image_output.write(operation)

extract_content_from_spreadsheets

스프레드시트 내용을 추출합니다. media_item_rid와 suppress_errors: bool=True를 받습니다. 집합 전체에서 True이면 오류를 결과에 포함하고 False이면 빌드가 실패합니다. 단일 항목에는 오류 억제 옵션을 적용하지 않습니다.

단일 결과는 각 sheet 이름을 키로 하고, 그 값에 table과 merged_cells를 가진 JSON 문자열입니다. 집합 전체는 media_item_rid, path, media_reference, extracted_content 열의 DataFrame이며 extracted_content는 문자열입니다.

def spreadsheet_contents(spreadsheets, dataset_output):
    dataset_output.write_dataframe(spreadsheets.transform().extract_content_from_spreadsheets())

extract_email_body

인자자료형기본값과 의미
media_item_ridOptional[str]None, 집합 전체
output_formatLiteral["TEXT", "HTML"]TEXT
suppress_errorsboolTrue, 집합 전체의 오류를 결과에 포함. False이면 빌드 실패

단일 항목은 선택한 형식의 이메일 본문 문자열을 반환합니다. 집합 전체는 공통 식별자 열과 email_body: str 열을 반환합니다.

def email_bodies(emails, dataset_output):
    dataset_output.write_dataframe(emails.transform().extract_email_body())

extract_email_attachments

이메일의 첨부 미디어를 추출하며 MediaSetInputTransform을 반환합니다.

인자자료형기본값과 의미
media_item_ridOptional[str]None
schema_typeOptional[str]None이면 모든 첨부. 지정하면 해당 schema만 추출

schema_type은 audio, image, video, document, spreadsheet, dicom, email 중 선택합니다. 여러 형식의 첨부를 함께 추출하면 그 결과를 수용하는 multimodal 출력을 준비합니다.

def email_attachments(emails, multimodal_output):
    multimodal_output.write(emails.transform().extract_email_attachments())

filter_to

혼합 미디어에서 schema 유형과 필요하면 세부 형식을 선택합니다.

인자자료형조건
schema_typestr필수. audio, image, video, document, spreadsheet, dicom, email 중 하나
formatsOptional[list[str]]생략하면 해당 schema의 모든 형식

formats 인자가 받는 값은 다음과 같습니다.

Schema세부 형식
documentpdf, docx, pptx, txt
imagepng, jpeg, jpg, tiff, bmp, webp, jp2, jp2k, nitf
audiomp3, wav, flac, ogg, opus, m4a, webm_audio
videomp4, ts, mov, mkv
spreadsheetxlsx
emaileml
dicom세부 형식으로 좁히는 기능 없음

필터는 MediaSetInputTransform을 반환하므로 이후 작업을 연결할 수 있습니다. 다음 절단 예제에서는 선택한 문서들이 최소 다섯 페이지이며 문서 절단을 지원하는 형식이어야 합니다.

def slice_documents(media, document_output):
    operation = media.transform().filter_to("document").slice_document(
        start_page=0, end_page=5
    )
    document_output.write(operation)


def ocr_only_pdfs(media, dataset_output):
    result = media.transform().filter_to("document", formats=["pdf"]).ocr()
    dataset_output.write_dataframe(result)


def copy_pdf_and_docx(media, document_output):
    operation = media.transform().filter_to("document", formats=["pdf", "docx"])
    document_output.write(operation)

마지막 필터는 DOCX를 PDF로 바꾸지 않고 두 형식의 항목을 선택합니다. 출력 schema가 두 결과 형식을 받아야 합니다. 출력의 경로 정책과 지연 평가 및 오류 처리는 write 계약을 따릅니다.