示例#1
0
        public void GetSuggestedWords_Returns_Candidate_With_EditDistance_2()
        {
            // Arrange
            var spellChecker = new MSpell.SpellChecker();
            var dictionary   = new List <string> {
                "moon", "soon", "mono", "windows"
            };

            spellChecker.Train(dictionary);

            // Act
            var suggestion = spellChecker.GetSuggestedWords("windwo", 2);

            // Assert
            Assert.AreEqual(1, suggestion.Count);
            Assert.AreEqual("windows", suggestion[0].Word);
        }
示例#2
0
        public void GetSuggestedWords_Returns_Candidate_With_Sorted_By_EditDistance_Then_by_Word()
        {
            // Arrange
            var spellChecker = new MSpell.SpellChecker();
            var dictionary   = new List <string> {
                "moon", "son", "mono", "money"
            };

            spellChecker.Train(dictionary);

            // Act
            var suggestion = spellChecker.GetSuggestedWords("mon", 2);

            // Assert
            Assert.AreEqual(4, suggestion.Count);
            Assert.AreEqual(1, suggestion[0].EditDistance);
            Assert.AreEqual("mono", suggestion[0].Word);
            Assert.AreEqual(1, suggestion[1].EditDistance);
            Assert.AreEqual("moon", suggestion[1].Word);
            Assert.AreEqual(1, suggestion[2].EditDistance);
            Assert.AreEqual("son", suggestion[2].Word);
            Assert.AreEqual(2, suggestion[3].EditDistance);
            Assert.AreEqual("money", suggestion[3].Word);
        }