基于DAWG和AC自动机的高效动态字典匹配
Efficient Dynamic Dictionary Matching with DAWGs and AC-automata
摘要:
字典匹配是在文本$T$上的集合$D$(称为字典)中找到所有模式的任务。Aho-Corasick-automaton(AC-automaton)是一种数据结构,它使我们能够在$O(d\logσ)$预处理时间和$O(n\logσ+occ)$匹配时间内解决字典匹配问题,其中$d$是$D$中模式的总长度,$n$是文本的长度,$σ$是字母表大小,而$occ$是文本中所有模式出现的总次数。动态字典匹配是一种变体,其中模式可以动态地插入$D$中和从$D$中删除。如果只允许插入,这个问题被称为半动态字典匹配。在本文中,我们提出了两个有效的算法。对于长度为$m$的模式,我们的第一个算法在半动态设置下支持$O(m\logσ+\log d/\log\log d)$时间的插入和$O(n\logσ+occ)$时间的模式匹配,在动态设置下通过一些修改支持$O(σm+\log d/\log\log d)$时间的插入和删除以及$O(n(\log d/\log\log d+\logσ)+occ(\log d/\log\log d))$时间的模式匹配。该算法基于有向无环词图。我们的第二个算法,这是基于AC-自动机,支持插入在$O(m\log σ+u_f+u_o)$时间的半动态设置,并支持插入和删除在$O(σm+u_f+u_o)$时间的动态设置,其中$u_f$和$u_o$分别表示在故障功能和输出功能需要更新的状态的数量。该算法在$O(n\logσ+occ)$时间内为两种设置执行模式匹配。我们的算法实现了最佳的更新时间AC自动机为基础的方法在恒定大小的字母表,因为任何算法,明确维护AC自动机需要$Ω(m+u_f+u_o)$更新时间。
英文摘要:
The dictionary matching is a task to find all occurrences of patterns in a set $D$ (called a dictionary) on a text $T$. The Aho-Corasick-automaton (AC-automaton) is a data structure which enables us to solve the dictionary matching problem in $O(d\logσ)$ preprocessing time and $O(n\logσ+occ)$ matching time, where $d$ is the total length of the patterns in $D$, $n$ is the length of the text, $σ$ is the alphabet size, and $occ$ is the total number of occurrences of all the patterns in the text. The dynamic dictionary matching is a variant where patterns may dynamically be inserted into and deleted from $D$. This problem is called semi-dynamic dictionary matching if only insertions are allowed. In this paper, we propose two efficient algorithms. For a pattern of length $m$, our first algorithm supports insertions in $O(m\logσ+\log d/\log\log d)$ time and pattern matching in $O(n\logσ+occ)$ time for the semi-dynamic setting and supports both insertions and deletions in $O(σm+\log d/\log\log d)$ time and pattern matching in $O(n(\log d/\log\log d+\logσ)+occ(\log d/\log\log d))$ time for the dynamic setting by some modifications. This algorithm is based on the directed acyclic word graph. Our second algorithm, which is based on the AC-automaton, supports insertions in $O(m\log σ+u_f+u_o)$ time for the semi-dynamic setting and supports both insertions and deletions in $O(σm+u_f+u_o)$ time for the dynamic setting, where $u_f$ and $u_o$ respectively denote the numbers of states in which the failure function and the output function need to be updated. This algorithm performs pattern matching in $O(n\logσ+occ)$ time for both settings. Our algorithm achieves optimal update time for AC-automaton based methods over constant-size alphabets, since any algorithm which explicitly maintains the AC-automaton requires $Ω(m+u_f+u_o)$ update time.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。