Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions TextProcessing/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,21 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace TextProcessing
{
internal class Program
{
// Main program: asks for a file, reads its contents, and counts unique word occurrences.
static void Main(string[] args)
{
Console.WriteLine("Enter the full path of the text file: ");
Console.WriteLine("Please enter the path to the text file you want to process:");
string filePath = Console.ReadLine();

if (!File.Exists(filePath))
{
Console.WriteLine("The file does not exist. Exiting...");
Console.WriteLine($"Sorry, the file \"{filePath}\" does not exist. Exiting program.");
return;
}

Expand Down Expand Up @@ -45,8 +44,10 @@ static void Main(string[] args)
}
}

Console.WriteLine("\nProcessing complete!\n");

// Output word counts
Console.WriteLine("\n Word occurrences:");
Console.WriteLine("Word occurrences:");
foreach (var pair in wordCounts.OrderBy(p=>p.Key))
{
Console.WriteLine($"{pair.Key}: {pair.Value}");
Expand All @@ -55,6 +56,5 @@ static void Main(string[] args)
Console.WriteLine($"\nTotal number of unique words: {wordCounts.Count}");
Console.ReadKey();
}

}
}