public void analizeFile(Object fullPath) { String path = fullPath.ToString(); WordAnalizer wa = new WordAnalizer(path); wa.proccessFile(); lock (this) { FileAnalizer.words.AddRange(wa.getWordList()); FileAnalizer.words.Sort(); FileAnalizer.words = WordAnalizer.groupWords(FileAnalizer.words); } FileAnalizer.quantity--; Console.WriteLine("Ending Process File " + Path.GetFileName(path) + " - " + FileAnalizer.quantity); }
public void proccessFile(Boolean process) { StreamReader rFile = new StreamReader(this.path, Encoding.Default); List <Word> tempWords = new List <Word>(); while (rFile.Peek() >= 0) { String line = rFile.ReadLine(); char[] separator = { ' ' }; String[] wordsLine = line.Split(separator); foreach (String word in wordsLine) { StringBuilder sbWord = new StringBuilder(word); char[] removedChars = { ',', '.', ';', ':', '-', '—', '<', '[', '_', '!', '¡', '?', '¿', '(', '>', ']', ')', '»', '«', '"', '©', '+', '|', '=' }; Regex regex = new Regex("^[0-9]+$"); foreach (char cr in removedChars) { sbWord = sbWord.Replace(cr, ' '); } String finalWord = sbWord.ToString().ToLower().Trim(); if (finalWord.Length > 0 && !regex.Match(finalWord).Success) { tempWords.Add(new Word(finalWord, 1)); } } if (process) { Console.Write("#"); } words = WordAnalizer.groupWords(tempWords); StreamWriter wfile = new StreamWriter(this.path + ".log"); foreach (Word w in words) { wfile.Write(w.word + "," + w.quantity + "\n"); } wfile.Close(); } }