private AnalysisInformation GetAnalysisInformation(string focusKeyword) { var topwords = _wordOccurenceHelper.GetKeywords(HtmlResult).Take(10); var information = new AnalysisInformation { Alias = "keywordanalyzer_top_words" }; information.Tokens.Add(focusKeyword); foreach (var wordOccurence in topwords) { information.Tokens.Add(wordOccurence.Key); information.Tokens.Add(wordOccurence.Value.ToString()); } return(information); }
public void GetKeywords_OnExecute_ReturnsOccurencesOfWords() { var wordCounter = new WordCounter(); var text = "test1 test2 test3 test4 test5 test6 test1 test2 test3"; var result = wordCounter.GetKeywords(text); Assert.IsNotNull(result); Assert.AreEqual(6, result.Count()); Assert.AreEqual(2, result.FirstOrDefault(x => x.Key == "test1").Value); Assert.AreEqual(2, result.FirstOrDefault(x => x.Key == "test2").Value); Assert.AreEqual(2, result.FirstOrDefault(x => x.Key == "test3").Value); Assert.AreEqual(1, result.FirstOrDefault(x => x.Key == "test4").Value); Assert.AreEqual(1, result.FirstOrDefault(x => x.Key == "test5").Value); Assert.AreEqual(1, result.FirstOrDefault(x => x.Key == "test6").Value); }
public void GetKeywords_OnExecuteWithNull_ThrowsException() { _wordCounter.GetKeywords(null); }