Exemple #1
0
        public double GetDistance(string text)
        {
            string[] sentences = text.Split('\n').Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
            double   maxCost = 0, curCost = 0;

            if (sentences.Length > 1)
            {
                for (int i = 0; i < sentences.Length - 1; i++)
                {
                    curCost = JaroWinklerDistance.Distance(sentences[i], sentences[i + 1]);
                    if (maxCost < curCost)
                    {
                        maxCost = curCost;
                    }
                }
            }
            else if (sentences.Length == 1)
            {
                maxCost = JaroWinklerDistance.Distance(sentences[0], "");
            }
            return(maxCost);
        }