public static CompareHashes ( string lhs, string rhs ) : double | ||
lhs | string | |
rhs | string | |
return | double |
public static double CompareHashes(string lhs, string rhs) {
var lhsLines = Encoding.UTF8.GetString(Convert.FromBase64String(lhs)).Split('\n');
var rhsLines = Encoding.UTF8.GetString(Convert.FromBase64String(rhs)).Split('\n');
var size = lhsLines.Length - 1;
if (size != rhsLines.Length - 1) return 0.0;
var same = 0;
for (var i = 0; i < size; i++) {
if (lhsLines[i] == rhsLines[i]) {
same++;
}
}
return (double)same / size;
}
RulesSet::CompareHashes ( string lhs, string rhs, |
public IEnumerable <Simular> FindSimular(string carId, string rulesSetId, string hashValue, double threshold, RulesSet set = null) { RulesSet.Rule[] workedRules = null; if (!_dictionary.ContainsKey(rulesSetId)) { yield break; } foreach (var pair in _dictionary[rulesSetId]) { if (pair.Key == carId) { continue; } var value = set == null?RulesSet.CompareHashes(hashValue, pair.Value) : RulesSet.CompareHashes(hashValue, pair.Value, set, out workedRules); if (value > threshold) { yield return(new Simular { CarId = pair.Key, Value = value, WorkedRules = workedRules }); } } }