English

Speeding-up $q$-gram mining on grammar-based compressed texts

Data Structures and Algorithms 2013-05-27 v1

Abstract

We present an efficient algorithm for calculating qq-gram frequencies on strings represented in compressed form, namely, as a straight line program (SLP). Given an SLP T\mathcal{T} of size nn that represents string TT, the algorithm computes the occurrence frequencies of all qq-grams in TT, by reducing the problem to the weighted qq-gram frequencies problem on a trie-like structure of size m=Tdup(q,T)m = |T|-\mathit{dup}(q,\mathcal{T}), where dup(q,T)\mathit{dup}(q,\mathcal{T}) is a quantity that represents the amount of redundancy that the SLP captures with respect to qq-grams. The reduced problem can be solved in linear time. Since m=O(qn)m = O(qn), the running time of our algorithm is O(min{Tdup(q,T),qn})O(\min\{|T|-\mathit{dup}(q,\mathcal{T}),qn\}), improving our previous O(qn)O(qn) algorithm when q=Ω(T/n)q = \Omega(|T|/n).

Keywords

Cite

@article{arxiv.1202.3311,
  title  = {Speeding-up $q$-gram mining on grammar-based compressed texts},
  author = {Keisuke Goto and Hideo Bannai and Shunsuke Inenaga and Masayuki Takeda},
  journal= {arXiv preprint arXiv:1202.3311},
  year   = {2013}
}
R2 v1 2026-06-21T20:19:47.098Z