Aho-Corasick Multi-Pattern Matching
Implements the Aho-Corasick algorithm for efficient, simultaneous multi-pattern string matching in linear time.
This skill provides a robust implementation of the Aho-Corasick algorithm, a dictionary-matching utility that locates all instances of a set of patterns within a text simultaneously. By constructing a trie with KMP-style failure links, it achieves optimal O(n + m + z) complexity, making it significantly faster than brute-force or repeated KMP searches. It is particularly valuable in bioinformatics for genomic motif searching, as well as in security for high-speed keyword filtering and log analysis where searching for thousands of patterns in a single pass is required.
Key Features
01Automated failure link construction via BFS
02Optimal O(n + m + z) time complexity for search and build
033 GitHub stars
04Simultaneous multi-pattern searching in a single text pass
05Memory-efficient trie-based architecture for large pattern dictionaries
06Support for overlapping pattern detection (e.g., finding 'he' within 'she')
Use Cases
01Content Filtering: Detecting sets of prohibited keywords or sensitive data in streaming text
02Bioinformatics: Searching for multiple DNA motifs or protein sequences in genomic data
03Log Analysis: Scanning massive server logs for hundreds of specific error patterns or security threats