예제 #1
0
        public HashSet <Proposition> Process(Proposition p)
        {
            HashSet <Proposition> res  = new HashSet <Proposition>();
            SortedSet <string>    tmp1 = new SortedSet <string>(arrLiteral1, new MyCompare_1());

            foreach (string i in p.arrLiteral1)
            {
                tmp1.Add(i);
            }
            SortedSet <string> tmp2 = new SortedSet <string>(arrLiteral2, new MyCompare_1());

            foreach (string i in p.arrLiteral2)
            {
                tmp2.Add(i);
            }

            foreach (string i in arrLiteral1)
            {
                foreach (string j in p.arrLiteral2)
                {
                    if (i.Equals(j) == true)
                    {
                        Proposition tmp = new Proposition(tmp1, tmp2);
                        tmp.Remove(i, 1);
                        tmp.Remove(j, 2);
                        res.Add(tmp);
                    }
                }
            }

            foreach (string i in p.arrLiteral1)
            {
                foreach (string j in arrLiteral2)
                {
                    if (i.Equals(j) == true)
                    {
                        Proposition tmp = new Proposition(tmp1, tmp2);
                        tmp.Remove(i, 1);
                        tmp.Remove(j, 2);
                        res.Add(tmp);
                    }
                }
            }

            return(res);
        }
예제 #2
0
        public int Compare(Proposition p)
        {
            int n1 = arrLiteral1.Count + arrLiteral2.Count;
            int n2 = p.arrLiteral1.Count + p.arrLiteral2.Count;

            if (n1 > n2)
            {
                return(1);
            }
            if (n1 < n2)
            {
                return(-1);
            }
            string tmp1 = this.ToString();
            string tmp2 = p.ToString();

            return(tmp1.CompareTo(tmp2));
        }
예제 #3
0
        public KnowledgeBase(string fileName)
        {
            arrProposition = new SortedSet <Proposition>(new MyCompare_2());
            arrString      = new List <string>();
            string[] text = System.IO.File.ReadAllLines(fileName);
            int      n    = text.Length;
            string   s    = "";

            for (int i = 1; i < n - 2; ++i)
            {
                arrProposition.Add(new Proposition(text[i]));
                s += (text[i] + ",");
            }
            arrString.Add(text[n - 1]);
            Proposition tmp = new Proposition();

            tmp.Set(text[n - 1]);
            s += tmp.ToString();
            arrProposition.Add(tmp);
            arrString.Add(s);
        }
예제 #4
0
 public Proposition(Proposition p)
 {
     arrLiteral1 = new SortedSet <string>(p.arrLiteral1, new MyCompare_1());
     arrLiteral2 = new SortedSet <string>(p.arrLiteral2, new MyCompare_1());
 }
예제 #5
0
 public bool Equals(Proposition p)
 {
     return(arrLiteral1.Equals(p.arrLiteral1) && arrLiteral2.Equals(p.arrLiteral2));
 }