Fast Approximate String Matching with Suffix Arrays and A* Parsing

Philipp Koehn, Jean SenellartAMTA 2010

Introduction

In the professional translation industry, efficiency is paramount. Human translators rely on Translation Memories (TM)—massive databases of previously translated segments. When a new sentence arrives, the system must perform "fuzzy matching" to find similar existing translations. However, as these databases grow to tens of millions of words, traditional approximate string matching methods become a bottleneck. This paper presents a novel algorithm that achieves a 100x speedup over standard approaches by combining suffix arrays with A* search heuristics.

The Challenge: Beyond Dynamic Programming

The standard approach to approximate string matching involves dynamic programming (DP) to calculate edit distance, typically requiring an $O(nm)$ matrix. While effective for small datasets, this linear dependency on corpus size makes real-time search impossible for massive TMs. Unlike biological sequence matching (DNA), natural language features a large vocabulary and shorter sequences, allowing for more aggressive optimization. The goal is a sub-linear search algorithm that maintains perfect accuracy within a defined error threshold (e.g., 30% edit distance).

Methodology: The Filter-and-Validate Pipeline

The proposed method replaces brute-force DP with a sophisticated "filter-and-validate" pipeline designed to discard irrelevant data as early as possible.

1. Suffix Array Indexing

The first step involves indexing the entire corpus into a suffix array. This data structure enables the system to locate exact n-gram matches between the query and the corpus in $O(g \log n)$ time, where $g$ is the n-gram length. By identifying shared sequences of words, the algorithm quickly narrows down potential candidates.

Figure 4: Construction of a suffix array for a text segment, providing a sorted index for rapid corpus lookups.

2. A* Filtering and the Unigram Trick

Once n-gram matches are found, the algorithm applies A* filtering. It establishes a "ceiling cost"—the maximum allowable edit distance. For each candidate, it calculates a theoretical minimum edit distance based on segment length differences and n-gram positions. If this minimum exceeds the ceiling, the candidate is immediately pruned.

A critical optimization is the "Unigram Trick." Common words and punctuation (unigrams) appear everywhere, creating noise. The authors postpone unigram processing until after longer, more specific n-grams have already filtered out the majority of the search space, resulting in a nearly 10x speedup on its own.

3. A* Parsing for Validation

For the remaining candidates, the algorithm uses A* parsing rather than standard DP. It treats n-gram matches as grammar rules, building an optimal edit path bottom-up. As it finds better alignments, it lowers the ceiling cost, allowing it to prune sub-optimal paths dynamically.

Figure 6: The A* matching process iteratively refines the search by lowering the cost ceiling and pruning candidates.

Results

The algorithm was tested on two major datasets: the JRC-Acquis (23.5 million words) and a commercial Product manual corpus. The results were transformative:

  • 100x Speedup: The method consistently outperformed the DP baseline.
  • Real-time Performance: Lookup times for the massive Acquis corpus dropped from 33.7 seconds to just 247 milliseconds.
  • Effective Pruning: On the Acquis corpus, initial lookups flagged ~24,000 segments, but A* filtering reduced this to fewer than 80 segments for full validation.

Conclusion

By leveraging the unique properties of natural language—specifically its large vocabulary and segment-based structure—this A* suffix array approach makes real-time fuzzy matching practical for even the largest translation databases. Future work may involve further optimizing the ceiling cost reduction and handling degenerate input cases more gracefully.

Summary updated

BibTeX
@inproceedings{koehn2010fast,
  author = {Philipp Koehn and Jean Senellart},
  title = {{Fast Approximate String Matching with Suffix Arrays and A* Parsing}},
  booktitle = {AMTA},
  year = {2010},
}
Figure