コード例 #1
0
ファイル: MainForm.cs プロジェクト: MasterRok/ExpertSystem
        private void btnLoadCv_Click(object sender, EventArgs e)
        {
            using (var openCvFileDialog = new OpenFileDialog())
            {
                openCvFileDialog.Filter = "Книга Excel (*.xlsx)|*.xlsx| (*.xls)|*.xls";
                if (openCvFileDialog.ShowDialog() == DialogResult.OK)
                {
                    string fileName = openCvFileDialog.FileName;
                    openCvFileDialog.Reset();
                    var cv = CvHandler.LoadCv(fileName);
                    foreach (var pair in cv)
                    {
                        string[] arr = { pair.Key, pair.Value };
                        lvCv.Items.Add(new ListViewItem(arr));
                        lvCv.Update();
                    }

                    var jobs = KnowledgeBase.GetJobs();

                    cv = cv.FilterValues();
                    CvHandler.AnalyzeCv(cv, jobs);
                    lvCv.Clear();
                }
            }
        }
コード例 #2
0
        public ExpertSystemForm()
        {
            InitializeComponent();
            _propertyKnowledge.PropertySort = PropertySort.NoSort;

            knowledgeBase = new KnowledgeBase();
        }
コード例 #3
0
        public void SerializeKnowledgeBase(KnowledgeBase KB)
        {
            XmlWriter     writer = null;
            XmlSerializer xser   = new XmlSerializer(typeof(KnowledgeBase));

            try
            {
                XmlWriterSettings settings = new XmlWriterSettings()
                {
                    Indent             = true,
                    Encoding           = Encoding.UTF8,
                    OmitXmlDeclaration = false
                };
                writer = XmlWriter.Create(fileName, settings);

                /* Serialize object */
                xser.Serialize(writer, KB, null);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Wyjątek: {0}", ex.Message);
            }
            finally
            {
                if (writer != null)
                {
                    writer.Close();
                }
            }
        }
コード例 #4
0
        public ForwardChaining(KnowledgeBase kb)
        {
            this.Rules  = new RuleCollection();
            this.CFacts = new LiteralCollection();
            this.FFacts = new LiteralCollection();

            foreach (Fact f in kb.Facts)
            {
                this.CFacts.Add(f);
            }
            foreach (Rule r in kb.Rules)
            {
                this.Rules.Add(r);
            }

            DetermineIdNextRules();
        }
コード例 #5
0
 private void _newKnowledgeBaseToolStripMenuItem_Click(object sender, EventArgs e)
 {
     knowledgeBase = new KnowledgeBase();
     fileName      = string.Empty;
     ClearEditor();
 }