NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Constant-Delay Enumeration for Nondeterministic Document Spanners

Antoine Amarilli, Pierre Bourhis, Stefan Mengel, Matthias Niewerth

Abstract

One of the classical tasks in information extraction is to extract subparts of texts through regular expressions. In the database theory literature, this approach has been generalized and formalized as document spanners. In this model, extraction is performed by evaluating a particular kind of automata, called a sequential variable-set automaton (VA). The efficiency of this task is then measured in the context of enumeration algorithms: we first run a preprocessing phase computing a compact representation of the answers, and second we produce the results one after the other with a short time between consecutive answers, called the delay of the enumeration. Our goal is to have an algorithm that is tractable in combined complexity, i.e., in the sizes of the input document and the VA, while ensuring the best possible data complexity bounds in the input document size, i.e., a constant delay that does not depend on the document. We present such an algorithm for a variant of VAs called extended sequential VAs and give an experimental evaluation of this algorithm.

Introduction

In the era of big data, extracting structured information from massive unstructured text is a critical challenge. Information extraction often relies on regular expressions augmented with variables, a framework formalized in database theory as document spanners. These spanners identify subsegments of text (spans) and assign them to specific variables, such as extracting names, dates, or addresses from legal documents or web logs.

The standard computational model for evaluating these spanners is the Variable-set Automaton (VA). However, two significant hurdles often impede practical implementation. First, the Output Explosion problem: a single document may contain a quadratic or even exponential number of valid matches relative to its length. Simply listing all matches can overwhelm system resources. Second, the Nondeterminism Trap: while most extraction rules are naturally nondeterministic, converting them into deterministic forms to simplify processing often leads to an exponential "state explosion," making the resulting rules too large to handle.

Previously, it was widely conjectured that one could not simultaneously achieve constant delay between results and avoid this exponential blowup. This paper refutes that notion, presenting an algorithm that achieves constant-delay enumeration even for nondeterministic rules.

Methodology: The Product DAG and Jump Functions

The core of the proposed solution lies in treating the extraction task as a graph traversal problem. The algorithm constructs a Product Directed Acyclic Graph (DAG) that represents the intersection of the document and the extraction rules. Every path from the start node to a final node in this DAG corresponds to a valid piece of extracted information.

Variable-set Automaton (top) and its corresponding Product DAG (bottom) illustrating the state transitions across a document.

To ensure efficiency, the authors introduce two primary innovations:

  1. The Jump Function: In large documents, there are frequently long sequences of text where no variables are assigned. A naive algorithm would traverse every character, leading to delays proportional to the document's length. The "Jump" function allows the algorithm to skip directly to the next "interesting" position in the document—where a variable is modified or a state change occurs—ensuring the delay remains independent of the document size.
  2. Flashlight Search: To handle nondeterminism without generating duplicate results, the algorithm employs a "flashlight search" technique. This allows the system to explore possible variable assignments at any point and determine, in constant time relative to the document, which paths will lead to a valid final result. This effectively performs a localized, on-the-fly determinization.

Key Insights and Results

The most significant theoretical contribution is the refutation of previous hardness conjectures. While counting the total number of results for nondeterministic VAs is computationally difficult (SpanL-hard), the authors prove that enumerating them one by one is not. This distinction allows for a balance between combined complexity (the algorithm remains efficient as rules become more complex) and data complexity (the document size only impacts the initial setup).

Complexity Bounds

The authors establish rigorous bounds in Theorem 1.1:

  • Preprocessing Time: $O((|Q|^{\omega+1} + |\delta|) \times |d|)$, where $|Q|$ is the number of states, $|d|$ is the document size, and $\omega$ is the exponent for matrix multiplication (approx. 2.37). This phase is linear with respect to the document size.
  • Enumeration Delay: $O(|V| \times (|Q|^2 + |\delta| \times |V|^2))$, where $|V|$ is the number of variables. Crucially, this delay is constant relative to the document size. Once preprocessing is complete, the time taken to produce each subsequent result remains stable, regardless of whether the document is a kilobyte or a gigabyte in size.

Limitations and Future Directions

While this algorithm represents a major step forward, several areas for future research remain. Currently, the algorithm assumes static documents. If a document is updated, the entire preprocessing phase must be re-executed. Developing "dynamic update" capabilities is a priority for real-time applications.

Furthermore, the current model is optimized for linear text. Generalizing these techniques to tree-structured data (such as XML or JSON) is more complex, as the "Jump" function does not easily translate to branching structures. Finally, while the theoretical polynomial bounds are promising, production-ready implementations will require careful optimization to manage the constants associated with large variable-set automata.

Summary updated

BibTeX
@inproceedings{amarilli2018constant,
  author = {Antoine Amarilli and Pierre Bourhis and Stefan Mengel and Matthias Niewerth},
  title = {{Constant-Delay Enumeration for Nondeterministic Document Spanners}},
  booktitle = {SIGMOD Rec},
  year = {2018},
}
Figure