private static void Match() { AddrSet addrset = AddrSet.GetInstance(); //Match MatchMachine m = new MatchMachine(addrset); MatchResult result = m.Match(new string[] { "B" }); MatchHelper.rwLockDashboard(addrset); }
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); }
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(); }
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(); }
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); }
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(); }
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"); }
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); }