Only treat the first letter of an ALLCAPS word as the biginning of that
word (it is not CamelCase).
| ... | ... |
@@ -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++){
|