private ScoredString GetSuggestionPrefixScore(string wordToSuggest, string suggestion) { int smallestLength = Math.Min(wordToSuggest.Length, suggestion.Length); ScoredString suggestionScore = new ScoredString() {Text = suggestion}; int score = 0; for (int i = 0; i < smallestLength; ++i) { if (wordToSuggest[i] != suggestion[i]) break; score++; } suggestionScore.Score = score; return suggestionScore; }
private ScoredString GetSuggestionPrefixScore(string wordToSuggest, string suggestion) { int smallestLength = Math.Min(wordToSuggest.Length, suggestion.Length); ScoredString suggestionScore = new ScoredString() { Text = suggestion }; int score = 0; for (int i = 0; i < smallestLength; ++i) { if (wordToSuggest[i] != suggestion[i]) { break; } score++; } suggestionScore.Score = score; return(suggestionScore); }
private ScoredString GetSuggestionPrefixScore(string wordToSuggest, string suggestion) { int smallestLength = Math.Min(wordToSuggest.Length, suggestion.Length); ScoredString suggestionScore = new ScoredString() { Text = suggestion }; int score = 0; for (int i = 0; i < smallestLength; ++i) { // To cater the comparison with case insensitive words if (wordToSuggest.ToLower()[i] != suggestion.ToLower()[i]) { break; } score++; } suggestionScore.Score = score; return(suggestionScore); }