Exemplo n.º 1
0
        private void BenchmarkAutocompleteProvider(IAutocompleteProvider provider)
        {
            var warAndPeacePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "war_and_peace.txt");

            if (!File.Exists(warAndPeacePath))
            {
                return;
            }

            Console.WriteLine("Benchmarking {0}", provider.GetType().GetFriendlyName());

            var passage     = File.ReadAllText(warAndPeacePath);
            var prefixInput = "th";

            var stopwatch = Stopwatch.StartNew();

            provider.Train(passage);

            stopwatch.Stop();
            Console.WriteLine("{0} ms to train war_and_peace.txt", stopwatch.ElapsedMilliseconds);

            stopwatch = Stopwatch.StartNew();
            int n = 1000;

            for (int i = 0; i < n; i++)
            {
                var candidates = provider.GetWords(prefixInput).ToList();
            }
            stopwatch.Stop();
            Console.WriteLine("{0} ms to get autocompletions {1} times for '{2}'.", stopwatch.ElapsedMilliseconds, n, prefixInput);
            long bytesCount = VeryRoughEstimateOfMemoryConsumption(provider);

            Console.WriteLine("Trained provider uses roughly {0} KB.", bytesCount / 1024);
            Console.WriteLine();
        }
Exemplo n.º 2
0
 private void Train_Click(object sender, RoutedEventArgs e)
 {
     _autocomplete.Train(txtTrain.Text);
 }
 private IEnumerable <ICandidate> GetSuggestions(IAutocompleteProvider provider, string passage)
 {
     provider.Train(passage);
     return(provider.GetWords("th"));
 }