void SetTextHint(TextSlice slice) { _predictionSlice = slice; if (slice.Text.Length == 0) { _ambiguousKeys.Clear(); } var hints = _ambiguousKeys.Count > 0 ? _ambiguousKeys : null; _queuedPrediction = _predictor.CreatePrediction(slice.Text, slice.Start, slice.Length, _isAutoSpaceNeeded, hints); if (AppSettings.Instance.Prediction.PredictCharacters) { var characterSuggestions = _queuedPrediction.GetSuggestions(SuggestionType.Character); _environment.GazeProvider?.SetCharacterSuggestions(characterSuggestions); } foreach (var item in SuggestionItems) { item.IsEnabled = false; } foreach (var item in PhraseItems) { item.IsEnabled = false; } if (!_suggesterRunning) { _suggesterRunning = true; ThreadPool.QueueUserWorkItem(SuggesterThread); } }
public IPrediction CreatePrediction(string text, int selectionStart, int selectionLength, bool isAutoSpace, object hints) { var innerPrediction = innerPredictor.CreatePrediction(text, selectionStart, selectionLength, isAutoSpace, hints); var prediction = new NoveltyWordPrediction(this, innerPrediction); return(prediction); }
void CheckPrediction(IPredictor predictor, string root, params string[] expectations) { var prediction = predictor.CreatePrediction(root, root.Length, 0, false, null); Assert.IsNotNull(prediction, "Should get a prediction"); var collection = prediction.GetSuggestions(SuggestionType.Word); Assert.IsNotNull(collection, "Should get a collection"); using (var enumerator = collection.GetEnumerator()) { for (var i = 0; i < expectations.Length; i++) { Assert.IsTrue(enumerator.MoveNext(), "Should be another suggestion"); Assert.AreEqual(expectations[i], enumerator.Current.Text, "Suggestions should match"); } // Run enumerator to exhaustion to get code coverage. while (enumerator.MoveNext()) { // Spin. } if (expectations.Length != 0) { var primeSuggestion = collection.First(); primeSuggestion.Accepted(0); } } }