/* // Line.h: interface for the C_Line class. ////////////////////////////////////////////////////////////////////// */ // Levenshtein.h: interface for the Levenshtein class. // ////////////////////////////////////////////////////////////////////// #if !defined(LEVENSHTEIN_H) #define LEVENSHTEIN_H #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 #include /// \brief une classe qui sert � calculer la distance entre deux chaines de caracters /*! \class C_OCROutput * \brief une classe qui sert � calculer la distance entre deux chaines de caracters ** */ class Levenshtein { public: //**************************** // Get minimum edit (levenstein) between two strings //**************************** [[nodiscard]] int Get (const char* a, const char* b); [[nodiscard]] int Get (const char* a, size_t aLen, const char* b, size_t bLen); [[nodiscard]] int Get2 (char const *s, char const *t); [[nodiscard]] int Get2 (char const *s, size_t n, char const *t, size_t dst); //************************** // construct/destruct //************************** Levenshtein(); virtual ~Levenshtein(); private: //**************************** // Get minimum of three values //**************************** int Minimum (int a, int b, int c) { int mi = a; if (b < mi) mi = b; if (c < mi) mi = c; return mi; } //************************************************** // Get a pointer to the specified cell of the matrix //************************************************** int *GetCellPointer (int *pOrigin, size_t col, size_t row, size_t nCols) { return pOrigin + col + (row * (nCols + 1)); } //***************************************************** // Get the contents of the specified cell in the matrix //***************************************************** int GetAt (int *pOrigin, size_t col, size_t row, size_t nCols) { int *pCell = GetCellPointer (pOrigin, col, row, nCols); return *pCell; } //******************************************************** // Fill the specified cell in the matrix with the value x //******************************************************** void PutAt (int *pOrigin, size_t col, size_t row, size_t nCols, int x) { int *pCell = GetCellPointer (pOrigin, col, row, nCols); *pCell = x; } }; #endif // !defined(LEVENSHTEIN_H)