Contextual Pattern Mining and Counting
Abstract
Given a string of length , a longer string of length , and two integers and , the context of in is the set of all string pairs , with and , such that the string occurs in . We introduce two problems related to the notion of context: (1) the Contextual Pattern Mining (CPM) problem, which given , , and an integer , asks for outputting the context of each substring of length of , provided that the size of the context of is at least ; and (2) the Contextual Pattern Counting (CPC) problem, which asks for preprocessing so that the size of the context of a given query string of length can be found efficiently. For CPM, we propose a linear-work algorithm that either uses only internal memory, or a bounded amount of internal memory and external memory, which allows much larger datasets to be handled. For CPC, we propose an -space index that can be constructed in time and answers queries in time. We further improve the practical performance of the CPC index by optimizations that exploit the LZ77 factorization of and an upper bound on the query length. Using billion-letter datasets from different domains, we show that the external memory version of our CPM algorithm can deal with very large datasets using a small amount of internal memory while its runtime is comparable to that of the internal memory version. Interestingly, we also show that our optimized index for CPC outperforms an approach based on the state of the art for the reporting version of CPC [Navarro, SPIRE 2020] in terms of query time, index size, construction time, and construction space, often by more than an order of magnitude.
Cite
@article{arxiv.2506.17613,
title = {Contextual Pattern Mining and Counting},
author = {Ling Li and Daniel Gibney and Sharma V. Thankachan and Solon P. Pissis and Grigorios Loukides},
journal= {arXiv preprint arXiv:2506.17613},
year = {2025}
}
Comments
27 pages, 15 figures