🤖 AI Summary
This work addresses the challenge of applying traditional context-aware pattern matching to large-scale repetitive texts, where the O(n) space overhead renders conventional methods impractical. To overcome this limitation, the paper proposes a novel approach based on the Symmetric Compact Directed Acyclic Word Graph (SCDAWG), enabling context-aware pattern matching directly within a compressed representation. By integrating an improved linear-space distance-sensitive weighted ancestor data structure, the method achieves optimal enumeration of all matching positions along with their surrounding contexts of length λ on both sides. After O(m) preprocessing, queries are answered with O(log log λ) delay and in O(m + occ) total time, where m is the pattern length and occ the number of occurrences. This is the first solution to achieve optimal-time context-aware matching on a compressed text representation, substantially reducing space requirements while preserving high query efficiency.
📝 Abstract
Contextual pattern matching is the task of, given a pattern $P[1,m]$, a context length $λ$, and a text $T[1,n]$, find all the $occ$ distinct contexts in which $P$ occurs in $T$, the context being the $λ$ symbols preceding and the $λ$ symbols following the occurrence; a text position where each context occurs must be output. While the problem can be solved in optimal time $O(m+occ)$ using $O(n)$-space precomputed data structures on $T$, this type of search is particularly relevant on large repetitive text collections, where $O(n)$ space can be prohibitive. We present the first optimal-time solution that runs in compressed space, namely that of a symmetric CDAWG (SCDAWG) of $T$. Further, we show how the set of $occ$ solutions can be enumerated with $O(\log\logλ)$ delay after $O(m)$-time preprocessing of $P$. To achieve this, we develop an improved linear-space distance-sensitive weighted ancestor data structure.