Beispiel #1
0
        private void NameSearch(string searchStringElement, BaseProduct productToConvert)
        {
            SearchProduct productToAdd = new SearchProduct(productToConvert);

            List <string> searchSplit = searchStringElement.Split(' ').ToList();

            WordPairer(ref searchSplit);
            List <string> nameSplit = productToConvert.GetName().ToLower().Split(' ').ToList();

            WordPairer(ref nameSplit);
            foreach (string searchWord in searchSplit)
            {
                foreach (string nameWord in nameSplit)
                {
                    if (searchWord == nameWord)
                    {
                        productToAdd.NameMatch += 5;
                    }
                    else if (WithinLevenstheinLimit(searchWord, nameWord))
                    {
                        productToAdd.NameMatch += 1;
                    }
                }
            }
            weigthedSearchList.Add(productToAdd);
        }