Beispiel #1
0
        private List <Results> CalculateMetrics(string path)
        {
            var         res     = new List <Results>();
            ITextReader reader1 = new TextFileReader(path);

            TextAnalyzer textAnalyzer = new TextAnalyzer(reader1);

            textAnalyzer.AddMetrics(new MostCommonCharacter());
            textAnalyzer.AddMetrics(new Language());
            textAnalyzer.AddMetrics(new MostCommonWorld());
            textAnalyzer.AddMetrics(new MostCommonNotSimpleWord());
            textAnalyzer.AddMetrics(new CountSentence());
            textAnalyzer.Analyz();

            foreach (MetricsBase metrics in textAnalyzer.Metrics)
            {
                res.Add(new Results {
                    Name = metrics.Result().Keys.FirstOrDefault(), Value = metrics.Result().Values.FirstOrDefault()
                });
            }

            return(res);
        }