public void Filter(UserSearchPipelineResult pipelineResult, UserSearchPipelineRequest request)
        {
            if (pipelineResult == null) throw new ArgumentNullException("pipelineResult");
            if (pipelineResult.ScoredInterests == null) throw new ArgumentNullException("pipelineResult", "Scored results should be provided");

            pipelineResult.ScoredInterests = pipelineResult.ScoredInterests.Where(x => x.Score >= Constants.EXPLICIT_SEARCH_INTEREST_THRESHOLD).ToList();
        }
        public void Filter(UserSearchPipelineResult pipelineResult, UserSearchPipelineRequest request)
        {
            if (pipelineResult == null) throw new ArgumentNullException("pipelineResult");
            if (pipelineResult.ScoredInterests == null) throw new ArgumentNullException("pipelineResult", "Scored results should be provided");

            _mainCategoryScoreCalculator.CalculateMainCategoryScores(pipelineResult.ScoredInterests);
        }
        public void Filter(UserSearchPipelineResult pipelineResult, UserSearchPipelineRequest request)
        {
            if (pipelineResult == null) throw new ArgumentNullException("pipelineResult");
            if (pipelineResult.ScoredInterests == null) throw new ArgumentNullException("pipelineResult", "Scored results should be provided");

            pipelineResult.ScoredInterests = _closeInterestLimiter.LimitCloseInterests(pipelineResult.ScoredInterests).Cast<ScoredRelatedInterestDto>().ToList();
        }
        public void Filter(UserSearchPipelineResult pipelineResult, UserSearchPipelineRequest request)
        {
            if (pipelineResult == null) throw new ArgumentNullException("pipelineResult");
            if (request == null) throw new ArgumentNullException("request", "Location data is required");
            if (request.LocationData == null) throw new ArgumentNullException("request", "Location data is required");

            var geo = new GeoCoordinate(request.LocationData.Latitude, request.LocationData.Longitude);

            foreach (var user in pipelineResult.Users)
            {
                var distanceTo = (float) geo.GetDistanceTo(new GeoCoordinate(user.Latitude, user.Longitude));

                float miles = distanceTo / _metersToMiles;

                var res = (int) Math.Round(miles, 0, MidpointRounding.AwayFromZero);

                float locationMultiplier = (Constants.LOCATION_MAX_MILES - res) * Constants.LOCATION_MILE_MULTIPLIER;

                if (Math.Abs(locationMultiplier) < float.Epsilon) //float precision - if not 0
                {
                    locationMultiplier = float.Epsilon;
                }

                user.Score *= locationMultiplier;
            }
        }
        public void Filter(UserSearchPipelineResult pipelineResult, UserSearchPipelineRequest request)
        {
            if (pipelineResult == null) throw new ArgumentNullException("pipelineResult");

            _interestScoreCalculator.CalculateRelatedInterestScore(pipelineResult.RelatedInterests);

            pipelineResult.ScoredInterests = pipelineResult.RelatedInterests.Select(x => new ScoredRelatedInterestDto(x.Id, x.Score, x.Slug, x.IsMainCategory, x.ExplicitSearch, x.Weight.Count)).ToList();
        }
        public void Filter(UserSearchPipelineResult pipelineResult, UserSearchPipelineRequest request)
        {
            if (pipelineResult == null) throw new ArgumentNullException("pipelineResult");
            if (request == null) throw new ArgumentNullException("request");
            if (request.User == null) throw new ArgumentNullException("request","User required");

            var relatedInterestDtos = _interestRepository.GetRelatedInterests(request.User.Interests.Select(x => x.Interest.Slug).ToList()).ToList();

            pipelineResult.RelatedInterests.AddRange(relatedInterestDtos);
        }
Ejemplo n.º 7
0
        public void Filter(UserSearchPipelineResult pipelineResult, UserSearchPipelineRequest request)
        {
            if (pipelineResult == null) throw new ArgumentNullException("pipelineResult");
            if (pipelineResult.Users == null) throw new ArgumentNullException("pipelineResult", "Users must be provided");

            pipelineResult.Users = pipelineResult
                .Users
                .OrderByDescending(x => x.Score)
                .ToList();
        }
        public void Filter(UserSearchPipelineResult pipelineResult, UserSearchPipelineRequest request)
        {
            if (pipelineResult == null) throw new ArgumentNullException("pipelineResult");
            if (request.User == null) throw new ArgumentNullException("request", "User cannot be null");

            pipelineResult.UserQuery =
                pipelineResult
                    .UserQuery
                    .Where(x => x != request.User);
        }
        public void Filter(UserSearchPipelineResult pipelineResult, UserSearchPipelineRequest request)
        {
            if (pipelineResult == null) throw new ArgumentNullException("pipelineResult");
            if (request == null) throw new ArgumentNullException("request");
            if (request.InterestSearch == null) throw new ArgumentNullException("request", "Search keys required");

            var relatedInterestDtos = _interestRepository.GetRelatedInterests(request.InterestSearch).ToList();
            relatedInterestDtos.ForEach(x => x.ExplicitSearch = true);
            pipelineResult.RelatedInterests.AddRange(relatedInterestDtos);
        }
        public void Filter(UserSearchPipelineResult pipelineResult, UserSearchPipelineRequest request)
        {
            if (pipelineResult == null) throw new ArgumentNullException("pipelineResult");

            foreach (var user in pipelineResult.Users)
            {
                user.Score += user.InterestDtos.Sum(
                    x =>
                    {
                        var foundInterest = pipelineResult.ScoredInterests.SingleOrDefault(y => y.Id == x.InterestId);
                        return foundInterest != null ? foundInterest.Score : 0f;
                    });
            }
        }
        public void Filter(UserSearchPipelineResult pipelineResult, UserSearchPipelineRequest request)
        {
            if (pipelineResult == null) throw new ArgumentNullException("pipelineResult");
            if (pipelineResult.ScoredInterests == null) throw new ArgumentNullException("pipelineResult", "Scored results should be provided");

            var scoredRelatedInterestDtos = pipelineResult
                .ScoredInterests
                .Where(x => x.ExplicitSearch && x.Hops < Constants.EXPLICIT_SEARCH_INTEREST_MULTIPLIER.Length)
                .ToList();

            foreach (var scoredRelatedInterestDto in scoredRelatedInterestDtos)
            {
                scoredRelatedInterestDto.Score *= Constants.EXPLICIT_SEARCH_INTEREST_MULTIPLIER[scoredRelatedInterestDto.Hops];
            }
        }
Ejemplo n.º 12
0
        public void Filter(UserSearchPipelineResult pipelineResult, UserSearchPipelineRequest request)
        {
            if (pipelineResult == null) throw new ArgumentNullException("pipelineResult");
            if (pipelineResult.ScoredInterests == null) throw new ArgumentNullException("pipelineResult", "ScoredInterests is required");

            var interestIds = pipelineResult
                .ScoredInterests
                .Select(x => x.Id)
                .ToList(); //this needs to be a list since it's used in a query expression

            pipelineResult.UserQuery =
                pipelineResult
                    .UserQuery
                    .Where(x => x.Interests.Any(y => interestIds.Contains(y.Interest.Id)));
        }
        public void ExplicitSearchIncreasesScore()
        {
            var score1 = new ScoredRelatedInterestDto(0, 4, "", false, true, 0);

            var userSearchPipelineResult = new UserSearchPipelineResult
            {
                ScoredInterests = new List<ScoredRelatedInterestDto>
                {
                    score1
                }
            };

            _calculateExplicitSearchInterestScoreFilter.Filter(userSearchPipelineResult, null);

            Assert.That(userSearchPipelineResult.ScoredInterests.Single().Score, Is.EqualTo(20f));
        }
        public void Filter(UserSearchPipelineResult userSearchPipelineResult, UserSearchPipelineRequest request)
        {
            if (userSearchPipelineResult == null) throw new ArgumentNullException("userSearchPipelineResult");

            userSearchPipelineResult.Users = userSearchPipelineResult.UserQuery.Select(x => new UserSearchResultDto(x)).ToList();
        }
Ejemplo n.º 15
0
        public UserSearchPipelineResult Execute(UserSearchPipelineRequest request)
        {
            //set flags
            var explicitSearch = request.InterestSearch != null;

            //start with list of users
            var retVal = new UserSearchPipelineResult { UserQuery = _userRepository.FindAll() };

            /************ Find Dependent Data  ******************/

            //run filter to query potential interests based on the user's list of interests
            _findTargetUsersRelatedInterestsFilter.Filter(retVal, request);

            //run filter to query potential interests based on what was explicitly searched for
            if (explicitSearch)
            {
                _findRelatedInterestsFromKeywordSearchFilter.Filter(retVal, request);
            }

            /************ Calculate Signal Data ******************/

            //score interests based on user
            _calculateRelatedInterestScoreFilter.Filter(retVal, request);

            //score interests based on explicit search
            if (explicitSearch)
            {
                _calculateExplicitSearchInterestScoreFilter.Filter(retVal, request);
            }

            //main categories get less points - too vague
            _calculateMainCategoryInterestScoreFilter.Filter(retVal, request);

            //keep only the highest scored interests
            _calculateHighestScoredInterestFilter.Filter(retVal, request);

            /************ Limits/Constraints ******************/

            //if explicit search, hide less relevant interests
            if (explicitSearch)
            {
                _limitByExplicitSearchScoreFilter.Filter(retVal, request);
            }
            else
            {
                //only keep 'close' interests
                _limitByCloseInterestFilter.Filter(retVal, request);
            }

            //filter users by interests and related
            _limitByInterestFilter.Filter(retVal, request);

            //dont show the target user in results
            _limitByTargetUserFilter.Filter(retVal, request);

            /************ Transform ******************/

            //transform users to found dtos
            _transformUserToScoredUserFilter.Filter(retVal, request);

            /************ Assign User Score ******************/

            //sort users by interests points
            _assignInterestCommonalityScoreFilter.Filter(retVal, request);

            _assignLocationScoreFilter.Filter(retVal, request);

            /************ Sort ******************/

            //order by scores
            _sortUserScoreFilter.Filter(retVal, request);

            return retVal;
        }