Exemplo n.º 1
0
 static void ReadPhrases(string path, IMatcher matcher)
 {
     var timer = Stopwatch.StartNew();
     int count = 0;
     using (var stream = new StreamReader(path))
     {
         var splitter = new Regex("(?:^|,)(?:(?:\"((?:[^\"]|\"\")*)\")|([^,\"]*))", RegexOptions.Compiled);
         Func<string, string[]> split = (input) => (from Match match in splitter.Matches(input) select match.Groups[1].Success ? match.Groups[1].Value : match.Groups[2].Value).ToArray();
         var columns = split(stream.ReadLine());
         while (!stream.EndOfStream)
         {
             var line = stream.ReadLine();
             var values = split(line);
             matcher.AddEntities("DVD", values[0]);
             ++count;
         }
     }
     matcher.Compute();
     matcher.Interpretations("dkjkjh", 1, 0.0).ToList();
     Console.WriteLine($"Reading {count} phrases from {path} took {timer.Elapsed.TotalSeconds}s");
 }
Exemplo n.º 2
0
        static void ReadPhrases(string path, IMatcher matcher)
        {
            var timer = Stopwatch.StartNew();
            int count = 0;

            using (var stream = new StreamReader(path))
            {
                var splitter = new Regex("(?:^|,)(?:(?:\"((?:[^\"]|\"\")*)\")|([^,\"]*))", RegexOptions.Compiled);
                Func <string, string[]> split = (input) => (from Match match in splitter.Matches(input) select match.Groups[1].Success ? match.Groups[1].Value : match.Groups[2].Value).ToArray();
                var columns = split(stream.ReadLine());
                while (!stream.EndOfStream)
                {
                    var line   = stream.ReadLine();
                    var values = split(line);
                    matcher.AddEntities("DVD", values[0]);
                    ++count;
                }
            }
            matcher.Compute();
            matcher.Interpretations("dkjkjh", 1, 0.0).ToList();
            Console.WriteLine($"Reading {count} phrases from {path} took {timer.Elapsed.TotalSeconds}s");
        }