public void CountWordMetric_ShouldAssosiationWordAndWordPositionsCount(params string[] words) { var result = new CountWordMetric().GetMetric(words); foreach (var word in words) { result.Should().Contain(new KeyValuePair <string, double>(word, words.Where(w => w == word).Count())); } }
public void ReadConvertExcludeAndGetCountMetric() { var path = $".{Path.DirectorySeparatorChar}fileTest.txt"; var text = "I\nam\nBetman\nI\nSpeed\nI\nPower\n\nPower\nRanger\nRed\nPower\nRanger"; File.WriteAllText(path, text); var textReader = new TextReaderTxt(); var textProcessor = new ParagraphTextProcessor(); var wordsMetric = new CountWordMetric(); var result = wordsMetric.GetMetric(textProcessor.GetLiterals(textReader.ReadText(path))); File.Delete(path); var expected = new Dictionary <string, double>(); expected["am"] = 1; expected["betman"] = 1; expected["speed"] = 1; expected["power"] = 3; expected["ranger"] = 2; expected["red"] = 1; Assert.AreEqual(expected, result); }
public void CountWordMetrix_ShouldContainOnlyWordsFromCollection(params string[] words) { var result = new CountWordMetric().GetMetric(words); result.Keys.Should().BeEquivalentTo(words.ToHashSet()); }