private void openToolStripMenuItem_Click(object sender, EventArgs e) { openFileDialog.Filter = "XML Files (.xml)|*.xml|JSON Files (.json)|*.json"; openFileDialog.FilterIndex = 1; if(openFileDialog.ShowDialog() == DialogResult.OK) { network = new Network(); string fileContents = network.ReadFile(openFileDialog.FileName); //Dont continue if file is invalid if(fileContents == null) { MessageBox.Show("Attempted to parse invalid XML/JSON string", "XML/JSON invalid"); return; } //GUI control information txt_FileDetails.Text = fileContents; lbl_fileName.Text = "Showing contents of: "+openFileDialog.SafeFileName; //Start building the network from the XML string network.Build(fileContents); //Create inference class for loaded network inference = new Inference(network); lstNodes.Items.Clear(); foreach(DictionaryEntry de in network.NodeHash) { Node n = (Node)de.Value; Console.WriteLine(n.CPTValue); lstNodes.Items.Add(n.Name.ToLower()); } } }
public Inference(Network _network) { network = _network; buckets = new List<Bucket>(); InitBuckets(); }