public static void FuzzyMatchDemo()
        {
            List <string> words =
                System.IO.File
                .ReadAllLines("google-10000-english/google-10000-english.txt")
                .Where(x =>
                       !(x.Equals("magic", StringComparison.InvariantCultureIgnoreCase)) &&
                       !(x.Equals("light", StringComparison.InvariantCultureIgnoreCase)))
                .ToList();

            // Listing 2.22 A fuzzy match
            Demo.Benchmark("Listing 2.22 A fuzzy match", () =>
            {
                string fuzzyMatch = ConcurrentSpeculation.FuzzyMatch(words, "magic"); //#D

                Console.WriteLine($"FuzzyMatch for 'magic' = {fuzzyMatch}");
            });

            Demo.Benchmark("Listing 2.23 Fast Fuzzy Match using precomputation", () =>
            {
                Func <string, string> fastFuzzyMatch = PartialFuzzyMatch(words); //#D

                string magicFuzzyMatch = fastFuzzyMatch("magic");
                string lightFuzzyMatch = fastFuzzyMatch("light");   //#E

                Console.WriteLine($"FastFuzzyMatch for 'magic' = {magicFuzzyMatch}");
                Console.WriteLine($"FastFuzzyMatch for 'light' = {lightFuzzyMatch}");
            });
        }
示例#2
0
        static void Main(string[] args)
        {
            Closure closure = new Closure();

            closure.Closure_Strange_Behavior();
            Demo.PrintSeparator();
            closure.Closure_Correct_Behavior();
            Demo.PrintSeparator();

            RunDemoMemoization();
            Demo.PrintSeparator();

            WebCrawlerExample.RunDemo();
            Demo.PrintSeparator();

            ConcurrentSpeculation.FuzzyMatchDemo();
            Demo.PrintSeparator();

            Person.RunDemo();
        }