このページは FormatArc のブログ記事が引用している実測の生データです。検索結果には表示されません (noindex)。
| File | Size |
|---|---|
| README.md | 4.8 KB |
| corpus.json | 2.4 KB |
| fetch-corpus.mjs | 1.7 KB |
| measure.mjs | 3.6 KB |
| package-lock.json | 10.5 KB |
| package.json | 428 B |
| results.json | 4.0 KB |
# PDF → Markdown の表・見出し抽出の実測
`pdf-to-markdown` ツールページと関連記事で使う数値の一次ソース。
「PDF を Markdown にすると表が崩れる」現象を 2 系統の実装で実測する。
## 測定対象
| 系統 | 構成 | 表の扱い |
| --- | --- | --- |
| `pdfjs` | pdf.js + `@opendocsg/pdf2md` | 表を組み立てる処理を持たない |
| `inspector` | pdf-inspector (Rust/WASM) | 矩形とフォント・座標から表構造を推定する |
実行環境: Apple M5 Pro / macOS (Darwin 25.5.0) / Node v26.3.1。
バージョンは `results.json` の `environment.dependencies` を参照。
## 対象 PDF
PDF 本体はリポジトリに含めない (サイズと再配布の都合)。`npm run fetch` が
下表の URL から取得し、`corpus.json` に sha256 を書き戻す。取得時点で配布元が
更新されていれば警告が出る。
| PDF | sha256 (先頭 16) | ライセンス |
| --- | --- | --- |
| Attention Is All You Need (arXiv:1706.03762) | `bdfaa68d8984f0dc…` | arXiv / 著者表示 |
| BERT (arXiv:1810.04805) | `5692a5514787a8c6…` | arXiv / 著者表示 |
| NIST Cybersecurity Framework 2.0 | `3c31f46fee98cac0…` | 米国政府著作物 (public domain) |
| IRS Form 1040 (2025) | `3d31c226df0d189c…` | 米国政府著作物 (public domain) |
| 労働力調査年報 基本集計 (総務省統計局) | `f0b2754b4d669730…` | 政府著作物 / 二次利用可 |
| 令和7年版 情報通信白書 概要 (総務省) | `554ec9b3c8beecc8…` | 総務省 二次利用許諾 |
| 経済・物価情勢の展望 (日本銀行) | `c35494595ea0cd6c…` | 日本銀行 / 引用 |
## 再現手順
```bash
cd scripts/benchmarks/pdf-table-extraction
npm install
npm run fetch # PDF を取得し sha256 を記録 (pdfs/ は gitignore)
npm run measure # results.json を生成
```
## 結果 (2026-08-02)
| PDF | 種類 | pdf.js+pdf2md 表行 | pdf-inspector 表行 | pdf.js 見出し | inspector 見出し |
| --- | --- | --- | --- | --- | --- |
| Attention Is All You Need | 2 段組の学術論文 | 0 | 50 | 45 | 38 |
| BERT | 2 段組の学術論文 | 0 | 106 | 27 | 42 |
| NIST Cybersecurity Framework 2.0 | 図版の多い技術文書 | 0 | 45 | 3 | 27 |
| IRS Form 1040 (2025) | 記入フォーム | 0 | 42 | 24 | 5 |
| 労働力調査年報 基本集計 | 多段の統計表 | 0 | 405 | 1360 | 6 |
| 令和7年版 情報通信白書 概要 | 図版中心のスライド | 0 | 9 | 38 | 112 |
| 経済・物価情勢の展望 (日本銀行) | 段組の中央銀行レポート | 0 | 19 | 211 | 1 |
## この数値が言えること・言えないこと
**`tableRows` は「表として出力された行数」であって、その表が正しいという意味ではない。**
自動判定できないので、誤検出の実例を手作業で以下に残す。
### 1. 図を表と誤検出する
NIST CSF 2.0 の円環図 (Fig. 1 CSF Core structure) は、図中に配置された文字が
表として出力される。頭文字も落ちる。
```
| Fig. 1. CSF Core structure |||
| --- | --- | --- |
| DENTIFY | ROTECT | ETECT ESPOND |
```
正しくは IDENTIFY / PROTECT / DETECT / RESPOND。円環に沿って配置された文字が
分断され、先頭文字が別要素として扱われている。
BERT 論文でも、モデル構成図のラベル (`Masked Sentence A | Masked Sentence B |
Question | Paragraph`) が表として出力される。
### 2. 本物の表でもセルの割り当てがずれる
労働力調査年報の統計表は 405 行の表として出力されるが、複数年の数値が 1 セルに
まとまる。
```
|15~ 64歳 6625 5878 6678 5893 6732 5912 …|15~ 24歳 595|25~ 34歳 1168|
```
一方 pdf.js + pdf2md はこの PDF で表を 1 行も出さず、代わりに本文行を
**1360 個の見出し**として出力する (正しい見出しは 4 個程度)。どちらも
そのままでは使えないが、失敗の仕方が違う。
### 3. 段組の文書全体が表になることがある
日本銀行「経済・物価情勢の展望」では、タイトルも本文も表のセルに入り、
見出しは末尾の「以 上」1 個だけになる。
```
|||||2025 年5月1日|
| --- | --- | --- | --- | --- |
||【基本的見解】|1|経済・物価情勢の展望(2025 年4月) <概要>|日本銀行|
```
**この破綻は表行の比率では検出できない。** 日銀レポートの表行比率は 0.43、
正常に表を持つ IRS Form 1040 は 0.45 で、閾値で分離できない。
## 限界
- 対象 7 本は文書種別の代表として選んだもので、統計的な標本ではない
- `headings` / `tableRows` は行数の計数であり、内容の正しさを測っていない
- 変換系の比較であって、OCR を持つ製品との比較ではない (両系統とも OCR を持たない)
{
"generatedAt": "2026-08-02",
"environment": {
"node": "v26.3.1",
"platform": "darwin/arm64",
"dependencies": {
"@firecrawl/pdf-inspector-wasm": "0.1.3",
"@opendocsg/pdf2md": "0.2.7",
"pdfjs-dist": "6.2.108"
}
},
"note": "tableRows / headings は出力された行数であって正しさではない。誤検出の実例は README を参照。",
"results": [
{
"id": "attention",
"label": "Attention Is All You Need (arXiv:1706.03762)",
"kind": "2 段組の学術論文",
"pdfjs": {
"chars": 40797,
"headings": 45,
"tableRows": 0,
"headingRatio": 0.156794425087108
},
"inspector": {
"chars": 40723,
"headings": 38,
"tableRows": 50,
"headingRatio": 0.14285714285714285,
"pdfType": "TextBased",
"hasEncodingIssues": false,
"pagesWithTables": 5
}
},
{
"id": "bert",
"label": "BERT (arXiv:1810.04805)",
"kind": "2 段組の学術論文",
"pdfjs": {
"chars": 65006,
"headings": 27,
"tableRows": 0,
"headingRatio": 0.1062992125984252
},
"inspector": {
"chars": 66132,
"headings": 42,
"tableRows": 106,
"headingRatio": 0.10144927536231885,
"pdfType": "TextBased",
"hasEncodingIssues": false,
"pagesWithTables": 10
}
},
{
"id": "nist-csf",
"label": "NIST Cybersecurity Framework 2.0",
"kind": "図版の多い技術文書",
"pdfjs": {
"chars": 69830,
"headings": 3,
"tableRows": 0,
"headingRatio": 0.01079136690647482
},
"inspector": {
"chars": 68386,
"headings": 27,
"tableRows": 45,
"headingRatio": 0.08411214953271028,
"pdfType": "TextBased",
"hasEncodingIssues": false,
"pagesWithTables": 6
}
},
{
"id": "irs-1040",
"label": "IRS Form 1040 (2025)",
"kind": "記入フォーム",
"pdfjs": {
"chars": 9990,
"headings": 24,
"tableRows": 0,
"headingRatio": 0.26373626373626374
},
"inspector": {
"chars": 10444,
"headings": 5,
"tableRows": 42,
"headingRatio": 0.05319148936170213,
"pdfType": "TextBased",
"hasEncodingIssues": false,
"pagesWithTables": 2
}
},
{
"id": "rodoryoku",
"label": "労働力調査年報 基本集計 (総務省統計局)",
"kind": "多段の統計表",
"pdfjs": {
"chars": 62270,
"headings": 1360,
"tableRows": 0,
"headingRatio": 0.8262454434993924
},
"inspector": {
"chars": 52196,
"headings": 6,
"tableRows": 405,
"headingRatio": 0.008836524300441826,
"pdfType": "TextBased",
"hasEncodingIssues": false,
"pagesWithTables": 18
}
},
{
"id": "soumu-hakusho",
"label": "令和7年版 情報通信白書 概要 (総務省)",
"kind": "図版中心のスライド",
"pdfjs": {
"chars": 11934,
"headings": 38,
"tableRows": 0,
"headingRatio": 0.1144578313253012
},
"inspector": {
"chars": 11680,
"headings": 112,
"tableRows": 9,
"headingRatio": 0.5384615384615384,
"pdfType": "TextBased",
"hasEncodingIssues": false,
"pagesWithTables": 6
}
},
{
"id": "boj-outlook",
"label": "経済・物価情勢の展望 (日本銀行)",
"kind": "段組の中央銀行レポート",
"pdfjs": {
"chars": 10128,
"headings": 211,
"tableRows": 0,
"headingRatio": 0.793233082706767
},
"inspector": {
"chars": 8923,
"headings": 1,
"tableRows": 19,
"headingRatio": 0.022727272727272728,
"pdfType": "TextBased",
"hasEncodingIssues": false,
"pagesWithTables": 2
}
}
]
}