Menu serwera

Takiego spamu jeszcze nie miałem…

OK, zostałem rozwalony… Spam z gatunku „bawiąc uczy, ucząc – bawi”. Mam wszakże jeden problem: co do jasnej cholery mam kupić??? :)


// The "Levenshtein distance" is a measure of the similarity between two strings,

// this algorithm is also refered to as "edit distance". The "Levenshtein distance"

// was named after the russian scientist "Vladimir Levenshtein", who has discovered

// it back in 1965. The smaller the distance between two strings, the closer are

// these strings syntacticaly. The "Levenshtein distance" is computed by

// calculating the minimum number of operations that has to be made to transform

// one string to another one,usualy this operations are: replace,insert or delete a character

// example: we can change the word: "mathematics" to "mathematician" by changing one character

// and by inserting two more characters at the end.(we can replace "s" by "i" and 

// also insert "a" and "n" after that). The total number of operations that was needed in this

// case to change "mathematics" to "mathematician" was 3 operations and since it is

// also the smallest number of operation that can be use to transform one of this strings

// to the other one, that value is also a measure of the "Levenshtein distance" between

// these two strings. 

// There has been many application of the "Levenshtein distance", here is a few of them: 

// Spell Checking, Speech Recognition, Pattern Recognition etc.

// ****************************************************************************



#include "distance.h"





// finds the minimum of tree integers

int _min(int a, int b, int c) {

        return min(min(a, b), c);

}



// allocates a 2D array of integers

int **create_matrix(int Row, int Col) {

        int **array = new int*[Row];

        for(int i = 0; i < Row; ++i) {

                array[i] = new int[Col];

        }

        return array;

}



// deallocates memory

int **delete_matrix(int **array, int Row, int Col) {

        for(int i = 0; i < Row; ++i) {

                delete array[i];

        }

        delete [] array;

        return array;

}



// computes the Levenshtein distance between two strings

// "x" represent the pattern and "y" represent the text

// "m" is the pattern length and "n" is the text length



int LD(const char *x, unsigned int m, const char *y, unsigned int n) {

        // if the length of the second string is zero

        // then the distance between the two strings will

        // be equal to the length of the first string

        // and vis-versa

        // if the length of both strings is equal to zero

        // then the distance between this two strings will

        // simply be zero

        if (n == 0) {

                return m;

        } 

        else if (m == 0) {

                return n;

        }



        // creating a matrix of m+1 rows and n+1 columns

        int **matrix = create_matrix(m + 1, n + 1);



        // initialising the first row of the matrix

        for(unsigned int i = 0; i

Mail przybył z adresu w domenie, która nie istnieje, na mój adres ale z jakimś stochastycznym imieniem i nazwiskiem... Komuś się chyba bot spamowy popindolił :). Anyway, zawsze o kilka linijek kodu i - przede wszystkim - komentarza jestem bogatszy!

2 odpowiedź do Takiego spamu jeszcze nie miałem…

  1. Michal Kwiecień 24, 2008 o 23:13 #

    Mnie ciągle oferują powiększanie penisa. O co im chodzi? :)

    • wyzimir Kwiecień 25, 2008 o 15:09 #

      Michal, zastanów się dlaczego wybrali właśnie Ciebie do swojej grupy docelowej.

Dodaj komentarz

Przeczytaj poprzedni wpis:
Side Liner – My Guardian Angel

Side Liner - My Guardian AngelDawno już żadnej recenzji muzycznej nie pisałem. Nieco wyleciałem z wprawy, zastałem się, muzycznie co...

Zamknij