F
F
fruitbooter2011-05-12 00:32:30
PHP
fruitbooter, 2011-05-12 00:32:30

Port PHP string comparison algorithm to C/C++?

About the algorithm
Description and examples of the algorithm can be found here , and its implementation on GitHub (Gist)
Problem
I encountered the fact that the algorithm itself is slow (in comparison with the function built into PHP similar_text()ten times slower), but IMHO, high-quality.
The reason why the finished similar_text()quality did not fit (experimental path). There was an idea to convert it into a compiled program in the hope of increasing the speed of work.
My unsuccessful solutions
- I wanted to use HipHop PHP, but did not master the installation on a 32-bit machine.
- I tried to write it myself, but I realized that knowledge is not enough.
Outcome
I hope that the PHP version of this algorithm will be useful to someone, and I will be very grateful to those who are interested and help convert it to C / C ++.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Z
zizop, 2011-05-12
@fruitbooter

If you need a faster substring search algorithm (and, as a result, string comparison), you can try a PHP extension written in C - Fast String Search . It uses the Kommentz-Walter algorithm, by analogy with the Aho-Korasik automaton, is a modification of the BM algorithm for a variety of patterns.
Maybe this option will work for you. If not, write in a personal, somewhere I had a comprehensive guide on creating a Hello World extension for PHP in C, with creating your own function, into which you can shove your algorithm.

K
Konstantin, 2011-05-12
@Norraxx

Maybe this will fit? cz.php.net/manual/en/function.levenshtein.php

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question