Aho-Corasick
One automaton for the whole dictionary, one pass over the text, demoing the p/moul/x/daily/ahocorasick library.
thermos
Patterns the, he, fox, over, lazy.
| start | end | pattern |
|---|---|---|
0 |
3 |
the |
1 |
3 |
he |
5 patterns, 17 automaton nodes, 7 bytes read once, 2 matches. Running a single-pattern scan per word would read those bytes 5 times instead.