/// <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>
        /// Initializes the Presage word prediction engine.
        /// </summary>
        /// <param name="ci">language for word prediction</param>
        /// <returns>true on success</returns>
        private bool initPresage(CultureInfo ci)
        {
            bool retVal = true;

            try
            {
                presage = new PresageClient();

                if (ci == null)
                {
                    ci = Thread.CurrentThread.CurrentUICulture;
                }

                cultureInfo = ci;

                Log.Debug("Calling initdatabase");
                retVal = initDatabase(ci);
                Log.Debug("Returned from initdb " + retVal);

                if (retVal)
                {
                    presage.save_config();
                }

                // this is a workaround for a bug in presage.  If you
                // switch languages, it seems to use the database from the
                // previous language
                deleteConfigFile();
            }
            catch (Exception ex)
            {
                Log.Debug("Presage init error " + ex);
                retVal = false;
            }

            Log.Debug("Returning from initpresage " + retVal);

            return(retVal);
        }