예제 #1
0
        private static void Match()
        {
            AddrSet addrset = AddrSet.GetInstance();

            //Match
            MatchMachine m = new MatchMachine(addrset);

            MatchResult result = m.Match(new string[] { "B" });

            MatchHelper.rwLockDashboard(addrset);
        }
예제 #2
0
        private static void Train()
        {
            AddrSet addrset = AddrSet.GetInstance();

            TrainMachine t = new TrainMachine(addrset);

            List <InsertElement> list = new List <InsertElement>();

            Random rnd = new Random();

            list.Add(new InsertElement(rnd.Next().ToString("0.00"), LEVEL.City, InsertMode.AutoPlace | InsertMode.ExactlyLevel));

            t.Train(list, true);

            MatchHelper.rwLockDashboard(addrset);
        }
예제 #3
0
        public TrainMachine(AddrSet addrset)
        {
            if (addrset == null)
            {
                throw new Exception("AddrSet is not initialized");
            }
            if (AddrSet.AddrGraph == null)
            {
                throw new Exception("Graph is not initialized");
            }

            _addrset = addrset;

            //LocalTrainRule = defualtRule;

            //init();
        }
예제 #4
0
        public TrainMachine(AddrSet addrset)
        {
            if (addrset == null)
            {
                throw new Exception("AddrSet is not initialized");
            }
            if (AddrSet.AddrGraph == null)
            {
                throw new Exception("Graph is not initialized");
            }

            _addrset = addrset;

            //LocalTrainRule = defualtRule;

            //init();
        }
예제 #5
0
        public void Match()
        {
            //start
            AddrSet addrset = AddrSet.GetInstance();

            //Match
            MatchMachine m = new MatchMachine(addrset);

            // Custom the MatchRule
            //m.SetMatchRule(rule);

            MatchResult result = m.Match(new string[] { "B" });


            MatchHelper.PrintResult(result);

            //close
            //addrset.Dump();
        }
예제 #6
0
        public static void InitFromFile()
        {
            AddrSet set = AddrSet.GetInstance();

            //foreach(GraphNode gnode in AddrSet.AddrGraph.root.NextNodeList)
            //{
            //    TableNode tnode = new TableNode(gnode);
            //    AddrSet.AddrGraph.NodeTable.Add(tnode.Name,tnode);
            //}
            set.Dump();
            //AddrSet.AddrGraph = new Graph();
            //AddrSet.AddrGraph.root = new GraphNode("root", LEVEL.Root);
            //AddrSet.AddrGraph.NodeTable = new Hashtable();
            //AddrSet.AddrGraph.NodeCount = 0;
            //AddrSet.DumpDirectory = @"D:\";
            //AddrSet set = new AddrSet(1);
            //set.Dump();
            //TableNode tnode = new TableNode(gnode);
            //AddrSet.AddrGraph.NodeTable.Add(tnode.Name,tnode);
        }
예제 #7
0
        public void Train()
        {
            //start
            AddrSet addrset = AddrSet.GetInstance();

            TrainMachine m = new TrainMachine(addrset);

            List <InsertElement> list = new List <InsertElement>();

            list.Add(new InsertElement("武汉", LEVEL.City, InsertMode.AutoPlace | InsertMode.ExactlyLevel));

            list.Add(new InsertElement("理工大", LEVEL.Other, InsertMode.AutoPlace | InsertMode.ExactlyLevel));

            list.Add(new InsertElement("屋檐下", LEVEL.Uncertainty, InsertMode.AutoPlace | InsertMode.ExactlyLevel));

            m.Train(list, true);

            //close
            //addrset.Dump();
        }
예제 #8
0
        public static void Test()
        {
            Thread[] thread_match = new Thread[10];
            for (int i = 0; i < 10; i++)
            {
                thread_match[i] = new Thread(new ThreadStart(Match));
                thread_match[i].Start();
            }
            Thread[] thread_train = new Thread[10];
            for (int i = 0; i < 10; i++)
            {
                thread_train[i] = new Thread(new ThreadStart(Train));
                thread_train[i].Start();
            }
            for (int i = 0; i < 10; i++)
            {
                thread_match[i].Join();
                thread_train[i].Join();
            }
            AddrSet addrset = AddrSet.GetInstance();

            Console.WriteLine("end");
        }
예제 #9
0
        public DemoTest()
        {
            //start
            AddrSet addrset = AddrSet.GetInstance();

            //Match
            MatchMachine m = new MatchMachine(addrset);

            MatchResult result = m.Match(new string[] { "B" });


            MatchHelper.PrintResult(result);

            //Train   ----------TODO


            //close
            //addrset.Dump();

            TableNode t    = AddrSet.AddrGraph.NodeTable["B"] as TableNode;
            bool      flag = result.Result.Equals(t.GNode);

            Console.WriteLine("XXX  " + flag);
        }