public static void Main(string[] args) { List <string> workSentences; string[] workWords; string wholeWorkString; if (File.Exists(@"WorkFile.txt")) { (workSentences, workWords, wholeWorkString) = TxtReader.LoadSentences(@"WorkFile.txt", numberOfWords); var startupPath = @"source\"; if (Directory.Exists(startupPath)) { // This path is a directory ProcessDirectory(startupPath, workSentences); } else { Console.WriteLine("{0} is not a valid path.", startupPath); } WriteWordsCountWithPercents(workWords); WriteBadDateSpaces(wholeWorkString); WriteAllQuotes(wholeWorkString); StringBuilder builder = new StringBuilder(); foreach (var word in workWords) { builder.Append(word + " "); } HtmlGenerator generator = new HtmlGenerator(); generator.AddText(builder.ToString()); generator.AddMaches(matchedSentences, searchGroups); var html = generator.GenerateHtml(); using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"Output.html", false)) { file.Write(html); } } else { Console.WriteLine("WorkFile.txt not found"); } Console.ReadKey(); }
public static void ProcessFile(string path, List <string> sourceSentences) { // load source (List <string> sentences, string[] wordArray, string str) = TxtReader.LoadSentences(path, numberOfWords); //print filename Console.WriteLine(path); Console.WriteLine(); //find all sentences var matches = sourceSentences.Intersect(sentences); matches = TxtReader.CombineFollowingSencences(matches.ToList(), numberOfWords); WriteFileMatches(matches.ToList()); foreach (var match in matches) { matchedSentences.Add(match); } }