LibreOffice Module i18npool (master) 1
Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
WLevDistance Class Reference

Weighted Levenshtein Distance (WLD) More...

#include <levdis.hxx>

Collaboration diagram for WLevDistance:
[legend]

Public Member Functions

 WLevDistance (const sal_Unicode *cPattern, int nOtherX, int nShorterY, int nLongerZ, bool bRelaxed)
 CTor with user input. More...
 
 WLevDistance (const WLevDistance &rWLD)
 
 ~WLevDistance ()
 
int WLD (const sal_Unicode *cString, sal_Int32 nStringLen)
 Calculate the Weighted Levenshtein Distance from string to pattern. More...
 
void CalcLPQR (int nOtherX, int nShorterY, int nLongerZ, bool bRelaxed)
 Calculate the internal weighs corresponding to the user input values. More...
 
int GetLimit () const
 
int levdisbalance (sal_Int32 jj, sal_Int32 ii, sal_Unicode c, const sal_Unicode *cString, sal_Int32 nStringLen) const
 

Private Member Functions

void InitData (const sal_Unicode *cPattern)
 

Static Private Member Functions

static int Mid3 (int x, int y, int z)
 middle value of 3 values More...
 

Private Attributes

sal_Int32 nPatternLen
 length of pattern More...
 
WLevDisPatternMem aPatMem
 manage allocation of pattern array More...
 
sal_UnicodecpPattern
 pointer to pattern array More...
 
bool * bpPatIsWild
 pointer to bool array whether pattern is wildcard More...
 
sal_Int32 nArrayLen
 length of distance array More...
 
WLevDisDistanceMem aDisMem
 manage allocation of distance array More...
 
intnpDistance
 pointer to distance array More...
 
int nLimit
 WLD limit replacements/insertions/deletions. More...
 
int nRepP0
 replacement weigh More...
 
int nInsQ0
 insertion weigh More...
 
int nDelR0
 deletion weigh More...
 
int nStars
 count of '*' wildcards in pattern More...
 
bool bSplitCount
 if TRUE, Rep/Ins/Del are counted separately More...
 

Detailed Description

Weighted Levenshtein Distance (WLD)

For a more detailed explanation see documentation in i18npool/source/search/levdis.hxx

Definition at line 133 of file levdis.hxx.

Constructor & Destructor Documentation

◆ WLevDistance() [1/2]

WLevDistance::WLevDistance ( const sal_Unicode cPattern,
int  nOtherX,
int  nShorterY,
int  nLongerZ,
bool  bRelaxed 
)

CTor with user input.

Internally calls CalcLPQR().

After this, obtain the resulting limit using GetLimit().

Parameters
bRelaxedthe mathematically incorrect method is default (TRUE)

Definition at line 331 of file levdis.cxx.

References CalcLPQR(), and InitData().

◆ WLevDistance() [2/2]

WLevDistance::WLevDistance ( const WLevDistance rWLD)

◆ ~WLevDistance()

WLevDistance::~WLevDistance ( )

Definition at line 369 of file levdis.cxx.

Member Function Documentation

◆ CalcLPQR()

void WLevDistance::CalcLPQR ( int  nOtherX,
int  nShorterY,
int  nLongerZ,
bool  bRelaxed 
)

Calculate the internal weighs corresponding to the user input values.

Returns
nLimit for later comparison with WLD()

Definition at line 262 of file levdis.cxx.

References bSplitCount, Mid3(), nDelR0, nInsQ0, nLimit, and nRepP0.

Referenced by WLevDistance().

◆ GetLimit()

int WLevDistance::GetLimit ( ) const
inline

Definition at line 175 of file levdis.hxx.

References nLimit.

◆ InitData()

void WLevDistance::InitData ( const sal_Unicode cPattern)
private

◆ levdisbalance()

int WLevDistance::levdisbalance ( sal_Int32  jj,
sal_Int32  ii,
sal_Unicode  c,
const sal_Unicode cString,
sal_Int32  nStringLen 
) const
inline

Definition at line 181 of file levdis.hxx.

References cpPattern, and nPatternLen.

Referenced by WLD().

◆ Mid3()

int WLevDistance::Mid3 ( int  x,
int  y,
int  z 
)
staticprivate

middle value of 3 values

Definition at line 285 of file levdis.cxx.

References min(), x, y, and z.

Referenced by CalcLPQR().

◆ WLD()

int WLevDistance::WLD ( const sal_Unicode cString,
sal_Int32  nStringLen 
)

Calculate the Weighted Levenshtein Distance from string to pattern.

Definition at line 75 of file levdis.cxx.

References aDisMem, bpPatIsWild, bSplitCount, cpPattern, i, levdisbalance(), LEVDISBIG, LEVDISDOUBLEBUF, nArrayLen, nDelR0, WLevDisDistanceMem::NewMem(), nInsQ0, nLimit, nPatternLen, npDistance, nRepP0, and nStars.

Member Data Documentation

◆ aDisMem

WLevDisDistanceMem WLevDistance::aDisMem
private

manage allocation of distance array

Definition at line 140 of file levdis.hxx.

Referenced by InitData(), WLD(), and WLevDistance().

◆ aPatMem

WLevDisPatternMem WLevDistance::aPatMem
private

manage allocation of pattern array

Definition at line 136 of file levdis.hxx.

Referenced by InitData(), and WLevDistance().

◆ bpPatIsWild

bool* WLevDistance::bpPatIsWild
private

pointer to bool array whether pattern is wildcard

Definition at line 138 of file levdis.hxx.

Referenced by InitData(), WLD(), and WLevDistance().

◆ bSplitCount

bool WLevDistance::bSplitCount
private

if TRUE, Rep/Ins/Del are counted separately

Definition at line 147 of file levdis.hxx.

Referenced by CalcLPQR(), and WLD().

◆ cpPattern

sal_Unicode* WLevDistance::cpPattern
private

pointer to pattern array

Definition at line 137 of file levdis.hxx.

Referenced by InitData(), levdisbalance(), WLD(), and WLevDistance().

◆ nArrayLen

sal_Int32 WLevDistance::nArrayLen
private

length of distance array

Definition at line 139 of file levdis.hxx.

Referenced by WLD().

◆ nDelR0

int WLevDistance::nDelR0
private

deletion weigh

Definition at line 145 of file levdis.hxx.

Referenced by CalcLPQR(), and WLD().

◆ nInsQ0

int WLevDistance::nInsQ0
private

insertion weigh

Definition at line 144 of file levdis.hxx.

Referenced by CalcLPQR(), and WLD().

◆ nLimit

int WLevDistance::nLimit
private

WLD limit replacements/insertions/deletions.

Definition at line 142 of file levdis.hxx.

Referenced by CalcLPQR(), GetLimit(), and WLD().

◆ nPatternLen

sal_Int32 WLevDistance::nPatternLen
private

length of pattern

Definition at line 135 of file levdis.hxx.

Referenced by InitData(), levdisbalance(), WLD(), and WLevDistance().

◆ npDistance

int* WLevDistance::npDistance
private

pointer to distance array

Definition at line 141 of file levdis.hxx.

Referenced by InitData(), WLD(), and WLevDistance().

◆ nRepP0

int WLevDistance::nRepP0
private

replacement weigh

Definition at line 143 of file levdis.hxx.

Referenced by CalcLPQR(), and WLD().

◆ nStars

int WLevDistance::nStars
private

count of '*' wildcards in pattern

Definition at line 146 of file levdis.hxx.

Referenced by InitData(), and WLD().


The documentation for this class was generated from the following files: