Click here to Skip to main content
16,020,877 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I need an implementation of aho corasick pattern matching algorithm in c++ could any one help?
Posted
Updated 19-May-11 5:57am
v2

1 solution

By some reason, I could not quickly find C++ implementation of the algorithm for you. I think you can better help yourself by doing your own search.

So far, I got too ideas:
1) You can use this C# implementation: Aho-Corasick string matching in C#[^]. I have no idea how good is this one, but you can give it a try. Translation in C++ is not such a big problem.

2) The Wikipedia article (http://en.wikipedia.org/wiki/Aho–Corasick_string_matching_algorithm[^]) says that the Aho–Corasick string matching algorithm formed the basis of the original Unix command fgrep (http://en.wikipedia.org/wiki/Grep#Variations[^]). You could download Unix source code for this application and find the algorithm implementation there. See other references on these Wikipedia articles.

—SA
 
Share this answer
 
Comments
alaa.ali1981 19-May-11 12:11pm    
thanks ........... I am running a project that uses AC in some parts and i an in the final stage, I have an implementation of AC but I fount that its bugged toooooo lateeee, so I need a C++ implementation or atechnique to run c# in c++(it is not easy!)


I searched for too long, and I am still searching.
Sergey Alexandrovich Kryukov 20-May-11 15:36pm    
Yes, this algorithm is more complex that most other algorithms requested here at CodeProject (which are often described as pseudocode in 10-20 lines in Wikipedia). But C++ code is certainly available; this is all I could find. I suspect the Unix source code is the best place to find it.

If you think it makes some sense, please formally accept the answer (green button).
--SA
alaa.ali1981 22-May-11 3:13am    
ok, I get I modified it to match my need, the problem is that in c and my code in c++ ......... any advice on how to mix it .......... i searched on how to mix it but I still get errors, is there a good tutorial in mixing c and c++ codes.
Sergey Alexandrovich Kryukov 22-May-11 3:31am    
You can freely mix C++ and C. One way it to create C files in C++ project (you should share *.h files, so make them C-compatible). More advanced way is to minimally beef-up the C code to C++, which is usually easy (especially if the quality of C code is reasonable good), and use it in C++ files.
(C++/CLI or plain old C++? Even to C++/CLI you can mix with C, using mixed-mode managed+unmanaged project.)

I did not get it -- do you already extracted C code of the algorithm? From what source, I wonder?

Anyway, if you find my advices somehow useful, please formally accept this answer (green button).
Thank you.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900