From 26e495379638dd2b1ca1d71897c5822a2b39882f Mon Sep 17 00:00:00 2001 From: munaxshe <29699568@students.lincoln.ac.uk> Date: Thu, 31 Jul 2025 13:03:33 +0100 Subject: [PATCH] Improved variable names, added file checks and comments --- TestProcessing-1/Program.cs | 60 +++++++++++++++++++++++-------------- 1 file changed, 37 insertions(+), 23 deletions(-) diff --git a/TestProcessing-1/Program.cs b/TestProcessing-1/Program.cs index 696b14e..f5a4282 100644 --- a/TestProcessing-1/Program.cs +++ b/TestProcessing-1/Program.cs @@ -1,43 +1,57 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Text.RegularExpressions; +using System.Text.RegularExpressions; using System.Threading.Tasks; namespace TestProcessing_1 { internal class Program { + // Main entry point: asks for a filename, reads the file, counts word occurrences, and prints results. static void Main(string[] args) { - Console.WriteLine("gimmefile"); - var z = Console.ReadLine(); - var q = File.ReadAllLines(z); - Dictionary a = new Dictionary(); - for (int i=0; i wordCounts = new Dictionary(); + for (int i = 0; i < lines.Length; i++) { - var s = Regex.Replace(q[i],@"[^\w\s]", "").ToLower(); - var t = s.Split(' '); - for (int j=0;j