예제 #1
0
 public SuggestionParameter(string word, Hunspell hunspell)
 {
     InputWord = word;
     Suggestions = new List<string>();
     Hunspell = hunspell;
     Success = false;
 }
예제 #2
0
 private void LoadHunspell(string dictionary)
 {
     _currentDictionary = dictionary;
     if (_hunspell != null)
         _hunspell.Dispose();
     _hunspell = Hunspell.GetHunspell(dictionary);
 }
예제 #3
0
 private void LoadHunspell(string dictionary)
 {
     _currentDictionary = dictionary;
     _hunspell = Hunspell.GetHunspell(dictionary);
 }
예제 #4
0
 /// <summary>
 /// Clean up any resources being used.
 /// </summary>
 /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
 protected override void Dispose(bool disposing)
 {
     if (disposing && (components != null))
     {
         if (_hunspell != null)
         {
             _hunspell.Dispose();
             _hunspell = null;
         }
         components.Dispose();
     }
     base.Dispose(disposing);
 }
예제 #5
0
 public void Dispose()
 {
     if (_hunspell != null)
     {
         _hunspell.Dispose();
         _hunspell = null;
     }
     if (_spellCheck != null)
     {
         _spellCheck.Dispose();
         _spellCheck = null;
     }
 }
예제 #6
0
        private void LoadSpellingDictionariesViaDictionaryFileName(string threeLetterIsoLanguageName, CultureInfo culture, string dictionaryFileName, bool resetSkipList)
        {
            _fiveLetterWordListLanguageName = Path.GetFileNameWithoutExtension(dictionaryFileName);
            if (_fiveLetterWordListLanguageName.Length > 5)
                _fiveLetterWordListLanguageName = _fiveLetterWordListLanguageName.Substring(0, 5);
            string dictionary = Utilities.DictionaryFolder + _fiveLetterWordListLanguageName;
            if (resetSkipList)
            {
                _wordSkipList = new HashSet<string> { Configuration.Settings.Tools.MusicSymbol, "*", "%", "#", "+", "$" };
            }

            // Load names etc list (names/noise words)
            _namesList = new NamesList(Configuration.DictionariesFolder, _fiveLetterWordListLanguageName, Configuration.Settings.WordLists.UseOnlineNamesEtc, Configuration.Settings.WordLists.NamesEtcUrl);
            _namesEtcList = _namesList.GetNames();
            _namesEtcMultiWordList = _namesList.GetMultiNames();
            _namesEtcListUppercase = new HashSet<string>();
            foreach (string name in _namesEtcList)
                _namesEtcListUppercase.Add(name.ToUpper());

            _namesEtcListWithApostrophe = new HashSet<string>();
            if (threeLetterIsoLanguageName.Equals("eng", StringComparison.OrdinalIgnoreCase))
            {
                foreach (string namesItem in _namesEtcList)
                {
                    if (!namesItem.EndsWith('s'))
                        _namesEtcListWithApostrophe.Add(namesItem + "'s");
                    else
                        _namesEtcListWithApostrophe.Add(namesItem + "'");
                }
            }

            // Load user words
            _userWordList = new HashSet<string>();
            _userWordListXmlFileName = Utilities.LoadUserWordList(_userWordList, _fiveLetterWordListLanguageName);

            // Find abbreviations
            _abbreviationList = new HashSet<string>();
            foreach (string name in _namesEtcList)
            {
                if (name.EndsWith('.'))
                    _abbreviationList.Add(name);
            }
            if (threeLetterIsoLanguageName.Equals("eng", StringComparison.OrdinalIgnoreCase))
            {
                if (!_abbreviationList.Contains("a.m."))
                    _abbreviationList.Add("a.m.");
                if (!_abbreviationList.Contains("p.m."))
                    _abbreviationList.Add("p.m.");
                if (!_abbreviationList.Contains("o.r."))
                    _abbreviationList.Add("o.r.");
            }

            foreach (string name in _userWordList)
            {
                if (name.EndsWith('.'))
                    _abbreviationList.Add(name);
            }

            // Load Hunspell spell checker
            try
            {
                if (!File.Exists(dictionary + ".dic"))
                {
                    var fileMatches = Directory.GetFiles(Utilities.DictionaryFolder, _fiveLetterWordListLanguageName + "*.dic");
                    if (fileMatches.Length > 0)
                        dictionary = fileMatches[0].Substring(0, fileMatches[0].Length - 4);
                }
                if (_hunspell != null)
                    _hunspell.Dispose();
                _hunspell = Hunspell.GetHunspell(dictionary);
                IsDictionaryLoaded = true;
                _spellCheckDictionaryName = dictionary;
                DictionaryCulture = culture;
            }
            catch
            {
                IsDictionaryLoaded = false;
            }
        }
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">
        /// true if managed resources should be disposed; otherwise, false.
        /// </param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                if (this._hunspell != null)
                {
                    this._hunspell.Dispose();
                    this._hunspell = null;
                }

                this.components.Dispose();
            }

            base.Dispose(disposing);
        }
        /// <summary>
        /// The dispose.
        /// </summary>
        public void Dispose()
        {
            if (this._hunspell != null)
            {
                this._hunspell.Dispose();
                this._hunspell = null;
            }

            if (this._spellCheck != null)
            {
                this._spellCheck.Dispose();
                this._spellCheck = null;
            }
        }