cloudflare / ahocorasick

A Golang implementation of the Aho-Corasick string matching algorithm
BSD 3-Clause "New" or "Revised" License
589 stars 95 forks source link

Doesn't support incremental string matching #14

Open issamemari opened 2 years ago

issamemari commented 2 years ago

The algorithm assumes that the dictionary is fixed. I've found that in practical applications it may happen that the user needs to add new strings to the keyword dictionary and have the matching algorithm be able to start matching those on the fly.

This problem has been studied and a modification to the Aho Corasick algorithm to make it support incremental matching has been proposed by Bertrand Meyer in his article "Incremental string matching".

I've made several modifications to the implementation in my fork , among which is adding the possibility to do incremental string matching as described in Bertrand's article.

I'm happy to submit a PR with only the changes related to this.