private void button_DecipherShortWords_Click(object sender, EventArgs e) { button_DecipherShortWords.Enabled = false; HistoryWorker.appendLnToHistory(richTextBox_FileFormattingHistory, MSG_STARTED_SHORT_WORD_READING); try { HistoryWorker.appendLnToHistory(richTextBox_FileFormattingHistory, MSG_SUCCESS_SHORT_WORD_READING); shortWordDriver.asyncFindShortWordsInText(PreProcessData.getSentences()); if (shortWordDriver.isReadyForShortWord()) { StartShortWordForm(shortWordDriver.sentencesWithShortWords); } else { HistoryWorker.appendLnToHistory(richTextBox_FileFormattingHistory, new HistoryMessage("Короткие слова не найдены", MessageType_en.eStandart)); } } catch (Exception) { HistoryWorker.appendLnToHistory(richTextBox_FileFormattingHistory, MSG_ERROR_SHORT_WORD_READING); } button_DecipherShortWords.Enabled = true; }
private void button_ChangeSimilarWords_Click(object sender, EventArgs e) { button_ChangeSimilarWords.Enabled = false; if (pronounDriver.readyForRead()) { try { HistoryWorker.appendLnToHistory(richTextBox_FileFormattingHistory, new HistoryMessage("Начат поиск местоимений в тексте...", MessageType_en.eStandart)); pronounDriver.asyncFindPronouns(PreProcessData.getSentences()); StartShortWordForm(pronounDriver.SENTENCES); HistoryWorker.appendLnToHistory(richTextBox_FileFormattingHistory, new HistoryMessage("Новые значения местоимений успешно приняты!", MessageType_en.eSuccess)); } catch (Exception) { HistoryWorker.appendLnToHistory(richTextBox_FileFormattingHistory, MSG_ERROR_SHORT_WORD_READING); } } button_ChangeSimilarWords.Enabled = true; }
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])); } } } } } } }); }