Esempio n. 1
0
        /// <summary>
        /// Returns sorted phone models suitable for customer information
        /// </summary>
        /// <param name="consultOptions">customer information</param>
        /// <param name="models">phone models (as [modelKey, modelName]) to consult</param>
        /// <returns> List with key is model, and value is count of suitable properties on model</returns>
        public static List <KeyValuePair <string, int> > DoConsult(ConsultOptions consultOptions, Dictionary <string, string> models)
        {
            ModelFacts = new Dictionary <string, List <Fact> >();

            Dictionary <string, int> DModels = new Dictionary <string, int>();

            foreach (var model in models)
            {
                DModels[model.Key] = 0;
            }

            InitKnown(consultOptions);

            ForwardChaining();

            ScoreMatchingFacts(DModels);

            List <KeyValuePair <string, int> > LModels = new List <KeyValuePair <string, int> >();

            foreach (var model in DModels)
            {
                LModels.Add(model);
            }

            SortModels(LModels);

            return(LModels);
        }
Esempio n. 2
0
        public AdvancedConsultForm(ConsultOptions consultOptions)
        {
            InitializeComponent();
            this.consultOptions = new ConsultOptions(consultOptions);

            genderComboBox.Items.AddRange(ConsultOptions.GenderValues);
            ageComboBox.Items.AddRange(ConsultOptions.AgeValues);
            hobbyCheckedListBox.Items.AddRange(ConsultOptions.HobbyValues);
            majorCheckedListBox.Items.AddRange(ConsultOptions.MajorValues);
            demandCheckedListBox.Items.AddRange(ConsultOptions.DemandValues);
        }
Esempio n. 3
0
        public ConsultOptions(ConsultOptions options)
        {
            this.GenderIndex   = options.GenderIndex;
            this.AgeIndex      = options.AgeIndex;
            this.HobbyIndices  = new List <int>(options.HobbyIndices);
            this.MajorIndices  = new List <int>(options.MajorIndices);
            this.DemandIndices = new List <int>(options.DemandIndices);

            this.GenderScore  = options.GenderScore;
            this.AgeScore     = options.AgeScore;
            this.HobbyScores  = new Dictionary <int, int>(options.HobbyScores);
            this.MajorScores  = new Dictionary <int, int>(options.MajorScores);
            this.DemandScores = new Dictionary <int, int>(options.DemandScores);
        }
Esempio n. 4
0
        private void consultLinkLabel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            AdvancedConsultForm form = new AdvancedConsultForm(consultOptions);

            if (form.ShowDialog() == DialogResult.OK)
            {
                consultOptions = form.consultOptions;

                ignoreCheckEvent = true;
                foreach (int i in hobbyCheckedListBox.CheckedIndices)
                {
                    hobbyCheckedListBox.SetItemChecked(i, false);
                }
                foreach (int i in majorCheckedListBox.CheckedIndices)
                {
                    majorCheckedListBox.SetItemChecked(i, false);
                }
                foreach (int i in demandCheckedListBox.CheckedIndices)
                {
                    demandCheckedListBox.SetItemChecked(i, false);
                }

                genderComboBox.SelectedIndex = consultOptions.GenderIndex;
                ageComboBox.SelectedIndex    = consultOptions.AgeIndex;
                foreach (int i in consultOptions.HobbyIndices)
                {
                    hobbyCheckedListBox.SetItemChecked(i, true);
                }
                foreach (int i in consultOptions.MajorIndices)
                {
                    majorCheckedListBox.SetItemChecked(i, true);
                }
                foreach (int i in consultOptions.DemandIndices)
                {
                    demandCheckedListBox.SetItemChecked(i, true);
                }
                ignoreCheckEvent = false;

                UpdatePhones();
            }
        }
Esempio n. 5
0
        static void InitKnown(ConsultOptions consultOptions)
        {
            Known = new HashSet <Fact>();
            Fact fact;
            int  i;

            i = consultOptions.GenderIndex;
            if (i != 0)
            {
                fact            = new Fact("Gender", "=", ConsultOptions.GenderKeys[i]);
                FactScore[fact] = consultOptions.GenderScore;
                Known.Add(fact);
            }

            i = consultOptions.AgeIndex;
            if (i > 1)
            {
                i = int.Parse(consultOptions.AgeIndex.ToString()) + 8;

                Fuzzy f = new Fuzzy();
                FuzzyAge = f.DoTuoi(i);
                keyList  = new List <string>(FuzzyAge.Keys);

                fact            = new Fact("Age", "=", keyList[0]);
                FactScore[fact] = consultOptions.AgeScore;
                Known.Add(fact);
                if (FuzzyAge[keyList[1]] != 0)
                {
                    fact            = new Fact("Age", "=", keyList[1]);
                    FactScore[fact] = consultOptions.AgeScore;
                    Known.Add(fact);
                }
            }
            else if (i == 1)
            {
                fact = new Fact("Age", "=", "ThieuNhi");
                FuzzyAge["ThieuNhi"] = 1;
                keyList         = new List <string>(FuzzyAge.Keys);
                FactScore[fact] = consultOptions.AgeScore;
                Known.Add(fact);
            }

            foreach (int j in consultOptions.HobbyIndices)
            {
                fact            = new Fact("Hobby", "=", ConsultOptions.HobbyKeys[j]);
                FactScore[fact] = consultOptions.HobbyScores[j];
                Known.Add(fact);
            }

            foreach (int j in consultOptions.MajorIndices)
            {
                fact            = new Fact("Major", "=", ConsultOptions.MajorKeys[j]);
                FactScore[fact] = consultOptions.MajorScores[j];
                Known.Add(fact);
            }

            foreach (int j in consultOptions.DemandIndices)
            {
                fact            = new Fact("Demand", "=", ConsultOptions.DemandKeys[j]);
                FactScore[fact] = consultOptions.DemandScores[j];
                Known.Add(fact);
            }
        }