private void MatchKeywords(WebEntity query, WebEntity page)
        {
            //List that will store the Product of Query Keyword Weight and Page Keyword Weight
            List <int> productOfKeywordWeights = new List <int>();

            //Loop through each keyword of the given Query
            for (var i = 0; i < query.GetKeywordCount(); i++)
            {
                //Th current Keyword of the Query is stored in a local variable
                var currentKeyword = query.GetKeyword(i);

                //Now we loop through each Keyword of given Page
                for (var k = 0; k < page.GetKeywordCount(); k++)
                {
                    //We check if the current Query Keyword is equal to the Current Page Keyword. If so, then calculate the product of Keyword Weights and store that in the local list
                    if (currentKeyword.ToLower() == page.GetKeyword(k).ToLower())
                    {
                        var product = query.GetKeywordWeight(i) * page.GetKeywordWeight(k);
                        productOfKeywordWeights.Add(product);
                    }
                }
            }

            //Now ALL Keywords of the Query have been evaluated against ALL Keywords of the given Page
            //If the Keyword Weight List count is more than 0, then the given Page is sent to the Query (Web Entity) class for further processing (The Query object decides how to proceed further)
            if (productOfKeywordWeights.Count > 0)
            {
                query.PreProcessPageStrength(page, productOfKeywordWeights);
            }
        }
Exemple #2
0
 public void PreProcessPageStrength(WebEntity page, List <int> keywordWeights)
 {
     if (page != null && keywordWeights != null)
     {
         ProcessPageStrength(page, keywordWeights);
     }
     else
     {
         Console.WriteLine("There was a problem.. Please check the Supplied Data..");
     }
 }
Exemple #3
0
        //Method mainly used by the QUERY type to Process Strength of a Page
        private void ProcessPageStrength(WebEntity page, List <int> keywordWeights)
        {
            //The Sum of All Keyword Weights is calculated and stored
            var sum = keywordWeights.Sum();

            //Page Strength Object is created with the incoming PAGE and the Sum of Keyword Weights. This object is then stored in the private list member
            pageStrengths.Add(new PageStrength(page.GetEntityName(), sum));

            //The Pagestrength List is then Sorted, in descending order, according to the Strength Value
            pageStrengths.Sort((x, y) => y.GetPageStrength().CompareTo(x.GetPageStrength()));
        }