예제 #1
0
        public override async Task <bool> GetRatings(BufferBlock <BasicInfo> entitiesInfoQueue,
                                                     BufferBlock <RatingDataContainer> entitiesRatingQueue, bool outputResults)
        {
            while (await entitiesInfoQueue.OutputAvailableAsync())
            {
                BasicInfo entityInfo = await entitiesInfoQueue.ReceiveAsync();

                var    movieTmdbInfo = (TmdbMovieInfo)entityInfo;
                double rating        = _fuzzyController.CalculateRating(
                    movieTmdbInfo.VoteCount, movieTmdbInfo.VoteAverage,
                    movieTmdbInfo.ReleaseDate.Year, movieTmdbInfo.Popularity,
                    movieTmdbInfo.Adult ? 1 : 0
                    );

                var resultInfo = new RatingDataContainer(entityInfo, rating);

                await entitiesRatingQueue.SendAsync(resultInfo);

                if (outputResults)
                {
                    GlobalMessageHandler.OutputMessage($"Appraised {resultInfo} by {Tag}");
                }
            }
            return(true);
        }
예제 #2
0
        public virtual async Task <bool> GetRatings(BufferBlock <BasicInfo> entitiesInfoQueue,
                                                    BufferBlock <RatingDataContainer> entitiesRatingQueue, bool outputResults)
        {
            while (await entitiesInfoQueue.OutputAvailableAsync())
            {
                BasicInfo entityInfo = await entitiesInfoQueue.ReceiveAsync();

                var resultInfo = new RatingDataContainer(entityInfo, entityInfo.VoteAverage);
                await entitiesRatingQueue.SendAsync(resultInfo);

                if (outputResults)
                {
                    GlobalMessageHandler.OutputMessage(resultInfo.ToString());
                }
            }
            return(true);
        }
        public override async Task <bool> GetRatings(BufferBlock <BasicInfo> entitiesInfoQueue,
                                                     BufferBlock <RatingDataContainer> entitiesRatingQueue, bool outputResults)
        {
            while (await entitiesInfoQueue.OutputAvailableAsync())
            {
                BasicInfo entityInfo = await entitiesInfoQueue.ReceiveAsync();

                var gameInfo = (OmdbMovieInfo)entityInfo;

                var resultInfo = new RatingDataContainer(entityInfo, gameInfo.VoteAverage);
                await entitiesRatingQueue.SendAsync(resultInfo);

                if (outputResults)
                {
                    GlobalMessageHandler.OutputMessage($"Appraised {resultInfo} by {Tag}");
                }
            }
            return(true);
        }
예제 #4
0
        public RatingDataContainer GetRatings(BasicInfo entityInfo, bool outputResults)
        {
            if (!(entityInfo is T convertedInfo))
            {
                throw new ArgumentException(
                          $"Element \"{entityInfo.Title}\" (ID = {entityInfo.ThingId.ToString()}) " +
                          $"type \"{entityInfo.GetType().FullName}\" is invalid for appraiser with " +
                          $"type \"{TypeId.FullName}\"."
                          );
            }

            double ratingValue = _appraisal.CalculateRating(convertedInfo);

            var resultInfo = new RatingDataContainer(entityInfo, ratingValue, RatingId);

            if (outputResults)
            {
                GlobalMessageHandler.OutputMessage(resultInfo.ToString());
            }

            return(resultInfo);
        }