private static void CalculateResultLevelMetric(string metricName, QueryMetadata queryMetadata, ResultMetadata result) { if (result.metric.ContainsKey(metricName)) { return; } double metricScore = 0; if (metricName == "matchscore") { metricScore = CalIntentMatchScore(result); } else if (metricName == "popularscore") { metricScore = result.Popularity / 100000.0; } else if (metricName == "distancescore") { metricScore = CalDistanceMatchScore(result, queryMetadata); } else if (metricName == "linedistance") { metricScore = CalLineDistanceScore(result, queryMetadata); } else if (metricName == "linedistance2") { metricScore = CalLineDistanceScore(result, queryMetadata); if (queryMetadata.ManualInnerRadius > 20) { metricScore = -1;; } } else if (metricName == "linedistance3") { metricScore = CalLineDistanceScore(result, queryMetadata); if (metricScore > 100) { metricScore = -1;; } } else if (metricName == "linedistanceinner") { metricScore = CalLineDistanceInnerScore(result, queryMetadata); } else if (metricName == "distanceinnerratio") { metricScore = CalLineDistanceInnerRatio(result, queryMetadata); } else if (metricName == "urlscore") { metricScore = string.IsNullOrWhiteSpace(result.Url) ? 0 : 1; } else if (metricName == "reviewscore") { metricScore = (result.ReviewCount > 3 || result.Rating > 0) ? 1 : 0; } else if (metricName == "nojunkscore") { metricScore = (result.ReviewCount > 3 || result.Rating > 0 || !string.IsNullOrWhiteSpace(result.Url)) ? 1 : 0; } else if (metricName == "l3dcgrelevance") { CalculateResultLevelMetric("matchscore", queryMetadata, result); CalculateResultLevelMetric("popularscore", queryMetadata, result); CalculateResultLevelMetric("urlscore", queryMetadata, result); CalculateResultLevelMetric("reviewscore", queryMetadata, result); metricScore = CalculateL3dcgIntent(result); } else if (metricName == "pldcgrelevance") { CalculateResultLevelMetric("l3dcgrelevance", queryMetadata, result); metricScore = CalculatePLdcgIntent(result); } else if (metricName.StartsWith("l3dcg")) { CalculateResultLevelMetric("l3dcgrelevance", queryMetadata, result); CalculateResultLevelMetric("distancescore", queryMetadata, result); metricScore = result.metric["l3dcgrelevance"] * result.metric["distancescore"] * 100; metricName = "l3dcg"; } else if (metricName.StartsWith("pldcg")) { CalculateResultLevelMetric("pldcgrelevance", queryMetadata, result); CalculateResultLevelMetric("distancescore", queryMetadata, result); metricScore = result.metric["pldcgrelevance"] * result.metric["distancescore"] * 100; metricName = "pldcg"; } if (!result.metric.ContainsKey(metricName)) { result.metric.Add(metricName, metricScore); } }