Sorensen–Dice coefficient: Difference between revisions
m
C++ - minor performance improvement
(Added C++ solution) |
m (C++ - minor performance improvement) |
||
Line 57:
#include <vector>
using bigram = std::pair<char, char>;
std::multiset<std::string> split(const std::string& phrase) {▼
std::multiset<std::string> result;▼
std::istringstream is(phrase);
std::string word;
Line 67 ⟶ 69:
size_t length = word.size();
if (length == 1) {
result.emplace(
} else {
for (size_t i = 0; i + 1 < length; ++i) {
result.
}
}
Line 80 ⟶ 82:
auto a = split(s1);
auto b = split(s2);
std::multiset<
std::set_intersection(a.begin(), a.end(), b.begin(), b.end(),
std::inserter(c, c.begin()));
|