|
@ -6,7 +6,7 @@ namespace storm { |
|
|
namespace utility { |
|
|
namespace utility { |
|
|
namespace string { |
|
|
namespace string { |
|
|
|
|
|
|
|
|
SimilarStrings::SimilarStrings(std::string reference, double similarityFactor, bool caseSensitive) : reference(reference), similarityFactor(similarityFactor), caseSensitive(caseSensitive), cmp([](std::pair<uint64_t, std::string> const& lhs, std::pair<uint64_t, std::string> const& rhs) { return lhs.first > rhs.first; }), distances(cmp) { |
|
|
|
|
|
|
|
|
SimilarStrings::SimilarStrings(std::string reference, double similarityFactor, bool caseSensitive) : reference(reference), similarityFactor(similarityFactor), caseSensitive(caseSensitive) { |
|
|
// intentionally left empty.
|
|
|
// intentionally left empty.
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -20,11 +20,9 @@ namespace storm { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
std::vector<std::string> SimilarStrings::toList() const { |
|
|
std::vector<std::string> SimilarStrings::toList() const { |
|
|
auto distancesCopy = distances; |
|
|
|
|
|
std::vector<std::string> result; |
|
|
std::vector<std::string> result; |
|
|
while (!distancesCopy.empty()) { |
|
|
|
|
|
result.push_back(distancesCopy.top().second); |
|
|
|
|
|
distancesCopy.pop(); |
|
|
|
|
|
|
|
|
for (auto const& dist : distances) { |
|
|
|
|
|
result.push_back(dist.second); |
|
|
} |
|
|
} |
|
|
return result; |
|
|
return result; |
|
|
} |
|
|
} |
|
@ -41,7 +39,6 @@ namespace storm { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
uint64_t levenshteinDistance(std::string const& lhs, std::string const& rhs, bool caseSensitive) { |
|
|
uint64_t levenshteinDistance(std::string const& lhs, std::string const& rhs, bool caseSensitive) { |
|
|
std::vector<std::vector<uint64_t>> d(lhs.size() + 1, std::vector<uint64_t>(rhs.size() + 1, 0ull)); |
|
|
std::vector<std::vector<uint64_t>> d(lhs.size() + 1, std::vector<uint64_t>(rhs.size() + 1, 0ull)); |
|
|
for (uint64_t row = 1; row < d.size(); ++row) { |
|
|
for (uint64_t row = 1; row < d.size(); ++row) { |
|
|