New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sift3 string distance in IE7 is invalid. #14
Comments
Changing the array access to use charAt instead of [] seems to fix this bug too. Here is a rough patch:
while ((c + offset1 < s1.length) && (c + offset2 < s2.length)) {
- if (s1[c + offset1] == s2[c + offset2]) {
- if (s1.charAt(c + offset1) == s2.charAt(c + offset2)) {
lcs++;
} else {
offset1 = 0;
offset2 = 0;
for (var i = 0; i < maxOffset; i++) {
- if ((c + i < s1.length) && (s1[c + i] == s2[c])) {
- if ((c + i < s1.length) && (s1.charAt(c + i) == s2.charAt(c))) {
offset1 = i;
break;
}
- if ((c + i < s2.length) && (s1[c] == s2[c + i])) {
- if ((c + i < s2.length) && (s1.charAt(c) == s2.charAt(c + i))) {
offset2 = i;
break;
}
|
good catch, i just made levenstein my default - but kept sift3 as an option. all my tests now pass in IE7 as well: http://fragged.org/dev/mailcheck/test/ if you actually read my test file (its buster not jasmine), some of the expectations are a bit off with sift3, like 1.5 when I'd have expected 2 when 1 typo + 1 new char, eg: vs levenstein for same case: cheers anyway |
Hi, I've implemented mailcheck on my site and also have problems with IE6 and 7, is there any possibility to fix this in the master branch? I always can download the non-minified version and apply the samoht625 patch but would be great to have it in the official version. Thanks |
My fork has an implementation of the Levenstein algorithm in the full and minimized versions, but it still defaults to the sift3 implementation at the moment and has not yet been submitted as a pull request to the master; use at your own risk. |
@samoht625 Good catch. From stackoverflow:
|
I'll merge the charAt change for sure. What are your views on sift3 vs Levenshtein? I'm not keen on offering two algorithms by default, and I'm open to changing the default as well. |
I ran some offline analysis of the email addresses for dropbox (we are |
Thanks @samoht625! Glad to see it on Dropbox. I've merged the IE fix into master. Closing this issue for now. We may offer alternate string similarity algorithms in the future, in way that doesn't introduce unnecessary bloat. (See #18). I'll be merging in a couple of pull requests (including @hpshelton's awesome one) for a 1.2 release shortly. |
like i said before:
so between 'gmail and 'gnails' it returns 1.5 when there is a 2 char 'distance'. levenstein returns 2 so makes more sense. |
…lems with suggestions. Patch proposed by samoht625 (https://github.com/samoht625) in mailcheck#14 (comment)
…lems with suggestions. Patch proposed by samoht625 (https://github.com/samoht625) in mailcheck/mailcheck#14 (comment)
This got caught by our QA team:
DimitarChristoff#1
compare:
String.distance('gmails.com', 'aol.co.uk')
Expected / seen:
8.5
in major browsers, actual:0.5
in IE7As a result, in IE7:
Expect
user@gmails.com' to suggest
user@gmail.com, actual:
user@aol.co.ukin our DB Expect
user@gmails.com' to suggestuser@gmail.com
, actual:user@google.com
in your kicksend DBAs a workaround, I have now added levenstein to calculate the distance instead, seems far more reliable. https://github.com/DimitarChristoff/mailcheck/blob/master/src/String.distance.js#L71-93 or google for other implementations.
This is now covered by my test coverage and buster.js reports the following tests in Ie7 (they pass in all other browsers):
The text was updated successfully, but these errors were encountered: