private IEnumerable<String> predict(String prevWords, String currentWord, ref bool success)
{
// update the internal buffer with prevWords + currentWord
_inputText = prevWords + " " + currentWord;
Log.Debug("[" + _inputText + "]");
var retVal = new List<string>();
success = true;
try
{
string[] prediction = _presage.predict(prevWords, currentWord);
// The code below was removing diacritics from the suggested words
// Commented out to enable localization
//for (int ii = 0; ii < prediction.Length; ii++)
//{
// // remove non-ascii characters
// prediction[ii] = Regex.Replace(prediction[ii], "[^ -~]", "");
//}
var predictionList = prediction.ToList();
for (int count = 0, ii = 0; count < PredictionWordCount && ii < predictionList.Count(); ii++)
{
if (matchPrefix(currentWord, predictionList[ii]))
{
//LogDebug(String.Format("Prediction["+ ii + "] = " + predictions[ii].Term));
retVal.Add(predictionList[ii]);
count++;
}
}
}
catch (Exception ex)
{
success = false;
Log.Debug("Presage Predict Exception " + ex);
retVal = new List<string>();
}
return retVal;
}