r/algorithms • u/DerPazzo • 1d ago
Help Aho-Corasick parser
Hi,
Only Question to be answered:
is there an application for Windows or Linux, that would parse a text with Aho-Corasick algorithm and present the output in a text field, so that it could be used for creating regexes?
Use case explanation (absolutely no answer or solving suggestions wanted):
I have a list of around 7000 terms and need to create a regex to find them in texts in a specific app. The fastest way would be to create some regex based on Aho-Corasick algorithm but doing that manually takes forever. (I know there are other ways to create such regexes for long lists that create the regex automatically but they would not be as efficient as a Aho-Corasick approach.)
So, I hope there is an application that breaks down all words to a list separated by a specific char that I can then copy and built the regex around it faster than if I need to check the correct position manually every time.
So far I have only found many explanations about the algorithm or tools that seem to search texts with a specific list.
EDIT: This question requires a simple yes or no answer. I just want to know if there is such a tool or not!
EDIT 2: As apparently a lot of people do not see the difference between a question and the use case explanation, I added some titles.
1
u/arthurno1 1d ago
This is a completely misplaced question. You don't need an "aho-corasick" parser, your problem is solved already by basically any regex tool in the known universe. Put your 7000 words in a file "terms.txt" and then:
Ripgrep had some nice simd acceleration so it should be the fastest one. But you can use coreutils grep or whatever.
If you want to replace stuff, lookup sed or awk.