> ## Documentation Index
> Fetch the complete documentation index at: https://developer.box.com/llms.txt
> Use this file to discover all available pages before exploring further.

# スマート分割

> 自然言語のプロンプトを使用して、PDFのページをどのようにグループ化して、出力ドキュメントに分割するかをBoxに決定させます。

export const MultiRelatedLinks = ({sections = []}) => {
  if (!sections || sections.length === 0) {
    return null;
  }
  return <div className="space-y-8">
      {sections.map((section, index) => <RelatedLinks key={index} title={section.title} items={section.items} />)}
    </div>;
};

export const RelatedLinks = ({title, items = []}) => {
  const getBadgeClass = badge => {
    if (!badge) return "badge-default";
    const badgeType = badge.toLowerCase().replace(/\s+/g, "-");
    return `badge-${badge === "ガイド" ? "guide" : badgeType}`;
  };
  if (!items || items.length === 0) {
    return null;
  }
  return <div className="my-8">
      {}
      <h3 className="text-sm font-bold uppercase tracking-wider mb-4">{title}</h3>

      {}
      <div className="flex flex-col gap-3">
        {items.map((item, index) => <a key={index} href={item.href} className="py-2 px-3 rounded related_link hover:bg-[#f2f2f2] dark:hover:bg-[#111827] flex items-center gap-3 group no-underline hover:no-underline border-b-0">
            {}
            <span className={`px-2 py-1 rounded-full text-xs font-semibold uppercase tracking-wide flex-shrink-0 ${getBadgeClass(item.badge)}`}>
              {item.badge}
            </span>

            {}
            <span className="text-base">{item.label}</span>
          </a>)}
      </div>
    </div>;
};

export const Link = ({href, children, className, ...props}) => {
  const localizedHref = localizeLink(href);
  return <a href={localizedHref} className={className} {...props}>
      {children}
    </a>;
};

`split_type`が`smart`の場合、Boxドキュメント分割は`prompt`を使用して、ページをどのようにグループ化して、出力ドキュメントに分割するかを決定します。プロンプトが明確で具体的であるほど、より信頼性の高い分割結果が得られます。

<Note>
  スマート分割はAIユニットを消費します。Boxは、4ページ処理するごとに1 AIユニットを消費します。
</Note>

## 前提条件

使用を開始する前に、<Link href="/guides/docgen/docgen-getting-started">Box Doc Genの使い方</Link>ガイドに記載されている手順に従って、Platformアプリを作成し、アクセストークンを生成してください。

以下も必要です。

* Boxにすでに格納されているソースPDF
* アプリが書き込み可能なBox上の保存先フォルダ
* ページをどのようにグループ化するかを説明するプロンプト。

## 構成するパラメータ

| パラメータ | 説明 |
| - | - |
| `source_file_id` | 分割対象のPDFのBoxファイルID |
| `destination_folder_id` | Boxが出力ドキュメントを保存するBoxフォルダID |
| `split_input.split_type` | `smart` |
| `split_input.prompt` | ソースPDFをどのように分析し、どこで分割するかをBoxに指示する自然言語のプロンプト |

## プロンプトのガイドライン

* 指定したBoxファイルがソースドキュメントであることを伝えます。
* ページ数、QRコードなどのマーカー、内容の条件といった、分割ルールを説明します。
* 契約書の添付資料の後に署名ページが続くケースなど、順序が重要な場合は、ページ番号順にページ範囲を指定します。
* 含めるページやセクションを明確に指定します。また、必要に応じて除外するページやセクションも指示します。
* 「適当に分割する」や「いい感じに分割する」といった曖昧な表現は避けます。

## プロンプトの例

### 明示的なページグループ

範囲を自然言語で説明し、1つのファイルを2つのドキュメントに分割します。

```text theme={null}
Use this document as the source, and split the documents into 2 parts.
Pages 1-3 should be the first document, and pages 5-8 should be the second document.
```

この結果、2つの出力が生成されます。1つは1～3ページ目、もう1つは5～8ページ目に対応しています。

<Tip>
  正確なページ範囲がすでにわかっている場合は、代わりに`split_type: "manual"`と`split_definition`を使用してください。決定的な結果については、<Link href="/guides/docgen/manual-split">手動分割</Link>を参照してください。
</Tip>

### QRコードを分割点として使用する

各QRコードページを、ドキュメントの区切りとして扱います。QRコードページの前までのページが1つの出力ドキュメントとなり、QRコードページ自体は特に指定がない限り出力から除外されます。

```text theme={null}
Use this document as the source. Identify individual pages that contain
a QR code, and use each QR code page as a breaking point between document
splits. Build the split definition so that if a QR code appears on page 5,
pages 1-4 are the first document. If the next QR code appears on page 11, 
pages 6-10 are the second document. Continue this pattern through the rest of the file.
```

この結果、マーカーページによって区切られた連続したページ範囲が生成されます。たとえば、マーカーが5ページ目と11ページ目にある場合、出力は1～4ページ目と6～10ページ目になります。

### 内容に基づいた契約書のページ分割

本人確認書類、署名ページ、締結済みの契約条件など、実質的な契約に関する内容を含むページのみを保持し、定型的な利用規約は除外します。また、保持するセクションを順番に分割します。

```text theme={null}
Use this document as the source. Identify all pages that contain
real contractual details, such as ID proofs of the signers, signatures
of the signers, and other executed contractual details. Skip pages 
that only contain terms and conditions. Split the retained sections sequentially.
For example, if ID proofs are on pages 1-3 and executed signatures are on
pages 4-6, produce two documents: pages 1-3 and pages 4-6.
```

この結果、1～3ページ目と4～6ページ目など、条件に一致する連続した内容のブロックごとに1つの出力が生成されます。

## スマート分割ジョブを作成する

```sh cURL theme={null}
curl -L 'https://api.box.com/2.0/document_splits' \
     -H 'Accept: application/json; version=1' \
     -H 'box-version: 2026.0' \
     -H 'Content-Type: application/json' \
     -H 'Authorization: Bearer <ACCESS_TOKEN>' \
     -d '{
       "source_file_id": "2390226613215",
       "destination_folder_id": "406457672606",
       "input_source": "api",
       "split_input": {
         "split_type": "smart",
         "prompt": "Identify pages with QR codes in the source file, use each one as a breaking point, and split the document. For example, if there is a QR code on page 5, followed by a QR code on page 11, followed by a QR code on page 18, the result is 2 split documents. The first covers pages 5 to 11 and the second covers pages 12 to 18."
       }
     }'
```

レスポンスには、分割ジョブのIDが含まれています。

```json theme={null}
{
  "id": "11678",
  "type": "document_split"
}
```

このIDを使用して、<Link href="/guides/docgen/doc-split">状態および生成されたファイルを取得</Link>します。そのレスポンスに含まれる`split_definition`には、Boxがプロンプトから導き出したページ範囲が表示されます。そのため、プロンプトによって期待どおりのグループ化が行われたかどうかを確認できます。

<RelatedLinks
  title="関連するガイド"
  items={[
{ label: translate("Box Doc Split"), href: "/guides/docgen/doc-split", badge: "GUIDE" },
{ label: translate("Manual split"), href: "/guides/docgen/manual-split", badge: "GUIDE" }
]}
/>
