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)
 

Private Member Functions

void InitData (const sal_Unicode *cPattern)
 

Static Private Member Functions

static int Min3 (int x, int y, int z)
 minimum value of 3 values More...
 
static int Mid3 (int x, int y, int z)
 middle value of 3 values More...
 
static int Max3 (int x, int y, int z)
 maximum value of 3 values More...
 
static int GCD (int a, int b)
 Greatest Common Divisor. More...
 
static int LCM (int a, int b)
 Least Common Multiple. 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::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 375 of file levdis.cxx.

References CalcLPQR(), and InitData().

WLevDistance::WLevDistance ( const WLevDistance rWLD)
WLevDistance::~WLevDistance ( )

Definition at line 413 of file levdis.cxx.

Member Function Documentation

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 261 of file levdis.cxx.

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

Referenced by WLevDistance().

int WLevDistance::GCD ( int  a,
int  b 
)
staticprivate

Greatest Common Divisor.

Definition at line 285 of file levdis.cxx.

Referenced by LCM().

int WLevDistance::GetLimit ( ) const
inline

Definition at line 179 of file levdis.hxx.

References nLimit.

void WLevDistance::InitData ( const sal_Unicode cPattern)
private
int WLevDistance::LCM ( int  a,
int  b 
)
staticprivate

Least Common Multiple.

Definition at line 302 of file levdis.cxx.

References GCD().

Referenced by CalcLPQR().

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

Definition at line 185 of file levdis.hxx.

References nPatternLen.

Referenced by WLD().

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

maximum value of 3 values

Definition at line 332 of file levdis.cxx.

Referenced by CalcLPQR().

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

middle value of 3 values

Definition at line 320 of file levdis.cxx.

References min, and Min3().

Referenced by CalcLPQR().

int WLevDistance::Min3 ( int  x,
int  y,
int  z 
)
inlinestaticprivate

minimum value of 3 values

Definition at line 311 of file levdis.cxx.

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

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

Calculate the Weighted Levenshtein Distance from string to pattern.

Definition at line 74 of file levdis.cxx.

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

Member Data Documentation

WLevDisDistanceMem WLevDistance::aDisMem
private

manage allocation of distance array

Definition at line 140 of file levdis.hxx.

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

WLevDisPatternMem WLevDistance::aPatMem
private

manage allocation of pattern array

Definition at line 136 of file levdis.hxx.

Referenced by InitData(), and WLevDistance().

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().

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().

sal_Unicode* WLevDistance::cpPattern
private

pointer to pattern array

Definition at line 137 of file levdis.hxx.

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

sal_Int32 WLevDistance::nArrayLen
private

length of distance array

Definition at line 139 of file levdis.hxx.

Referenced by WLD().

int WLevDistance::nDelR0
private

deletion weigh

Definition at line 145 of file levdis.hxx.

Referenced by CalcLPQR(), and WLD().

int WLevDistance::nInsQ0
private

insertion weigh

Definition at line 144 of file levdis.hxx.

Referenced by CalcLPQR(), and WLD().

int WLevDistance::nLimit
private

WLD limit replacements/insertions/deletions.

Definition at line 142 of file levdis.hxx.

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

sal_Int32 WLevDistance::nPatternLen
private

length of pattern

Definition at line 135 of file levdis.hxx.

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

int* WLevDistance::npDistance
private

pointer to distance array

Definition at line 141 of file levdis.hxx.

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

int WLevDistance::nRepP0
private

replacement weigh

Definition at line 143 of file levdis.hxx.

Referenced by CalcLPQR(), and WLD().

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: