コード例 #1
0
 private void TrainingThreadEntryPoint(MalTrainingData trainingData)
 {
     lock (m_underlyingRecSourceLock)
     {
         UnderlyingRecSource.Train(trainingData);
     }
 }
コード例 #2
0
        public DTO.GetMalRecsResponse GetRecommendations(MalUserListEntries animeList, GetMalRecsRequest recRequest, CancellationToken cancellationToken)
        {
            // Ignore the cancellation token - we're only cancelling on service shut down, and getting recommendations should be quick.
            // If getting recommendations takes longer than the final connection drain time limit, something is wrong.
            TInput recSourceInput             = GetRecSourceInputFromRequest(animeList, recRequest);
            TRecommendationResults recResults = UnderlyingRecSource.GetRecommendations(recSourceInput, recRequest.NumRecsDesired);

            List <TDtoRec> dtoRecs = new List <TDtoRec>();
            Dictionary <int, DTO.MalAnime> animes = new Dictionary <int, DTO.MalAnime>();

            foreach (TRecommendation rec in recResults)
            {
                TDtoRec dtoRec = new TDtoRec()
                {
                    MalAnimeId = rec.ItemId,
                };
                animes[rec.ItemId] = new DTO.MalAnime(rec.ItemId, Animes[rec.ItemId].Title, Animes[rec.ItemId].Type);

                SetSpecializedRecommendationProperties(dtoRec, rec);

                dtoRecs.Add(dtoRec);
            }

            TResponse response = new TResponse();

            response.RecommendationType = RecommendationType;
            response.Recommendations    = dtoRecs;
            SetSpecializedExtraResponseProperties(response, recResults);

            HashSet <int> extraAnimesToReturn = GetExtraAnimesToReturn(recResults);

            foreach (int extraAnimeId in extraAnimesToReturn)
            {
                if (!animes.ContainsKey(extraAnimeId))
                {
                    animes[extraAnimeId] = new DTO.MalAnime(extraAnimeId, Animes[extraAnimeId].Title, Animes[extraAnimeId].Type);
                }
            }

            response.Animes = animes.Values.ToList();

            return(response);
        }
コード例 #3
0
 public override string ToString()
 {
     return(UnderlyingRecSource.ToString());
 }