Perception

Split

client.documents.split(source, *, classes, **options)

ParameterTypeRequiredDescription
sourcestr | UrlSource | WorkspaceFileSource | ParseResultSourceYesThe document to split.
classeslist[dict]YesThe document classes to cut on. See classes. Split's own options are on Split.
unknown_policy"include" / "force" / "error"NoControls segments Split leaves without a class. Split can pick a class that seems unrelated. Default include. See Unknown pages.
overlap_policy"exclusive" / "shared_boundary_page"Noexclusive (default) keeps segments apart; shared_boundary_page puts a boundary page in both neighbors.
split_rulesstrNoFree-text guidance on how to cut the packet.
outputdictNoWhat each segment holds. See output.
page_rangeslist[dict]NoOne-based, inclusive ranges. Not for workbooks. Default: all pages.
parse_mode"low" / "medium" / "high"NoEffort of the parse Split runs first. Default: "low". A parse_result source runs at "low" whatever you pass, with a note in the result's warnings.

Each dict option takes these keys:

classes

One entry per class, each a dict:

KeyTypeDefaultDescription
classes[].idstrRequiredThe class's id.
classes[].labelstrRequiredThe class's name.
classes[].descriptionstr""What belongs in the class.
classes[].subclasseslist[dict]NoneFiner classes under this one, each with subclasses[].id and subclasses[].label (both required) and an optional subclasses[].description.
classes[].instance_keydictNoneDeprecated. Existing requests can still return segment.instance when Split finds the value. A valid non-null key adds a deprecation warning to the result. If name or description is missing, the API returns 422. Omit the key in new requests.
classes[].instance_key.namestrRequiredThe value's name.
classes[].instance_key.descriptionstrRequiredWhere to find it.
classes[].instance_key.requiredboolFalseWhether every document of the class has it.

output

KeyTypeDefaultDescription
output.include_contentboolFalseInclude available segment Markdown in content. A segment can still have null content.
output.materialize_filesboolFalseGive each segment a downloadable file.
split.py
from nace_sdk import NaceClient

with NaceClient() as client:
    job = client.documents.split(
        "https://example.com/packet.pdf",
        classes=[
            {"id": "invoice", "label": "Invoice", "description": "A supplier invoice"},
            {"id": "receipt", "label": "Receipt", "description": "A payment receipt"},
        ],
        wait_seconds=60,
    )
    if job.status != "succeeded":
        job = client.jobs.wait(job.job_id)

for segment in job.result["segments"]:
    print(segment["start_page"], segment["end_page"], segment["class"]["id"] if segment["class"] else None)

Class ids must be unique and can't contain /, and blank_page, unreadable_content and __ndi_unclassified are reserved. See Split.

On this page