Пример #1
0
        private void textObjPreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            TextListObject txtObj = sender as TextListObject;

            selectTextIndex = corpusListSt.Children.IndexOf(txtObj);
            ChangeSelectTextObj(selectTextIndex);
        }
Пример #2
0
 public static TextChangeWindow GetTextChangeWin(TextListObject txtObj)
 {
     if (textChangeWin is null)
     {
         textChangeWin = new TextChangeWindow();
     }
     textChangeWin.txtObj = txtObj;
     textChangeWin.changeTextTxtBox.Text = txtObj.RealText;
     return(textChangeWin);
 }
Пример #3
0
        private void InsideSubmitAct()
        {
            if (ToggleCountStatus() != 1)
            {
                MessageBox.Show("태그 상태가 하나가 아니라면 이 옵션을 실행할 수 없습니다.");
                return;
            }
            TextListObject txtObj = (corpusListSt.Children[selectTextIndex] as TextListObject);

            SubmitAct("I-" + ToggleStrStatus(), txtObj);
        }
Пример #4
0
        private void TextInputProcess(int flagPrevNext)
        {
            TextListObject inputTxtObj = new TextListObject(txtObj.SentenceName, insertTextTxtBox.Text);

            inputTxtObj.TagText = "O";
            App.TaggingJobWin.corpusListSt.Children.Insert(insertPosition + flagPrevNext, inputTxtObj);
            App.TaggingJobWin.TextList.Insert(insertPosition + flagPrevNext, inputTxtObj);
            App.TaggingJobWin.InputTextEvent(inputTxtObj);
            insertTextTxtBox.Text = "";
            this.Hide();
        }
Пример #5
0
 public static TextSplitWindow GetTextSplitWin(TextListObject txtObj)
 {
     if (textSplitWin is null)
     {
         textSplitWin = new TextSplitWindow();
     }
     textSplitWin.splitTextTxtBox.Text = txtObj.RealText;
     textSplitWin.splitTextTxtBox.Focus();
     textSplitWin.txtObj = txtObj;
     return(textSplitWin);
 }
Пример #6
0
        private void SentenceAdd(TextListObject txtObj)
        {
            txtObj.Text = StringResources.SentenceStartFlag + txtObj.Text;
            int txtObjIndex = corpusListSt.Children.IndexOf(txtObj);

            for (int indexNum = txtObjIndex; indexNum < corpusListSt.Children.Count; indexNum++)
            {
                (corpusListSt.Children[indexNum] as TextListObject).SentenceName = "sent_" + sentenceCount;
                corpusListCombo.ItemsSource = taggingJobWin.corpusComboList;
            }
            sentenceCount++;
        }
Пример #7
0
 public static TextInsertWindow GetTextInsertWin(TextListObject txtObj)
 {
     if (textInsertWin is null)
     {
         textInsertWin = new TextInsertWindow();
     }
     textInsertWin.insertTextTxtBox.Focus();
     textInsertWin.txtObj         = txtObj;
     textInsertWin.insertPosition = App.TaggingJobWin.corpusListSt.Children.IndexOf(txtObj);
     textInsertWin.dataPosition   = App.TaggingJobWin.TextList.IndexOf(txtObj);
     return(textInsertWin);
 }
Пример #8
0
        private void SubmitAct(string submitMode, TextListObject txtObj)
        {
            if (startSentenceBtn.IsChecked == true)
            {
                SentenceAdd(txtObj);
            }
            InitializeToggleButton();
            txtObj.TagText = submitMode;
            SaveToCsvFile();
            ShowingTextUpdate(txtObj);
            SelectTextIndexPlus();

            // 문장시작 초기화
            startSentenceBtn.Background = Brushes.Yellow;
            startSentenceBtn.IsChecked  = false;
        }
Пример #9
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++;
            }
        }
Пример #10
0
        private void moveSavePositionBtn_Click(object sender, RoutedEventArgs e)
        {
            int            maxCount      = textList.Count;
            TextListObject currentTxtObj = corpusListSt.Children[selectTextIndex] as TextListObject;

            for (int txtObjIndex = textList.IndexOf(currentTxtObj) + 1; txtObjIndex != textList.IndexOf(currentTxtObj); txtObjIndex++)
            {
                Console.WriteLine(txtObjIndex);
                if (textList[txtObjIndex].TagText == "SAVE")
                {
                    int innerMaxCount = corpusComboList.Count;
                    for (int comboIndex = corpusListCombo.SelectedIndex; comboIndex != corpusListCombo.SelectedIndex - 1; comboIndex++)
                    {
                        if (corpusComboList[comboIndex].Content.ToString() == textList[txtObjIndex].SentenceName)
                        {
                            int resultIndex = comboIndex;
                            ComboSelectChange(resultIndex);
                            resultIndex = corpusListSt.Children.IndexOf(textList[txtObjIndex]);
                            ChangeSelectTextObj(resultIndex);
                            (corpusListSt.Children[resultIndex] as TextListObject).BringIntoView();
                            break;
                        }
                        else if (comboIndex >= innerMaxCount - 1)
                        {
                            comboIndex = -1;
                        }
                    }
                    break;
                }
                else if (txtObjIndex >= maxCount - 1)
                {
                    txtObjIndex = -1;
                }
                else if (txtObjIndex == textList.IndexOf(currentTxtObj) - 1 && currentTxtObj.TagText != "SAVE")
                {
                    MessageBox.Show("저장해 둔 책갈피가 없습니다.");
                    break;
                }
            }
        }
Пример #11
0
        private void ShowingTextUpdate(TextListObject txtObj)
        {
            bool sentenceStartFlag = false;
            int  flagLength        = StringResources.SentenceStartFlag.Length;

            if (txtObj.Text.Length >= flagLength && txtObj.Text.Substring(0, flagLength) == StringResources.SentenceStartFlag) // 시작 문장임을 알려줌
            {
                sentenceStartFlag = true;
            }
            if (txtObj.TagText != "")
            {
                txtObj.Text = txtObj.RealText + " (" + txtObj.TagText + ")";
            }
            else
            {
                txtObj.Text = txtObj.RealText;
            }
            if (sentenceStartFlag)
            {
                txtObj.Text = StringResources.SentenceStartFlag + txtObj.Text;
            }
        }
Пример #12
0
        private void TextSplitProcess()
        {
            int    splitIndex   = splitTextTxtBox.SelectionStart;
            string prevSplitStr = splitTextTxtBox.Text.Substring(0, splitIndex);
            string nextSplitStr = splitTextTxtBox.Text.Substring(splitIndex);

            // 이전거 변경하기
            txtObj.RealText = prevSplitStr;
            App.TaggingJobWin.TextChangeEvent(txtObj);

            // 다음거 추가하기
            TextListObject inputTxtObj = new TextListObject(txtObj.SentenceName, nextSplitStr);

            inputTxtObj.TagText = "O";
            int insertPosition = App.TaggingJobWin.corpusListSt.Children.IndexOf(txtObj) + 1;

            App.TaggingJobWin.corpusListSt.Children.Insert(insertPosition, inputTxtObj);
            App.TaggingJobWin.TextList.Insert(insertPosition, inputTxtObj);
            App.TaggingJobWin.InputTextEvent(inputTxtObj);
            splitTextTxtBox.Text = "";

            this.Hide();
        }
Пример #13
0
        private void OutsideSubmitAct()
        {
            TextListObject txtObj = (corpusListSt.Children[selectTextIndex] as TextListObject);

            SubmitAct("O", txtObj);
        }
Пример #14
0
 public void InputTextEvent(TextListObject txtObj)
 {
     txtObj.PreviewMouseLeftButtonDown += textObjPreviewMouseLeftButtonDown;
     TextChangeEvent(txtObj);
     ChangeSelectTextObj(corpusListSt.Children.IndexOf(txtObj));
 }
Пример #15
0
 public void TextChangeEvent(TextListObject txtObj)
 {
     ShowingTextUpdate(txtObj);
     SaveToCsvFile();
 }
Пример #16
0
        private void jobSaveBtn_Click(object sender, RoutedEventArgs e)
        {
            TextListObject txtObj = (corpusListSt.Children[selectTextIndex] as TextListObject);

            SubmitAct("SAVE" + ToggleStrStatus(), txtObj);
        }
Пример #17
0
        private void ReadCsvFile()
        {
            int startCount = StringResources.CsvHeader.Length;

            if (startCount == saveFileText.Length)
            {
                // 빈 파일일 경우에
                return;
            }
            string csvContent = saveFileText.Substring(startCount, saveFileText.Length - startCount);

            csvContent = csvContent.Replace("\r", "");
            csvContent = csvContent.Replace("\n", ",");
            if (csvContent[0] == ',')
            {
                csvContent = csvContent.Remove(0, 1); // 첫 컴마는 없애기
            }
            csvContent = ChangeExceptionComma(csvContent);
            string[]       csvSplitText     = csvContent.Split(',');
            int            indexNum         = 0;
            string         sentenceName     = null;
            string         realText         = null;
            string         tagText          = null;
            string         comboBoxItemName = null;
            TextListObject txtObj;

            foreach (string csvText in csvSplitText)
            {
                if (indexNum == 0)
                {
                    sentenceName = csvText.Replace(StringResources.ExceptionArea, ",");
                    if (comboBoxItemName != sentenceName && sentenceName != "")
                    {
                        // 콤보 박스에 파일 이름 추가하기
                        ComboBoxItem comboBoxItem = new ComboBoxItem();
                        comboBoxItem.Content = sentenceName;
                        comboBoxItemName     = sentenceName;
                        corpusComboList.Add(comboBoxItem);
                        sentenceCount = corpusComboList.Count;
                        corpusListCombo.SelectedItem = comboBoxItem;
                        selectedFileIndex            = sentenceName;
                    }
                    if (sentenceName == "")
                    {
                        sentenceName = comboBoxItemName;
                    }
                }
                else if (indexNum == 1)
                {
                    realText = csvText.Replace(StringResources.ExceptionArea, ",");
                }
                else if (indexNum == 2)
                {
                    tagText = csvText.Replace(StringResources.ExceptionArea, ",");
                    txtObj  = new TextListObject(sentenceName, realText);
                    txtObj.PreviewMouseLeftButtonDown += textObjPreviewMouseLeftButtonDown;
                    if (txtObj.TagText != "")
                    {
                        txtObj.TagText = tagText;
                    }
                    ShowingTextUpdate(txtObj);

                    textList.Add(txtObj);
                    ;                   sentenceName = null;
                    realText = null;
                    tagText  = null;
                    txtObj   = null;

                    indexNum = -1;
                }
                indexNum++;
            }

            SelectTextFile();
        }