Exemplo n.º 1
0
 private void LoadHunspell(string dictionary)
 {
     _currentDictionary = dictionary;
     _hunspell?.Dispose();
     _hunspell = null;
     _hunspell = Hunspell.GetHunspell(dictionary);
 }
Exemplo n.º 2
0
 private void LoadHunspell(string dictionary)
 {
     _currentDictionary = dictionary;
     if (_hunspell != null)
     {
         _hunspell.Dispose();
     }
     _hunspell = Hunspell.GetHunspell(dictionary);
 }
Exemplo n.º 3
0
    public void CreationAndDestructionTest()
    {
        Hunspell hunspell = new Hunspell("en_us.aff", "en_us.dic");

        Assert.IsFalse(hunspell.IsDisposed);

        // Multiple dispose must be allowed
        hunspell.Dispose();
        Assert.IsTrue(hunspell.IsDisposed);
        hunspell.Dispose();
        Assert.IsTrue(hunspell.IsDisposed);
    }
Exemplo n.º 4
0
 protected virtual void Dispose(bool isDisposing)
 {
     if (isDisposing)
     {
         _speller.Dispose(true);
     }
 }
Exemplo n.º 5
0
        /// <summary>
        /// Dispose(bool disposing) executes in two distinct scenarios.
        /// If disposing equals true, the method has been called directly
        /// or indirectly by a user's code. Managed and unmanaged resources
        /// can be disposed.
        /// If disposing equals false, the method has been called by the
        /// runtime from inside the finalizer and you should not reference
        /// other objects. Only unmanaged resources can be disposed.
        /// </summary>
        private void Dispose(bool disposing)
        {
            if (!_disposed)
            {
                if (disposing)
                {
                    // dispose managed state (managed objects).
                    if (_hyphen != null)
                    {
                        _hyphen.Dispose();
                    }

                    if (_hunspell != null)
                    {
                        _hunspell.Dispose();
                    }
                }

                // free unmanaged resources (unmanaged objects) and override a finalizer below.
                // set large fields to null.

                _hyphen    = null;
                _hunspell  = null;
                _thesaurus = null;
                _disposed  = true;
            }
        }
Exemplo n.º 6
0
 public void Dispose()
 {
     if (hunSpell != null)
     {
         hunSpell.Dispose();
     }
 }
Exemplo n.º 7
0
    public void MemoryLeakTest()
    {
        // Libraries etc should be loaded two times to init the static backbone of the classes (first and repeat code path)
        // On the third run all code paths are established and all allocated memory should free
        Hunspell hunspell = new Hunspell("en_us.aff", "en_us.dic");

        hunspell.Spell("Recommendation");
        hunspell.Suggest("Recommendatio");
        hunspell.Dispose();

        hunspell = new Hunspell("en_us.aff", "en_us.dic");
        hunspell.Spell("Recommendation");
        hunspell.Suggest("Recommendatio");
        hunspell.Dispose();

        GC.Collect();
        GC.WaitForPendingFinalizers();
        long memoryOnBegin = GC.GetTotalMemory(true);

        hunspell = new Hunspell("en_us.aff", "en_us.dic");
        hunspell.Spell("Recommendation");
        hunspell.Suggest("Recommendatio");
        hunspell.Dispose();

        GC.Collect();
        GC.WaitForPendingFinalizers();
        long memoryOnEnd = GC.GetTotalMemory(true);

        Assert.AreEqual(memoryOnBegin, memoryOnEnd);
    }
        private void LoadHunspell()
        {
            var dictionary = Utilities.DictionaryFolder + GetLanguageCode();

            _hunspell?.Dispose();
            _hunspell = null;
            _hunspell = Hunspell.GetHunspell(dictionary);
        }
Exemplo n.º 9
0
 protected virtual void Dispose(bool includeManagedResources)
 {
     if (null != _core)
     {
         _core.Dispose();
         _core = null;
     }
 }
Exemplo n.º 10
0
 protected override void Dispose(bool disposing)
 {
     if (_hunspell != null)
     {
         _hunspell.Dispose();
         _hunspell = null;
     }
 }
Exemplo n.º 11
0
        private void ApplyConfig(Config config)
        {
            if (config.InterfaceStyle == 0) //System
            {
                toolStrip1.RenderMode = ToolStripRenderMode.System;
            }
            else if (config.InterfaceStyle == 1) //Office 2003
            {
                toolStrip1.RenderMode = ToolStripRenderMode.ManagerRenderMode;
            }

            //rtbIMText.BackColor = instance.Config.CurrentConfig.BgColour;

            if (instance.Config.CurrentConfig.EnableSpelling)
            {
                dicfile = instance.Config.CurrentConfig.SpellLanguage;   // "en_GB.dic";

                this.instance.AffFile        = afffile = dicfile + ".aff";
                this.instance.DictionaryFile = dicfile + ".dic";

                dic = dir + dicfile;

                dicfile += ".dic";

                if (!System.IO.File.Exists(dic + ".csv"))
                {
                    //System.IO.File.Create(dic + ".csv");

                    using (StreamWriter sw = File.CreateText(dic + ".csv"))
                    {
                        sw.Dispose();
                    }
                }

                hunspell.Dispose();
                hunspell = new Hunspell();

                hunspell.Load(dir + afffile, dir + dicfile);
                ReadWords();
            }
            else
            {
                hunspell.Dispose();
            }
        }
Exemplo n.º 12
0
    public void UnicodeFilenameTest()
    {
        Hunspell hunspell = new Hunspell("de_de_ö_frami.aff", "de_de_ö_frami.dic");

        var correct = hunspell.Spell("Änderung");
        var suggest = hunspell.Suggest("Änderun");

        hunspell.Dispose();
    }
Exemplo n.º 13
0
    public void GermanUmlautTest()
    {
        Hunspell hunspell = new Hunspell("de_de_frami.aff", "de_de_frami.dic");

        var correct = hunspell.Spell("Änderung");
        var suggest = hunspell.Suggest("Änderun");

        hunspell.Dispose();
    }
Exemplo n.º 14
0
        protected override void Dispose(bool disposing)
        {
            Debug.WriteLineIf(!disposing, "****** Missing Dispose() call for " + GetType().Name + ". ****** ");
            if (disposing)
            {
                _hunspellHandle?.Dispose();
            }

            base.Dispose(disposing);
        }
Exemplo n.º 15
0
        public void DisableSpellCheck()
        {
            spellingErrorRanges.Clear();

            myAdornerLayer.Remove(myAdorner);
            myAdorner.Dispose();

            if (spellChecker != null)
            {
                spellChecker.Dispose();
            }
        }
Exemplo n.º 16
0
 internal SpellEngineWindows(string affixPath, string dictPath, string exceptionPath)
     : base(exceptionPath)
 {
     try
     {
         _hunspellHandle = new Hunspell(affixPath, dictPath);
     }
     catch (Exception e)
     {
         Debug.WriteLine("Initializing Hunspell: {0} exception: {1} ", e.GetType(), e.Message);
         _hunspellHandle?.Dispose();
         throw;
     }
 }
Exemplo n.º 17
0
 protected virtual void Dispose(bool disposing)
 {
     if (!Disposed)
     {
         if (disposing)
         {
             //unmanaged
             if (Hunspell != null)
             {
                 Hunspell.Dispose();
             }
         }
         //managed
     }
     Disposed = true;
 }
Exemplo n.º 18
0
        public SpellChecker(Document document)
        {
            if (hunspell != null)
            {
                hunspell.Dispose();
            }

            this.document = document;

            ignoreList = new List <string>();
            UpdateIgnoreList();

            string dll = System.IO.Path.GetDirectoryName(
                System.Reflection.Assembly.GetExecutingAssembly().Location);

            try
            {
                if (Hunspell.NativeDllPath != dll)
                {
                    Hunspell.NativeDllPath = dll;
                }
            }
            catch (System.Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
            }

#if DEBUG
            //// SCaddinsApp.WindowManager.ShowMessageBox(System.IO.Path.Combine(dll, "Assets"));
            hunspell = new Hunspell(
                System.IO.Path.Combine(dll, @"Assets/en_AU.aff"),
                System.IO.Path.Combine(dll, @"Assets/en_AU.dic"));
#else
            hunspell = new Hunspell(
                System.IO.Path.Combine(Constants.InstallDirectory, "etc", "en_AU.aff"),
                System.IO.Path.Combine(Constants.InstallDirectory, "etc", "en_AU.dic"));
#endif

            // add some arch specific words
            hunspell.Add("approver");
            hunspell.Add(@"&");
            hunspell.Add(@"-");
            hunspell.Add(@"Autodesk");

            allTextParameters = GetAllTextParameters(document);
            currentIndex      = -1;
        }
Exemplo n.º 19
0
        // Protected implementation of Dispose pattern.
        protected virtual void Dispose(bool disposing)
        {
            if (disposed)
            {
                return;
            }

            if (disposing)
            {
                handle.Dispose();
                // Free any other managed objects here.
                //
                _spc?.Dispose();
            }

            disposed = true;
        }
Exemplo n.º 20
0
        public string SpellCheck(string Text)
        {
            Hunspell hunspell = new Hunspell(System.Web.HttpContext.Current.Server.MapPath("~/Assets/SpellCheck/en_US.aff"), System.Web.HttpContext.Current.Server.MapPath("~/Assets/SpellCheck/en_US.dic"));            
        
        try
            {
                                         
                    
                        //// Do spell check and look for suggested word. only if text does NOT contain number
                        if (Text.text.Length >= 3) 
                        {
                            var containsNumber = Text.text.Any(char.IsDigit);
                            if (!containsNumber)
                            {
                                var Correct = hunspell.Spell(Text.text);
                                if (!Correct)
                                {
                                    List<string> suggestions = hunspell.Suggest(Text.text);
                                    foreach (string suggestion in suggestions.Take(1))
                                    {
                                       //// Do something with the Suggested word
										////// suggestion is the object that is corrected word
									   }
                                }
                            }

                            // check for Commas, Dashes, Periods right after Text
                            var lastLetter = Text.text.Substring(Text.text.Length - 1);
                            if ( (lastLetter == ",") || (lastLetter == ".") || (lastLetter == "-") )
                            {
                                var suggestion = Text.text.Remove(Text.text.Length - 1);
                             ////// Do something with word
							 }
                        }
                   
                }

                hunspell.Dispose();

                }
Exemplo n.º 21
0
 public void Dispose()
 {
     hunspell.Dispose();
 }
Exemplo n.º 22
0
 public void Dispose()
 {
     _hunSpell?.Dispose();
 }
Exemplo n.º 23
0
 void scintilla_Disposed(object sender, EventArgs e, Hunspell hunspell)
 {
     hunspell.Dispose();
 }
Exemplo n.º 24
0
 public void Dispose()
 {
     Hunspell?.Dispose();
     Hunspell = null;
 }