Пример #1
0
        static List <TermMatch> FindStartAndContain(List <TermMatch> options, string name)
        {
            var watch = System.Diagnostics.Stopwatch.StartNew();

            var    arr    = NamingTransformations.SplitSearchGroupName(name);
            var    first  = name;
            string second = null;

            if (arr.Length > 1)
            {
                first  = arr[0];
                second = arr.LastOrDefault();
            }

            List <TermMatch> rez;

            if (string.IsNullOrEmpty(second))
            {
                rez = options
                      .Where(x =>
                             x.term.ToLower().Contains(first)).ToList();
            }
            else
            {
                rez = options
                      .Where(x =>
                             x.term.ToLower().Contains(first) ||
                             x.term.ToLower().Contains(second)).ToList();
            }

            watch.Stop();
            var elapsedMs2 = watch.ElapsedMilliseconds;

            return(rez);
        }
Пример #2
0
        static void FilterByAllComponArrange(string name, List <TermMatch> foundRange,
                                             List <TermMatch> rez, List <TermMatch> theOne, fuzzinesSettings f = null, bool ignoreEmpty = true)
        {
            var watch = System.Diagnostics.Stopwatch.StartNew();

            var arr = NamingTransformations.SplitSearchGroupName(name);

            double substr_coef = f == null ? 1.5 : f.substring_coef;

            if (foundRange != null && foundRange.Count > 0)
            {
                foreach (var itm in foundRange)
                {
                    int okcou  = 0;
                    var itmArr = NamingTransformations.SplitSearchGroupName(itm.term);


                    okcou = NamingTransformations.Alike(arr, itm.term);
                    double mathchPerc;

                    if ((mathchPerc = isMatched(okcou, arr.Length, itmArr.Length, f)) > 0 &&
                        (!ignoreEmpty || itm.NotValid == 0))
                    {
                        if (f != null)
                        {
                            itm.MatchingPoints = (int)(mathchPerc + (itm.term.ToLower().Contains(name) ? mathchPerc * substr_coef : 0));
                        }

                        rez.Add(itm);
                        if (ArraysAreEqual(itmArr, arr))
                        {
                            theOne.Add(itm);
                        }
                    }
                }
            }

            watch.Stop();
            var elapsedMs2 = watch.ElapsedMilliseconds;
        }