Ejemplo n.º 1
0
 private async void startDeletingAllTiere()
 {
     await Task.Run(() =>
     {
         string[] splitWords = PreProcessData.docxManager != null ?
                               PreProcessData.getSpaceSplitWords(PreProcessData.docxManager.Text) :
                               PreProcessData.getSpaceSplitWords(PreProcessData.fullFileData);
         List <string> wordsToDelete         = new List <string>();
         List <string> correctWordsWithTiere = getWordsWithTiereFromFile();
         foreach (string splitword in splitWords)
         {
             if (splitword.Contains('-') && !correctWordsWithTiere.Contains(splitword))
             {
                 wordsToDelete.Add(splitword);
             }
         }
         if (PreProcessData.fileFormat == FileFormat_en.eTXT)
         {
             foreach (string wordtodelete in wordsToDelete)
             {
                 string correctWord          = wordtodelete.Replace("-", "");
                 PreProcessData.fullFileData = PreProcessData.fullFileData.Replace(wordtodelete, correctWord);
             }
         }
         else
         {
             foreach (string wordtodelete in wordsToDelete)
             {
                 string correctWord = wordtodelete.Replace("-", "");
                 PreProcessData.docxManager.ReplaceText(wordtodelete, correctWord);
             }
         }
     });
 }
Ejemplo n.º 2
0
        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;
        }
Ejemplo n.º 3
0
        private async void startAsyncClearingStopWords()
        {
            HistoryWorker.appendLnToHistory(richTextBox_FileHistory, new HistoryMessage("Начата автоматическая обработка стоп-слов.", MessageType_en.eStandart));
            await Task.Run(() =>
            {
                StreamReader reader = new StreamReader(STR_STOP_WORDS_FILE);
                string[] stopWords;
                using (reader)
                {
                    stopWords = reader.ReadToEnd().Split(new char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries);
                }

                reader.Close();

                string[] wordsFromText = PreProcessData.getSpaceSplitWords();

                foreach (string word in wordsFromText)
                {
                    if (stopWords.Contains(word.ToLower()))
                    {
                        PreProcessData.changeTextAccordingToFormat(word, "");
                    }
                }
            });

            HistoryWorker.appendLnToHistory(richTextBox_FileHistory, new HistoryMessage("Стоп-Слова успешно удалены.", MessageType_en.eSuccess));
        }
Ejemplo n.º 4
0
 private void radioButton_TXT_CheckedChanged(object sender, EventArgs e)
 {
     setSelectedFormatRadioButtons(radioButton_TXT, radioButton_TXT.Checked);
     setButtonSaveChangesEnabled();
     PreProcessData.setSaveAs(FileFormat_en.eTXT);
     groupBox_FormatDocx.Enabled = false;
 }
Ejemplo n.º 5
0
        private void startTxtReading(string filePath)
        {
            PreProcessData.docxManager = null;

            StreamReader reader = new StreamReader(filePath);

            using (reader)
            {
                PreProcessData.setSpaceSplitText(reader.ReadToEnd());
            }
            reader.Close();
        }
Ejemplo n.º 6
0
        public static void setFileInfo(string path, Label lFileName, Label lFileSize, Label lQuantityOfSentences, Label lTimeCreation, Label lFolderName, Label lWriteTime)
        {
            FileInfo fileInfo = new FileInfo(path);

            if (fileInfo != null)
            {
                lFileName.Text            = fileInfo.Name;
                lTimeCreation.Text        = fileInfo.CreationTime.ToString();
                lFolderName.Text          = fileInfo.DirectoryName;
                lWriteTime.Text           = fileInfo.LastWriteTime.ToString();
                lFileSize.Text            = getFileStrSize(fileInfo.Length);
                lQuantityOfSentences.Text = PreProcessData.getQuantityOfSentences().ToString();
            }
        }
Ejemplo n.º 7
0
        private async void asyncStartReadingSimilarWords(string wordPart)
        {
            //await Task.Run(() =>
            {
                string[] allWordsFromText = PreProcessData.getSpaceSplitWords();


                foreach (string wordFromText in allWordsFromText)
                {
                    if (wordFromText.ToLower().Contains(wordPart.ToLower()))
                    {
                        L_FoundSameWordsFromText.Add(wordFromText);
                    }
                }
            }//);
        }
Ejemplo n.º 8
0
        private async void asyncStartFileReading()
        {
            string filePath = getUserFile();

            if (filePath != null)
            {
                PreProcessData.filePath = filePath;
                try
                {
                    PreProcessData.setFileFormat(filePath.Split('.')[1]);
                }
                catch (FileFormatException)
                {
                    HistoryWorker.appendLnToHistory(richTextBox_FileHistory, MSG_ERROR_FILE_READING_FORMAT);
                    Button_UploadFile.Enabled = true;
                    return;
                }
                HistoryWorker.appendLnToHistory(richTextBox_FileHistory, MSG_STARTED_FILE_LOADING);

                switch (PreProcessData.fileFormat)
                {
                case FileFormat_en.eTXT:
                    await Task.Run(() => startTxtReading(filePath));

                    break;

                case FileFormat_en.eDOCX:
                    await Task.Run(() => startDocxReading(filePath));

                    break;
                }

                HistoryWorker.appendLnToHistory(richTextBox_FileHistory, MSG_SUCCESS_FILE_LOADED);

                FileInfoWorker.setFileInfo(filePath, Label_FileName, Label_FileSize, label_QuantitySentences, label_creationTime, label_FolderName, label_LatestWriteTime);
            }

            Button_UploadFile.Enabled = true;
            setEnabledAllTabs(true);
        }
Ejemplo n.º 9
0
        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;
        }
Ejemplo n.º 10
0
 private void button_ChangeRomaniansToArab_Click(object sender, EventArgs e)
 {
     HistoryWorker.appendLnToHistory(richTextBox_FileFormattingHistory, MSG_STARTED_FILE_ROMAN_SEARCHING);
     button_SaveChanges.Enabled = false;
     PreProcessData.asyncRomanianNumbersToArab(button_SaveChanges, richTextBox_FileFormattingHistory, MSG_FINISHED_FILE_ROMAN_SEARCH);
 }
Ejemplo n.º 11
0
        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]));
                                    }
                                }
                            }
                        }
                    }
                }
            });
        }
Ejemplo n.º 12
0
        private void startDocxReading(string filePath)
        {
            PreProcessData.docxManager = File.Exists(filePath) ? DocX.Load(filePath) : DocX.Create(filePath);

            PreProcessData.setNewFullFileData(String.Empty);
        }