Esempio n. 1
0
        static void Main(string[] args)
        {
            // We'll write results out to a text file
            sw = new StreamWriter(
                Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "results.txt"));

            while (true)
            {
                // Get the user to provide two strings to compare
                Console.Write("Enter source string : ");
                string source = Console.ReadLine();

                Console.Write("Enter target string : ");
                string target = Console.ReadLine();

                // Eye candy
                string divider = string.Empty.PadRight(50, '-');
                WriteLine(divider);
                WriteLine();

                // Do the work and display the result
                Levenshtein calculator = new Levenshtein(source, target);

                string result = string.Format("Levenstein distance = {0}", calculator.CalculateDistance());
                WriteLine(result);

                PrettyPrintMatrix(calculator.GetMatrix(), source, target);
            }
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            // We'll write results out to a text file
            sw = new StreamWriter(
                Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "results.txt"));

            while (true)
            {
                // Get the user to provide two strings to compare
                Console.Write("Enter source string : ");
                string source = Console.ReadLine();

                Console.Write("Enter target string : ");
                string target = Console.ReadLine();

                // Eye candy
                string divider = string.Empty.PadRight(50, '-');
                WriteLine(divider);
                WriteLine();

                // Do the work and display the result
                Levenshtein calculator = new Levenshtein(source, target);

                string result = string.Format("Levenstein distance = {0}", calculator.CalculateDistance());
                WriteLine(result);

                PrettyPrintMatrix(calculator.GetMatrix(), source, target);
            }
        }