Convert Levenshtein ratio to C++
Question: Is there a library for doing the following in C or C++? I don't mean a python
library that uses C or C++, but an actual C/C++ library:

    
    
    >>> import Levenshtein
    >>> ratio = Levenshtein.ratio('StackOver', 'Stackoverflow')
    0.7272727272727273
    


Answer: What about writing your own basing on the Wikipedia's implementation? Here:
<http://en.wikibooks.org/wiki/Algorithm_Implementation/Strings/Levenshtein_distance#C.2B.2B>

    
    
    template <class T> unsigned int edit_distance(const T& s1, const T& s2)
    {
        const size_t len1 = s1.size(), len2 = s2.size();
        vector<vector<unsigned int> > d(len1 + 1, vector<unsigned int>(len2 + 1));
    
        d[0][0] = 0;
        for(unsigned int i = 1; i <= len1; ++i) d[i][0] = i;
        for(unsigned int i = 1; i <= len2; ++i) d[0][i] = i;
    
        for(unsigned int i = 1; i <= len1; ++i)
            for(unsigned int j = 1; j <= len2; ++j)
    
                          d[i][j] = std::min( std::min(d[i - 1][j] + 1,d[i][j - 1] + 1),
                                              d[i - 1][j - 1] + (s1[i - 1] == s2[j - 1] ? 0 : 1) );
        return d[len1][len2];
    }
    

Usage:

    
    
    unsigned int distance = edit_distance<std::string>("StackOver", "Stackoverflow");
    

