When Reading Order Breaks: Why OCR Alignment Fails on Columns and Where Anchors Help
By Gregory Hain
Based on: Word-Level Alignment of OCR and Ground Truth under Zoning and Reading-Order Errors — Fonseca Cacho, Jorge Ramón
The 129-word train wreck
Picture an optical character recognition engine reading a historic two-column newspaper. Instead of processing down the left column and then starting at the top of the right column, the parser reads straight across both columns line by line, like a lawnmower cutting grass.
Imagine, for the moment, that it recognizes every word correctly. The transcription in your database contains the correct prose. The OCR output contains the same words, but its stream alternates between chunks from two different columns.
Now suppose you want to evaluate OCR word correspondences or extract word pairs to train an automated correction model. To do that, you need a word-level mapping: each OCR token links to the particular token in the transcription that it came from, or remains unmatched.
If you feed those two texts into a conventional monotone sequence aligner, it cannot preserve every correct correspondence across the reordered blocks. A local pointer-based tracker has a different weakness: it can search near the wrong place. In controlled experiments on paragraph swaps, the paper's reimplementation of a 2019 location-aware algorithm produced an error cascade averaging 129 consecutive tokens. For longer than one 86-word paragraph, its alignments remained incorrect, including words left unmatched.
This breakdown is the Zoning Problem revisited in a November 2026 paper, Word-Level Alignment of OCR and Ground Truth under Zoning and Reading-Order Errors (arXiv:2611.13752). Jorge Ramón Fonseca Cacho of the University of Nevada, Las Vegas, examines where local tracking fails, tests a multi-region anchor strategy, and highlights a scenario where anchor-based methods fall apart while a local tracker fares better.
Along the way, the paper uncovers a measurement trap in an early version of its own benchmark.

The invisible bug in the benchmark
Before fixing an algorithm, you have to measure it honestly. The paper opens with a cautionary confession about benchmarking.
In an early test harness for this project, the synthetic test generator displaced an out-of-order text block in both the OCR stream and the reference ground truth simultaneously. Because both sides were scrambled together, the reading order between them never actually diverged. On top of that, the evaluation code measured the raw percentage of words that received any match at all, rather than verifying whether the match was correct.
Under that flawed harness, every aligner looked perfect. A metric that counts any match as success could give full marks even if every word were mapped to the wrong position.
Fonseca Cacho rebuilt the synthetic protocol around three strict rules:
- Permute only the OCR side: The ground-truth sequence stays fixed. Only the OCR stream suffers block moves, paragraph swaps, or column interleaving.
- Track construction gold: Every OCR token retains an index pointing back to the exact ground-truth token it came from, even after synthetic character noise is added.
- Score true correctness, not match activity: When a token has a gold counterpart, a match to the wrong position counts simultaneously as a false positive and a false negative. Leaving it unmatched counts as a false negative; matching a token with no gold counterpart counts as a false positive. The harness tracks precision, recall, F1, mean cascade length, and recovery at 10 words ($R_{10}$): the share of breaks followed by at least one correct alignment within the next 10 OCR words.
When evaluated under this corrected protocol, the difficulty of non-sequential text became starkly visible.
Why reading-order errors corrupt your data
To understand why this matters, look at how post-OCR processing pipelines operate.
Raw OCR is imperfect. A correction model trained on aligned word pairs needs the garbled OCR input paired with its actual ground-truth word. If those correspondences are wrong, the training labels are wrong too.
Datasets rarely provide this mapping directly. They usually supply a page image, OCR text, and a ground-truth transcription. The developer must recover the token alignment.
Ground Truth: [The] [quick] [brown] [fox] ... [Section] [B]
OCR Output: [Section] [B] ... [The] [qu1ck] [brown] [fox]
Wrong Pair: [Section] -> [The] (Bad training pair!)
Anchor Jump: [Section] -> [Section], [The] -> [The]
Classic sequence alignment uses dynamic programming over edit operations, as in the Needleman-Wunsch and Wagner-Fischer algorithms. These alignments impose a strict constraint: monotonicity. If two OCR tokens are aligned in one order, their corresponding reference positions must appear in that same order.
That assumption works when the two texts preserve their sequence. It breaks when an OCR layout engine reads columns or document regions in a different order from the reference.
A monotone alignment cannot retain all correct links across that permutation. If the resulting wrong links become training pairs, a correction model can learn to turn one word into an unrelated one. An evaluation based on those links can also report the wrong error rate.
The important distinction is between matching the right spelling and matching the right occurrence. A repeated word may look identical in several places; only one position is its true counterpart.
Six ways to line up words
The paper compares six aligners, counting the two multi-region versions as one. The tour below separates those versions and groups the two external RETAS implementations together.
1. The 2019 Location-Aware Tracker
The baseline is a reimplementation of Fonseca Cacho and Taghva's 2019 algorithm. It walks through the OCR text token by token while maintaining a pointer $p$ into the ground truth. For each OCR token, it inspects a local window ($w = 20$) around $p$:
- First, it looks for an exact match at $p+1$.
- Next, it checks the forward window $[p+1, p+w]$ for an exact match.
- Then, it checks the backward window $[p-w, p-1]$.
- Finally, it tries increasing edit distances from 1 to 3, searching forward before backward at each distance.
If it finds a match, $p$ moves to that position, which can be behind its previous location. If it finds nothing, it leaves the word unmatched and bumps $p$ forward by 1, betting that the word was simply garbled noise.
The weakness is straightforward: when the true target lies outside the search windows, the tracker cannot reach it on that step. Misses advance the pointer and can cause further drift through the text that follows.
2. The Re-anchoring Extension
To heal that drift, the author added a second pass. It scans the initial alignment for streaks of four or more consecutive unmatched words. Within the first 80 positions of each streak, it looks for a four-word sequence, then a three-word sequence, matching a ground-truth sequence between 80 positions behind and 200 ahead of the last good match.
The sequence may disagree in at most one word; the other words must be identical or within edit distance 1. If it finds an anchor, it greedily matches the next 40 OCR words, looking forward up to 60 ground-truth positions and overwriting earlier matches.
This repairs some local drift. But its search still starts near the last good match, leaving sufficiently distant material out of reach.
3. RETAS-lite
Yalniz and Manmatha's 2011 Recursive Text Alignment Scheme (RETAS) approaches long-document alignment through unique word anchors: words that appear exactly once in the OCR text and exactly once in the ground truth.
RETAS was designed for books, where text order is reliable. It recursively processes the segments between anchors and finishes with edit-distance alignment.
Fonseca Cacho built a simplified single-level variant called RETAS-lite. Crucially, RETAS-lite keeps out-of-order anchors. If the word "biodiversity" appears once on each side, it matches those two instances regardless of where they sit. Between consecutive OCR anchors, it searches forward up to 40 ground-truth positions for words within edit distance 2, without passing the next anchor.
RETAS-lite is the author's own baseline. Its scores are not measurements of the original RETAS implementation.
4. Multi-Region Alignment (v1)
Multi-region v1 expands the anchor concept into a four-stage pipeline:
- Multi-scale anchors: It matches unique words. Then, for $k \in {4, 3, 2}$, it finds word $k$-grams that appear exactly once on both sides and do not overlap already anchored positions. This adds anchors where individual words are common but their sequences are unique.
- Local fill: It fills gaps between consecutive anchors whose ground-truth positions increase, using unused ground-truth words within edit distance 2 and a look-ahead of 60 positions.
- Chunk-to-window assignment: It partitions the OCR sequence into chunks of 16, 12, and 8 words in turn, retaining chunks with at least $\max(2,\lfloor s/3\rfloor)$ unmatched words. Ground-truth windows use the same sizes and stride $s/2$; windows containing any matched position are excluded. Chunk-window pairs score by their multiset word intersection. Pairs scoring at least 2 are accepted greedily from highest score down, with each chunk used at most once and accepted windows forbidden to overlap.
- Final cleanup: Remaining OCR words are matched to unused exact counterparts, searching forward from the previous match and wrapping around, or otherwise to an unused word within edit distance 1.
The v1 code freeze is commit e7813fc, recorded by the multiregion-v1-frozen tag. Its parameters were set during the initial synthetic and reading-order experiments, so those results are in-sample. The later stress and real-OCR evaluations followed the freeze.
5. Multi-Region Alignment (v2)
After observing v1's limitations, the author built v2 with three changes:
- An inverted index to accelerate chunk-to-window scoring.
- An automatic fallback to RETAS-lite for documents with 8,000 OCR tokens or more.
- A "scarcity merge": unmatched spans are aligned with the 2019 tracker if fewer than 5% of tokens and fewer than 2% of word 3-grams are unique on both sides, or if fewer than 35% of OCR words are matched after the v1 steps.
V2 was developed on separate synthetic seeds and IMPACT pages outside the 200-page test set, then frozen before the held-out evaluation.
6. External Baselines: genalog and Java RETAS
The study also includes Microsoft's genalog package and the original Java RETAS version 1.1, compiled with JDK 17.
Genalog aligns characters and uses Needleman-Wunsch on the final segments. Its output was converted to one ground-truth index per OCR word, choosing the closest spelling when several ground-truth words overlapped. Java RETAS ran at word level, with its output likewise parsed into a mapping.
These conversions matter: the paper checked the Java parsing against the tool's reported accuracy on one document pair, but that is not a general validation of either conversion.
What the benchmarks revealed
The experimental results split between synthetic controls, clean reading-order permutations, and noisy historical scans.
The synthetic torture test
On a 517-word base text subjected to medium-severity layout disruptions and a 6% per-word character-noise probability for words longer than two characters, the differences were striking. These are means over 10 seeds.
| Aligner | Block Move F1 | Paragraph Swap F1 | Column Interleave F1 | Swap Cascade ($\bar{C}$) | Swap Recovery ($R_{10}$) |
|---|---|---|---|---|---|
| Location-aware (2019) | 0.890 | 0.012 | 0.255 | 129.0 words | 0.17 |
| + Re-anchoring | 0.922 | 0.339 | 0.353 | 66.5 words | 0.17 |
| genalog (RETAS) | 0.920 | 0.181 | 0.500 | 207.0 words | 0.07 |
| RETAS-lite | 0.998 | 0.977 | 0.907 | 3.3 words | 0.98 |
| Multi-region v1 | 1.000 | 1.000 | 0.983 | 0.0 words | 1.00 |
On paragraph swaps, the 2019 pointer scored 0.012 F1. Its local search could remain near the wrong paragraph while the OCR stream read displaced text, producing the average cascade of 129 incorrectly aligned words. Microsoft's genalog also struggled, with 0.181 F1 and a 207-word mean cascade.
RETAS-lite kept cascades down to 3.3 words with 0.977 F1. Multi-region v1 reached a reported 1.000 F1 and zero mean cascade length on paragraph swaps.
There is a useful qualification: the synthetic interleave chunk lengths—8, 12, and 16 words—also match the multi-region aligner's chunk sizes. The author notes that this may help its column-interleave results. The real-OCR tests do not share that construction.
Real newspaper reading orders without OCR noise
For a historical-layout test, Fonseca Cacho used 40 KB IMPACT newspaper pages whose geometric region order differed from the XML traversal order of their PAGE region references. Those 40 came from the first 50 pages checked after shuffling the page list.
This test used the clean reference text on both sides: no OCR typos, only different region orders. Crucially, the XML traversal was a linearization convention, not a fully annotated human reading order. Ordering between articles in top-level unordered groups was unspecified.
Multi-region v1 posted an F1 of 0.987 and a recovery rate of 0.995, running in 9 milliseconds per page. RETAS-lite followed closely at 0.986 F1 in 5 milliseconds. The 2019 tracker scored 0.573, while Java RETAS achieved 0.590 and genalog reached 0.668, taking 2.544 seconds per page.
Real Tesseract OCR on historical scans
The main real-OCR test used Tesseract 5 on 200 held-out KB IMPACT page images, with Dutch and English models, page segmentation mode 6, and at most the first 600 OCR words per page.
These pages lacked word-level alignments. Their ground truth supplied region boxes, so the author approximated word boxes by dividing regions into line strips and allocating word widths in proportion to character counts. Tesseract boxes were then matched using Intersection over Union (IoU) and Normalized Edit Distance (NED).
On the high-confidence gold subset—identical word pairs, or pairs with NED ≤ 0.15 and IoU ≥ 0.05—the results were:
- Multi-region v1: 0.650 F1
- Multi-region v2: 0.607 F1
- RETAS-lite: 0.504 F1
- genalog: 0.371 F1
- Java RETAS: 0.273 F1
- Location-aware (2019): 0.053 F1
On all geometry gold, the corresponding page-mean scores for v1, RETAS-lite, and the 2019 tracker were 0.432, 0.354, and 0.038. The 2019 tracker fell below 0.10 on 191 of the 200 pages.
Also on all gold, multi-region v1 exceeded RETAS-lite on 175 pages and trailed on 25. The lift was uneven: the 52 largest positive page gaps accounted for at least half of the summed positive gap. The paper does not establish what caused those particular page-level advantages.

The boilerplate paradox and the quadratic cliff
The paper does not present multi-region v1 as a flawless cure. It documents two severe failure modes.
1. The boilerplate collapse
What happens when a document contains very few unique words?
The author tested a synthetic boilerplate page modeled after repetitive Federal Register notices: 693 words built from 59 distinct word types, only 10 of which appeared once. The test applied medium column interleaving and 6% noise.
The reported anchor-based methods struggled:
- RETAS-lite: 0.030 F1
- Java RETAS: 0.069 F1
- Multi-region v1: 0.125 F1
- Location-aware (2019): 0.456 F1
The 2019 location tracker scored more than three times v1's F1 on this fixture.
Repeated vocabulary removes the unique landmarks these methods depend on. Here, the local tracker's positional prior proved more useful than the tested anchor strategies. But the tracker is not strictly monotone: it can search backward as well as forward.
This is one synthetic text, not evidence that local tracking generally wins on forms, contracts, or repetitive notices. The paper explicitly leaves that generalization unestablished and does not independently annotate the residual errors to explain their causes.
2. The quadratic scaling penalty
Stage 3 of multi-region v1 compares candidate OCR chunks against candidate ground-truth windows. Its cost grows with the product of the two document lengths ($O(n \cdot m)$).
On synthetic texts built from distinct paragraphs, with medium column interleaving and 6% noise:
- At 1,000 tokens, v1 took 0.021 seconds and scored 0.771 F1.
- At 10,000 tokens, runtime climbed to 2.533 seconds, with 0.334 F1.
- At 50,000 tokens, runtime reached 61.5 seconds, with 0.256 F1.
A profiling run at about 10,000 tokens attributed 4.46 of 5.29 seconds—roughly 84%—to chunk-to-window scoring. The author suggests that more reading-order breaks and a smaller share of unique words may explain the declining accuracy with length; that explanation is not independently established.
RETAS-lite processed 50,000 tokens in 0.507 seconds while scoring 0.341 F1. At the largest tested lengths, it was both faster and more accurate than v1.
The mixed results of v2
Multi-region v2 addressed the runtime problem by indexing chunk scoring and handing documents of at least 8,000 OCR tokens to RETAS-lite. At those lengths, its alignments equal RETAS-lite's by construction.
In the separate v1–v2 comparison at 50,000 tokens, runtime fell from 57.7 seconds to 0.51 seconds and F1 rose from 0.256 to 0.341. The difference between v1's 57.7-second run and the scaling study's 61.5 seconds was timing variation.
The scarcity merge was less successful. On boilerplate, v2 reached 0.159 F1, improving over v1 by only 0.034 and missing its pre-specified improvement target of 0.15.
On the 200 IMPACT pages, v2 also scored lower than v1: 0.607 versus 0.650 on high-confidence gold. Scarcity fallback occurred on 48 pages, but those counts do not establish why accuracy fell. The author withholds a residual-error explanation pending independent annotation.
Why it matters for document parsing and OCR post-processing
For teams building document-processing pipelines, the findings offer useful checks rather than a universal recipe.
Stop treating match rate as correctness
Coverage—the percentage of OCR words assigned any ground-truth token—can describe an aligner's behavior. It cannot establish whether those assignments are right.
An aligner that maps every OCR word to the wrong position still scores 100% coverage. Evaluate correct positional links with precision, recall, and F1, and use cascade length and recovery to see what happens after a reading-order break. The paper retains match rate for comparison with earlier work, but never treats it as a correctness score.
Audit your training data for reading-order failures
If you train models to clean up OCR output, inspect how their training pairs were aligned. When OCR and reference reading orders differ, a monotone aligner cannot preserve every correct correspondence across the reordered material.
A local tracker can fail differently, continuing its search near an incorrect position. Either failure can contaminate training labels. The paper demonstrates these alignment risks; it does not show that every pipeline using dynamic programming or RETAS produces bad training data.
Test your aligner against the documents you actually have
No single tested method wins across every condition:
- For page-sized inputs with reading-order changes: Multi-region v1 performed well on the tested synthetic cases and led the reported real-OCR comparisons, subject to approximate-gold limitations. This supports testing it on similar inputs, not declaring it the strongest choice for all articles.
- For long documents: RETAS-lite and v2 were faster and had higher F1 than v1 at 25,000 and 50,000 tokens in the synthetic scaling test. That result does not establish performance on books or reports generally, or prove a linear runtime bound.
- For repetitive text: Include an anchor-scarce test in your evaluation. The 2019 tracker led on the single synthetic boilerplate fixture, but its advantage has not been established on real forms or repeated notices.
The study compares a limited set of implementations and settings. It does not claim a field-wide ranking, and non-monotone reference alignment itself is established prior work.
Better alignment does not automatically solve post-correction
The paper includes a sobering limitation. In a small LoRA corrector pilot evaluated at region level, alignment-derived training pairs did not improve character error rate over raw OCR.
The pilot is mentioned in the discussion rather than presented as a tabulated result. The paper does not report a statistical-significance finding for it or establish why correction failed to improve.
Better word-link scores and better downstream correction are separate outcomes. Whether improved alignment helps correction remains open in this study.
The missing ground truth
Fonseca Cacho's study brings a more explicit correctness protocol to a difficult corner of document processing. It shows how local tracking can lose its place, how anchors can recover displaced text, and where the tested anchor methods encounter their own limits.
The research also highlights a data gap: the author found no open dataset of modern multi-column pages with human word boxes under CC0, CC-BY, or public-domain terms. That is a reported search outcome, not proof that no such dataset exists.
The main real-OCR evaluation used historical Dutch newspapers with approximate word geometry derived from region boxes. A separate check used 14 pages of early modern blackletter and antiqua prints with human word coordinates. On those pages, v1 scored 0.742 F1 on all gold and 0.948 on high-confidence gold, but the small sample and automated word-box matching still limit the conclusions.
For the newspaper geometry gold, an automatic check on 20 pages produced a rough error estimate of 0.238. It mixed OCR spelling errors with possible gold-matching errors and could miss wrong matches between similar words. It is neither an independently measured gold-error rate nor an error bound.
Independent residual annotation and modern multi-column word-level ground truth remain missing. Until those gaps are filled, the practical lesson is to test reading-order changes explicitly—and keep the uncertainty in the reference alignment visible. ===END===