Browse code

Don't treat consecitive capitals as BOW

Only treat the first letter of an ALLCAPS word as the biginning of that
word (it is not CamelCase).

John Hawthorn authored on 18/07/2014 04:48:06
Showing 1 changed files

  • match.c index 78982d0..7a6166e 100644
... ...
@@ -58,11 +58,13 @@ double calculate_score(const char *needle, const char *haystack){
58 58
 
59 59
 	/* Which positions are beginning of words */
60 60
 	int at_bow = 1;
61
+	char last_ch = '\0';
61 62
 	for(int i = 0; i < m; i++){
62 63
 		char ch = haystack[i];
63 64
 		/* TODO: What about allcaps (ex. README) */
64
-		bow[i] = (at_bow && isalnum(ch)) || isupper(ch);
65
+		bow[i] = (at_bow && isalnum(ch)) || (isupper(ch) && !isupper(last_ch));
65 66
 		at_bow = !isalnum(ch);
67
+		last_ch = ch;
66 68
 	}
67 69
 
68 70
 	for(int i = 0; i < n; i++){