public static void MakeTrees(string contentTreeName) { IIO io = new FileIO(); IEnumerable<string> file = io.ReadSourceIterable(testpath + "TIME.ALL"); ITextExtractor it = new BeginMarkerExtraction(file, "*TEXT"); ITreeIO tio = new TreeIO(); IBaseTree tree = tio.LoadBaseTree(testpath + contentTreeName); int count = 1; while (it.HasNextContent()) { string content = it.FindNextContent(); //Console.WriteLine("-----"); string name = "" + count; //Console.WriteLine(name); content = Helpers.ConsumeName(content); //Console.WriteLine(content); IDataTree datatree = DataTreeBuilder.CreateDocumentMappedTree(tree); //Console.WriteLine(tree); //Console.WriteLine(datatree.GetBaseTree()); DataTreeBuilder.AddToDataTree(datatree, content); datatree.Name = name; tio.SaveDataTree(datatree, testpath + @"\datatrees\" + name + ".dtree"); //Console.WriteLine(datatree.MappedWords); count++; } }
public void LoadInvalidFileTest2() { ITreeIO io = new TreeIO(); IBaseTree basetree = setUpBaseTree(); IDataTree datatree = setUpDataTree(basetree); io.SaveDataTree(datatree, location); Assert.IsTrue(File.Exists(location)); IBaseTree loadedDatatree = io.LoadBaseTree(location); }
public void SaveDataTreeTest() { ITreeIO io = new TreeIO(); IBaseTree basetree = setUpBaseTree(); IDataTree datatree = setUpDataTree(basetree); io.SaveDataTree(datatree, location); Assert.IsTrue(File.Exists(location)); IDataTree loadedDatatree = io.LoadDataTree(location); Assert.AreNotSame(basetree, loadedDatatree); Assert.AreEqual(basetree.Root.KeyWord, loadedDatatree.Root.Keyword); Assert.IsNull(loadedDatatree.GetBaseTree()); Assert.IsNotNull(datatree.GetBaseTree()); }
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; }