Example #1
0
 public void PerformAutomaticInput(string filePath)
 {
     try
     {
         string[] fileContent = File.ReadAllLines(filePath);
         frequencyOfWords = SyllableRecognizer.RecognizeFrequencyOfWordFromArray(fileContent);
         int syllableCount;
         if (!int.TryParse(fileContent[frequencyOfWords.Count + 1], out syllableCount))
         {
             throw new ArgumentException("Неправильно задано количество слогов");
         }
         for (int syllableIndex = frequencyOfWords.Count + 2; syllableIndex < fileContent.Length; syllableIndex++)
         {
             syllables.Add(fileContent[syllableIndex]);
         }
     }
     catch (ArgumentException argException)
     {
         throw new ArgumentException("Некорректный формат входных данных", argException);
     }
     catch (Exception generalException)
     {
         throw new Exception("Некорректный формат входных данных", generalException);
     }
 }
Example #2
0
 public void LoadStatistics()
 {
     try
     {
         string[] fileContent = File.ReadAllLines(ServerConfig.FilePath);
         frequencyOfWords = SyllableRecognizer.RecognizeFrequencyOfWordFromArray(fileContent);
     }
     catch (Exception generalException)
     {
         throw new Exception("Невозможно открыть файл или файл содержит некорректные данные", generalException);
     }
 }
Example #3
0
 private void FillFrequencyOfWords()
 {
     try
     {
         int rowsCount = InputNumberOfRows();
         frequencyOfWords = new Dictionary <string, int>();
         while (rowsCount > 0)
         {
             var inputedRow = Console.ReadLine();
             KeyValuePair <string, int> processedRow = SyllableRecognizer.RecognizeFrequencyOfWord(inputedRow);
             frequencyOfWords.Add(processedRow);
             rowsCount--;
         }
     }
     // two different types of exceptions
     catch (ArgumentException argException)
     {
         throw new ArgumentException("Строка имеет неверный формат", argException);
     }
     catch (Exception generalException)
     {
         throw new Exception("Строка имеет неверный формат", generalException);
     }
 }