Skip to content

Commit 83ddd88

Browse files
committed
Fix limit cases
1 parent cea17d8 commit 83ddd88

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

fingerprint.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ string best_jaccard_substr(const string &fixtext, const string &subtext)
108108
Fingerprint f1 = getFingerprint(fixtext);
109109
int maxlen = subtext.length();
110110
double best = 1.0;
111-
int best_s1, best_s2;
111+
int best_s1 = 0;
112+
int best_s2 = maxlen - 1;
112113
int d1 = fixtext.length() - 1;
113114
for (int s1 = 0; s1 < maxlen; s1++) {
114115
Fingerprint f2 = getFingerprint(""); // empty
@@ -117,7 +118,7 @@ string best_jaccard_substr(const string &fixtext, const string &subtext)
117118
int d2 = 0;
118119
int d = 0;
119120

120-
for (int s2 = s1 + 1; s2 + 1 < maxlen; s2++) { // update fingerprint for subtext
121+
for (int s2 = s1; s2 + 1 < maxlen; s2++) { // update fingerprint for subtext
121122
char first = subtext.at(s2) - 'a';
122123
char second = subtext.at(s2 + 1) - 'a';
123124
(f2.m_data[first][second])++;

0 commit comments

Comments
 (0)