Example #1
0
        private static async Task VerifyPackageIdsExistAsync(SearchScorerSettings settings, HttpClient httpClient)
        {
            var searchClient = new SearchClient(httpClient);
            var validator    = new PackageIdPatternValidator(searchClient);

            // Verify all desired package IDs exist.
            var feedback = FeedbackSearchQueriesCsvReader
                           .Read(settings.FeedbackSearchQueriesCsvPath)
                           .SelectMany(x => x.MostRelevantPackageIds);

            var curated = CuratedSearchQueriesCsvReader
                          .Read(settings.CuratedSearchQueriesCsvPath)
                          .SelectMany(x => x.PackageIdToScore.Keys);

            var clientCurated = CuratedSearchQueriesCsvReader
                                .Read(settings.ClientCuratedSearchQueriesCsvPath)
                                .SelectMany(x => x.PackageIdToScore.Keys);

            Console.WriteLine("Searching for non-existent package IDs");
            var allPackageIds         = feedback.Concat(curated);
            var nonExistentPackageIds = await validator.GetNonExistentPackageIdsAsync(allPackageIds, settings);

            Console.WriteLine();
            Console.WriteLine($"Found {nonExistentPackageIds.Count}.");
            foreach (var packageId in nonExistentPackageIds)
            {
                Console.WriteLine($" - {packageId}");
            }
        }
        public static IReadOnlyList <SearchQueryRelevancyScores <FeedbackSearchQuery> > FromFeedbackSearchQueriesCsv(SearchScorerSettings settings)
        {
            var output = new List <SearchQueryRelevancyScores <FeedbackSearchQuery> >();
            var feedbackSearchQueries = FeedbackSearchQueriesCsvReader.Read(settings.FeedbackSearchQueriesCsvPath);

            foreach (var feedback in feedbackSearchQueries)
            {
                // Give expected package IDs the maximum relevancy score.
                var scores = feedback
                             .MostRelevantPackageIds
                             .ToDictionary(x => x, x => MaximumRelevancyScore, StringComparer.OrdinalIgnoreCase);;

                output.Add(new SearchQueryRelevancyScores <FeedbackSearchQuery>(
                               feedback.SearchQuery,
                               scores,
                               feedback));
            }

            return(output);
        }