Esempio n. 1
0
        public void Activate()
        {
            List <LetterOccurrenceModel> letterOccurrenceList = new List <LetterOccurrenceModel>();

            String text = Regex.Replace(TextFileFetcher.GetTextFileString(), @"(\W|\d|_)+", "");

            foreach (char letter in text)
            {
                LetterOccurrenceModel letterOccurrenceModel = letterOccurrenceList.Find(item => item.letter == letter);
                if (letterOccurrenceModel == null)
                {
                    letterOccurrenceList.Add(new LetterOccurrenceModel(letter, 1));
                }
                else
                {
                    letterOccurrenceModel.Increase();
                }
            }
            Writer.WriteMessege("Report of letter occurrence in text:\n");

            foreach (LetterOccurrenceModel letterOccurrenceModel in letterOccurrenceList.OrderBy(o => o.letter).ToList())
            {
                Writer.WriteMessege("Letter {0} : occurs {1} time(s)\n", letterOccurrenceModel.letter, letterOccurrenceModel.count);
            }

            Writer.WriteMessege("");
        }
        public void Activate()
        {
            String text = TextFileFetcher.GetTextFileString();

            /**
             * Sign Count
             * Writer.WriteMessege("Text sign count: {0}", text.Length.ToString());
             */
            Writer.WriteMessege("Text letter count [a-Z]: {0}\n", Regex.Matches(text, @"[a-zA-Z]").Count.ToString());
        }
Esempio n. 3
0
        public void Activate()
        {
            var text = TextFileFetcher.GetTextFileString();

            var total = Regex.Matches(text, @"[a-zA-Z]").Count;

            var vowels = Regex.Matches(text, @"[AEIOUaeiou]").Count;

            Writer.WriteMessege($"Text vowels count : {vowels} \nText consonants count: {total - vowels}");
        }
        public void Activate()
        {
            Writer.WriteMessege("Would you like to download file from internet? (Y/N)");
            string option = Console.ReadLine();

            if (option.ToString().ToLower() == "y")
            {
                Writer.WriteMessege("Type URL of text file (type 'default' for default file):");
                string url = Console.ReadLine();

                if (url.ToLower() == "default")
                {
                    url = TextFileFetcher.Link;
                }

                Console.Clear();

                Writer.WriteMessege("Choose file name:");
                string name = Console.ReadLine();

                Writer.WriteMessege("Downloading file...");
                if (TextFileFetcher.DownloadFileFromURL(url, name))
                {
                    Writer.WriteMessege($"File {TextFileFetcher.FileName} downloaded correctly");
                }
                else
                {
                    Writer.WriteMessege("Cannot download a file");
                }
            }
            else
            {
                Console.Clear();

                Writer.WriteMessege("Getting file from local disk");
                Writer.WriteMessege("Type text file name:");
                string url = Console.ReadLine();
                Writer.WriteMessege("You typed: " + url);

                TextFileFetcher.FileName = url;
                if (!TextFileFetcher.CheckIfFileExists())
                {
                    Writer.WriteMessege("\nThe file does not exist!");
                }
            }

            Writer.WriteMessege(TextFileFetcher.GetTextFileString());
        }
 public void Activate()
 {
     Writer.WriteMessege(TextFileFetcher.GetTextFileString());
 }