public void GetListOfClosestWordsFuncTest() { // arrange ILevenshteinDistance levDist = new WagnerFischer(); List<string> origWords = new List<string>() { "First", "Second", "Third", "Fourth", "Fifth", "Sixth" }; MockDictionaryFileFiller filler = new MockDictionaryFileFiller(origWords); WordsDictionary dic = new WordsDictionary(levDist, filler); List<string> resWords = new List<string>() { "First", "Fifth" }; // act List<string> res = dic.GetClosestWords("Funci"); // assert Assert.IsTrue(Enumerable.SequenceEqual(resWords, res)); }
public void GetListOfClosestWordsCountTest() { // arrange MockLevenshteinDictionary levDist = new MockLevenshteinDictionary(); List<string> origWords = new List<string>() { "First", "Second", "Third", "Fourth", "Fifth", "Sixth" }; MockDictionaryFileFiller filler = new MockDictionaryFileFiller(origWords); WordsDictionary dic = new WordsDictionary(levDist, filler); // act List<string> res = dic.GetClosestWords("Seventh"); // assert Assert.AreEqual(origWords.Count, levDist.CalcLevenshteinDistanceEnters); }
public ActionResult ResultWords(string inputedWord) { List<Word> words = new List<Word>(); if (inputedWord != null) { string language = Request.Form["Language"].ToString(); string dictionaryFilename = AppDomain.CurrentDomain.BaseDirectory + "/Dictionaries/UK.txt"; WordsDictionary dictionary = new WordsDictionary( Singleton.Instance.Factory.CreateLevenshteinDistanceAlgorithm(), Singleton.Instance.Factory.CreateDictionaryFiller(db, language) //Singleton.Instance.Factory.CreateDictionaryFiller(dictionaryFilename) ); List<string> closestWords = dictionary.GetClosestWords(inputedWord); foreach (string word in closestWords) { words.Add(new Word() { Text = word }); } } return View(words); }