Exemplo n.º 1
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            InMemoryGlobalSemanticWordDal.GetGlobalSemanticWordList();
            app.UseCors(builder => builder.WithOrigins("https://siteindexer-729f6.web.app").AllowAnyHeader().AllowAnyOrigin());
            app.UseHttpsRedirection();

            app.UseRouting();

            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });
        }
        //Stage Five - Stage four and Semantic Analysis
        public IDataResult <UrlSimilaritySubSemanticWebSiteDto> UrlSimilarityWithSemanticCalculate(WebSite webSite, List <WebSite> webSitePool)
        {
            globalList = new List <WebSite>();
            foreach (var item in webSitePool)
            {
                globalList.Add(item);
            }
            globalList.Add(webSite);
            //Sub Url Tree
            List <UrlTreeDto> tempUrlTree = new List <UrlTreeDto>();

            webSitePool.ForEach(p => tempUrlTree.Add(_webSiteOperation.SubUrlFinder(p, globalList).Data));

            //Adding sub urls to webSitePool
            List <WebSite> tempSubUrls = new List <WebSite>();

            webSitePool.ForEach(p =>
            {
                p.SubUrls.ForEach(l =>
                {
                    tempSubUrls.Add(l);
                    l.SubUrls.ForEach(m =>
                    {
                        tempSubUrls.Add(m);
                    });
                });
            });
            webSitePool = webSitePool.Concat(tempSubUrls).ToList();

            //Semantic keyword generate
            List <SemanticWordJsonDto> Dictionary = InMemoryGlobalSemanticWordDal.GetGlobalSemanticWordList();

            webSite = _keywordOperation.SemanticKeywordGeneratorForTarget(webSite, ref Dictionary).Data;

            //Similarity calculating
            InputDto input = _keywordOperation.SimilarityCalculate(webSite, webSitePool, true, true).Data;

            //Return Object
            KeywordWebSiteDto tempWebSite = new KeywordWebSiteDto
            {
                Url      = input.webSite.Url,
                Title    = input.webSite.Title,
                Keywords = input.webSite.Keywords
            };

            List <SimilarityScoreSemanticDto> tempWebSitesPool = new List <SimilarityScoreSemanticDto>();

            input.webSitePool.ForEach(p =>
            {
                tempWebSitesPool.Add(new SimilarityScoreSemanticDto
                {
                    SimilarityScore = p.SimilarityScore,
                    webSite         = new KeywordWebSiteSemanticDto
                    {
                        Url              = p.Url,
                        Title            = p.Title,
                        Keywords         = p.Keywords,
                        SemanticKeywords = p.SemanticKeywords
                    }
                });
            });

            return(new SuccessDataResult <UrlSimilaritySubSemanticWebSiteDto>(
                       data: new UrlSimilaritySubSemanticWebSiteDto
            {
                webSite = tempWebSite,
                webSitePool = tempWebSitesPool,
                UrlTree = tempUrlTree
            }));
        }