/// <summary>
        /// Gets all of the recommended starting point for relevant <see cref="EventModel"/> classes.
        /// </summary>
        /// <param name="end">The ending <see cref="DateTime"/> for the time period to recommend.</param>
        /// <param name="mode">Specifies the calculation mode to use.</param>
        /// <returns>An <see cref="IEnumerable{T}"/> of all <see cref="RecommendationModel"/> classes.</returns>
        public IEnumerable <RecommendationModel> GetRecommendations(DateTime end, RecommendationMode mode)
        {
            try
            {
                // Handle everything in EST (to make thing easier for now).
                var estTimeZone = TimeZoneInfo.FindSystemTimeZoneById(Constants.EasternStandardTimeZoneId);
                var start       = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, estTimeZone);

                builder
                .Create(start, end)
                .ConstructIterative()
                .ReorderOverruns()
                .SpreadBackwards();
                if (mode == RecommendationMode.MinimalClustering)
                {
                    builder.SpreadForwards();
                }
                return(builder
                       .FillEmpty()
                       .Build());
            }
            catch (Exception)
            {
                throw;
            }
        }
示例#2
0
        public IReadOnlyList <TagSearchResult> GetRecommendations(
            IEnumerable <string> currentFilters,
            string search,
            RecommendationMode mode)
        {
            var filters   = currentFilters.Select(filter => filter.ToLowerInvariant()).ToList();
            var newFilter = search.ToLowerInvariant();

            return(_lock.Read(() => _tagManager.GetRecommendations(_previewModels, filters, newFilter, mode)));
        }
示例#3
0
        public IReadOnlyList <TagSearchResult> GetRecommendations(IEnumerable <ITagged> previewModels,
                                                                  IEnumerable <string> currentFilters,
                                                                  string search, RecommendationMode mode)
        {
            IEnumerable <TagSearchResult> Search()
            {
                if (string.IsNullOrWhiteSpace(search))
                {
                    yield break;
                }

                var currentSet = currentFilters.ToHashSet();

                var positiveSearch = search.TrimStart('-', ' ');
                var isNotSearch    = search.StartsWith("-");

                var possibleTags = _trie.Find(positiveSearch)
                                   .Select(result => result.word)
                                   .Where(tag => !currentSet.Contains(tag));

                var currentModels = Filter(previewModels, currentSet);

                foreach (var tag in possibleTags)
                {
                    if (mode == RecommendationMode.Tagging || currentModels.Count(model => model.Tags.Contains(tag)) > 0)
                    {
                        var rebuiltTag = isNotSearch ? "-" + tag : tag;
                        yield return(new TagSearchResult(rebuiltTag, currentModels.Count(model => model.Tags.Contains(tag))));
                    }
                }
            }

            return(Search()
                   .OrderByDescending(result => result.MatchingItemCount)
                   .ToList());
        }