Exemplo n.º 1
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="dicPath"></param>
 /// <param name="affPath"></param>
 public Speller(string dicPath, string affPath)
 {
     Dictionary       = WordList.CreateFromFiles(dicPath, affPath);
     CustomDictionary = WordList.CreateFromWords(new List <string> {
         "RFI"
     });
 }
Exemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="dicPath"></param>
        /// <param name="affPath"></param>
        /// <param name="additions"></param>
        public Speller(string dicPath, string affPath, IReadOnlyCollection <string> additions = null)
        {
            Dictionary = WordList.CreateFromFiles(dicPath, affPath);

            if (additions != null && additions.Any())
            {
                CustomDictionary = WordList.CreateFromWords(additions);
            }
        }
        /// <summary>
        /// Creates a user dictionary.
        /// </summary>
        /// <param name="wordStrings">A list of words to use within a user dictionary.</param>
        public static void LoadUserDictionary(params string[] wordStrings)
        {
            // create the user dictionary..
            UserDictionary = WordList.CreateFromWords(wordStrings);

            // save the words to the list, so the user dictionary can be
            // reconstructed..
            UserDictionaryWords = new List <string>(wordStrings);
        }
            public void can_suggest_typos_when_constructed_from_list(string given, string expected)
            {
                var words    = "The quick brown fox jumps over the lazy dog".Split(' ');
                var wordList = WordList.CreateFromWords(words);

                var suggestions = wordList.Suggest(given);

                wordList.Check(given).Should().BeFalse();
                suggestions.Should().Contain(expected);
            }
Exemplo n.º 5
0
            public void contains_words_when_constructed_from_list()
            {
                var words = "The quick brown fox jumps over the lazy dog".Split(' ');

                var wordList = WordList.CreateFromWords(words);

                foreach (var word in words)
                {
                    var entry = wordList[word];
                    entry.Should().NotBeNullOrEmpty();
                }
            }
            public void can_check_words_when_constructed_from_list()
            {
                var words = "The quick brown fox jumps over the lazy dog".Split(' ');

                var wordList = WordList.CreateFromWords(words);

                foreach (var word in words)
                {
                    wordList.Check(word).Should().BeTrue();
                }
                wordList.Check("missing").Should().BeFalse();
                wordList.Check("Wot?").Should().BeFalse();
            }
Exemplo n.º 7
0
        /// <summary>
        ///
        /// </summary>
        public Speller()
        {
            var dllPath = Assembly.GetExecutingAssembly().Location;
            var binPath = Path.GetDirectoryName(dllPath);

            if (binPath == null)
            {
                return;
            }

            var packagePath = Path.Combine(binPath, @"..\");
            var extraPath   = Path.Combine(packagePath, "extra");
            var dicPath     = Path.Combine(extraPath, "en_US.dic");
            var affPath     = Path.Combine(extraPath, "en_US.aff");

            Dictionary       = WordList.CreateFromFiles(dicPath, affPath);
            CustomDictionary = WordList.CreateFromWords(new List <string> {
                "RFI"
            });
        }