27 const size_t MAX_LEN = 100;
28 const size_t len1 = strlen(s1);
29 const size_t len2 = strlen(s2);
31 if (len1 >= MAX_LEN || len2 >= MAX_LEN)
return(-1);
34 int dist[MAX_LEN][MAX_LEN] = { 0 };
35 for (
int i = 0;i <= len1;i++) {
38 for (
int j = 0;j <= len2; j++) {
42 for (
int j = 1;j <= len1; j++) {
43 for (
int i = 1;i <= len2; i++) {
45 if (s1[i - 1] == s2[j - 1]) {
48 int t =
MIN((dist[i - 1][j] + 1), (dist[i][j - 1] + 1));
49 dist[i][j] =
MIN(t, (dist[i - 1][j - 1] + track));
52 return dist[len2][len1];
84 bool sim_found = (param.find(filter) != std::string::npos) || (filter.find(param) != std::string::npos);
87 size_t dist = util::levenshtein_distance(filter.c_str(), param.c_str());
88 if (dist <= (param.length() / 2)) {
91 if (dist >= param.length() || dist >= filter.length()) {
96 size_t diff = util::str_hist_diffrence(filter.c_str(), param.c_str());
97 if (diff <= (param.length() / 2) || diff <= (filter.length() / 2)) {
100 if (diff >= param.length() || diff >= filter.length()) {