Exemplo n.º 1
0
        public void NonexistentTagTest()
        {
            ITextExtractor t = new XMLTextExtractor(testString1, nonexistentTag);

            Assert.IsFalse(t.HasNextContent());
            Assert.IsNull(t.FindNextContent());
        }
Exemplo n.º 2
0
        public void EmptyTagAssignedLaterTest()
        {
            ITextExtractor t = new XMLTextExtractor(testString1);

            t.Tag = "";
            t.FindNextContent();
        }
Exemplo n.º 3
0
        public void NullTagAssignedLaterSecondConstTest()
        {
            ITextExtractor t = new XMLTextExtractor(testString1, tag);

            t.Tag = null;
            t.FindNextContent();
        }
Exemplo n.º 4
0
        public void TextExtractionTest()
        {
            ITextExtractor t = new XMLTextExtractor(testString1, tag);

            Assert.IsTrue(t.HasNextContent());
            Assert.IsNotNull(t.Tag);

            for (int i = 0; i < 3; i++)
            {
                Assert.IsTrue(t.HasNextContent());
                string post = t.FindNextContent();
                Assert.AreEqual(content[i], post);
            }

            Assert.IsFalse(t.HasNextContent());
            Assert.IsNull(t.FindNextContent());
        }
Exemplo n.º 5
0
 public void EmptyTagTest()
 {
     ITextExtractor t = new XMLTextExtractor(testString1, "");
 }
Exemplo n.º 6
0
 public void NullTagTest()
 {
     ITextExtractor t = new XMLTextExtractor(testString1, null);
 }
Exemplo n.º 7
0
 public void NullContentTestWithTagOperator()
 {
     ITextExtractor t = new XMLTextExtractor(null, tag);
 }
Exemplo n.º 8
0
 public void NullContentTest()
 {
     ITextExtractor t = new XMLTextExtractor(null);
 }
Exemplo n.º 9
0
        private void formatOkay_Click(object sender, RoutedEventArgs e)
        {
            if (baseTree == null)
            {
                MessageBox.Show("Please select a content tree for the data tree.");
                return;
            }

            if (formatBox.SelectedIndex == -1)
            {
                formatBox.BorderBrush = Brushes.Red;
                return;
            }
            if (string.IsNullOrEmpty(documentFormatBox.Text))
            {
                documentFormatBox.BorderBrush = Brushes.Red;
                return;
            }

            OpenFileDialog ofd = new OpenFileDialog();

            ofd.FileName   = "Tree";
            ofd.DefaultExt = ".txt";

            Nullable <bool> result = ofd.ShowDialog();

            if (result == true)
            {
                string filename = ofd.FileName;
                documentLabel.Content = filename + "datatrees";
                using (Ookii.Dialogs.Wpf.ProgressDialog dial = new ProgressDialog()) {
                    dial.ProgressBarStyle = ProgressBarStyle.MarqueeProgressBar;
                    dial.Show();
                    dial.Description = "Analyzing text...";
                    IIO            io = new FileIO();
                    ITextExtractor it = null;
                    switch (formatBox.SelectedIndex)
                    {
                    case 0:
                        string text = io.ReadSource(filename);
                        it = new XMLTextExtractor(text, documentFormatBox.Text);
                        break;

                    case 1:
                        var texts = io.ReadSourceIterable(filename);
                        it = new BeginMarkerExtraction(texts, documentFormatBox.Text);
                        break;

                    default:
                        throw new InvalidOperationException();
                    }
                    documents = new ObservableCollection <string>();
                    while (it.HasNextContent())
                    {
                        string content = it.FindNextContent();
                        string name    = Helpers.GetNameWhenFirst(content);
                        documents.Add(name);

                        IDataTree tree = DataTreeBuilder.CreateDocumentMappedTree(baseTree);
                        DataTreeBuilder.AddToDataTree(tree, content);

                        ITreeIO tio = new TreeIO();
                        tio.SaveDataTree(tree, filename + @"datatrees\" + name + ".dtree");
                    }
                    documentList.ItemsSource = documents;
                }
            }


            buildDataTreePopup.IsOpen = false;
        }