aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/string_utils
diff options
context:
space:
mode:
authordvorkanton <dvorkanton@yandex-team.ru>2022-02-10 16:46:04 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:46:04 +0300
commit110a978b66fe6c0916572df51cfead2a9b647174 (patch)
tree1a2c5ffcf89eb53ecd79dbc9bc0a195c27404d0c /library/cpp/string_utils
parentce1ca0f8ad5b8231d32b35629f85bb09beea1bfb (diff)
downloadydb-110a978b66fe6c0916572df51cfead2a9b647174.tar.gz
Restoring authorship annotation for <dvorkanton@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/string_utils')
-rw-r--r--library/cpp/string_utils/levenshtein_diff/levenshtein_diff.cpp2
-rw-r--r--library/cpp/string_utils/levenshtein_diff/levenshtein_diff.h6
-rw-r--r--library/cpp/string_utils/levenshtein_diff/levenshtein_diff_ut.cpp84
-rw-r--r--library/cpp/string_utils/levenshtein_diff/ut/ya.make4
-rw-r--r--library/cpp/string_utils/levenshtein_diff/ya.make2
-rw-r--r--library/cpp/string_utils/ya.make4
6 files changed, 51 insertions, 51 deletions
diff --git a/library/cpp/string_utils/levenshtein_diff/levenshtein_diff.cpp b/library/cpp/string_utils/levenshtein_diff/levenshtein_diff.cpp
index 98402ac53a..8883d7df07 100644
--- a/library/cpp/string_utils/levenshtein_diff/levenshtein_diff.cpp
+++ b/library/cpp/string_utils/levenshtein_diff/levenshtein_diff.cpp
@@ -1 +1 @@
-#include "levenshtein_diff.h"
+#include "levenshtein_diff.h"
diff --git a/library/cpp/string_utils/levenshtein_diff/levenshtein_diff.h b/library/cpp/string_utils/levenshtein_diff/levenshtein_diff.h
index 40d33ee048..8a240bfed8 100644
--- a/library/cpp/string_utils/levenshtein_diff/levenshtein_diff.h
+++ b/library/cpp/string_utils/levenshtein_diff/levenshtein_diff.h
@@ -8,7 +8,7 @@
#include <type_traits>
#include <utility>
-namespace NLevenshtein {
+namespace NLevenshtein {
enum EEditMoveType {
EMT_SPECIAL,
EMT_PRESERVE,
@@ -140,7 +140,7 @@ namespace NLevenshtein {
}
template <class TStringType>
- size_t Distance(const TStringType& str1, const TStringType& str2) {
+ size_t Distance(const TStringType& str1, const TStringType& str2) {
TEditChain editChain;
GetEditChain(str1, str2, editChain);
size_t result = 0;
@@ -169,7 +169,7 @@ namespace NLevenshtein {
{
}
};
-
+
template <class TStringType>
void GetStringReplacements(const TStringType& str1, const TStringType& str2, TVector<TReplacement>& res) {
TEditChain editChain;
diff --git a/library/cpp/string_utils/levenshtein_diff/levenshtein_diff_ut.cpp b/library/cpp/string_utils/levenshtein_diff/levenshtein_diff_ut.cpp
index 36ec9253cb..cf0f78637f 100644
--- a/library/cpp/string_utils/levenshtein_diff/levenshtein_diff_ut.cpp
+++ b/library/cpp/string_utils/levenshtein_diff/levenshtein_diff_ut.cpp
@@ -1,4 +1,4 @@
-#include "levenshtein_diff.h"
+#include "levenshtein_diff.h"
#include <library/cpp/testing/unittest/registar.h>
@@ -33,17 +33,17 @@ Y_UNIT_TEST_SUITE(Levenstein) {
Y_UNIT_TEST_SUITE(WeightedLevenstein) {
Y_UNIT_TEST(EqualStrings) {
- NLevenshtein::TEditChain chain;
+ NLevenshtein::TEditChain chain;
float distance = 0.0f;
- NLevenshtein::GetEditChain(TString("12345"), TString("12345"), chain, &distance, binaryMaxWeigher, unaryMaxWeigher, unaryMaxWeigher);
+ NLevenshtein::GetEditChain(TString("12345"), TString("12345"), chain, &distance, binaryMaxWeigher, unaryMaxWeigher, unaryMaxWeigher);
UNIT_ASSERT_VALUES_EQUAL(distance, 0.0f);
UNIT_ASSERT_VALUES_EQUAL(chain.size(), 5);
}
Y_UNIT_TEST(EmptyStrings) {
- NLevenshtein::TEditChain chain;
+ NLevenshtein::TEditChain chain;
float distance = 0.0f;
- NLevenshtein::GetEditChain(TString(""), TString(""), chain, &distance, binaryMaxWeigher, unaryMaxWeigher, unaryMaxWeigher);
+ NLevenshtein::GetEditChain(TString(""), TString(""), chain, &distance, binaryMaxWeigher, unaryMaxWeigher, unaryMaxWeigher);
UNIT_ASSERT_VALUES_EQUAL(distance, 0.0f);
UNIT_ASSERT_VALUES_EQUAL(chain.size(), 0);
}
@@ -52,9 +52,9 @@ Y_UNIT_TEST_SUITE(WeightedLevenstein) {
auto unaryWeigher = [](const char&) {
return 2.0f;
};
- NLevenshtein::TEditChain chain;
+ NLevenshtein::TEditChain chain;
float distance = 0.0f;
- NLevenshtein::GetEditChain(TString(""), TString("12345"), chain, &distance, binaryZeroWeigher, unaryZeroWeigher, unaryWeigher);
+ NLevenshtein::GetEditChain(TString(""), TString("12345"), chain, &distance, binaryZeroWeigher, unaryZeroWeigher, unaryWeigher);
UNIT_ASSERT_VALUES_EQUAL(distance, 10.0f);
UNIT_ASSERT_VALUES_EQUAL(chain.size(), 5);
}
@@ -63,9 +63,9 @@ Y_UNIT_TEST_SUITE(WeightedLevenstein) {
auto unaryWeigher = [](const char&) {
return 3.0f;
};
- NLevenshtein::TEditChain chain;
+ NLevenshtein::TEditChain chain;
float distance = 0.0f;
- NLevenshtein::GetEditChain(TString("54321"), TString(""), chain, &distance, binaryZeroWeigher, unaryWeigher, unaryZeroWeigher);
+ NLevenshtein::GetEditChain(TString("54321"), TString(""), chain, &distance, binaryZeroWeigher, unaryWeigher, unaryZeroWeigher);
UNIT_ASSERT_VALUES_EQUAL(distance, 15.0f);
UNIT_ASSERT_VALUES_EQUAL(chain.size(), 5);
}
@@ -76,20 +76,20 @@ Y_UNIT_TEST_SUITE(WeightedLevenstein) {
const float trgDistance = 2.0f;
const size_t trgChainLen = 5;
- NLevenshtein::TEditChain chainLeftRight;
+ NLevenshtein::TEditChain chainLeftRight;
float distanceLeftRight = 0.0f;
- NLevenshtein::GetEditChain(str1, str2, chainLeftRight, &distanceLeftRight, binaryMaxWeigher, unaryMaxWeigher, unaryMaxWeigher);
+ NLevenshtein::GetEditChain(str1, str2, chainLeftRight, &distanceLeftRight, binaryMaxWeigher, unaryMaxWeigher, unaryMaxWeigher);
UNIT_ASSERT_VALUES_EQUAL(distanceLeftRight, trgDistance);
UNIT_ASSERT_VALUES_EQUAL(chainLeftRight.size(), trgChainLen);
- UNIT_ASSERT_VALUES_EQUAL(static_cast<int>(chainLeftRight[0]), static_cast<int>(NLevenshtein::EMT_REPLACE));
- UNIT_ASSERT_VALUES_EQUAL(static_cast<int>(chainLeftRight[1]), static_cast<int>(NLevenshtein::EMT_PRESERVE));
- UNIT_ASSERT_VALUES_EQUAL(static_cast<int>(chainLeftRight[2]), static_cast<int>(NLevenshtein::EMT_PRESERVE));
- UNIT_ASSERT_VALUES_EQUAL(static_cast<int>(chainLeftRight[3]), static_cast<int>(NLevenshtein::EMT_REPLACE));
- UNIT_ASSERT_VALUES_EQUAL(static_cast<int>(chainLeftRight[4]), static_cast<int>(NLevenshtein::EMT_PRESERVE));
+ UNIT_ASSERT_VALUES_EQUAL(static_cast<int>(chainLeftRight[0]), static_cast<int>(NLevenshtein::EMT_REPLACE));
+ UNIT_ASSERT_VALUES_EQUAL(static_cast<int>(chainLeftRight[1]), static_cast<int>(NLevenshtein::EMT_PRESERVE));
+ UNIT_ASSERT_VALUES_EQUAL(static_cast<int>(chainLeftRight[2]), static_cast<int>(NLevenshtein::EMT_PRESERVE));
+ UNIT_ASSERT_VALUES_EQUAL(static_cast<int>(chainLeftRight[3]), static_cast<int>(NLevenshtein::EMT_REPLACE));
+ UNIT_ASSERT_VALUES_EQUAL(static_cast<int>(chainLeftRight[4]), static_cast<int>(NLevenshtein::EMT_PRESERVE));
- NLevenshtein::TEditChain chainRightLeft;
+ NLevenshtein::TEditChain chainRightLeft;
float distanceRightLeft = 0.0f;
- NLevenshtein::GetEditChain(str2, str1, chainRightLeft, &distanceRightLeft, binaryMaxWeigher, unaryMaxWeigher, unaryMaxWeigher);
+ NLevenshtein::GetEditChain(str2, str1, chainRightLeft, &distanceRightLeft, binaryMaxWeigher, unaryMaxWeigher, unaryMaxWeigher);
UNIT_ASSERT_VALUES_EQUAL(distanceRightLeft, trgDistance);
UNIT_ASSERT_VALUES_EQUAL(chainRightLeft.size(), trgChainLen);
UNIT_ASSERT(chainRightLeft == chainLeftRight);
@@ -99,9 +99,9 @@ Y_UNIT_TEST_SUITE(WeightedLevenstein) {
auto binaryWeigher = [](const char&, const char&) {
return 0.0625f;
};
- NLevenshtein::TEditChain chain;
+ NLevenshtein::TEditChain chain;
float distance = 0.0f;
- NLevenshtein::GetEditChain(TString("54321"), TString("43210"), chain, &distance, binaryWeigher, unaryMaxWeigher, unaryMaxWeigher);
+ NLevenshtein::GetEditChain(TString("54321"), TString("43210"), chain, &distance, binaryWeigher, unaryMaxWeigher, unaryMaxWeigher);
UNIT_ASSERT_VALUES_EQUAL(distance, 0.3125f);
UNIT_ASSERT_VALUES_EQUAL(chain.size(), 5);
}
@@ -110,9 +110,9 @@ Y_UNIT_TEST_SUITE(WeightedLevenstein) {
auto unaryWeigher = [](const char&) {
return 0.0625f;
};
- NLevenshtein::TEditChain chain;
+ NLevenshtein::TEditChain chain;
float distance = 0.0f;
- NLevenshtein::GetEditChain(TString("54321"), TString("98765"), chain, &distance, binaryMaxWeigher, unaryWeigher, unaryWeigher);
+ NLevenshtein::GetEditChain(TString("54321"), TString("98765"), chain, &distance, binaryMaxWeigher, unaryWeigher, unaryWeigher);
UNIT_ASSERT_VALUES_EQUAL(distance, 0.5f);
UNIT_ASSERT_VALUES_EQUAL(chain.size(), 9);
}
@@ -121,12 +121,12 @@ Y_UNIT_TEST_SUITE(WeightedLevenstein) {
auto unaryWeigher = [](const char& c) {
return c == 'x' ? 100.0f : 1.0f;
};
- NLevenshtein::TEditChain chain;
+ NLevenshtein::TEditChain chain;
float distance = 0.0f;
- NLevenshtein::GetEditChain(TString("543x1"), TString("5431"), chain, &distance, binaryMaxWeigher, unaryWeigher, unaryMaxWeigher);
+ NLevenshtein::GetEditChain(TString("543x1"), TString("5431"), chain, &distance, binaryMaxWeigher, unaryWeigher, unaryMaxWeigher);
UNIT_ASSERT_VALUES_EQUAL(chain.size(), 5);
- UNIT_ASSERT_VALUES_EQUAL(static_cast<int>(chain[3]), static_cast<int>(NLevenshtein::EMT_REPLACE));
- UNIT_ASSERT_VALUES_EQUAL(static_cast<int>(chain[4]), static_cast<int>(NLevenshtein::EMT_DELETE));
+ UNIT_ASSERT_VALUES_EQUAL(static_cast<int>(chain[3]), static_cast<int>(NLevenshtein::EMT_REPLACE));
+ UNIT_ASSERT_VALUES_EQUAL(static_cast<int>(chain[4]), static_cast<int>(NLevenshtein::EMT_DELETE));
UNIT_ASSERT_VALUES_EQUAL(distance, 2.0f);
}
@@ -134,12 +134,12 @@ Y_UNIT_TEST_SUITE(WeightedLevenstein) {
auto unaryWeigher = [](const char& c) {
return c == 'x' ? 100.0f : 1.0f;
};
- NLevenshtein::TEditChain chain;
+ NLevenshtein::TEditChain chain;
float distance = 0.0f;
- NLevenshtein::GetEditChain(TString("5431"), TString("543x1"), chain, &distance, binaryMaxWeigher, unaryMaxWeigher, unaryWeigher);
+ NLevenshtein::GetEditChain(TString("5431"), TString("543x1"), chain, &distance, binaryMaxWeigher, unaryMaxWeigher, unaryWeigher);
UNIT_ASSERT_VALUES_EQUAL(chain.size(), 5);
- UNIT_ASSERT_VALUES_EQUAL(static_cast<int>(chain[3]), static_cast<int>(NLevenshtein::EMT_REPLACE));
- UNIT_ASSERT_VALUES_EQUAL(static_cast<int>(chain[4]), static_cast<int>(NLevenshtein::EMT_INSERT));
+ UNIT_ASSERT_VALUES_EQUAL(static_cast<int>(chain[3]), static_cast<int>(NLevenshtein::EMT_REPLACE));
+ UNIT_ASSERT_VALUES_EQUAL(static_cast<int>(chain[4]), static_cast<int>(NLevenshtein::EMT_INSERT));
UNIT_ASSERT_VALUES_EQUAL(distance, 2.0f);
}
@@ -147,12 +147,12 @@ Y_UNIT_TEST_SUITE(WeightedLevenstein) {
auto binaryWeigher = [](const char& l, const char&) {
return l == 'x' ? 100.0f : 1.0f;
};
- NLevenshtein::TEditChain chain;
+ NLevenshtein::TEditChain chain;
float distance = 0.0f;
- NLevenshtein::GetEditChain(TString("5432x"), TString("5432y"), chain, &distance, binaryWeigher, unaryMaxWeigher, unaryMaxWeigher);
+ NLevenshtein::GetEditChain(TString("5432x"), TString("5432y"), chain, &distance, binaryWeigher, unaryMaxWeigher, unaryMaxWeigher);
UNIT_ASSERT_VALUES_EQUAL(chain.size(), 6);
- UNIT_ASSERT_VALUES_EQUAL(static_cast<int>(chain[4]), static_cast<int>(NLevenshtein::EMT_DELETE));
- UNIT_ASSERT_VALUES_EQUAL(static_cast<int>(chain[5]), static_cast<int>(NLevenshtein::EMT_INSERT));
+ UNIT_ASSERT_VALUES_EQUAL(static_cast<int>(chain[4]), static_cast<int>(NLevenshtein::EMT_DELETE));
+ UNIT_ASSERT_VALUES_EQUAL(static_cast<int>(chain[5]), static_cast<int>(NLevenshtein::EMT_INSERT));
UNIT_ASSERT_VALUES_EQUAL(distance, 2.0f);
}
@@ -160,12 +160,12 @@ Y_UNIT_TEST_SUITE(WeightedLevenstein) {
auto binaryWeigher = [](const char&, const char& r) {
return r == 'x' ? 100.0f : 1.0f;
};
- NLevenshtein::TEditChain chain;
+ NLevenshtein::TEditChain chain;
float distance = 0.0f;
- NLevenshtein::GetEditChain(TString("y4321"), TString("x4321"), chain, &distance, binaryWeigher, unaryMaxWeigher, unaryMaxWeigher);
+ NLevenshtein::GetEditChain(TString("y4321"), TString("x4321"), chain, &distance, binaryWeigher, unaryMaxWeigher, unaryMaxWeigher);
UNIT_ASSERT_VALUES_EQUAL(chain.size(), 6);
- UNIT_ASSERT_VALUES_EQUAL(static_cast<int>(chain[0]), static_cast<int>(NLevenshtein::EMT_DELETE));
- UNIT_ASSERT_VALUES_EQUAL(static_cast<int>(chain[1]), static_cast<int>(NLevenshtein::EMT_INSERT));
+ UNIT_ASSERT_VALUES_EQUAL(static_cast<int>(chain[0]), static_cast<int>(NLevenshtein::EMT_DELETE));
+ UNIT_ASSERT_VALUES_EQUAL(static_cast<int>(chain[1]), static_cast<int>(NLevenshtein::EMT_INSERT));
UNIT_ASSERT_VALUES_EQUAL(distance, 2.0f);
}
@@ -179,12 +179,12 @@ Y_UNIT_TEST_SUITE(WeightedLevenstein) {
auto insertWeigher = [](const char&) {
return 0.9f;
};
- NLevenshtein::TEditChain chain;
+ NLevenshtein::TEditChain chain;
float distance = 0.0f;
- NLevenshtein::GetEditChain(TString("y0"), TString("0x"), chain, &distance, replaceWeigher, deleteWeigher, insertWeigher);
+ NLevenshtein::GetEditChain(TString("y0"), TString("0x"), chain, &distance, replaceWeigher, deleteWeigher, insertWeigher);
UNIT_ASSERT_VALUES_EQUAL(chain.size(), 2);
- UNIT_ASSERT_VALUES_EQUAL(static_cast<int>(chain[0]), static_cast<int>(NLevenshtein::EMT_REPLACE));
- UNIT_ASSERT_VALUES_EQUAL(static_cast<int>(chain[1]), static_cast<int>(NLevenshtein::EMT_REPLACE));
+ UNIT_ASSERT_VALUES_EQUAL(static_cast<int>(chain[0]), static_cast<int>(NLevenshtein::EMT_REPLACE));
+ UNIT_ASSERT_VALUES_EQUAL(static_cast<int>(chain[1]), static_cast<int>(NLevenshtein::EMT_REPLACE));
UNIT_ASSERT_VALUES_EQUAL(distance, 1.0f);
}
}
diff --git a/library/cpp/string_utils/levenshtein_diff/ut/ya.make b/library/cpp/string_utils/levenshtein_diff/ut/ya.make
index 316ddabc89..a3b9b8fea5 100644
--- a/library/cpp/string_utils/levenshtein_diff/ut/ya.make
+++ b/library/cpp/string_utils/levenshtein_diff/ut/ya.make
@@ -1,9 +1,9 @@
-UNITTEST_FOR(library/cpp/string_utils/levenshtein_diff)
+UNITTEST_FOR(library/cpp/string_utils/levenshtein_diff)
OWNER(myltsev)
SRCS(
- levenshtein_diff_ut.cpp
+ levenshtein_diff_ut.cpp
)
END()
diff --git a/library/cpp/string_utils/levenshtein_diff/ya.make b/library/cpp/string_utils/levenshtein_diff/ya.make
index 531fd976b7..bafefe5365 100644
--- a/library/cpp/string_utils/levenshtein_diff/ya.make
+++ b/library/cpp/string_utils/levenshtein_diff/ya.make
@@ -3,7 +3,7 @@ LIBRARY()
OWNER(g:mt)
SRCS(
- levenshtein_diff.cpp
+ levenshtein_diff.cpp
)
PEERDIR(
diff --git a/library/cpp/string_utils/ya.make b/library/cpp/string_utils/ya.make
index 024bd766d3..cd731bda95 100644
--- a/library/cpp/string_utils/ya.make
+++ b/library/cpp/string_utils/ya.make
@@ -12,8 +12,8 @@ RECURSE(
col_diff
col_diff/ut
indent_text
- levenshtein_diff
- levenshtein_diff/ut
+ levenshtein_diff
+ levenshtein_diff/ut
old_url_normalize
old_url_normalize/ut
parse_size