private void LoadHunspell(string dictionary) { _currentDictionary = dictionary; _hunspell?.Dispose(); _hunspell = null; _hunspell = Hunspell.GetHunspell(dictionary); }
private void LoadHunspell(string dictionary) { _currentDictionary = dictionary; if (_hunspell != null) { _hunspell.Dispose(); } _hunspell = Hunspell.GetHunspell(dictionary); }
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); }
protected virtual void Dispose(bool isDisposing) { if (isDisposing) { _speller.Dispose(true); } }
/// <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; } }
public void Dispose() { if (hunSpell != null) { hunSpell.Dispose(); } }
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); }
protected virtual void Dispose(bool includeManagedResources) { if (null != _core) { _core.Dispose(); _core = null; } }
protected override void Dispose(bool disposing) { if (_hunspell != null) { _hunspell.Dispose(); _hunspell = null; } }
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(); } }
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(); }
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(); }
protected override void Dispose(bool disposing) { Debug.WriteLineIf(!disposing, "****** Missing Dispose() call for " + GetType().Name + ". ****** "); if (disposing) { _hunspellHandle?.Dispose(); } base.Dispose(disposing); }
public void DisableSpellCheck() { spellingErrorRanges.Clear(); myAdornerLayer.Remove(myAdorner); myAdorner.Dispose(); if (spellChecker != null) { spellChecker.Dispose(); } }
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; } }
protected virtual void Dispose(bool disposing) { if (!Disposed) { if (disposing) { //unmanaged if (Hunspell != null) { Hunspell.Dispose(); } } //managed } Disposed = true; }
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; }
// 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; }
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(); }
public void Dispose() { hunspell.Dispose(); }
public void Dispose() { _hunSpell?.Dispose(); }
void scintilla_Disposed(object sender, EventArgs e, Hunspell hunspell) { hunspell.Dispose(); }
public void Dispose() { Hunspell?.Dispose(); Hunspell = null; }