@@ -31,18 +31,18 @@ public MatchResult FuzzyMatch(string query, string stringToCompare)
31
31
}
32
32
33
33
/// <summary>
34
- /// Current method includes two part , Acronym Match and Fuzzy Search:
34
+ /// Current method has two parts , Acronym Match and Fuzzy Search:
35
35
///
36
36
/// Acronym Match:
37
- /// Charater lists below will be considered as Acronym
37
+ /// Charater listed below will be considered as acronym
38
38
/// 1. Character on index 0
39
39
/// 2. Character appears after a space
40
40
/// 3. Character that is UpperCase
41
41
/// 4. Character that is number
42
42
///
43
- /// Acronym Search will match all query when meeting with Acronyms in the stringToCompare
44
- /// If any of the character in Query isn't matched with the string , Acronym Search fail.
45
- /// Score will be calculated based on the number of mismatched acronym before all query has been matched
43
+ /// Acronym Match will succeed when all query characters match with acronyms in stringToCompare.
44
+ /// If any of the characters in the query isn't matched with stringToCompare , Acronym Match will fail.
45
+ /// Score will be calculated based the percentage of all query characters matched with total acronyms in stringToCompare.
46
46
///
47
47
/// Fuzzy Search:
48
48
/// Character matching + substring matching;
@@ -65,7 +65,6 @@ public MatchResult FuzzyMatch(string query, string stringToCompare, MatchOption
65
65
66
66
var currentAcronymQueryIndex = 0 ;
67
67
var acronymMatchData = new List < int > ( ) ;
68
-
69
68
int acronymsTotalCount = 0 ;
70
69
int acronymsMatched = 0 ;
71
70
@@ -106,7 +105,7 @@ public MatchResult FuzzyMatch(string query, string stringToCompare, MatchOption
106
105
if ( fullStringToCompareWithoutCase [ compareStringIndex ] == ' ' && currentQuerySubstringIndex == 0 )
107
106
spaceIndices . Add ( compareStringIndex ) ;
108
107
109
- // Acronym check
108
+ // Acronym Match
110
109
if ( IsAcronym ( stringToCompare , compareStringIndex ) )
111
110
{
112
111
if ( fullStringToCompareWithoutCase [ compareStringIndex ] ==
@@ -122,8 +121,6 @@ public MatchResult FuzzyMatch(string query, string stringToCompare, MatchOption
122
121
if ( IsAcronymCount ( stringToCompare , compareStringIndex ) )
123
122
acronymsTotalCount ++ ;
124
123
125
- // Acronym end
126
-
127
124
if ( allQuerySubstringsMatched || fullStringToCompareWithoutCase [ compareStringIndex ] !=
128
125
currentQuerySubstring [ currentQuerySubstringCharacterIndex ] )
129
126
{
@@ -232,7 +229,6 @@ private bool IsAcronymCount(string stringToCompare, int compareStringIndex)
232
229
if ( IsAcronymNumber ( stringToCompare , compareStringIndex ) )
233
230
return compareStringIndex == 0 || char . IsWhiteSpace ( stringToCompare [ compareStringIndex - 1 ] ) ;
234
231
235
-
236
232
return false ;
237
233
}
238
234
@@ -241,7 +237,8 @@ private bool IsAcronymChar(string stringToCompare, int compareStringIndex)
241
237
compareStringIndex == 0 || // 0 index means char is the start of the compare string, which is an acronym
242
238
char . IsWhiteSpace ( stringToCompare [ compareStringIndex - 1 ] ) ;
243
239
244
- private bool IsAcronymNumber ( string stringToCompare , int compareStringIndex ) => stringToCompare [ compareStringIndex ] >= 0 && stringToCompare [ compareStringIndex ] <= 9 ;
240
+ private bool IsAcronymNumber ( string stringToCompare , int compareStringIndex )
241
+ => stringToCompare [ compareStringIndex ] >= 0 && stringToCompare [ compareStringIndex ] <= 9 ;
245
242
246
243
// To get the index of the closest space which preceeds the first matching index
247
244
private int CalculateClosestSpaceIndex ( List < int > spaceIndices , int firstMatchIndex )
0 commit comments