Пример #1
0
        static int CalculateRank(List <string[]> requests, BootstrapDemoModelBase demo, BootstrapDemoSectionModel section)
        {
            int resultRank  = 0;
            int keywordRank = 0;

            foreach (var request in requests)
            {
                int requestRank = -1;
                if (section != null && demo is BootstrapDemoPageModel && ((BootstrapDemoPageModel)demo).Sections.Count > 1 && SearchAgregator.CalculateRank(request, section.KeywordsRankList, out keywordRank))
                {
                    requestRank += keywordRank;
                }
                if (SearchAgregator.CalculateRank(request, demo.KeywordsRankList, out keywordRank))
                {
                    requestRank += keywordRank;
                }
                if (demo is BootstrapDemoGroupPageModel && SearchAgregator.CalculateRank(request, ((BootstrapDemoGroupPageModel)demo).KeywordsRankList, out keywordRank))
                {
                    requestRank += keywordRank;
                }
                if (requestRank == -1 && Search.WordsExclusions.Any(re => re.Equals(request[0], SearchAgregator.DefaultStringComparison)))
                {
                    requestRank = 0;
                }
                if (requestRank > -1)
                {
                    resultRank += requestRank;
                }
                else
                {
                    return(-1);
                }
            }
            return(resultRank);
        }
Пример #2
0
        static int CalculateRank(List <string[]> requests, DemoPageModel demo)
        {
            int resultRank  = 0;
            int keywordRank = 0;

            foreach (var request in requests)
            {
                int requestRank = -1;
                if (SearchAgregator.CalculateRank(request, demo.KeywordsRankList, out keywordRank))
                {
                    requestRank += keywordRank;
                }
                if (demo.Group != null && SearchAgregator.CalculateRank(request, demo.Group.KeywordsRankList, out keywordRank))
                {
                    requestRank += keywordRank;
                }
                if (SearchAgregator.CalculateRank(request, demo.Product.KeywordsRankList, out keywordRank))
                {
                    requestRank += keywordRank;
                }
                if (requestRank == -1 && Search.WordsExclusions.Any(re => re.Equals(request[0], SearchAgregator.DefaultStringComparison)))
                {
                    requestRank = 0;
                }
                if (requestRank > -1)
                {
                    resultRank += requestRank;
                }
                else
                {
                    return(-1);
                }
            }
            return(resultRank);
        }
Пример #3
0
        static IEnumerable <SearchResult> DoSearch(List <string[]> requests, DemoProductModel product)
        {
            var results = new List <SearchResult>();

            if (product.Overview != null)
            {
                results.AddRange(GetRes(requests, product.Overview, string.Format("{0}", SearchAgregator.HighlightOccurences(product.NavItemTitle, requests, true)), product.Overview.Product.Title.ToUpper()));
            }
            foreach (var group in product.Groups)
            {
                foreach (var demo in group.Demos)
                {
                    results.AddRange(GetRes(requests, demo, string.Format("{0}", SearchAgregator.HighlightOccurences(demo.Title, requests, true)), demo.Product.Title.ToUpper()));
                }
            }
            return(results);
        }
Пример #4
0
        static IEnumerable <BootstrapSearchResult> DoSearch(List <string[]> requests, BootstrapDemoGroupPageModel group)
        {
            var results = new List <BootstrapSearchResult>();

            foreach (var demo in group.Demos)
            {
                foreach (var section in demo.Sections)
                {
                    results.AddRange(GetRes(requests, demo, section, SearchAgregator.HighlightOccurences(section.Title, requests)));
                }
                if (results.Count == 0)
                {
                    results.AddRange(GetRes(requests, demo, null, SearchAgregator.HighlightOccurences(demo.Title, requests)));
                }
            }
            results.AddRange(GetRes(requests, group, null, SearchAgregator.HighlightOccurences(group.Title, requests)));
            return(results);
        }
Пример #5
0
 static BootstrapSearchUtils()
 {
     Search = new SearchAgregator(BootstrapDemosModel.Instance.Search);
 }
Пример #6
0
 static SearchUtils()
 {
     Search = new SearchAgregator(DemosModel.Instance.Search);
 }