public SpellCheckerVerifier(bool isPrespellChecker, PersianSpellChecker engine, SessionLogger sessionLogger)
     : base(1, 1)
 {
     m_engine            = engine;
     m_sessionLogger     = sessionLogger;
     m_isPrespellChecker = isPrespellChecker;
 }
Example #2
0
        private void Initialize()
        {
            var config = new PersianSpellCheckerConfig()
            {
                DicPath         = GetFullPath("Dic.dat"),
                StemPath        = GetFullPath("Stem.dat"),
                EditDistance    = 2,
                SuggestionCount = 7,
            };

            m_spellEngine = new PersianSpellChecker(config);
            m_verifier    = new SpellCheckerInlineVerifier(false, m_spellEngine);
        }
 public SpellCheckerVerifier(bool isPrespellChecker, PersianSpellChecker engine)
     : this(isPrespellChecker, engine, new SessionLogger())
 {
 }
        /// <summary>
        /// Initializes the specified plugin options.
        /// </summary>
        /// <param name="pluginOptions">The plugin options.</param>
        public override void Initialize(IProperties pluginOptions)
        {
            // This will set the Options property
            base.Initialize(pluginOptions);

            // And we'll use a wrapper instead
            m_options = new Options(Options);

            m_resourceManger = new ResourceManager(Assembly.GetAssembly(typeof(VirastyarWLWplugin)));

            #region Create SpellChecker

            CheckDependencies();

            m_engines = new VerificationEngines<PersianSpellCheckerWithCache>(
                Path.Combine(m_basePath, "Dic.dat"),
                Path.Combine(m_basePath, "Stem.dat"),
                null, null, null);

            m_controller = new InlineVerificationController<PersianSpellCheckerWithCache>(m_engines);
            m_speller = m_engines.GetSpellCheckerEngine();

            #endregion
        }
Example #5
0
        /// <summary>
        /// Initializes this instance.
        /// </summary>
        /// <returns></returns>
        public bool InitializeCore(SpellCheckSettingsChangedEventArgs e)
        {
            bool isFirstLoad = (e == null);

            try
            {
                if (m_spellCheckerEngine == null)
                {
                    isFirstLoad          = true;
                    m_spellCheckerEngine = new PersianSpellChecker(m_spellCheckerSettings);
                }
                else if (e != null && e.ReloadSpellCheckerEngine)
                {
                    m_spellCheckerEngine.ClearDictionary();
                    m_spellCheckerEngine.Reconfigure(m_spellCheckerSettings);
                }

                #region Prespelling Rules

                if (m_prespellCorrectPrefixes)
                {
                    m_spellCheckerEngine.SetOnePassCorrectionRules(OnePassCorrectionRules.CorrectPrefix);
                }
                else
                {
                    m_spellCheckerEngine.UnsetOnePassCorrectionRules(OnePassCorrectionRules.CorrectPrefix);
                }


                if (m_prespellCorrectSuffixes)
                {
                    m_spellCheckerEngine.SetOnePassCorrectionRules(OnePassCorrectionRules.CorrectSuffix);
                }
                else
                {
                    m_spellCheckerEngine.UnsetOnePassCorrectionRules(OnePassCorrectionRules.CorrectSuffix);
                }

                if (m_prespellCorrectBe)
                {
                    m_spellCheckerEngine.SetOnePassCorrectionRules(OnePassCorrectionRules.CorrectBe);
                }
                else
                {
                    m_spellCheckerEngine.UnsetOnePassCorrectionRules(OnePassCorrectionRules.CorrectBe);
                }

                #endregion
            }
            catch (FileLoadException ex)
            {
                LogHelper.DebugException("Some DLLs could not be loaded.", ex);
                IsInitialized        = false;
                m_spellCheckerEngine = null;
                if (e != null)
                {
                    e.CancelLoadingUserDictionary = true;
                }
                return(false);
            }
            catch (Exception ex)
            {
                LogHelper.DebugException("", ex);
                IsInitialized        = false;
                m_spellCheckerEngine = null;
                if (e != null)
                {
                    e.CancelLoadingUserDictionary = true;
                }
                return(false);
            }

            if (isFirstLoad || e.ReloadSpellCheckerEngine)
            {
                foreach (string t in m_dictionaries)
                {
                    try
                    {
                        if (!m_spellCheckerEngine.AppendDictionary(t))
                        {
                            throw new Exception();
                        }
                    }
                    catch (Exception)
                    {
                        if (e != null)
                        {
                            e.ErroneousUserDictionaries.Add(t);
                        }
                    }
                }
            }

            IsInitialized = true;
            Enabled       = true;

            return(IsInitialized);
        }