public void combineWordTracker(WordTracker WT1)
        {
            foreach (WordTrack word in WT1.getWordTr())
            {
                addWordTrack(word);
            }

            wordCount = wordCount + WT1.getWordCount();
        }
Пример #2
0
        /*
         * This program reads through a .txt file and tracks the number of appearances of each word, and the length of each word.
         * Before the program ends it outputs the longest, shortest, and most common words, allowing for ties, by outputting all of the tying words.
         *
         *
         * Next Step, streamline code, and make derivitave program which utilizes multithreading to speed the process up.
         */



        static void Main(string[] args)
        {
            WordTracker WT = new WordTracker();

            string[] lines = System.IO.File.ReadAllLines(@"..\..\Sample.txt");

            WT.processArray(lines);


            WT.calculateWords();
            WT.printWordTracker();

            Console.Read();
        }
        public void processThread(string[] lines)
        {
            WordTracker temp = new WordTracker();

            for (int i = 0; i < lines.Length; i++)
            {
                int      j     = 0;
                string[] words = lines[i].Split(separators, StringSplitOptions.RemoveEmptyEntries);
                while (j < words.Length)
                {
                    temp.addWordTrack(words[j].ToLower());
                    j++;
                }
            }
            mut.WaitOne();
            combineWordTracker(temp);
            mut.ReleaseMutex();
        }