Пример #1
0
        private void addTextFileBtn_Click(object sender, RoutedEventArgs e)
        {
            string textFilePath = FileDialogHandler.FindFileDialogStr("txt");

            if (textFilePath == "" || textFilePath is null)
            {
                return;
            }
            //string textContent = File.ReadAllText(textFilePath, Encoding.GetEncoding("euc-kr"));
            string textContent = File.ReadAllText(textFilePath);

            textContent = textContent.Replace(".", StringResources.TempSentSpliter); // 점을 임시 문자열로 바꿈
            textContent = textContent.Replace(StringResources.SentSpliter, ".");     // 문장 분리 문자열을 점으로 바꿈

            textContent = textContent.Replace("\r", " ");
            textContent = textContent.Replace("\n", " ");    // 개행문자는 제외함
            string[] sentSplitText = textContent.Split('.'); // 문자열 나눔
            foreach (string splitSent in sentSplitText)
            {
                if (splitSent == "")
                {
                    // 아무 내용이 없으면 건너뜀
                    continue;
                }
                string   resultSent   = splitSent.Replace(StringResources.TempSentSpliter, ".");
                string[] dotSplitText = resultSent.Split(' ');
                string   corpusName   = "sent_" + sentenceCount.ToString();
                foreach (string text in dotSplitText)
                {
                    if (text != "" && text != " ")
                    {
                        // 값이 존재하는 경우에만 받아옴
                        TextListObject textObj = new TextListObject(corpusName, text);
                        textObj.Text = text + " (O)";
                        textObj.PreviewMouseLeftButtonDown += textObjPreviewMouseLeftButtonDown;
                        taggingJobWin.corpusListSt.Children.Add(textObj);
                        textList.Add(textObj); // 리스트에도 저장함
                    }
                }
                ComboBoxItem comboItem = new ComboBoxItem();
                comboItem.Content = corpusName;
                corpusComboList.Add(comboItem);
                corpusListCombo.SelectedItem = comboItem;
                SaveToCsvFile();
                sentenceCount++;
            }
        }
 private void findSaveCsvFileBtn_Click(object sender, RoutedEventArgs e)
 {
     saveCsvFileTxtBlock.Text = FileDialogHandler.FindFileDialogStr("csv");
 }