private void startTxtReading(string filePath) { PreProcessData.docxManager = null; StreamReader reader = new StreamReader(filePath); using (reader) { PreProcessData.setSpaceSplitText(reader.ReadToEnd()); } reader.Close(); }
private async void startAsyncHighChrRemoving() { await Task.Run(() => { string fileHighWords = STR_TIERE_UPPER_WORD_FILE_NAME; List <string> wordWhichNeedsHighs = new List <string>(); StreamReader reader = new StreamReader(fileHighWords); if (reader != null) { string allData; using (reader) { allData = reader.ReadToEnd(); } reader.Close(); string[] splitAllData = allData.Split(new char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries); foreach (string split in splitAllData) { if (isWordStartsWithHigh(split)) { wordWhichNeedsHighs.Add(split); } } PreProcessData.setSpaceSplitText(PreProcessData.docxManager != null ? PreProcessData.docxManager.Text : PreProcessData.fullFileData); string[] sentences = PreProcessData.getSentences(); foreach (string sentence in sentences) { PreProcessData.setSpaceSplitText(sentence); string[] words = PreProcessData.fileWordsSplit; if (words.Length > 1) { words[0] = wordWithFirstBig(words[0]); for (int i = 1; i < words.Length; i++) //first word always ok { if (!wordWhichNeedsHighs.Contains(wordWithFirstBig(words[i]))) { if (PreProcessData.fileFormat == FileFormat_en.eTXT) { PreProcessData.fullFileData = PreProcessData.fullFileData.Replace(words[i], words[i].ToLower()); } else { PreProcessData.docxManager.ReplaceText(words[i], words[i].ToLower()); } } else { if (PreProcessData.fileFormat == FileFormat_en.eTXT) { PreProcessData.fullFileData = PreProcessData.fullFileData.Replace(words[i], wordWithFirstBig(words[i])); } else { PreProcessData.docxManager.ReplaceText(words[i], wordWithFirstBig(words[i])); } } } } } } }); }