diff options
author | dvorkanton <dvorkanton@yandex-team.ru> | 2022-02-10 16:46:04 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:46:04 +0300 |
commit | ce1ca0f8ad5b8231d32b35629f85bb09beea1bfb (patch) | |
tree | 19b21fdcf9ef01e0c94a15434fb08a4a555a79e9 /library/cpp/string_utils | |
parent | fc361854fd6ee8d747229b090f0b8018e260d1fb (diff) | |
download | ydb-ce1ca0f8ad5b8231d32b35629f85bb09beea1bfb.tar.gz |
Restoring authorship annotation for <dvorkanton@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/string_utils')
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 8883d7df07..98402ac53a 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 8a240bfed8..40d33ee048 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 cf0f78637f..36ec9253cb 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 a3b9b8fea5..316ddabc89 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 bafefe5365..531fd976b7 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 cd731bda95..024bd766d3 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 |