Ejemplo n.º 1
0
        public void TestTopHits100Percent()
        {
            var str1        = "card card card card card";
            var substrings1 = _counter.GenerateSubstrings(str1.Split(' '), 4);
            var topTen      = _counter.GetTopNHits(substrings1, 10).ToList();

            Assert.Equal(1, topTen[0].Value);
            Assert.Equal("card", topTen[0].Key);
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            var reader  = new FileReader();
            var counter = new WordsCounter();

            var words      = reader.ReadWords(args[0]);
            var substrings = counter.GenerateSubstrings(words, 4);
            var topTen     = counter.GetTopNHits(substrings, 10);

            Console.WriteLine("Frequencies:");
            topTen.ToList().ForEach(item => Console.WriteLine($"{item.Key} {Math.Round(item.Value * 100, 2)}%"));
        }