Пример #1
0
        public override string Execute()
        {
            var tokinizer     = new Tokinizer(stopwords);
            var documentStore = new DocumentStorageMemory();
            var vocabulary    = new Vocabulary();
            var search        = new SearchEngine(vocabulary, documentStore, tokinizer);

            var bigram = new NGram(2, new Sentencezer(new Tokinizer(new HashSet <string>()
            {
                "-", "\"", "(", ")", ":", ";", ","
            })));
            var trigram = new NGram(3, new Sentencezer(new Tokinizer(new HashSet <string>()
            {
                "-", "\"", "(", ")", ":", ";", ","
            })));
            var numberOfDocuments = 0;

            foreach (var contentData in _contentLoader.GetAllChildren <MovieProduct>(_referenceConverter.GetRootLink()))
            {
                if (contentData is ISearch movieProduct)
                {
                    search.Indexing <ISearch>(contentData.ContentLink.ID, movieProduct);
                    bigram.Insert <ISearch>(movieProduct);
                    trigram.Insert <ISearch>(movieProduct);
                    numberOfDocuments++;
                    Debug.WriteLine(movieProduct.Title);
                }
            }

            _blobRepository.Save("BiGram", bigram.Export());
            _blobRepository.Save("TriGram", trigram.Export());
            _blobRepository.Save("Vocabulary", vocabulary.Export());
            _blobRepository.Save("Search", search.Export());
            return($"Number of documents; {numberOfDocuments}, number of words {vocabulary.Count()}");
        }
Пример #2
0
        public override string Execute()
        {
            var allMarkets = _marketService.GetAllMarkets();
            var added      = 0;

            foreach (var variant in _contentLoader.GetAllChildren <MovieVariant>(_referenceConverter.GetRootLink()))
            {
                var newPrices     = new List <PriceDetailValue>();
                var currentPrices = _priceDetailService.List(variant.ContentLink);
                //     var currentPrices2 = _priceService.GetCatalogEntryPrices(new CatalogKey(variant.Code));

                var markets = currentPrices?.Select(x => x.MarketId).Distinct().ToHashSet();

                foreach (var market in allMarkets)
                {
                    if (!markets.Contains(market.MarketId))
                    {
                        foreach (var currency in market.Currencies)
                        {
                            PriceDetailValue newPriceEntry = new PriceDetailValue();

                            newPriceEntry.CatalogKey      = new CatalogKey(variant.Code);
                            newPriceEntry.MinQuantity     = 0;
                            newPriceEntry.MarketId        = market.MarketId;
                            newPriceEntry.UnitPrice       = new Money(GetPrice(currency), currency);
                            newPriceEntry.ValidFrom       = DateTime.Now.AddDays(-1);
                            newPriceEntry.ValidUntil      = DateTime.Now.AddYears(20);
                            newPriceEntry.CustomerPricing = new CustomerPricing(0, "");
                            newPrices.Add(newPriceEntry);
                        }
                    }
                }

                if (newPrices.Any())
                {
                    _priceDetailService.Save(newPrices);
                    added += newPrices.Count;
                }
            }
            return($"Added {added} prices");
        }
        public override string Execute()
        {
            var numberOfDocuments = 0;

            _elasticClient.Indices.Delete("movie");
            _elasticClient.Indices.Create("movie", x => x.Map <MovieDocument>(mm => mm.Properties(p => p.Keyword(t => t.Name(n => n.Genres)))));
            foreach (var contentData in _contentLoader.GetAllChildren <MovieProduct>(_referenceConverter.GetRootLink()))
            {
                if (contentData is ISearch movieProduct)
                {
                    var indexMove = new MovieDocument
                    {
                        Id    = contentData.TheMovieDbId,
                        Adult = movieProduct.Adult,
                        BelongsToCollection = movieProduct.BelongsToCollection,
                        Casts           = movieProduct.Casts?.ToList() ?? new List <Cast>(),
                        ContentLink     = movieProduct.ContentLink,
                        Crews           = movieProduct.Crews?.ToList() ?? new List <Crew>(),
                        Genres          = movieProduct.Genres ?? "",
                        OrginalLang     = movieProduct.OrginalLang ?? "",
                        OriginalTitle   = movieProduct.OriginalTitle ?? "",
                        Overview        = movieProduct.Overview ?? "",
                        Popularity      = movieProduct.Popularity,
                        Poster          = movieProduct.Poster,
                        ReleaseDate     = movieProduct.ReleaseDate,
                        SpokenLanguages = movieProduct.SpokenLanguages ?? "",
                        Title           = movieProduct.Title ?? "",
                        VoteAverage     = movieProduct.VoteAverage,
                        VoteCount       = movieProduct.VoteCount
                    };

                    var indexResponse = _elasticClient.IndexDocument(indexMove);
                    numberOfDocuments++;
                }
            }
            return($"Number of documents; {numberOfDocuments}");
        }