Exemplo n.º 1
0
        public StringAnalyzer(string configurationPath = null, bool warningsAsErrors = false)
        {
            configuration = new AnalyzerConfiguration (configurationPath, warningsAsErrors);

            if (File.Exists (configuration.HunspellAffixPath) && File.Exists (configuration.HunspellDictionaryPath)) {
                try {
                    hunspell = new Hunspell (configuration.HunspellAffixPath, configuration.HunspellDictionaryPath);
                } catch (DllNotFoundException) {
                }

                if (hunspell != null && configuration.SpellcheckDictionaries != null) {
                    foreach (var path in configuration.SpellcheckDictionaries) {
                        using (var reader = new StreamReader (path)) {
                            string word;
                            while ((word = reader.ReadLine ()) != null) {
                                word = word.Trim ().ToLower ();
                                if (!String.IsNullOrWhiteSpace (word)) {
                                    hunspell.AddWordToDictionary (word);
                                }
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        public StringAnalyzer(string configurationPath = null, bool warningsAsErrors = false)
        {
            configuration = new AnalyzerConfiguration(configurationPath, warningsAsErrors);

            if (File.Exists(configuration.HunspellAffixPath) && File.Exists(configuration.HunspellDictionaryPath))
            {
                try {
                    hunspell = new Hunspell(configuration.HunspellAffixPath, configuration.HunspellDictionaryPath);
                } catch (DllNotFoundException) {
                }

                if (hunspell != null && configuration.SpellcheckDictionaries != null)
                {
                    foreach (var path in configuration.SpellcheckDictionaries)
                    {
                        using (var reader = new StreamReader(path)) {
                            string word;
                            while ((word = reader.ReadLine()) != null)
                            {
                                word = word.Trim().ToLower();
                                if (!String.IsNullOrWhiteSpace(word))
                                {
                                    hunspell.AddWordToDictionary(word);
                                }
                            }
                        }
                    }
                }
            }
        }