Perception
Split
client.documents.split(source, *, classes, **options)
| Parameter | Type | Required | Description |
|---|---|---|---|
source | str | UrlSource | WorkspaceFileSource | ParseResultSource | Yes | The document to split. |
classes | list[dict] | Yes | The document classes to cut on. See classes. Split's own options are on Split. |
unknown_policy | "include" / "force" / "error" | No | include (default) keeps unmatched pages as unclassified, force gives them the best class, error fails the job. |
overlap_policy | "exclusive" / "shared_boundary_page" | No | exclusive (default) keeps segments apart; shared_boundary_page puts a boundary page in both neighbors. |
split_rules | str | No | Free-text guidance on how to cut the packet. |
output | dict | No | What each segment holds. See output. |
page_ranges | list[dict] | No | One-based, inclusive ranges. Not for workbooks. Default: all pages. |
parse_mode | "low" / "medium" / "high" | No | Effort of the parse Split runs first. Default: "low", the only value a parse_result source takes. |
Each dict option takes these keys:
classes
One entry per class, each a dict:
| Key | Type | Default | Description |
|---|---|---|---|
classes[].id | str | Required | The class's id. |
classes[].label | str | Required | The class's name. |
classes[].description | str | "" | What belongs in the class. |
classes[].subclasses | list[dict] | None | Finer classes under this one, each with subclasses[].id and subclasses[].label (both required) and an optional subclasses[].description. |
classes[].instance_key | dict | None | A value that tells one document of the class from the next, such as an invoice number. |
classes[].instance_key.name | str | Required | The value's name. |
classes[].instance_key.description | str | Required | Where to find it. |
classes[].instance_key.required | bool | False | Whether every document of the class has it. |
output
| Key | Type | Default | Description |
|---|---|---|---|
output.include_content | bool | False | Put each segment's Markdown in content. |
output.materialize_files | bool | False | Give each segment a downloadable file. |
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.