public bool Add(Sys.Tool.Node node)
 {
     if (NodeA == null)
     {
         NodeA = node;
         return(true);
     }
     else if (NodeB == null)
     {
         NodeB = node;
         return(true);
     }
     else
     {
         //if( NodeA.Add(node) == false)
         //{
         //    return NodeB.Add(node);
         //}
         //throw new Exception("The node is full.");
         bool result = NodeA.Add(node);
         if (result)
         {
             return(true);
         }
         result = NodeB.Add(node);
         if (result)
         {
             return(true);
         }
         return(false);
     }
 }
        public void TestBinaryTree()
        {
            //******************************************************************
            //Test binary tree
            //******************************************************************
            Sys.Tool.Node n = new Sys.Tool.Node("0");
            n.Action.Add("0"); n.InquiryType.Add("0"); n.QuestionKey.Add("0"); n.Subject.Add("0"); n.Location.Add("0");
            n.Value = "value 0"; this.Node = n;

            n = new Sys.Tool.Node("1");
            n.Action.Add("1"); n.InquiryType.Add("1"); n.QuestionKey.Add("1"); n.Subject.Add("1"); n.Location.Add("1");
            n.Value = "value 1"; this.Node.Add(n);

            n = new Sys.Tool.Node("2");
            n.Action.Add("2"); n.InquiryType.Add("2"); n.QuestionKey.Add("2"); n.Subject.Add("2"); n.Location.Add("2");
            n.Value = "value 2"; this.Node.Add(n);

            n = new Sys.Tool.Node("3");
            n.Action.Add("3"); n.InquiryType.Add("3"); n.QuestionKey.Add("3"); n.Subject.Add("3"); n.Location.Add("3");
            n.Value = "value 3"; this.Node.Add(n);

            n = new Sys.Tool.Node("4");
            n.Action.Add("4"); n.InquiryType.Add("4"); n.QuestionKey.Add("4"); n.Subject.Add("4"); n.Location.Add("4");
            n.Value = "value 4"; this.Node.Add(n);

            n = new Sys.Tool.Node("5");
            n.Action.Add("5"); n.InquiryType.Add("5"); n.QuestionKey.Add("5"); n.Subject.Add("5"); n.Location.Add("5");
            n.Value = "value 5"; this.Node.Add(n);

            n = new Sys.Tool.Node("6");
            n.Action.Add("6"); n.InquiryType.Add("6"); n.QuestionKey.Add("6"); n.Subject.Add("6"); n.Location.Add("6");
            n.Value = "value 6"; this.Node.Add(n);

            n = new Sys.Tool.Node("7");
            n.Action.Add("7"); n.InquiryType.Add("7"); n.QuestionKey.Add("7"); n.Subject.Add("7"); n.Location.Add("7");
            n.Value = "value 7"; this.Node.Add(n);

            n = new Sys.Tool.Node("8");
            n.Action.Add("8"); n.InquiryType.Add("8"); n.QuestionKey.Add("8"); n.Subject.Add("8"); n.Location.Add("8");
            n.Value = "value 8"; this.Node.Add(n);

            n = new Sys.Tool.Node("9");
            n.Action.Add("9"); n.InquiryType.Add("9"); n.QuestionKey.Add("9"); n.Subject.Add("9"); n.Location.Add("9");
            n.Value = "value 9"; this.Node.Add(n);

            n = new Sys.Tool.Node("10");
            n.Action.Add("10"); n.InquiryType.Add("10"); n.QuestionKey.Add("10"); n.Subject.Add("10"); n.Location.Add("10");
            n.Value = "value 10"; this.Node.Add(n);

            n = new Sys.Tool.Node("11");
            n.Action.Add("11"); n.InquiryType.Add("11"); n.QuestionKey.Add("11"); n.Subject.Add("11"); n.Location.Add("11");
            n.Value = "value 11"; this.Node.Add(n);

            n = new Sys.Tool.Node("12");
            n.Action.Add("12"); n.InquiryType.Add("12"); n.QuestionKey.Add("12"); n.Subject.Add("12"); n.Location.Add("12");
            n.Value = "value 12"; this.Node.Add(n);

            n = new Sys.Tool.Node("13");
            n.Action.Add("13"); n.InquiryType.Add("13"); n.QuestionKey.Add("13"); n.Subject.Add("13"); n.Location.Add("13");
            n.Value = "value 13"; this.Node.Add(n);

            n = new Sys.Tool.Node("14");
            n.Action.Add("14"); n.InquiryType.Add("14"); n.QuestionKey.Add("14"); n.Subject.Add("14"); n.Location.Add("14");
            n.Value = "value 14"; this.Node.Add(n);

            //Search - Level 3 of Node B (8) - See Slide on "Custom knowledge base struture"
            Tool.SearchParameters pp = new Tool.SearchParameters();
            pp.Action = "8"; pp.QuestionKey = "8"; pp.Location = ""; pp.InquiryType = "8"; pp.Subject = "8";
            string ff = Search("", pp); //Passed

            //Search - Level 3 of Node B (10) - See Slide on "Custom knowledge base struture"
            pp        = new Tool.SearchParameters();
            pp.Action = "10"; pp.QuestionKey = "10"; pp.Location = ""; pp.InquiryType = "10"; pp.Subject = "10";
            ff        = Search("", pp); //Passed

            //Search - Level 3 of Node A (13) - See Slide on "Custom knowledge base struture"
            pp        = new Tool.SearchParameters();
            pp.Action = "13"; pp.QuestionKey = "13"; pp.Location = ""; pp.InquiryType = "13"; pp.Subject = "13";
            ff        = Search("", pp); //Passed

            //Search - Level 2 of Node A (5) - See Slide on "Custom knowledge base struture"
            pp        = new Tool.SearchParameters();
            pp.Action = "5"; pp.QuestionKey = "5"; pp.Location = ""; pp.InquiryType = "5"; pp.Subject = "5";
            ff        = Search("", pp); //Passed
            //******************************************************************
        }
        public void SetUpKnowledgeBase(DataTable Table)
        {
            if (Table == null)
            {
                return;
            }
            if (Table.Rows.Count == 0)
            {
                return;
            }
            Sys.Tool.Node n          = null;
            bool          IsRootNode = true;

            string[] data;
            char[]   delimiter = { '|' };
            //string[] parameters = { "location", "inquirytype", "subject", "questionkey", "action", "value" };
            int i = 0;

            n = new Sys.Tool.Node(i.ToString());

            foreach (DataRow row in Table.Rows)
            {
                //if((string)row[0]=="19"  ) {

                //sno, location, inquirytype, subject, questionkey, action, value
                //location
                data = (row["location"].ToString()).Split(delimiter);
                n.Location.Add(""); //add a blank location, necesscary for L3 logic
                foreach (var item in data)
                {
                    n.Location.Add(item.ToLower().Trim());
                }

                //inquirytype
                data = (row["inquirytype"].ToString()).Split(delimiter);
                foreach (var item in data)
                {
                    n.InquiryType.Add(item.ToLower().Trim());
                }

                //subject
                data = (row["subject"].ToString()).Split(delimiter);
                //n.Subject.Add(""); //add a blank location, necesscary for L3 logic
                foreach (var item in data)
                {
                    n.Subject.Add(item.ToLower().Trim());
                }

                //questionkey
                data = (row["questionkey"].ToString()).Split(delimiter);
                n.QuestionKey.Add(""); //add a blank location, necesscary for L3 logic
                foreach (var item in data)
                {
                    n.QuestionKey.Add(item.ToLower().Trim());
                }

                //action
                data = (row["action"].ToString()).Split(delimiter);
                foreach (var item in data)
                {
                    n.Action.Add(item.ToLower().Trim());
                }

                n.Value = (string)row["value"];

                if (IsRootNode)
                {
                    this.Node    = n;
                    this._Count += 1;
                }
                else
                {
                    if (this.Node.Add(n))
                    {
                        this._Count += 1;
                    }
                }

                n          = new Sys.Tool.Node(i.ToString());
                i         += 1;
                IsRootNode = false;
                // }
            }
        }
        public void SetUpKnowledgeBase()
        {
            Sys.Tool.Node n = new Sys.Tool.Node("ISSNUS");
            n.Action.Add("available"); n.Action.Add("have"); n.Action.Add("conduct"); n.Action.Add("offer");
            n.InquiryType.Add("programme"); n.InquiryType.Add("program"); n.InquiryType.Add("programmes"); n.InquiryType.Add("programs");
            n.QuestionKey.Add(""); n.QuestionKey.Add("what"); n.QuestionKey.Add("does");
            n.Subject.Add(""); n.Subject.Add("programme"); n.Subject.Add("program"); n.Subject.Add("programmes"); n.Subject.Add("programs");
            n.Location.Add(""); n.Location.Add("iss"); n.Location.Add("nus"); n.Location.Add("iss nus"); n.Location.Add("issnus");
            n.Value   = "There are Graduate Programmes and Stackable Certificate Programmes available at ISS NUS.";
            this.Node = n;


            n = new Sys.Tool.Node("Graduate Diploma in Systems Analysis");
            n.Action.Add("available"); n.Action.Add("have"); n.Action.Add("conduct"); n.Action.Add("offer");; n.Action.Add("is");
            n.InquiryType.Add("graduate diploma"); n.InquiryType.Add("systems analysis"); n.InquiryType.Add("diploma");
            n.QuestionKey.Add(""); n.QuestionKey.Add("what"); n.QuestionKey.Add("does");
            n.Subject.Add(""); n.Subject.Add("graduate diploma"); n.Subject.Add("systems analysis"); n.Subject.Add("diploma");
            n.Location.Add(""); n.Location.Add("iss"); n.Location.Add("nus"); n.Location.Add("iss nus"); n.Location.Add("issnus");
            n.Value = "The Graduate Diploma in Systems Analysis programme (GDipSA) is designed for non-IT graduates intending to craft a new career path in the IT industry. IT graduates and professionals who wish to advance their careers in their current field and recognise the need to equip themselves with the latest IT knowledge and skills to stay relevant may apply as well.";
            this.Node.Add(n);

            n = new Sys.Tool.Node("Master of Technology in Intelligent Systems");
            n.Action.Add("available"); n.Action.Add("have"); n.Action.Add("conduct"); n.Action.Add("offer"); n.Action.Add("is");
            n.InquiryType.Add("master of technology"); n.InquiryType.Add("master programme");
            n.QuestionKey.Add(""); n.QuestionKey.Add("what"); n.QuestionKey.Add("does");
            n.Subject.Add(""); n.Subject.Add("master of technology"); n.Subject.Add("master of technology in intelligent systems"); n.Subject.Add("intelligent systems"); n.Subject.Add("intelligent system");
            n.Location.Add(""); n.Location.Add("iss"); n.Location.Add("nus"); n.Location.Add("iss nus"); n.Location.Add("issnus");
            n.Value = "The NUS Master of Technology in Intelligent Systems programme is targeted at working professionals who wish to be able to design and build systems that utilise Artificial Intelligence and other Smart Systems techniques. Application areas are wide and diverse, and include robotics, autonomous vehicles, intelligent sensing systems, Internet of Things, Smart City applications and Industry 4.0 applications, as well as applications within business and commerce.";
            this.Node.Add(n);


            n = new Sys.Tool.Node("Master of Technology in Enterprise Business Analytics");
            n.Action.Add("available"); n.Action.Add("have"); n.Action.Add("conduct"); n.Action.Add("offer"); n.Action.Add("is");
            n.InquiryType.Add("master of technology"); n.InquiryType.Add("master programme");
            n.QuestionKey.Add(""); n.QuestionKey.Add("what"); n.QuestionKey.Add("does");
            n.Subject.Add(""); n.Subject.Add("master of technology"); n.Subject.Add("master of technology in enterprise business analytics"); n.Subject.Add("enterprise business analytics"); n.Subject.Add("business analytics");
            n.Location.Add(""); n.Location.Add("iss"); n.Location.Add("nus"); n.Location.Add("iss nus"); n.Location.Add("issnus");
            n.Value = "The NUS Master of Technology in Enterprise Business Analytics programme (MTech EBAC) is specifically designed to meet the industry demand for data scientists who can help organisations achieve improved business outcomes through data insights. It is best suited for professionals seeking to focus on the following - methodical data exploration and visualisation, diagnostic analytics, predictive modelling using statistical and machine learning techniques, text analytics, recommender systems, and big data engineering, etc.";
            this.Node.Add(n);

            n = new Sys.Tool.Node("Master of Technology in Software Engineering");
            n.Action.Add("available"); n.Action.Add("have"); n.Action.Add("conduct"); n.Action.Add("offer"); n.Action.Add("is");
            n.InquiryType.Add("master of technology"); n.InquiryType.Add("master programme");
            n.QuestionKey.Add(""); n.QuestionKey.Add("what"); n.QuestionKey.Add("does");
            n.Subject.Add(""); n.Subject.Add("master of technology"); n.Subject.Add("master of technology in software engineering"); n.Subject.Add("software engineering");
            n.Location.Add(""); n.Location.Add("iss"); n.Location.Add("nus"); n.Location.Add("iss nus"); n.Location.Add("issnus");
            n.Value = "The NUS Master of Technology in Software Engineering is designed to meet the industry demand for software engineers who can help Singapore organisations to realise the smart nation initiatives through building robust, reliable and scalable software systems. This programme is best suited for individuals who have a few years of experience in software engineering roles and are looking to further enhance their knowledge and skills in architecting scalable, secure and smart software systems.";
            this.Node.Add(n);

            n = new Sys.Tool.Node("Master of Technology in Digital Leadership");
            n.Action.Add("available"); n.Action.Add("have"); n.Action.Add("conduct"); n.Action.Add("offer"); n.Action.Add("is");
            n.InquiryType.Add("master of technology"); n.InquiryType.Add("master programme");
            n.QuestionKey.Add(""); n.QuestionKey.Add("what"); n.QuestionKey.Add("does");
            n.Subject.Add(""); n.Subject.Add("master of technology"); n.Subject.Add("master of technology in digital leadership"); n.Subject.Add("digital leadership");
            n.Location.Add(""); n.Location.Add("iss"); n.Location.Add("nus"); n.Location.Add("iss nus"); n.Location.Add("issnus");
            n.Value = "The Master of Technology in Digital Leadership programme focus on digital strategy and leadership will equip students with the critical thinking, hard and soft skills to become an effective leader. It will accelerate their career and enhance one's ability to take on greater roles and responsibilities in digital leadership. Students will be equipped with the right processes and people capabilities to ride the digital wave and to thrive in the digital economy. Our goal is also to help organisations to develop its next generation of IT and digital leaders.";
            this.Node.Add(n);

            n = new Sys.Tool.Node("Stackable Certificate Programme in Data Science");
            n.Action.Add("available"); n.Action.Add("have"); n.Action.Add("conduct"); n.Action.Add("offer"); n.Action.Add("is");
            n.InquiryType.Add("stackable certificate programme"); n.InquiryType.Add("stackable certificate programme in data science"); n.InquiryType.Add("programme in data science"); n.InquiryType.Add("data science");
            n.QuestionKey.Add(""); n.QuestionKey.Add("what"); n.QuestionKey.Add("does");
            n.Subject.Add(""); n.Subject.Add("stackable certificate programme"); n.Subject.Add("stackable certificate programme in data science"); n.Subject.Add("programme in data science"); n.Subject.Add("data science");
            n.Location.Add(""); n.Location.Add("iss"); n.Location.Add("nus"); n.Location.Add("iss nus"); n.Location.Add("issnus");
            n.Value = "The NUS-ISS Stackable Certificate Programme in Data Science, leading to the NUS Master of Technology in Enterprise Business Analytics is designed to meet the industry demand for data scientists who can help organisations achieve improved business outcomes through data insights. It is best suited for professionals who wish to enhance their existing skill sets to progress from the entry level to specialist or expert level positions in the data science and business analytics domain. ";
            this.Node.Add(n);

            n = new Sys.Tool.Node("ISS Stackable Certificate Programmes in Digital Solutions Development");
            n.Action.Add("available"); n.Action.Add("have"); n.Action.Add("conduct"); n.Action.Add("offer");
            n.InquiryType.Add("stackable certificate programmes"); n.InquiryType.Add("programmes in digital solutions development"); n.InquiryType.Add("digital solutions development");
            n.QuestionKey.Add(""); n.QuestionKey.Add("what"); n.QuestionKey.Add("does");
            n.Subject.Add(""); n.Subject.Add("stackable certificate programmes in digital solutions development"); n.Subject.Add("stackable certificate programmes");
            n.Location.Add(""); n.Location.Add("iss"); n.Location.Add("nus"); n.Location.Add("iss nus"); n.Location.Add("issnus");
            n.Value = "The Stackable Certificate Programmes in Digital Solutions Development course equips participants with necessary skills to design and develop IT solutions to resolve business problems, enable process automation and support smart living in our day to day life.";
            this.Node.Add(n);

            n = new Sys.Tool.Node("Stackable Certificate Programme in Artificial Intelligence");
            n.Action.Add("available"); n.Action.Add("have"); n.Action.Add("conduct"); n.Action.Add("offer");
            n.InquiryType.Add("stackable certificate programmes"); n.InquiryType.Add("programmes in artificial intelligence"); n.InquiryType.Add("artificial intelligence");
            n.QuestionKey.Add(""); n.QuestionKey.Add("what"); n.QuestionKey.Add("does");
            n.Subject.Add(""); n.Subject.Add("stackable certificate programme in artificial intelligence"); n.Subject.Add("stackable certificate programmes"); n.Subject.Add("programme in artificial intelligence");
            n.Location.Add(""); n.Location.Add("iss"); n.Location.Add("nus"); n.Location.Add("iss nus"); n.Location.Add("issnus");
            n.Value = "The Stackable Certificate Programme in Artificial Intelligence course equips participants with necessary skills to design and develop IT solutions to resolve business problems, enable process automation and support smart living in our day to day life.";
            this.Node.Add(n);

            n = new Sys.Tool.Node("Graduate Certificate in Intelligent Reasoning Systems");
            n.Action.Add("available"); n.Action.Add("have"); n.Action.Add("conduct"); n.Action.Add("offer");
            n.InquiryType.Add("graduate certificate "); n.InquiryType.Add("certificate in intelligent reasoning systems");
            n.QuestionKey.Add(""); n.QuestionKey.Add("what"); n.QuestionKey.Add("does");
            n.Subject.Add(""); n.Subject.Add("graduate certificate in intelligent reasoning systems"); n.Subject.Add("certificate in intelligent reasoning systems"); n.Subject.Add("intelligent reasoning systems");; n.Subject.Add("reasoning systems");
            n.Location.Add(""); n.Location.Add("iss"); n.Location.Add("nus"); n.Location.Add("iss nus"); n.Location.Add("issnus");
            n.Value = "The Graduate Certificate in Intelligent Reasoning Systems teaches how to build Intelligent Systems that solve problems by computational reasoning using captured domain knowledge and data. Example applications include, question answering systems such as IBM's Watson, personal assistants such as Amazon’s Alexa Skills and game-playing systems such as Google's AlphaGo.";
            this.Node.Add(n);
        }