63#define LEVDISBIG (nLimit + 1)
64#define LEVDISDOUBLEBUF 2048
71 return static_cast<sal_Int32
>(pTempStr-pStr);
105 for ( sal_Int32
i=0;
i <= nStringLen;
i++ )
111 for ( sal_Int32
i=0;
i <= nStringLen;
i++ )
127 int nReplacePos = -1;
129 for ( sal_Int32
i=1;
i <= nStringLen;
i++, nDelCnt +=
nDelR0 )
131 if ( cString[
i-1] == c )
137 if ( nReplacePos < 0 && nP )
142 else if ( nReplacePos > 0 && !nP )
163 int nP, nQ, nR, nPij, d2;
185 int nReplacePos = -1;
187 for ( sal_Int32
i=1;
i <= nStringLen;
i++ )
191 if ( cString[
i-1] == c )
194 if ( nReplacePos < 0 )
212 if ( nReplacePos < 0 && nPij &&
npDistance[
i] == d1 + nPij )
217 else if ( nReplacePos > 0 && !nPij )
248 if ( nRepS && nLenDiff > 0 )
250 if ( (nSPMin <= 2 *
nLimit)
264 if ( nX < 0 ) nX = 0;
265 if ( nY < 0 ) nY = 0;
266 if ( nZ < 0 ) nZ = 0;
267 if (0 == std::min({ nX, nY, nZ }))
270 nMax = std::max({ nX, nY, nZ });
271 if ( 0 == (nMid =
Mid3( nX, nY, nZ )) )
274 nLimit = std::lcm( nMid, nMax );
277 nLimit = std::lcm(std::lcm(nX, nY), nZ);
287 int min = std::min({
x,
y,
z });
289 return std::min(
y,
z);
291 return std::min(
x,
z);
293 return std::min(
x,
y);
311 if ( *(cp1+1) ==
'*' || *(cp1+1) ==
'?' )
318 else if ( *cp1 ==
'*' || *cp1 ==
'?' )
332 int nOtherX,
int nShorterY,
int nLongerZ,
335 aPatMem( nPatternLen + 1 ),
336 nArrayLen( nPatternLen + 1 ),
340 CalcLPQR( nOtherX, nShorterY, nLongerZ, bRelaxed );
345 nPatternLen( rWLD.nPatternLen ),
346 aPatMem( nPatternLen + 1 ),
347 nArrayLen( nPatternLen + 1 ),
348 aDisMem( nArrayLen ),
349 nLimit( rWLD.nLimit ),
350 nRepP0( rWLD.nRepP0 ),
351 nInsQ0( rWLD.nInsQ0 ),
352 nDelR0( rWLD.nDelR0 ),
353 nStars( rWLD.nStars ),
354 bSplitCount( rWLD.bSplitCount )
sal_Unicode * GetcPtr() const
Weighted Levenshtein Distance (WLD)
int levdisbalance(sal_Int32 jj, sal_Int32 ii, sal_Unicode c, const sal_Unicode *cString, sal_Int32 nStringLen) const
sal_Int32 nArrayLen
length of distance array
int nRepP0
replacement weigh
bool * bpPatIsWild
pointer to bool array whether pattern is wildcard
bool bSplitCount
if TRUE, Rep/Ins/Del are counted separately
WLevDisDistanceMem aDisMem
manage allocation of distance array
static int Mid3(int x, int y, int z)
middle value of 3 values
int nLimit
WLD limit replacements/insertions/deletions.
sal_Int32 nPatternLen
length of pattern
void InitData(const sal_Unicode *cPattern)
int WLD(const sal_Unicode *cString, sal_Int32 nStringLen)
Calculate the Weighted Levenshtein Distance from string to pattern.
WLevDisPatternMem aPatMem
manage allocation of pattern array
int nStars
count of '*' wildcards in pattern
int * npDistance
pointer to distance array
sal_Unicode * cpPattern
pointer to pattern array
WLevDistance(const sal_Unicode *cPattern, int nOtherX, int nShorterY, int nLongerZ, bool bRelaxed)
CTor with user input.
int nInsQ0
insertion weigh
void CalcLPQR(int nOtherX, int nShorterY, int nLongerZ, bool bRelaxed)
Calculate the internal weighs corresponding to the user input values.
static sal_Int32 Impl_WLD_StringLen(const sal_Unicode *pStr)
SwNodeOffset min(const SwNodeOffset &a, const SwNodeOffset &b)