Пример #1
0
 public static PartialMatchData Match(string first, string second)
 {
     PartialMatchData result = new PartialMatchData();
     //var words = Regex.Split(first, @"\W+").Where(s => s.Length > 0).ToArray();
     //var others = Regex.Split(second, @"\W+").Where(s => s.Length > 0).ToArray();
     var words = GetMatchWords(first);
     var others = GetMatchWords(second);
     result.FirstInSecond = (from f in words where others.Any(w => f.ToLower() == w.ToLower()) select f).Count();
     result.SecondInFirst = (from s in others where words.Any(w => s.ToLower() == w.ToLower()) select s).Count();
     result.PercentFirstInSecond = (((double)result.FirstInSecond) / ((double)words.Length)) * 100.0;
     result.PercentSecondInFirst = (((double)result.SecondInFirst) / ((double)others.Length)) * 100.0;
     result.FirstLength = words.Length;
     result.SecondLength = others.Length;
     return result;
 }
Пример #2
0
        public static PartialMatchData Match(string first, string second)
        {
            PartialMatchData result = new PartialMatchData();
            //var words = Regex.Split(first, @"\W+").Where(s => s.Length > 0).ToArray();
            //var others = Regex.Split(second, @"\W+").Where(s => s.Length > 0).ToArray();
            var words  = GetMatchWords(first);
            var others = GetMatchWords(second);

            result.FirstInSecond        = (from f in words where others.Any(w => f.ToLower() == w.ToLower()) select f).Count();
            result.SecondInFirst        = (from s in others where words.Any(w => s.ToLower() == w.ToLower()) select s).Count();
            result.PercentFirstInSecond = (((double)result.FirstInSecond) / ((double)words.Length)) * 100.0;
            result.PercentSecondInFirst = (((double)result.SecondInFirst) / ((double)others.Length)) * 100.0;
            result.FirstLength          = words.Length;
            result.SecondLength         = others.Length;
            return(result);
        }