Beispiel #1
0
 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;
     }
 }
Beispiel #2
0
        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;
        }
Beispiel #3
0
 public Node(Rule rule)
 {
     this.info = rule.info;
     this.leafFlag = false;
 }
Beispiel #4
0
        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;
            }
        }
Beispiel #5
0
            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();
            }