Exemplo n.º 1
0
 public Dictionary <string, int> MakeStatistics(IEnumerable <string> words)
 {
     return(lemmatizer.LemmatizeWords(words)
            .Where(l => filters.All(filter => filter.Filter(l)))
            .GroupBy(l => l.Lemma)
            .ToDictionary(group => group.Key, group => group.Count()));
 }
Exemplo n.º 2
0
        public void ReturnAsManyWords_AsPassFilter(int passFilterCount)
        {
            Mock.Arrange(() => lemmatizer.LemmatizeWords(words)).Returns(new[]
            {
                new Lexem("a", Arg.IsAny <PartOfSpeech>()),
                new Lexem("б", Arg.IsAny <PartOfSpeech>()),
                new Lexem("в", Arg.IsAny <PartOfSpeech>())
            });

            var filterResults = new bool[3];

            for (var i = 0; i < passFilterCount; i++)
            {
                filterResults[i] = true;
            }

            Mock.Arrange(() => filter1.Filter(Arg.IsAny <Lexem>())).ReturnsMany(filterResults);

            statisticsMaker.MakeStatistics(words)
            .Should().HaveCount(passFilterCount);
        }
Exemplo n.º 3
0
        public void SetUp()
        {
            words  = Enumerable.Repeat("слов", 3);
            lexems = Enumerable.Repeat(new Lexem("cлово", PartOfSpeech.Noun), 3);

            lemmatizer = Mock.Create <IWordLemmatizer>();
            Mock.Arrange(() => lemmatizer.LemmatizeWords(words)).Returns(lexems);

            filter1 = Mock.Create <IWordFilter>();
            filter2 = Mock.Create <IWordFilter>();
            Mock.Arrange(() => filter1.Filter(Arg.IsAny <Lexem>())).Returns(true);
            Mock.Arrange(() => filter2.Filter(Arg.IsAny <Lexem>())).Returns(false);

            statisticsMaker = new StatisticsMaker(lemmatizer, new[] { filter1 });
        }