63 #define LEVDISBIG (nLimit + 1) // Return value if distance > nLimit
64 #define LEVDISDOUBLEBUF 2048 // no doubling atop this border
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 )
134 npDistance[
i] = nDelCnt + nP;
137 if ( nReplacePos < 0 && nP )
142 else if ( nReplacePos > 0 && !nP )
154 nSPMin = std::min({ npDistance[0], npDistance[1], npDistance[2] });
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 )
242 if ( (nSPMin <= nLimit) && (
npDistance[nStringLen] <= nLimit) )
248 if ( nRepS && nLenDiff > 0 )
250 if ( (nSPMin <= 2 * nLimit)
252 && (nRepS *
nRepP0 <= 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 )
WLevDistance(const sal_Unicode *cPattern, int nOtherX, int nShorterY, int nLongerZ, bool bRelaxed)
CTor with user input.
SwNodeOffset min(const SwNodeOffset &a, const SwNodeOffset &b)
int nStars
count of '*' wildcards in pattern
sal_Unicode * cpPattern
pointer to pattern array
int levdisbalance(sal_Int32 jj, sal_Int32 ii, sal_Unicode c, const sal_Unicode *cString, sal_Int32 nStringLen) const
int nRepP0
replacement weigh
void InitData(const sal_Unicode *cPattern)
bool * bpPatIsWild
pointer to bool array whether pattern is wildcard
sal_Int32 nArrayLen
length of distance array
sal_Unicode * GetcPtr() const
void CalcLPQR(int nOtherX, int nShorterY, int nLongerZ, bool bRelaxed)
Calculate the internal weighs corresponding to the user input values.
int nLimit
WLD limit replacements/insertions/deletions.
int * npDistance
pointer to distance array
int WLD(const sal_Unicode *cString, sal_Int32 nStringLen)
Calculate the Weighted Levenshtein Distance from string to pattern.
Weighted Levenshtein Distance (WLD)
sal_Int32 nPatternLen
length of pattern
static int Mid3(int x, int y, int z)
middle value of 3 values
static sal_Int32 Impl_WLD_StringLen(const sal_Unicode *pStr)
WLevDisPatternMem aPatMem
manage allocation of pattern array
int nInsQ0
insertion weigh
bool bSplitCount
if TRUE, Rep/Ins/Del are counted separately
WLevDisDistanceMem aDisMem
manage allocation of distance array