Beispiel #1
0
        public static void Main(string[] args)
        {
            if (args.Length != 2)
            {
                WriteHelp();
                return;
            }

            string inputFilePath  = args[0];
            string outputFilePath = args[1];

            if (!File.Exists(inputFilePath))
            {
                Console.WriteLine($"Input file '{inputFilePath}' does not exists or not accessible.");
                return;
            }

            NewFrequencyCalculationService calculationService =
                new NewFrequencyCalculationService(
                    new FileDataReader(inputFilePath, MinBlockSize, MaxWordLength, delimiters),
                    new FileDataWriter(outputFilePath),
                    new FrequencyCalculatorWithUpdater(MaxWordLength));

            Console.WriteLine("Calculating frequencies...");

            calculationService.RunCalculationAsync().Wait();

            Console.WriteLine("Done.");
            Console.WriteLine($"Results written to output file: {outputFilePath}");
        }
Beispiel #2
0
        public void TestTextIsSplittedToWordsInParallelWithOneDictionary()
        {
            IDataWriter dataWriter = new TestDataWriter();

            FrequencyCalculationService.NewFrequencyCalculationService calculationService =
                new NewFrequencyCalculationService(
                    new StreamBlockReader(MinBlockSize, MinBlockSize + MaxWordLength, delimiters, inputStream),
                    dataWriter,
                    new FrequencyCalculatorWithUpdater(MaxWordLength));
            calculationService.RunCalculationAsync().Wait();

            Assert.AreEqual(80979, ((TestDataWriter)dataWriter).Data.Count);
        }