示例#1
0
        public void AddEntry_called_with_existing_entry_does_not_update_usage_count()
        {
            ConfigureProvider();

            // try to make this the "t"-word with the highest usage
            autoComplete.AddEntry("these", new DictionaryEntry("these", 101));

            var suggestions = autoComplete.GetSuggestions("t");

            Assert.AreNotEqual("these", suggestions.First());
        }
示例#2
0
        public SpellingCorrectionTestResult TestWord(MisspellingTest misspellingTest)
        {
            var stopwatch = new Stopwatch();

            stopwatch.Start();
            var charactersTyped = -1;

            for (var n = 1; n <= misspellingTest.Misspelling.Length; ++n)
            {
                var typedSoFar  = misspellingTest.Misspelling.Substring(0, n);
                var suggestions = managedSuggestion.GetSuggestions(typedSoFar).Take(NumberOfSuggestionsToCheck);

                if (!suggestions.Any(
                        suggestion =>
                        suggestion.Equals(misspellingTest.TargetWord, StringComparison.CurrentCultureIgnoreCase)))
                {
                    continue;
                }

                charactersTyped = n;
                break;
            }
            stopwatch.Stop();

            var timeTaken = stopwatch.Elapsed;

            return(new SpellingCorrectionTestResult(charactersTyped, timeTaken, misspellingTest));
        }
示例#3
0
        public IEnumerable <string> GetSuggestions(string root, bool nextWord)
        {
            try
            {
                return(managedSuggestions.GetSuggestions(root, nextWord));
            }
            catch (Exception e)
            {
                PublishError(this, e);
            }

            return(new List <string>());
        }
示例#4
0
 public IEnumerable <string> GetSuggestions(string root, bool nextWord)
 {
     return(managedSuggestions.GetSuggestions(root, nextWord));
 }