public Rule(Rule rule) { if (rule.rChild == null) { this.info = rule.info; this.lChild = rule.lChild; this.rChild = null; this.prob = rule.prob; } else { this.info = rule.info; this.lChild = rule.lChild; this.rChild = rule.rChild; this.prob = rule.prob; } }
public bool Equals(Rule rule) { if (rule.rChild == null) { if (this.info.Equals(rule.info) && this.lChild.Equals(rule.lChild)) { return true; } } else { if (this.info.Equals(rule.info) && this.lChild.Equals(rule.lChild) && this.rChild.Equals(rule.rChild)) { return true; } } return false; }
public Node(Rule rule) { this.info = rule.info; this.leafFlag = false; }
public void add(Rule rule) { if (dict.Contains(rule.info)) { ruleDict[rule.info].Add(rule); } else { dict.Add(rule.info); List<Rule> list = new List<Rule>(); list.Add(rule); ruleDict[rule.info] = list; } }
public static void readModel(String modelfile) { StreamReader sr = new StreamReader(modelfile); String line; while (!sr.EndOfStream) { line = sr.ReadLine(); String[] srule = line.Split('#'); for (int i = 0; i < srule.Length; i++) { srule[i] = srule[i].Trim(); } String[] sLeftRule = srule[1].Split(' '); Rule rule; if (sLeftRule.Length == 1) { rule = new Rule(srule[0], sLeftRule[0], null, double.Parse(srule[2])); } else { rule = new Rule(srule[0], sLeftRule[0], sLeftRule[1], double.Parse(srule[2])); } ruleprob.add(rule); } sr.Close(); }