ドローフェーズ(はじめに)
2026年11月20日にGAしたAmazon Textract Insightsは、書類の種類を判定して、決めた項目を抜き出すサービスです。詳しくはこちらの記事が参考になります。
これを見て真っ先に思い浮かんだのが請求書…ではなく「遊戯王カード」でした。遊戯王カードは種類ごとにフォーマットが少しずつ違うので種類を見分けて正しく項目を抜き出せるか試しました。それではデュエル開…じゃなくて検証開始〜!
📄 購読対象者
・決闘者(デュエリスト)
📄 処理の流れ
- ファイルを切り分ける(分割)
- Projectに登録したBlueprintと照らし合わせて判別する(分類)
- 項目を抜き出し、値ごとに信頼度と座標を付ける(抽出)
Blueprintとは?
Blueprintは出力フォーマットとAIへの指示書を兼ねた定義です。説明の書き方で結果が変わるので、ここがいちばんのキモです。書類全体の説明と、項目ごとの説明を書きます。
{
"class": "TradingCardMonster",
"description": "A single Japanese trading card game monster card. Decide the card kind by the frame (background) color first. ...(日本のトレーディングカードゲームのモンスターカード1枚。カードの種類は、まず枠(背景)の色で判断する。…)",
"properties": {
"card_name": {
"type": "string",
"inferenceType": "explicit",
"description": "Card name in the top banner, exactly as printed in Japanese. Exclude the small furigana (ruby) reading text printed above the name.(上部の帯のカード名。日本語で印字どおりに。名前の上の小さなふりがなは除く。)"
},
"level": {
"type": "number",
"inferenceType": "inferred",
"description": "Number of star icons in the row under the card name.(カード名の下の列にある星アイコンの数。)"
}
}
}
日本語は記事用に付けた訳です。Blueprintには日本語(全角記号を含む)を書くとエラーになるので、英語で書きます。抽出結果は日本語のまま返ってきます。
項目の取得方法(直接抽出 or 推論抽出)
項目の取り方は2種類あります。explicit は書類に書かれた文字をそのまま抜き出し、inferred は書かれていない答えを推論します。
カード名や効果のように印字されている値は explicit で抽出します。レベル(星の数)は文字としてはどこにも書かれていないので inferred にしました。生贄が必要かどうかも、レベルから推論させています。
遊戯王はレベル5以上のモンスター召喚はレベルに応じた数の生贄が必要なのです
🧪 メインフェーズ1(検証観点)
| カード | 正解の種類 | 確かめたいこと |
|---|---|---|
| クリボー | モンスター | 基本形。星1なので生贄はfalseになるか |
| 黒き魔術師-ブラック・マジシャン | 上級モンスター | 「魔法・罠カード」の文字に引っぱられないか、生贄trueになるか |
| オッドアイズ・ペンデュラム・ドラゴン | ペンデュラム | 特殊なフォーマットを判断できるか |
| サンダー・ボルト | 魔法 | 星もATK/DEFも無い種類 |
| 聖なるバリア -ミラーフォース- | 罠 | 魔法と見分けられるか |
Blueprintはカードの種類毎に作成しました。
カードの種類は主にカードの背景色で判断させるよう指示しました。
モンスター用(TradingCardMonster)
{
"class": "TradingCardMonster",
"description": "A single Japanese trading card game monster card. Decide the card kind by the frame (background) color first. The whole frame is one color: orange/brown (effect), yellow (normal), purple (fusion), blue (ritual), white (synchro) or black (xyz). A purple fusion frame is still this class: it has stars and ATK/DEF, magenta trap cards have neither. If the upper and lower halves of the frame differ in color, it is a pendulum monster, not this class. Layout: name; attribute icon at top right; star row; illustration; set number; bracketed type line and effect text; ATK/DEF; passcode at bottom left.(日本のトレーディングカードゲームのモンスターカード1枚。カードの種類は、まず枠(背景)の色で判断する。枠全体が1色で、オレンジ/茶(効果)、黄(通常)、紫(融合)、青(儀式)、白(シンクロ)、黒(エクシーズ)のいずれか。紫の融合の枠でもこのクラスに当たる(星とATK/DEFがある。赤紫の罠カードにはどちらも無い)。枠の上半分と下半分で色が違う場合はペンデュラムモンスターで、このクラスではない。レイアウト:名前、右上に属性アイコン、星の列、イラスト、カード番号、かっこの種族行と効果テキスト、ATK/DEF、左下にパスワード。)",
"properties": {
"card_name": {
"type": "string",
"inferenceType": "explicit",
"description": "Card name in the top banner, exactly as printed in Japanese. Exclude the small furigana (ruby) reading text printed above the name.(上部の帯のカード名。日本語で印字どおりに。名前の上の小さなふりがな(ルビ)は除く。)"
},
"monster_type": {
"type": "string",
"inferenceType": "explicit",
"description": "First line of the text box is in square brackets. Return the part before the first slash (the type word ending in zoku), without brackets.(テキスト枠の1行目はかっこで囲まれている。最初のスラッシュより前(「〜族」で終わる語)を、かっこなしで返す。)"
},
"card_category": {
"type": "string",
"inferenceType": "explicit",
"description": "Part of the bracketed first line after the first slash, such as effect or fusion. If several, keep them joined with the slash as printed. No brackets.(かっこの1行目のうち、最初のスラッシュより後ろ(効果、融合など)。複数あれば印字どおりスラッシュでつなぐ。かっこは付けない。)"
},
"effect_text": {
"type": "string",
"inferenceType": "explicit",
"description": "Full effect text below the bracketed line, exactly as printed, joined into one line without line breaks. Include fusion material lines. Exclude small furigana (ruby) text printed above kanji. Do not include ATK/DEF.(かっこの行の下の効果テキスト全文。印字どおりに、改行せず1行につなぐ。融合素材の行も含める。漢字の上の小さなふりがなは除く。ATK/DEFは含めない。)"
},
"attack": {
"type": "string",
"inferenceType": "explicit",
"description": "Value after ATK/ as printed, e.g. 2500 or ?.(ATK/の後の値を印字どおりに。例:2500 や ?。)"
},
"defense": {
"type": "string",
"inferenceType": "explicit",
"description": "Value after DEF/ as printed, e.g. 2000 or ?.(DEF/の後の値を印字どおりに。例:2000 や ?。)"
},
"attribute": {
"type": "string",
"inferenceType": "explicit",
"description": "The single kanji inside the round icon at the top right, as printed. Exclude the small furigana above it.(右上の丸いアイコンの中の漢字1文字を印字どおりに。上の小さなふりがなは除く。)"
},
"passcode": {
"type": "string",
"inferenceType": "explicit",
"description": "8 digit number printed at the bottom left corner of the card, below the text box. Empty string if not visible.(カード左下隅、テキスト枠の下の8桁の数字。見えなければ空文字。)"
},
"set_number": {
"type": "string",
"inferenceType": "explicit",
"description": "Alphanumeric number at the bottom right of the illustration frame, just above the text box, like XXXX-JP000. Empty string if not visible.(イラスト枠の右下、テキスト枠のすぐ上の英数字の番号(XXXX-JP000形式)。見えなければ空文字。)"
},
"level": {
"type": "number",
"inferenceType": "inferred",
"description": "Number of star icons in the row under the card name.(カード名の下の列にある星アイコンの数。)"
},
"tribute_required": {
"type": "boolean",
"inferenceType": "inferred",
"description": "Whether this monster needs tributes (sacrifices) to be summoned. Rule: true if the level (number of stars) is 5 or more, otherwise false.(このモンスターの召喚に生贄が必要か。ルール:レベル(星の数)が5以上ならtrue、それ以外はfalse。)"
}
}
}
書類全体の説明(訳)
日本のトレーディングカードゲームのモンスターカード1枚。カードの種類は、まず枠(背景)の色で判断する。枠全体が1色で、オレンジ/茶(効果)、黄(通常)、紫(融合)、青(儀式)、白(シンクロ)、黒(エクシーズ)のいずれか。紫の融合の枠でもこのクラスに当たる(星とATK/DEFがある。赤紫の罠カードにはどちらも無い)。枠の上半分と下半分で色が違う場合はペンデュラムモンスターで、このクラスではない。レイアウト:名前、右上に属性アイコン、星の列、イラスト、カード番号、かっこの種族行と効果テキスト、ATK/DEF、左下にパスワード。
| 項目 | 型 | 取り方 | 説明(訳) |
|---|---|---|---|
| card_name | 文字列 | 読み取り | 上部の帯のカード名。日本語で印字どおりに。名前の上の小さなふりがな(ルビ)は除く。 |
| monster_type | 文字列 | 読み取り | テキスト枠の1行目はかっこで囲まれている。最初のスラッシュより前(「〜族」で終わる語)を、かっこなしで返す。 |
| card_category | 文字列 | 読み取り | かっこの1行目のうち、最初のスラッシュより後ろ(効果、融合など)。複数あれば印字どおりスラッシュでつなぐ。かっこは付けない。 |
| effect_text | 文字列 | 読み取り | かっこの行の下の効果テキスト全文。印字どおりに、改行せず1行につなぐ。融合素材の行も含める。漢字の上の小さなふりがなは除く。ATK/DEFは含めない。 |
| attack | 文字列 | 読み取り | ATK/の後の値を印字どおりに。例:2500 や ?。 |
| defense | 文字列 | 読み取り | DEF/の後の値を印字どおりに。例:2000 や ?。 |
| attribute | 文字列 | 読み取り | 右上の丸いアイコンの中の漢字1文字を印字どおりに。上の小さなふりがなは除く。 |
| passcode | 文字列 | 読み取り | カード左下隅、テキスト枠の下の8桁の数字。見えなければ空文字。 |
| set_number | 文字列 | 読み取り | イラスト枠の右下、テキスト枠のすぐ上の英数字の番号(XXXX-JP000形式)。見えなければ空文字。 |
| level | 数値 | 推論 | カード名の下の列にある星アイコンの数。 |
| tribute_required | 真偽値 | 推論 | このモンスターの召喚に生贄が必要か。ルール:レベル(星の数)が5以上ならtrue、それ以外はfalse。 |
ペンデュラム用(PendulumMonster)
{
"class": "PendulumMonster",
"description": "A single Japanese trading card game pendulum monster card. Decide the card kind by the frame (background) color first. Key sign: the frame color differs between the upper and lower halves. The upper half has a monster color (orange, yellow, etc.) and the lower half, below the pendulum effect box, is green like a spell card. Also a blue scale number at the left and a red one at the right under the illustration. Layout: name; attribute icon; star row; illustration; blue scale, pendulum effect box, red scale; bracketed type line; monster effect box; ATK/DEF; passcode at bottom left.(日本のトレーディングカードゲームのペンデュラムモンスターカード1枚。カードの種類は、まず枠(背景)の色で判断する。決め手は、枠の色が上半分と下半分で違うこと。上半分はモンスターの色(オレンジ、黄など)で、ペンデュラム効果の枠より下の下半分は魔法カードと同じ緑になる。イラストの下の左に青いスケールの数字、右に赤いスケールの数字もある。レイアウト:名前、属性アイコン、星の列、イラスト、青スケール・ペンデュラム効果枠・赤スケール、かっこの種族行、モンスター効果の枠、ATK/DEF、左下にパスワード。)",
"properties": {
"card_name": {
"type": "string",
"inferenceType": "explicit",
"description": "Card name in the top banner, exactly as printed in Japanese. Exclude the small furigana (ruby) reading text printed above the name.(上部の帯のカード名。日本語で印字どおりに。名前の上の小さなふりがな(ルビ)は除く。)"
},
"attribute": {
"type": "string",
"inferenceType": "explicit",
"description": "The single kanji inside the round icon at the top right, as printed. Exclude the small furigana above it.(右上の丸いアイコンの中の漢字1文字を印字どおりに。上の小さなふりがなは除く。)"
},
"monster_type": {
"type": "string",
"inferenceType": "explicit",
"description": "First line of the text box is in square brackets. Return the part before the first slash (the type word ending in zoku), without brackets.(テキスト枠の1行目はかっこで囲まれている。最初のスラッシュより前(「〜族」で終わる語)を、かっこなしで返す。)"
},
"card_category": {
"type": "string",
"inferenceType": "explicit",
"description": "Part of the bracketed type line after the first slash, such as pendulum/effect. If several, keep them joined with the slash as printed. No brackets.(かっこの種族行のうち、最初のスラッシュより後ろ(ペンデュラム/効果など)。複数あれば印字どおりスラッシュでつなぐ。かっこは付けない。)"
},
"attack": {
"type": "string",
"inferenceType": "explicit",
"description": "Value after ATK/ as printed, e.g. 2500 or ?.(ATK/の後の値を印字どおりに。例:2500 や ?。)"
},
"defense": {
"type": "string",
"inferenceType": "explicit",
"description": "Value after DEF/ as printed, e.g. 2000 or ?.(DEF/の後の値を印字どおりに。例:2000 や ?。)"
},
"passcode": {
"type": "string",
"inferenceType": "explicit",
"description": "8 digit number printed at the bottom left corner of the card, below the text box. Empty string if not visible.(カード左下隅、テキスト枠の下の8桁の数字。見えなければ空文字。)"
},
"set_number": {
"type": "string",
"inferenceType": "explicit",
"description": "Alphanumeric number at the bottom right of the illustration frame, just above the text box, like XXXX-JP000. Empty string if not visible.(イラスト枠の右下、テキスト枠のすぐ上の英数字の番号(XXXX-JP000形式)。見えなければ空文字。)"
},
"level": {
"type": "number",
"inferenceType": "inferred",
"description": "Number of star icons in the row under the card name.(カード名の下の列にある星アイコンの数。)"
},
"pendulum_scale_left": {
"type": "number",
"inferenceType": "explicit",
"description": "Number printed under the blue scale icon at the left end of the pendulum effect box, under the illustration.(イラストの下、ペンデュラム効果枠の左端にある青いスケールアイコンの下の数字。)"
},
"pendulum_scale_right": {
"type": "number",
"inferenceType": "explicit",
"description": "Number printed under the red scale icon at the right end of the pendulum effect box, under the illustration.(イラストの下、ペンデュラム効果枠の右端にある赤いスケールアイコンの下の数字。)"
},
"pendulum_effect": {
"type": "string",
"inferenceType": "explicit",
"description": "Full text in the pendulum effect box between the blue left scale and the red right scale, exactly as printed, joined into one line without line breaks. Exclude small furigana (ruby) text. Do not include the scale numbers.(青スケールと赤スケールの間にあるペンデュラム効果枠の全文。印字どおりに、改行せず1行につなぐ。ふりがなは除く。スケールの数字は含めない。)"
},
"monster_effect": {
"type": "string",
"inferenceType": "explicit",
"description": "Full text in the box below the bracketed type line, exactly as printed, joined into one line without line breaks. Exclude small furigana (ruby) text. Do not include the pendulum effect or ATK/DEF.(かっこの種族行の下の枠の全文。印字どおりに、改行せず1行につなぐ。ふりがなは除く。ペンデュラム効果とATK/DEFは含めない。)"
},
"tribute_required": {
"type": "boolean",
"inferenceType": "inferred",
"description": "Whether this monster needs tributes (sacrifices) to be summoned. Rule: true if the level (number of stars) is 5 or more, otherwise false.(このモンスターの召喚に生贄が必要か。ルール:レベル(星の数)が5以上ならtrue、それ以外はfalse。)"
}
}
}
書類全体の説明(訳)
日本のトレーディングカードゲームのペンデュラムモンスターカード1枚。カードの種類は、まず枠(背景)の色で判断する。決め手は、枠の色が上半分と下半分で違うこと。上半分はモンスターの色(オレンジ、黄など)で、ペンデュラム効果の枠より下の下半分は魔法カードと同じ緑になる。イラストの下の左に青いスケールの数字、右に赤いスケールの数字もある。レイアウト:名前、属性アイコン、星の列、イラスト、青スケール・ペンデュラム効果枠・赤スケール、かっこの種族行、モンスター効果の枠、ATK/DEF、左下にパスワード。
| 項目 | 型 | 取り方 | 説明(訳) |
|---|---|---|---|
| card_name | 文字列 | 読み取り | 上部の帯のカード名。日本語で印字どおりに。名前の上の小さなふりがな(ルビ)は除く。 |
| attribute | 文字列 | 読み取り | 右上の丸いアイコンの中の漢字1文字を印字どおりに。上の小さなふりがなは除く。 |
| monster_type | 文字列 | 読み取り | テキスト枠の1行目はかっこで囲まれている。最初のスラッシュより前(「〜族」で終わる語)を、かっこなしで返す。 |
| card_category | 文字列 | 読み取り | かっこの種族行のうち、最初のスラッシュより後ろ(ペンデュラム/効果など)。複数あれば印字どおりスラッシュでつなぐ。かっこは付けない。 |
| attack | 文字列 | 読み取り | ATK/の後の値を印字どおりに。例:2500 や ?。 |
| defense | 文字列 | 読み取り | DEF/の後の値を印字どおりに。例:2000 や ?。 |
| passcode | 文字列 | 読み取り | カード左下隅、テキスト枠の下の8桁の数字。見えなければ空文字。 |
| set_number | 文字列 | 読み取り | イラスト枠の右下、テキスト枠のすぐ上の英数字の番号(XXXX-JP000形式)。見えなければ空文字。 |
| level | 数値 | 推論 | カード名の下の列にある星アイコンの数。 |
| pendulum_scale_left | 数値 | 読み取り | イラストの下、ペンデュラム効果枠の左端にある青いスケールアイコンの下の数字。 |
| pendulum_scale_right | 数値 | 読み取り | イラストの下、ペンデュラム効果枠の右端にある赤いスケールアイコンの下の数字。 |
| pendulum_effect | 文字列 | 読み取り | 青スケールと赤スケールの間にあるペンデュラム効果枠の全文。印字どおりに、改行せず1行につなぐ。ふりがなは除く。スケールの数字は含めない。 |
| monster_effect | 文字列 | 読み取り | かっこの種族行の下の枠の全文。印字どおりに、改行せず1行につなぐ。ふりがなは除く。ペンデュラム効果とATK/DEFは含めない。 |
| tribute_required | 真偽値 | 推論 | このモンスターの召喚に生贄が必要か。ルール:レベル(星の数)が5以上ならtrue、それ以外はfalse。 |
魔法用(SpellCard)
{
"class": "SpellCard",
"description": "A single Japanese trading card game spell card. Decide the card kind by the frame (background) color first. The whole frame, top to bottom, is green (teal). If the upper and lower halves differ in color (only the lower half green), it is a pendulum monster, not a spell. A magenta frame is a trap, not a spell. Spell cards have no star icons and no ATK/DEF. Layout: name; round icon with one kanji at top right; under the name, right aligned, the bracketed card type, then a small icon unless it is a normal spell; illustration; set number; effect text box; passcode at bottom left.(日本のトレーディングカードゲームの魔法カード1枚。カードの種類は、まず枠(背景)の色で判断する。枠全体が上から下まで緑(青緑)。上半分と下半分で色が違う(下半分だけ緑の)場合はペンデュラムモンスターで、魔法ではない。赤紫の枠は罠で、魔法ではない。魔法カードには星アイコンもATK/DEFも無い。レイアウト:名前、右上に漢字1文字の丸いアイコン、名前の下の右寄せにかっこのカード種別と、通常魔法以外は小さなアイコン、イラスト、カード番号、効果テキストの枠、左下にパスワード。)",
"properties": {
"card_name": {
"type": "string",
"inferenceType": "explicit",
"description": "Card name in the top banner, exactly as printed in Japanese. Exclude the small furigana (ruby) reading text printed above the name.(上部の帯のカード名。日本語で印字どおりに。名前の上の小さなふりがな(ルビ)は除く。)"
},
"card_icon_kanji": {
"type": "string",
"inferenceType": "explicit",
"description": "The single kanji inside the round icon at the top right, as printed. Exclude the small furigana above it.(右上の丸いアイコンの中の漢字1文字を印字どおりに。上の小さなふりがなは除く。)"
},
"spell_type": {
"type": "string",
"inferenceType": "inferred",
"description": "Spell type from the small icon right after the bracketed card type under the name. One of: normal, quick-play, continuous, field, equip, ritual. If there is no icon next to the bracket, return normal.(名前の下のかっこのカード種別の直後の小さなアイコンから判断する魔法の種類。normal(通常)/ quick-play(速攻)/ continuous(永続)/ field(フィールド)/ equip(装備)/ ritual(儀式)のどれか。アイコンが無ければnormal。)"
},
"effect_text": {
"type": "string",
"inferenceType": "explicit",
"description": "Full effect text in the text box below the illustration, exactly as printed, joined into one line without line breaks. Exclude small furigana (ruby) text.(イラストの下のテキスト枠の効果テキスト全文。印字どおりに、改行せず1行につなぐ。ふりがなは除く。)"
},
"passcode": {
"type": "string",
"inferenceType": "explicit",
"description": "8 digit number printed at the bottom left corner of the card, below the text box. Empty string if not visible.(カード左下隅、テキスト枠の下の8桁の数字。見えなければ空文字。)"
},
"set_number": {
"type": "string",
"inferenceType": "explicit",
"description": "Alphanumeric number at the bottom right of the illustration frame, just above the text box, like XXXX-JP000. Empty string if not visible.(イラスト枠の右下、テキスト枠のすぐ上の英数字の番号(XXXX-JP000形式)。見えなければ空文字。)"
}
}
}
書類全体の説明(訳)
日本のトレーディングカードゲームの魔法カード1枚。カードの種類は、まず枠(背景)の色で判断する。枠全体が上から下まで緑(青緑)。上半分と下半分で色が違う(下半分だけ緑の)場合はペンデュラムモンスターで、魔法ではない。赤紫の枠は罠で、魔法ではない。魔法カードには星アイコンもATK/DEFも無い。レイアウト:名前、右上に漢字1文字の丸いアイコン、名前の下の右寄せにかっこのカード種別と、通常魔法以外は小さなアイコン、イラスト、カード番号、効果テキストの枠、左下にパスワード。
| 項目 | 型 | 取り方 | 説明(訳) |
|---|---|---|---|
| card_name | 文字列 | 読み取り | 上部の帯のカード名。日本語で印字どおりに。名前の上の小さなふりがな(ルビ)は除く。 |
| card_icon_kanji | 文字列 | 読み取り | 右上の丸いアイコンの中の漢字1文字を印字どおりに。上の小さなふりがなは除く。 |
| spell_type | 文字列 | 推論 | 名前の下のかっこのカード種別の直後の小さなアイコンから判断する魔法の種類。normal(通常)/ quick-play(速攻)/ continuous(永続)/ field(フィールド)/ equip(装備)/ ritual(儀式)のどれか。アイコンが無ければnormal。 |
| effect_text | 文字列 | 読み取り | イラストの下のテキスト枠の効果テキスト全文。印字どおりに、改行せず1行につなぐ。ふりがなは除く。 |
| passcode | 文字列 | 読み取り | カード左下隅、テキスト枠の下の8桁の数字。見えなければ空文字。 |
| set_number | 文字列 | 読み取り | イラスト枠の右下、テキスト枠のすぐ上の英数字の番号(XXXX-JP000形式)。見えなければ空文字。 |
罠用(TrapCard)
{
"class": "TrapCard",
"description": "A single Japanese trading card game trap card. Decide the card kind by the frame (background) color first. The whole frame is magenta (pinkish purple). A green frame is a spell, not a trap. A purple fusion monster frame is close in color but has star icons and ATK/DEF; trap cards have neither. Layout: name; round icon with one kanji at top right; under the name, right aligned, the bracketed card type, then a small icon for continuous or counter traps; illustration; set number at the bottom right of the illustration frame; effect text box; passcode at bottom left.(日本のトレーディングカードゲームの罠カード1枚。カードの種類は、まず枠(背景)の色で判断する。枠全体が赤紫(ピンク寄りの紫)。緑の枠は魔法で、罠ではない。紫の融合モンスターの枠は色が近いが、星アイコンとATK/DEFがある(罠カードにはどちらも無い)。レイアウト:名前、右上に漢字1文字の丸いアイコン、名前の下の右寄せにかっこのカード種別と、永続・カウンター罠なら小さなアイコン、イラスト、イラスト枠の右下にカード番号、効果テキストの枠、左下にパスワード。)",
"properties": {
"card_name": {
"type": "string",
"inferenceType": "explicit",
"description": "Card name in the top banner, exactly as printed in Japanese. Exclude the small furigana (ruby) reading text printed above the name.(上部の帯のカード名。日本語で印字どおりに。名前の上の小さなふりがな(ルビ)は除く。)"
},
"card_icon_kanji": {
"type": "string",
"inferenceType": "explicit",
"description": "The single kanji inside the round icon at the top right, as printed. Exclude the small furigana above it.(右上の丸いアイコンの中の漢字1文字を印字どおりに。上の小さなふりがなは除く。)"
},
"trap_type": {
"type": "string",
"inferenceType": "inferred",
"description": "Trap type from the small icon right after the bracketed card type under the name. One of: normal, continuous, counter. If there is no icon next to the bracket, return normal.(名前の下のかっこのカード種別の直後の小さなアイコンから判断する罠の種類。normal(通常)/ continuous(永続)/ counter(カウンター)のどれか。アイコンが無ければnormal。)"
},
"effect_text": {
"type": "string",
"inferenceType": "explicit",
"description": "Full effect text in the text box below the illustration, exactly as printed, joined into one line without line breaks. Exclude small furigana (ruby) text.(イラストの下のテキスト枠の効果テキスト全文。印字どおりに、改行せず1行につなぐ。ふりがなは除く。)"
},
"passcode": {
"type": "string",
"inferenceType": "explicit",
"description": "8 digit number printed at the bottom left corner of the card, below the text box. Empty string if not visible.(カード左下隅、テキスト枠の下の8桁の数字。見えなければ空文字。)"
},
"set_number": {
"type": "string",
"inferenceType": "explicit",
"description": "Alphanumeric number at the bottom right of the illustration frame, just above the text box, like XXXX-JP000. Empty string if not visible.(イラスト枠の右下、テキスト枠のすぐ上の英数字の番号(XXXX-JP000形式)。見えなければ空文字。)"
}
}
}
書類全体の説明(訳)
日本のトレーディングカードゲームの罠カード1枚。カードの種類は、まず枠(背景)の色で判断する。枠全体が赤紫(ピンク寄りの紫)。緑の枠は魔法で、罠ではない。紫の融合モンスターの枠は色が近いが、星アイコンとATK/DEFがある(罠カードにはどちらも無い)。レイアウト:名前、右上に漢字1文字の丸いアイコン、名前の下の右寄せにかっこのカード種別と、永続・カウンター罠なら小さなアイコン、イラスト、イラスト枠の右下にカード番号、効果テキストの枠、左下にパスワード。
| 項目 | 型 | 取り方 | 説明(訳) |
|---|---|---|---|
| card_name | 文字列 | 読み取り | 上部の帯のカード名。日本語で印字どおりに。名前の上の小さなふりがな(ルビ)は除く。 |
| card_icon_kanji | 文字列 | 読み取り | 右上の丸いアイコンの中の漢字1文字を印字どおりに。上の小さなふりがなは除く。 |
| trap_type | 文字列 | 推論 | 名前の下のかっこのカード種別の直後の小さなアイコンから判断する罠の種類。normal(通常)/ continuous(永続)/ counter(カウンター)のどれか。アイコンが無ければnormal。 |
| effect_text | 文字列 | 読み取り | イラストの下のテキスト枠の効果テキスト全文。印字どおりに、改行せず1行につなぐ。ふりがなは除く。 |
| passcode | 文字列 | 読み取り | カード左下隅、テキスト枠の下の8桁の数字。見えなければ空文字。 |
| set_number | 文字列 | 読み取り | イラスト枠の右下、テキスト枠のすぐ上の英数字の番号(XXXX-JP000形式)。見えなければ空文字。 |
⚔️ バトルフェーズ(検証)
5枚を2回ずつ計10ジョブ流しました。非同期JOBのためポーリングしてます。
# Blueprint 4つのARNを並べてProjectを作る
PROJECT_ARN=$(aws textract create-project \
--project-name "$PROJECT_NAME" \
--extraction-configuration '{"BoundingBox":{"State":"ENABLED"},"Granularity":{"Types":["DOCUMENT"]},"OutputFormat":{"AdditionalFileFormat":{"State":"DISABLED"},"TextFormat":{"Types":["MARKDOWN"]}}}' \
--splitter-configuration '{"State":"ENABLED"}' \
--custom-configuration "{\"Blueprints\":[{\"BlueprintArn\":\"$BP_MONSTER\"},{\"BlueprintArn\":\"$BP_PENDULUM\"},{\"BlueprintArn\":\"$BP_SPELL\"},{\"BlueprintArn\":\"$BP_TRAP\"}]}" \
--query ProjectArn --output text)
# 画像1枚につき1ジョブ
JOB_ARN=$(aws textract start-document-insights \
--project-arn "$PROJECT_ARN" \
--input-configuration "{\"S3Uri\":\"s3://$BUCKET/input/card.png\"}" \
--output-configuration "{\"S3Uri\":\"s3://$BUCKET/output/card\"}" \
--query JobArn --output text)
# 終わるまで10秒おきに確認する
while :; do
STATUS=$(aws textract get-document-insights --job-arn "$JOB_ARN" --query Status --output text)
echo "$(date +%T) $STATUS"
[[ "$STATUS" != IN_PROGRESS ]] && break
sleep 10
done
🗂️ 分類の結果
10回すべて正しく振り分けられました
🔍 抽出の結果
テキストの四角は、抽出結果の座標をそのまま描いています。
96項目中82項目(85.4%)が正解でした。
| カード | 正解数(2回の合計) | 落とした項目 |
|---|---|---|
| クリボー | 19/22 | 効果テキスト(1〜数か所違い)、種族(「馬魔族」) |
| 黒き魔術師-ブラック・マジシャン | 20/22 | カード名(「-」が長音「ー」に)、効果テキスト(「①③」が「①~③」に) |
| オッドアイズ・ペンデュラム・ドラゴン | 26/28 | ペンデュラム効果(「エンドフェイズ」が「エンドフェイス」に) |
| サンダー・ボルト | 6/12 | カード名・アイコンの漢字・パスワードが空 OCRは「サンター・ホルト」と読み抽出結果では「サンダー・ボルト」 |
| 聖なるバリア -ミラーフォース- | 11/12 | カード名(「-」が長音「ー」に) |
例として、クリボー(1回目)の結果を載せます。
クリボーの抽出結果(result.json)
custom/0/result.json の中身です。explainability_info(項目ごとの信頼度と座標)は長いので、別に attack の分だけ抜き出しています。ARNのアカウントIDは伏せています。
{
"matched_blueprint": {
"arn": "arn:aws:textract:us-east-1:123456789012:blueprint/xxxxxxxxxxxx",
"name": "fin-monster",
"confidence": 0.9999992
},
"document_class": {
"type": "TradingCardMonster"
},
"split_document": {
"page_indices": [0]
},
"inference_result": {
"tribute_required": false,
"defense": "200",
"level": 1,
"attack": "300",
"card_category": "効果",
"card_name": "クリボー",
"set_number": "PAC1-JP010",
"attribute": "闇",
"passcode": "40640057",
"monster_type": "悪魔族",
"effect_text": "①:相手モンスターの攻撃で自分が戦闘ダメージを受けるダメージ計算時、このカードを手札から捨てて発動できる。その戦闘で発生する自分への戦闘ダメージを0にする。"
}
}
explainability_info の attack の部分です。
"attack": {
"success": true,
"confidence": 0.9710247203667184,
"type": "string",
"value": "300",
"geometry": [{
"page": 1,
"boundingBox": {"top": 0.9319837092504263, "left": 0.6289511928556452, "width": 0.06741740310362199, "height": 0.023805775902111748},
"vertices": [
{"x": 0.4411291013420868, "y": 0.8885780884305536},
{"x": 0.4884138172051566, "y": 0.8885780884305536},
{"x": 0.4884138172051566, "y": 0.9112751491567735},
{"x": 0.4411291013420868, "y": 0.9112751491567735}
],
"token_scores": [1, 1, 1, 1, 1],
"word_references": [{"word_index": 10, "page_index": 0}]
}]
}
表にするとこうなります。
| 項目 | 取り方 | 抽出値 | 信頼度 | 判定 |
|---|---|---|---|---|
| card_name | 読み取り | クリボー | 0.65 | ○ |
| monster_type | 読み取り | 悪魔族 | 0.35 | ○ |
| card_category | 読み取り | 効果 | 0.60 | ○ |
| attack | 読み取り | 300 | 0.97 | ○ |
| defense | 読み取り | 200 | 0.97 | ○ |
| attribute | 読み取り | 闇 | 0.93 | ○ |
| passcode | 読み取り | 40640057 | 0.42 | ○ |
| set_number | 読み取り | PAC1-JP010 | 0.94 | ○ |
| effect_text | 読み取り | …ダメージ計算時、このカードを… | 0.35 | △(印字の「計算時に」が「計算時、」になった1か所) |
| level | 推論 | 1 | 0.83 | ○ |
| tribute_required | 推論 | false | 0.88 | ○ |
効果テキストの「①:」「0」は半角で返ってくるので、全角・半角をそろえて比べています。
💡 メインフェーズ2(分かったこと・注意点)
種類ごとのフォーマットの違いを判断できた
黒き魔術師、ペンデュラム、魔法と罠も含めて10回すべて正しく分類できました。Blueprintに背景の色で判断するよう書き足すと正解率が上がったので、OCRの文字だけでなく背景もちゃんと見てくれていると思われます。
種類に合った項目を抜き出せた
ペンデュラムのスケール2つと効果2枠も混ざらず、種類ごとのBlueprintどおりに返ってきました。
書かれていない情報も推論できた
星のアイコンを数えてレベルを出し、「星5以上なら生贄が必要」というルールを当てはめて、生贄の要否を正しく判断できました。業務の書類なら「金額が10万円以上なら承認が必要」のような判定も、抽出と同じジョブでやらせられそうです。
項目の信頼度は目安程度
抽出結果には項目ごとに信頼度(0〜1)が付きます。間違えた項目は0.3〜0.7あたりに多く、目安にはなりました。ただ、ミラーフォースのカード名は「-」を「ー」と間違えたのに0.83で、正しく読めた回より高く出ていました。逆にクリボーの種族「悪魔族」は正しいのに0.38でした。しきい値で線を引いて「低いものだけ人が確認する」のは今回の検証では難しそうでした。
推論による補正?
Insightsはまず、OCRで読んだ文字(extraction/0/result.json)を元にAIが項目の値(custom/0/result.json)を作っているようです。サンダー・ボルトのカード名はOCRでは「サンター・ホルト」でしたが、抽出結果では「サンダー・ボルト」に直っていました。
Blueprintの説明から「これはカード名だ」と判断したうえで読み間違いを補正したと考えられます(あくまで私の予想です)。
コスト
料金はページ単位で自作のBlueprintでの抽出は1ページ0.04 USDでした。カード1枚ドローするごとに0.04 USDです。
🍜 エンドフェーズ(締め)
これまでのAI-OCRで決まった項目を抜き出すには、帳票ごとにフォーマットや項目の位置を登録したりサンプルを読み込ませて学習させたりするのが一般的でした。Textract Insightsは取りたい項目を自然言語で書いておくだけでAIが書類の種類を判断して値を抜き出してくれます。
フォーマットが少しずつ違う書類でも位置の登録や学習なしで扱えるのはとても使いやすいと感じました。
日本語はまだ正式サポート外ですが思ったより良い精度でした。日本語が正式にサポートされたら日本語で書いたBlueprintでもう一度デュエルしたいですね。
これで私はターンエンド‼️
カードの画像・カード名・テキストは株式会社コナミデジタルエンタテインメント(KONAMI)の著作物です。記事中の画像は検証の説明に必要な範囲で引用しています。
記事の内容は2026年11月22日時点の挙動です。








