<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>hOCR 与 ALTO on File Format Blog</title>
    <link>https://blog.fileformat.com/zh/tag/hocr-%E4%B8%8E-alto/</link>
    <description>Recent content in hOCR 与 ALTO on File Format Blog</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>zh</language>
    <lastBuildDate>Mon, 30 Nov 2026 00:00:00 +0000</lastBuildDate><atom:link href="https://blog.fileformat.com/zh/tag/hocr-%E4%B8%8E-alto/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>hOCR 与 ALTO XML：哪种 OCR 格式更适合数字图书馆？</title>
      <link>https://blog.fileformat.com/zh/ocr/hocr-vs-alto-xml-which-ocr-format-is-better-for-digital-libraries/</link>
      <pubDate>Mon, 30 Nov 2026 00:00:00 +0000</pubDate>
      
      <guid>https://blog.fileformat.com/zh/ocr/hocr-vs-alto-xml-which-ocr-format-is-better-for-digital-libraries/</guid>
      <description>比较数字图书馆中的 hOCR 与 ALTO XML。了解模式验证、METS 集成、文件大小以及 IIIF 搜索支持如何影响您的 OCR 工作流。</description>
      <content:encoded><![CDATA[<p><strong>最后更新</strong>: 20 Aug, 2026</p>
<figure class="align-center ">
    <img loading="lazy" src="images/hocr-vs-alto-xml-which-ocr-format-is-better-for-digital-libraries.png#center"
         alt="hOCR vs. ALTO XML: Which OCR Format Is Better for Digital Libraries?"/> 
</figure>

<h2 id="hocr-与-alto-xml数字保存与检索的关键差异">hOCR 与 ALTO XML：数字保存与检索的关键差异</h2>
<p>数字化实体收藏——无论是19世纪的报纸、稀有专著，还是市政档案——需要的远不止运行光学字符识别（OCR）引擎并将输出转储到纯文本文件。当纯文本剥离了边界框、列层次结构、字体样式和置信度分数时，下游搜索界面无法在页面图像上高亮命中词汇，长期保存库也会失去关键的结构上下文。</p>
<p>为了同时保留文本和空间布局，数字图书馆架构师通常在两种主流开放标准之间进行选择：<strong>hOCR</strong> 和 <strong>ALTO XML</strong>。虽然这两种格式都将识别的文本与几何坐标一起编码，但它们的设计理念、治理模型和仓库生态系统根本不同。</p>
<h2 id="了解-hocrweb-原生微格式">了解 hOCR：Web 原生微格式</h2>
<p>由 Thomas Breuel 于 2007 年创建，<strong>hOCR</strong> 采用务实的、面向网页的 OCR 序列化方法。它并未从头创建自定义 XML 词汇表，而是将布局、边界框和识别置信度元数据直接嵌入有效的 <strong>HTML 或 XHTML</strong> 文档中，使用标准化的 <code>class</code> 和 <code>title</code> 属性。</p>
<h3 id="hocr-如何结构化数据">hOCR 如何结构化数据</h3>
<p>hOCR 文件可以立即在任何网页浏览器中渲染。结构层次通过标准 HTML 元素与语义化的类名相结合来表达：</p>
<ul>
<li><code>ocr_page</code>：表示扫描的页面图像及其像素尺寸。</li>
<li><code>ocr_carea</code>：定义内容区域或列块。</li>
<li><code>ocr_par</code>：表示逻辑段落。</li>
<li><code>ocr_line</code>：捕获单行文本及其基线几何信息。</li>
<li><code>ocrx_word</code>：包装单个标记，在 <code>title</code> 属性中存储边界框（<code>bbox</code>）和引擎置信度（<code>x_wconf</code>）。</li>
</ul>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-html" data-lang="html"><span style="display:flex;"><span><span style="color:#75715e">&lt;!DOCTYPE html&gt;</span>
</span></span><span style="display:flex;"><span>&lt;<span style="color:#f92672">html</span> <span style="color:#a6e22e">xmlns</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;[http://www.w3.org/1999/xhtml](http://www.w3.org/1999/xhtml)&#34;</span> <span style="color:#a6e22e">xml:lang</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;en&#34;</span> <span style="color:#a6e22e">lang</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;en&#34;</span>&gt;
</span></span><span style="display:flex;"><span>&lt;<span style="color:#f92672">head</span>&gt;
</span></span><span style="display:flex;"><span>  &lt;<span style="color:#f92672">title</span>&gt;Digitized Page 001&lt;/<span style="color:#f92672">title</span>&gt;
</span></span><span style="display:flex;"><span>  &lt;<span style="color:#f92672">meta</span> <span style="color:#a6e22e">name</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;ocr-system&#34;</span> <span style="color:#a6e22e">content</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;tesseract 5.4.1&#34;</span> /&gt;
</span></span><span style="display:flex;"><span>  &lt;<span style="color:#f92672">meta</span> <span style="color:#a6e22e">name</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;ocr-capabilities&#34;</span> <span style="color:#a6e22e">content</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;ocr_page ocr_carea ocr_par ocr_line ocrx_word&#34;</span> /&gt;
</span></span><span style="display:flex;"><span>&lt;/<span style="color:#f92672">head</span>&gt;
</span></span><span style="display:flex;"><span>&lt;<span style="color:#f92672">body</span>&gt;
</span></span><span style="display:flex;"><span>  &lt;<span style="color:#f92672">div</span> <span style="color:#a6e22e">class</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;ocr_page&#34;</span> <span style="color:#a6e22e">id</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;page_1&#34;</span> <span style="color:#a6e22e">title</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;image &#39;scan_001.tif&#39;; bbox 0 0 2480 3508; ppageno 0&#34;</span>&gt;
</span></span><span style="display:flex;"><span>    &lt;<span style="color:#f92672">div</span> <span style="color:#a6e22e">class</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;ocr_carea&#34;</span> <span style="color:#a6e22e">id</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;block_1_1&#34;</span> <span style="color:#a6e22e">title</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;bbox 210 340 2250 520&#34;</span>&gt;
</span></span><span style="display:flex;"><span>      &lt;<span style="color:#f92672">p</span> <span style="color:#a6e22e">class</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;ocr_par&#34;</span> <span style="color:#a6e22e">id</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;par_1_1&#34;</span> <span style="color:#a6e22e">title</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;bbox 210 340 2250 520&#34;</span>&gt;
</span></span><span style="display:flex;"><span>        &lt;<span style="color:#f92672">span</span> <span style="color:#a6e22e">class</span><span style="color:#f92672">=</span><span style="color:#e6db74">\&#34;ocr_line\&#34;</span> <span style="color:#a6e22e">id</span><span style="color:#f92672">=</span><span style="color:#e6db74">\&#34;line_1_1\&#34;</span> <span style="color:#a6e22e">title</span><span style="color:#f92672">=</span><span style="color:#e6db74">\&#34;bbox</span> <span style="color:#a6e22e">215</span> <span style="color:#a6e22e">345</span> <span style="color:#a6e22e">1420</span> <span style="color:#a6e22e">410</span><span style="color:#960050;background-color:#1e0010">;</span> <span style="color:#a6e22e">baseline</span> <span style="color:#a6e22e">-0</span><span style="color:#960050;background-color:#1e0010">.</span><span style="color:#a6e22e">002</span> <span style="color:#a6e22e">-12</span><span style="color:#960050;background-color:#1e0010">\&#34;</span>&gt;\n          &lt;<span style="color:#f92672">span</span> <span style="color:#a6e22e">class</span><span style="color:#f92672">=</span><span style="color:#e6db74">\&#34;ocrx_word\&#34;</span> <span style="color:#a6e22e">id</span><span style="color:#f92672">=</span><span style="color:#e6db74">\&#34;word_1_1\&#34;</span> <span style="color:#a6e22e">title</span><span style="color:#f92672">=</span><span style="color:#e6db74">\&#34;bbox</span> <span style="color:#a6e22e">215</span> <span style="color:#a6e22e">345</span> <span style="color:#a6e22e">480</span> <span style="color:#a6e22e">410</span><span style="color:#960050;background-color:#1e0010">;</span> <span style="color:#a6e22e">x_wconf</span> <span style="color:#a6e22e">96</span><span style="color:#960050;background-color:#1e0010">\&#34;</span>&gt;档案&lt;/<span style="color:#f92672">span</span>&gt;\n          &lt;<span style="color:#f92672">span</span> <span style="color:#a6e22e">class</span><span style="color:#f92672">=</span><span style="color:#e6db74">\&#34;ocrx_word\&#34;</span> <span style="color:#a6e22e">id</span><span style="color:#f92672">=</span><span style="color:#e6db74">\&#34;word_1_2\&#34;</span> <span style="color:#a6e22e">title</span><span style="color:#f92672">=</span><span style="color:#e6db74">\&#34;bbox</span> <span style="color:#a6e22e">505</span> <span style="color:#a6e22e">348</span> <span style="color:#a6e22e">890</span> <span style="color:#a6e22e">408</span><span style="color:#960050;background-color:#1e0010">;</span> <span style="color:#a6e22e">x_wconf</span> <span style="color:#a6e22e">94</span><span style="color:#960050;background-color:#1e0010">\&#34;</span>&gt;集合&lt;/<span style="color:#f92672">span</span>&gt;\n        &lt;/<span style="color:#f92672">span</span>&gt;
</span></span><span style="display:flex;"><span>      &lt;/<span style="color:#f92672">p</span>&gt;
</span></span><span style="display:flex;"><span>    &lt;/<span style="color:#f92672">div</span>&gt;
</span></span><span style="display:flex;"><span>  &lt;/<span style="color:#f92672">div</span>&gt;
</span></span><span style="display:flex;"><span>&lt;/<span style="color:#f92672">body</span>&gt;
</span></span><span style="display:flex;"><span>&lt;/<span style="color:#f92672">html</span>&gt;
</span></span></code></pre></div><h3 id="hocr-的优势">hOCR 的优势</h3>
<ul>
<li><strong>Zero-Friction Web Tooling</strong>：开发者可以使用标准 HTML 解析器（<code>BeautifulSoup</code>、<code>lxml</code>、浏览器 DOM API）解析 hOCR，并直接使用 CSS 对布局进行样式化或检查。</li>
<li><strong>快速 PDF 层生成:</strong> 开源工具如 <strong>OCRmyPDF</strong> 原生使用 hOCR 将不可见、可搜索的文本层叠加到扫描的 TIFF 或 PDF 图像上，几乎没有转换开销。</li>
<li><strong>轻量化占用:</strong> 由于不为每个空格或字体属性使用冗长的嵌套 XML 标签，hOCR 文件紧凑且在高吞吐量批处理流水线中生成快速。</li>
</ul>
<h2 id="了解-alto-xml档案保存标准">了解 ALTO XML：档案保存标准</h2>
<p><strong>ALTO（分析布局和文本对象）</strong> 是由 <strong>美国国会图书馆</strong> 维护的开放 XML 架构。最初在欧盟的 METAe 项目期间开发，ALTO 专为文化遗产机构、国家图书馆和大规模保存库而设计。</p>
<h3 id="alto-xml-如何结构化数据">ALTO XML 如何结构化数据</h3>
<p>与 hOCR 过度使用 HTML 属性不同，ALTO 强制使用严格、强类型的 XML 架构定义（XSD）。一个 ALTO 文件将每个文档划分为三个核心部分：</p>
<ol>
<li><code>&lt;Description&gt;</code>: 捕获测量单位（<code>pixel</code>、<code>mm10</code> 或 <code>inch1200</code>）、源图像标识符以及 OCR 处理历史。</li>
<li><code>&lt;Styles&gt;</code>: 集中管理字体定义（<code>FONTFAMILY</code>、<code>FONTSIZE</code>、<code>FONTSTYLE</code>）和段落对齐，以避免单词重复样式元数据。</li>
<li><code>&lt;Layout&gt;</code>：将物理页面区域（<code>TopMargin</code>、<code>LeftMargin</code>、<code>RightMargin</code>、<code>BottomMargin</code> 和 <code>PrintSpace</code>）映射到 <code>TextBlock</code>、<code>TextLine</code>、<code>String</code> 和显式的 <code>SP</code>（空白）元素。</li>
</ol>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-xml" data-lang="xml"><span style="display:flex;"><span><span style="color:#75715e">&lt;?xml version=&#34;1.0&#34; encoding=&#34;UTF-8&#34;?&gt;</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">&lt;alto</span> <span style="color:#a6e22e">xmlns=</span><span style="color:#e6db74">&#34;[http://www.loc.gov/standards/alto/ns-v4#](http://www.loc.gov/standards/alto/ns-v4#)&#34;</span>
</span></span><span style="display:flex;"><span>      <span style="color:#a6e22e">xmlns:xsi=</span><span style="color:#e6db74">&#34;[http://www.w3.org/2001/XMLSchema-instance](http://www.w3.org/2001/XMLSchema-instance)&#34;</span>
</span></span><span style="display:flex;"><span>      <span style="color:#a6e22e">xsi:schemaLocation=</span><span style="color:#e6db74">&#34;[http://www.loc.gov/standards/alto/ns-v4#](http://www.loc.gov/standards/alto/ns-v4#) [http://www.loc.gov/standards/alto/v4/alto-4-4.xsd](http://www.loc.gov/standards/alto/v4/alto-4-4.xsd)&#34;</span><span style="color:#f92672">&gt;</span>
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">&lt;Description&gt;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&lt;MeasurementUnit&gt;</span>pixel<span style="color:#f92672">&lt;/MeasurementUnit&gt;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&lt;sourceImageInformation&gt;</span>
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">&lt;fileName&gt;</span>scan_001.tif<span style="color:#f92672">&lt;/fileName&gt;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&lt;/sourceImageInformation&gt;</span>
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">&lt;/Description&gt;</span>
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">&lt;Styles&gt;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&lt;TextStyle</span> <span style="color:#a6e22e">FONTFAMILY=</span><span style="color:#e6db74">&#34;Times New Roman&#34;</span> <span style="color:#a6e22e">FONTSIZE=</span><span style="color:#e6db74">&#34;14&#34;</span> <span style="color:#a6e22e">FONTSTYLE=</span><span style="color:#e6db74">&#34;bold&#34;</span> <span style="color:#a6e22e">ID=</span><span style="color:#e6db74">&#34;STYLE_1&#34;</span><span style="color:#f92672">/&gt;</span>
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">&lt;/Styles&gt;</span>
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">&lt;Layout&gt;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&lt;Page</span> <span style="color:#a6e22e">HEIGHT=</span><span style="color:#e6db74">&#34;3508&#34;</span> <span style="color:#a6e22e">ID=</span><span style="color:#e6db74">&#34;PAGE_1&#34;</span> <span style="color:#a6e22e">PHYSICAL_IMG_NR=</span><span style="color:#e6db74">&#34;1&#34;</span> <span style="color:#a6e22e">WIDTH=</span><span style="color:#e6db74">&#34;2480&#34;</span><span style="color:#f92672">&gt;</span>
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">&lt;PrintSpace</span> <span style="color:#a6e22e">HEIGHT=</span><span style="color:#e6db74">&#34;2900&#34;</span> <span style="color:#a6e22e">HPOS=</span><span style="color:#e6db74">&#34;200&#34;</span> <span style="color:#a6e22e">VPOS=</span><span style="color:#e6db74">&#34;300&#34;</span> <span style="color:#a6e22e">WIDTH=</span><span style="color:#e6db74">&#34;2080&#34;</span><span style="color:#f92672">&gt;</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">&lt;TextBlock</span> <span style="color:#a6e22e">HEIGHT=</span><span style="color:#e6db74">&#34;180&#34;</span> <span style="color:#a6e22e">HPOS=</span><span style="color:#e6db74">&#34;210&#34;</span> <span style="color:#a6e22e">ID=</span><span style="color:#e6db74">&#34;TB_1&#34;</span> <span style="color:#a6e22e">VPOS=</span><span style="color:#e6db74">&#34;340&#34;</span> <span style="color:#a6e22e">WIDTH=</span><span style="color:#e6db74">&#34;2040&#34;</span><span style="color:#f92672">&gt;</span>
</span></span><span style="display:flex;"><span>          <span style="color:#f92672">&lt;TextLine</span> <span style="color:#a6e22e">HEIGHT=</span><span style="color:#e6db74">&#34;65&#34;</span> <span style="color:#a6e22e">HPOS=</span><span style="color:#e6db74">&#34;215&#34;</span> <span style="color:#a6e22e">ID=</span><span style="color:#e6db74">&#34;TL_1&#34;</span> <span style="color:#a6e22e">VPOS=</span><span style="color:#e6db74">&#34;345&#34;</span> <span style="color:#a6e22e">WIDTH=</span><span style="color:#e6db74">&#34;1205&#34;</span><span style="color:#f92672">&gt;</span>
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&lt;String</span> <span style="color:#a6e22e">CONTENT=</span><span style="color:#e6db74">&#34;Archive&#34;</span> <span style="color:#a6e22e">HEIGHT=</span><span style="color:#e6db74">&#34;65&#34;</span> <span style="color:#a6e22e">HPOS=</span><span style="color:#e6db74">&#34;215&#34;</span> <span style="color:#a6e22e">ID=</span><span style="color:#e6db74">&#34;ST_1&#34;</span> <span style="color:#a6e22e">STYLEREFS=</span><span style="color:#e6db74">&#34;STYLE_1&#34;</span> <span style="color:#a6e22e">VPOS=</span><span style="color:#e6db74">&#34;345&#34;</span> <span style="color:#a6e22e">WC=</span><span style="color:#e6db74">&#34;0.96&#34;</span> <span style="color:#a6e22e">WIDTH=</span><span style="color:#e6db74">&#34;265&#34;</span><span style="color:#f92672">/&gt;</span>
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&lt;SP</span> <span style="color:#a6e22e">HPOS=</span><span style="color:#e6db74">&#34;480&#34;</span> <span style="color:#a6e22e">VPOS=</span><span style="color:#e6db74">&#34;345&#34;</span> <span style="color:#a6e22e">WIDTH=</span><span style="color:#e6db74">&#34;25&#34;</span><span style="color:#f92672">/&gt;</span>
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&lt;String</span> <span style="color:#a6e22e">CONTENT=</span><span style="color:#e6db74">&#34;Collection&#34;</span> <span style="color:#a6e22e">HEIGHT=</span><span style="color:#e6db74">&#34;60&#34;</span> <span style="color:#a6e22e">HPOS=</span><span style="color:#e6db74">&#34;505&#34;</span> <span style="color:#a6e22e">ID=</span><span style="color:#e6db74">&#34;ST_2&#34;</span> <span style="color:#a6e22e">STYLEREFS=</span><span style="color:#e6db74">&#34;STYLE_1&#34;</span> <span style="color:#a6e22e">VPOS=</span><span style="color:#e6db74">&#34;348&#34;</span> <span style="color:#a6e22e">WC=</span><span style="color:#e6db74">&#34;0.94&#34;</span> <span style="color:#a6e22e">WIDTH=</span><span style="color:#e6db74">&#34;385&#34;</span><span style="color:#f92672">/&gt;</span>
</span></span><span style="display:flex;"><span>          <span style="color:#f92672">&lt;/TextLine&gt;</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">&lt;/TextBlock&gt;</span>
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">&lt;/PrintSpace&gt;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&lt;/Page&gt;</span>
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">&lt;/Layout&gt;</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">&lt;/alto&gt;</span>
</span></span></code></pre></div><h3 id="alto-xml-的优势">ALTO XML 的优势</h3>
<ul>
<li><strong>METS 与存储库互操作性：</strong> ALTO 旨在嵌入 <strong>METS（元数据编码与传输标准）</strong> 包装器中，将结构化页面映射、描述性 MARC/Dublin Core 记录以及保存元数据（PREMIS）链接成单一的归档提交信息包（SIP）。</li>
<li><strong>丰富的排版和页边模型：</strong> ALTO 明确将页眉、页脚、边注、插图（<code>Illustration</code>）和图形分隔线（<code>GraphicalElement</code>）与正文文本分离。</li>
<li><strong>现代多边形与手写文本识别（HTR）支持：</strong> 从 ALTO v4 开始，模式加入了对多边形边界形状和基线折线的原生支持，使其兼容诸如 <strong>Transkribus</strong> 和 <strong>eScriptorium</strong> 等手写文本识别（HTR）工具。</li>
</ul>
<h2 id="并排比较hocr-与-alto-xml">并排比较：hOCR 与 ALTO XML</h2>
<table>
<thead>
<tr>
<th style="text-align:left">特性 / 标准</th>
<th style="text-align:left">hOCR</th>
<th style="text-align:left">ALTO XML</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left"><strong>基础语法</strong></td>
<td style="text-align:left">带微格式（<code>class</code>、<code>title</code>）的 HTML / XHTML</td>
<td style="text-align:left">受 XSD 架构约束的强类型 XML</td>
</tr>
<tr>
<td style="text-align:left"><strong>维护主体</strong></td>
<td style="text-align:left">社区维护的开放规范（<code>kba/hocr-spec</code>）</td>
<td style="text-align:left">美国国会图书馆（ALTO 编辑委员会）</td>
</tr>
<tr>
<td style="text-align:left"><strong>模式验证</strong></td>
<td style="text-align:left">宽松；依赖 HTML 验证器和自定义属性检查工具</td>
<td style="text-align:left">严格的 XSD 验证确保结构一致性</td>
</tr>
<tr>
<td style="text-align:left"><strong>元数据与坐标存储</strong></td>
<td style="text-align:left">在 <code>title</code> 属性中使用分号分隔的键值字符串</td>
<td style="text-align:left">显式类型的 XML 属性（<code>HPOS</code>、<code>VPOS</code>、<code>WIDTH</code>、<code>HEIGHT</code>、<code>WC</code>）</td>
</tr>
<tr>
<td style="text-align:left"><strong>排版与字体建模</strong></td>
<td style="text-align:left">最小化；在 OCR 引擎之间很少标准化</td>
<td style="text-align:left">专用的 <code>&lt;Styles&gt;</code> 块，包含 <code>TextStyle</code> 和 <code>ParagraphStyle</code> 引用</td>
</tr>
<tr>
<td style="text-align:left"><strong>页面区域粒度</strong></td>
<td style="text-align:left">基本块、段落、行和单词</td>
<td style="text-align:left">显式边距（<code>TopMargin</code>、<code>BottomMargin</code>），<code>PrintSpace</code>、表格和插图</td>
</tr>
<tr>
<td style="text-align:left"><strong>METS / PREMIS 集成</strong></td>
<td style="text-align:left">需要自定义包装或转换</td>
<td style="text-align:left">METS/PREMIS 档案包的原生伴随标准</td>
</tr>
<tr>
<td style="text-align:left"><strong>OCR 引擎支持</strong></td>
<td style="text-align:left">Tesseract, OCRopus, Calamari, Kraken</td>
<td style="text-align:left">Tesseract (v4.1+), ABBYY FineReader, Transkribus, eScriptorium</td>
</tr>
<tr>
<td style="text-align:left"><strong>文件详细程度</strong></td>
<td style="text-align:left">紧凑且轻量化</td>
<td style="text-align:left">由于显式的 <code>&lt;SP&gt;</code> 标签和属性模式而显得冗长</td>
</tr>
</tbody>
</table>
<h2 id="影响数字图书馆的关键架构差异">影响数字图书馆的关键架构差异</h2>
<h3 id="1-模式验证-vs-字符串解析">1. 模式验证 vs. 字符串解析</h3>
<p>在 <strong>ALTO XML</strong> 中，每个坐标、置信度分数和样式引用都是显式的 XML 属性，并根据官方 XSD 架构进行验证。如果 OCR 流程产生了格式错误的坐标或无效的引用 ID，自动摄取验证会立即捕获，防止仓库被损坏。</p>
<p>在 <strong>hOCR</strong> 中，关键的几何数据被打包在 HTML <code>title</code> 属性内部的非结构化文本字符串中（例如，<code>title=\&quot;bbox 215 345 480 410; x_wconf 96\&quot;</code>）。使用者必须编写二次字符串拆分解析器来提取坐标和置信度值，而标准的 HTML5 验证器不会标记 <code>title</code> 字符串中的拼写错误。</p>
<h3 id="2-报纸和复杂布局分割">2. 报纸和复杂布局分割</h3>
<p>历史报纸和多栏期刊给搜索和发现平台带来严峻挑战。如果 OCR 引擎将页眉、页码、广告和文章栏合并为单一的阅读流，全文搜索的相关性会迅速下降。</p>
<p>ALTO XML 通过将页面几何划分为不同的区域（<code>TopMargin</code>、<code>PrintSpace</code>、<code>ComposedBlock</code>、<code>Illustration</code>）并编码显式的阅读顺序属性（<code>IDNEXT</code>）来结构化地解决此问题。虽然 hOCR 支持 <code>ocr_carea</code> 和 <code>ocr_header</code> 类，但不同 OCR 引擎的实现差异很大。</p>
<h3 id="3-发现层和-iiif-集成">3. 发现层和 IIIF 集成</h3>
<p>现代数字图书馆在展示高分辨率扫描件并提供命中高亮覆盖层时，严重依赖 <strong>International Image Interoperability Framework (IIIF)</strong> 和 <strong>Mirador</strong> 或 <strong>Universal Viewer</strong> 等查看器。</p>
<ul>
<li><strong>ALTO XML</strong> 开箱即集成主要的存储库平台——包括 <strong>Islandora</strong>、<strong>Samvera/Hyrax</strong>、<strong>DSpace</strong>、<strong>Kitodo</strong> 和 <strong>Goobi</strong>——以及 IIIF Content Search 服务器（例如 <code>iiif-content-search</code> 和基于 Solr 的 OCR 插件，如 <code>solr-ocrhighlighting</code>）。</li>
<li><strong>hOCR</strong> 与轻量级网页查看器以及 <code>solr-ocrhighlighting</code> 无缝配合，尤其是当团队在没有完整的 METS/ALTO 存储库堆栈的情况下构建自定义的 Python 或 Node.js 前端时。</li>
</ul>
<h3 id="4-存储开销与处理速度">4. 存储开销与处理速度</h3>
<p>由于 ALTO XML 为每个单词之间的空格记录显式的 <code>&lt;SP&gt;</code> 元素，并附带详细的坐标属性，ALTO 文件通常比同页的等效 hOCR 文件大 <strong>30% 到 60%</strong>。对于跨越数千万页的收藏，这一差异会影响存储预算和 XML 索引吞吐量——尽管 gzip 压缩可以显著降低磁盘占用。</p>
<h2 id="实用工作流在-hocr-与-alto-xml-之间转换">实用工作流：在 hOCR 与 ALTO XML 之间转换</h2>
<p>数字图书馆很少会永久锁定在单一格式上。由于两种格式都表示层次化的边界框和文本标记，您可以使用成熟的开源工具在它们之间进行转换：</p>
<ol>
<li><strong>直接导出自 Tesseract:</strong> 现代 Tesseract 发行版能够在单次识别过程中原生输出两种格式，无需额外转换步骤：</li>
</ol>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>tesseract page_001.tif output_base -l eng hocr alto
</span></span></code></pre></div><ol start="2">
<li><strong>XSLT 转换（<code>hOCR-to-ALTO</code>）：</strong> 标准化的 XSLT 2.0 样式表（在开源 <code>filak/hOCR-to-ALTO</code> 仓库中维护）将传统的 Tesseract hOCR 档案转换为有效的 ALTO v2.0、v2.1、v3 或 v4 XML，使用 Saxon-HE。</li>
<li><strong>Python 库（<code>ocr-fileformat</code>）：</strong> 对于自动化摄取流水线，像 <code>ocr-fileformat</code> 这样的命令行包装器可在 hOCR、ALTO XML 和 PAGE XML 之间统一转换。</li>
</ol>
<h2 id="数字图书馆应选择哪种-ocr-格式">数字图书馆应选择哪种 OCR 格式？</h2>
<p>在 hOCR 与 ALTO XML 之间的选择取决于您的重点是 <strong>长期档案管理</strong> 还是 <strong>敏捷的面向网络的处理</strong>：</p>
<ul>
<li>
<p><strong>如果选择 ALTO XML，请在以下情况下：</strong></p>
<ul>
<li>您管理的大学、博物馆或国家图书馆仓库基于 <strong>METS、PREMIS、Islandora、Samvera、Kitodo 或 Goobi</strong> 构建。</li>
<li>您的收藏包括需要严格区分页眉、页脚、插图和正文的复杂多栏报纸、期刊或历史书籍。</li>
<li>您的资助拨款或机构保存政策要求遵守 <strong>美国国会图书馆</strong> 档案标准，并进行严格的 XSD 架构验证。</li>
</ul>
</li>
<li>
<p><strong>如果选择 hOCR：</strong></p>
<ul>
<li>您的主要目标是通过 OCRmyPDF 生成 <strong>可搜索的 PDF/A 派生文件</strong>，或为轻量级网页搜索覆盖层提供支持。</li>
<li>您正在使用 Python 或 JavaScript 构建一个由开发者主导的自定义数字化流水线，在该流水线中，标准的 HTML DOM 工具可加速开发。</li>
<li>您希望在快速原型阶段使用紧凑的中间 OCR 文件，然后再归档最终的派生文件。</li>
</ul>
</li>
</ul>
<p>对于大多数负责跨数十年保存文化遗产的机构数字图书馆而言，<strong>ALTO XML（v4.x）<strong>仍是更强大的长期标准——而</strong>hOCR</strong>则是用于快速网页交付和 PDF 生成的理想轻量级伴侣。</p>
<h2 id="常见问题解答faq">常见问题解答（FAQ）</h2>
<p><strong>Q1. Tesseract OCR 能否同时生成 hOCR 和 ALTO XML 文件？</strong> 是的，Tesseract 允许您在单个命令中传递 <code>hocr</code> 和 <code>alto</code> 配置参数，从一次 OCR 运行中同时输出两个文件。</p>
<p><strong>Q2. 哪种 OCR 格式更适合与 METS 和 PREMIS 存档包一起使用？</strong> ALTO XML 专为与 METS 和 PREMIS 结合使用而设计，适用于结构化的数字保存工作流。</p>
<p><strong>Q3. hOCR 与 ALTO XML 哪个更适合创建可搜索的 PDF？</strong> hOCR 通常更快，并且在开源工具（如 OCRmyPDF）中作为本机中间格式得到更广泛的支持，可用于嵌入隐藏文本层。</p>
<p><strong>Q4. 能否在不重新运行 OCR 的情况下将已有的 hOCR 文件转换为有效的 ALTO XML？</strong> 可以，您可以使用开源 XSLT 样式表（例如 <code>hOCR-to-ALTO</code>）或 Python 工具如 <code>ocr-fileformat</code> 将 hOCR 转换为符合模式的 ALTO XML。</p>
<p><strong>Q5. ALTO XML 是否支持手写文本识别（HTR）基线？</strong> 是的，从 ALTO 版本 4 开始，模式支持多边形坐标和基线折线，适用于诸如 Transkribus 和 eScriptorium 等 HTR 引擎。</p>
<h2 id="另见">另见</h2>
<ul>
<li><a href="https://blog.fileformat.com/en/pdf/pdfa-3-the-hybrid-monster-embedding-original-data-inside-your-ocr/">PDF/A-3 - 混合怪兽？在您的 OCR 中嵌入原始数据</a></li>
<li><a href="https://blog.fileformat.com/ocr/understanding-ocr-file-formats-hocr-vs-alto-vs-pdfa-explained/">了解 OCR 文件格式 - HOCR、ALTO 与 PDF/A 解析</a></li>
<li><a href="https://blog.fileformat.com/pdf/what-is-the-difference-between-pdf-and-fdf/">PDF 与 FDF 有何区别？</a></li>
<li><a href="https://blog.fileformat.com/pdf/what-is-fdf-used-for/">FDF 用途是什么？了解表单数据格式的目的</a></li>
<li><a href="https://blog.fileformat.com/file-formats/pdf-vs-word-which-one-should-you-use-and-when/">PDF 与 Word：何时使用哪一个？</a></li>
</ul>
<!-- raw HTML omitted -->
]]></content:encoded>
    </item>
    
  </channel>
</rss>
