/// <summary>
        /// Initializes the Presage word prediction engine.
        /// </summary>
        /// <returns>true on success</returns>
        private bool initPresage()
        {
            bool retVal = true;

            try
            {
                var presageDataDir = UserManager.GetFullPath("WordPredictors\\Presage");

                _presage = new PresageClient();

                var dbFileName = Path.Combine(presageDataDir, _presageSettings.DatabaseFileName);
                _presage.set_config("Presage.Predictors.DefaultSmoothedNgramPredictor.DBFILENAME", dbFileName);

                dbFileName = Path.Combine(presageDataDir, _presageSettings.LearningDatabaseFileName);
                _presage.set_config("Presage.Predictors.UserSmoothedNgramPredictor.DBFILENAME", dbFileName);

                _presage.set_config("Presage.Selector.REPEAT_SUGGESTIONS", "yes");
                _presage.set_config("Presage.ContextTracker.ONLINE_LEARNING", "no");
                _presage.save_config();
            }
            catch (Exception ex)
            {
                Log.Debug("Presage init error " + ex);
                retVal = false;
            }

            return retVal;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Sets presage config parameters to point to the
        /// database file for the specified culture
        /// </summary>
        /// <param name="ci">culture</param>
        /// <returns>true on success</returns>
        protected virtual bool initDatabase(CultureInfo ci)
        {
            bool retVal = true;

            try
            {
                // check if presage database file for the specified language exists.
                var dbFileName = getDatabaseFilePath(ci, DatabaseFileName);

                if (String.IsNullOrEmpty(dbFileName))
                {
                    return(false);
                }

                cultureInfo = ci;

                presage.set_config("Presage.Predictors.DefaultSmoothedNgramPredictor.DBFILENAME", dbFileName);

                presage.set_config("Presage.PredictorRegistry.PREDICTORS",
                                   "DefaultSmoothedNgramPredictor UserSmoothedNgramPredictor DefaultRecencyPredictor");

                var learningdbFileName = getLearningDBFilePath(ci.TwoLetterISOLanguageName, LearningDBFileName);
                presage.set_config("Presage.Predictors.UserSmoothedNgramPredictor.DBFILENAME", learningdbFileName);

                presage.set_config("Presage.Selector.REPEAT_SUGGESTIONS", "yes");
                presage.set_config("Presage.ContextTracker.ONLINE_LEARNING", "no");
            }
            catch (Exception ex)
            {
                Log.Debug("Error initializing Presage. " + ex);
                retVal = false;
            }

            return(retVal);
        }