Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CompareStringsResult ¶
type CompareStringsResult struct { SameCharCount int MatchPercent float64 SameCharCountNoCase int MatchPercentNoCase float64 }
func CompareStrings ¶
func CompareStrings(str1, str2 string) CompareStringsResult
CompareStrings takes two strings as input and returns a ComparisonResult struct containing various metrics that quantify their similarity.
Metrics included are:
- SameCharCount: The number of characters that are exactly the same at the corresponding positions in both strings.
- MatchPercent: 0 to 1. The percentage of characters that are exactly the same, calculated based on the shorter string's length.
- SameCharCountNoCase: The number of characters that are the same when case is ignored, at the corresponding positions in both strings.
- MatchPercentNoCase: 0 to 1. The percentage of characters that are the same when case is ignored, calculated based on the shorter string's length.
The function uses rune slices for Unicode support. It uses bitwise OR for fast ASCII character comparison, and falls back to unicode.SimpleFold for full Unicode case-insensitive comparison.