Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
ee3f2409
Kaydet (Commit)
ee3f2409
authored
Şub 11, 2015
tarafından
Eike Rathke
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
typos and nitpicks
Change-Id: I596e9f0941dbc9d2106767c19569e9771c42b076
üst
8fdf5e49
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
26 deletions
+28
-26
levdis.cxx
i18npool/source/search/levdis.cxx
+28
-26
No files found.
i18npool/source/search/levdis.cxx
Dosyayı görüntüle @
ee3f2409
...
@@ -103,12 +103,12 @@ int WLevDistance::WLD( const sal_Unicode* cString, sal_Int32 nStringLen )
...
@@ -103,12 +103,12 @@ int WLevDistance::WLD( const sal_Unicode* cString, sal_Int32 nStringLen )
npDistance
=
aDisMem
.
NewMem
(
nArrayLen
);
npDistance
=
aDisMem
.
NewMem
(
nArrayLen
);
}
}
//
calculate start values of the second column(first Pattern-value)
//
Calculate start values of the second column (first pattern value).
//
first column (0-Len P
attern) is always zero .. nStringLen * nInsQ0,
//
First column (0-Len p
attern) is always zero .. nStringLen * nInsQ0,
// therefore the minimum is 0
// therefore the minimum is 0
if
(
nPatternLen
==
0
)
if
(
nPatternLen
==
0
)
{
{
// Count of deletions
, to determine the P
attern
// Count of deletions
to reach p
attern
for
(
sal_Int32
i
=
0
;
i
<=
nStringLen
;
i
++
)
for
(
sal_Int32
i
=
0
;
i
<=
nStringLen
;
i
++
)
npDistance
[
i
]
=
i
*
nDelR0
;
npDistance
[
i
]
=
i
*
nDelR0
;
}
}
...
@@ -126,7 +126,7 @@ int WLevDistance::WLD( const sal_Unicode* cString, sal_Int32 nStringLen )
...
@@ -126,7 +126,7 @@ int WLevDistance::WLD( const sal_Unicode* cString, sal_Int32 nStringLen )
if
(
c
==
'?'
&&
bpPatIsWild
[
0
]
)
if
(
c
==
'?'
&&
bpPatIsWild
[
0
]
)
nP
=
0
;
// a '?' could be any character.
nP
=
0
;
// a '?' could be any character.
else
else
// Minimum
replace and delete +insert
weighting
// Minimum
of replacement and deletion+insertion
weighting
nP
=
Min3
(
nRepP0
,
nRepP0
,
nDelR0
+
nInsQ0
);
nP
=
Min3
(
nRepP0
,
nRepP0
,
nDelR0
+
nInsQ0
);
npDistance
[
0
]
=
nInsQ0
;
// start with simple insert
npDistance
[
0
]
=
nInsQ0
;
// start with simple insert
npDistance
[
1
]
=
nInsQ0
;
npDistance
[
1
]
=
nInsQ0
;
...
@@ -136,22 +136,22 @@ int WLevDistance::WLD( const sal_Unicode* cString, sal_Int32 nStringLen )
...
@@ -136,22 +136,22 @@ int WLevDistance::WLD( const sal_Unicode* cString, sal_Int32 nStringLen )
for
(
sal_Int32
i
=
1
;
i
<=
nStringLen
;
i
++
,
nDelCnt
+=
nDelR0
)
for
(
sal_Int32
i
=
1
;
i
<=
nStringLen
;
i
++
,
nDelCnt
+=
nDelR0
)
{
{
if
(
cString
[
i
-
1
]
==
c
)
if
(
cString
[
i
-
1
]
==
c
)
nP
=
0
;
// Replace from this position
with
0
nP
=
0
;
// Replace from this position
is
0
// Deletion
to determine the P
attern + Replace
// Deletion
s to match p
attern + Replace
npDistance
[
i
]
=
nDelCnt
+
nP
;
npDistance
[
i
]
=
nDelCnt
+
nP
;
if
(
bSplitCount
)
if
(
bSplitCount
)
{
{
if
(
nReplacePos
<
0
&&
nP
)
if
(
nReplacePos
<
0
&&
nP
)
{
// this
P
osition will be replaced
{
// this
p
osition will be replaced
nRepS
++
;
nRepS
++
;
nReplacePos
=
i
;
nReplacePos
=
i
;
}
}
else
if
(
nReplacePos
>
0
&&
!
nP
)
else
if
(
nReplacePos
>
0
&&
!
nP
)
{
{
// same count
c
// same count of
c
int
nBalance
=
levdisbalance
(
0
,
i
-
1
,
c
,
cString
,
nStringLen
);
int
nBalance
=
levdisbalance
(
0
,
i
-
1
,
c
,
cString
,
nStringLen
);
if
(
!
nBalance
)
if
(
!
nBalance
)
{
//
an insert was replace
d
{
//
one was replaced that was an insertion instea
d
nRepS
--
;
nRepS
--
;
nReplacePos
=
0
;
nReplacePos
=
0
;
}
}
...
@@ -162,7 +162,7 @@ int WLevDistance::WLD( const sal_Unicode* cString, sal_Int32 nStringLen )
...
@@ -162,7 +162,7 @@ int WLevDistance::WLD( const sal_Unicode* cString, sal_Int32 nStringLen )
}
}
// calculate distance matrix
// calculate distance matrix
sal_Int32
j
=
0
;
//for all columns of the pattern, till limit is not reached
sal_Int32
j
=
0
;
//
for all columns of the pattern, till limit is not reached
while
(
(
j
<
nPatternLen
-
1
)
while
(
(
j
<
nPatternLen
-
1
)
&&
nSPMin
<=
(
bSplitCount
?
2
*
nLimit
:
nLimit
)
)
&&
nSPMin
<=
(
bSplitCount
?
2
*
nLimit
:
nLimit
)
)
{
{
...
@@ -177,20 +177,20 @@ int WLevDistance::WLD( const sal_Unicode* cString, sal_Int32 nStringLen )
...
@@ -177,20 +177,20 @@ int WLevDistance::WLD( const sal_Unicode* cString, sal_Int32 nStringLen )
nP
=
nRepP0
;
nP
=
nRepP0
;
if
(
c
==
'*'
&&
bpPatIsWild
[
j
]
)
if
(
c
==
'*'
&&
bpPatIsWild
[
j
]
)
{
{
nQ
=
0
;
// instertion
/
deletion without penalty
nQ
=
0
;
// instertion
and
deletion without penalty
nR
=
0
;
nR
=
0
;
}
}
else
else
{
{
nQ
=
nInsQ0
;
//usual weighting
nQ
=
nInsQ0
;
//
usual weighting
nR
=
nDelR0
;
nR
=
nDelR0
;
}
}
d2
=
npDistance
[
0
];
d2
=
npDistance
[
0
];
// increase insert count to get from null sting to pattern
// increase insert count to get from null st
r
ing to pattern
npDistance
[
0
]
=
npDistance
[
0
]
+
nQ
;
npDistance
[
0
]
=
npDistance
[
0
]
+
nQ
;
nSPMin
=
npDistance
[
0
];
nSPMin
=
npDistance
[
0
];
int
nReplacePos
=
-
1
;
// tristate
F
lag
int
nReplacePos
=
-
1
;
// tristate
f
lag
// for each pattern column run though the string
// for each pattern column run th
r
ough the string
for
(
sal_Int32
i
=
1
;
i
<=
nStringLen
;
i
++
)
for
(
sal_Int32
i
=
1
;
i
<=
nStringLen
;
i
++
)
{
{
int
d1
=
d2
;
// WLD( X(i-1), Y(j-1) )
int
d1
=
d2
;
// WLD( X(i-1), Y(j-1) )
...
@@ -200,7 +200,7 @@ int WLevDistance::WLD( const sal_Unicode* cString, sal_Int32 nStringLen )
...
@@ -200,7 +200,7 @@ int WLevDistance::WLD( const sal_Unicode* cString, sal_Int32 nStringLen )
nPij
=
0
;
// p(i,j)
nPij
=
0
;
// p(i,j)
if
(
nReplacePos
<
0
)
if
(
nReplacePos
<
0
)
{
{
// same
quantity
c
// same
count of
c
int
nBalance
=
levdisbalance
(
j
,
i
-
1
,
c
,
cString
,
nStringLen
);
int
nBalance
=
levdisbalance
(
j
,
i
-
1
,
c
,
cString
,
nStringLen
);
if
(
!
nBalance
)
if
(
!
nBalance
)
nReplacePos
=
0
;
// no replacement
nReplacePos
=
0
;
// no replacement
...
@@ -217,7 +217,7 @@ int WLevDistance::WLD( const sal_Unicode* cString, sal_Int32 nStringLen )
...
@@ -217,7 +217,7 @@ int WLevDistance::WLD( const sal_Unicode* cString, sal_Int32 nStringLen )
if
(
bSplitCount
)
if
(
bSplitCount
)
{
{
if
(
nReplacePos
<
0
&&
nPij
&&
npDistance
[
i
]
==
d1
+
nPij
)
if
(
nReplacePos
<
0
&&
nPij
&&
npDistance
[
i
]
==
d1
+
nPij
)
{
// this poition will be replaced
{
// this po
s
ition will be replaced
nRepS
++
;
nRepS
++
;
nReplacePos
=
i
;
nReplacePos
=
i
;
}
}
...
@@ -225,18 +225,20 @@ int WLevDistance::WLD( const sal_Unicode* cString, sal_Int32 nStringLen )
...
@@ -225,18 +225,20 @@ int WLevDistance::WLD( const sal_Unicode* cString, sal_Int32 nStringLen )
{
{
// character is equal in string and pattern
// character is equal in string and pattern
//
//
//If from this point:
// If from this point:
//* pattern and string have the same count of this character
// * pattern and string have the same count of this
//* and character count is the same before this position
// character
//the replace was none.
// * and character count is the same before this position
//
// then the replace was none.
//Scrambled letters are recognized and the replace is withdrawed.
//Whereby the double limit comes to fuition.
//
//
//Same quantity c
// Scrambled letters are recognized here and the nRepS
// replacement is withdrawn, whereby the double limit kicks
// in.
// Same count of c
int
nBalance
=
levdisbalance
(
j
,
i
-
1
,
c
,
cString
,
nStringLen
);
int
nBalance
=
levdisbalance
(
j
,
i
-
1
,
c
,
cString
,
nStringLen
);
if
(
!
nBalance
)
if
(
!
nBalance
)
{
//
insert was replace
d
{
//
one was replaced that was an insertion instea
d
nRepS
--
;
nRepS
--
;
nReplacePos
=
0
;
nReplacePos
=
0
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment