private Antecedent GetAntecedentFromJsonByTermSet(string json, IList <LogicalConnection> termSet)
        {
            Antecedent antecedent = new Antecedent();

            string[] jsonLines = Regex.Split(json, "],");
            IEnumerator <LogicalConnection> termSetEnum = termSet.GetEnumerator();

            foreach (string jsonLine in jsonLines)
            {
                while (!jsonLine.Contains(termSetEnum.Current.ToString()))
                {
                    termSetEnum.MoveNext();
                }

                IList <string> result = GetListValuesFromJson(jsonLine, termSetEnum.Current.ToString());

                if (termSetEnum.Current == LogicalConnection.AND)
                {
                    foreach (string judgmentStr in result)
                    {
                        antecedent.AND(GetJudgmentFromJson(judgmentStr));
                    }
                }
                else if (termSetEnum.Current == LogicalConnection.OR)
                {
                    antecedent.OR(GetJudgmentListFromString(result).ToArray());
                }
            }

            return(antecedent);
        }
Exemple #2
0
        public Antecedent Make()
        {
            Antecedent antecedent = new Antecedent();

            IDictionary <int, IList <Judgment> > judgmentsDict = GetJudgmentDictionary();

            foreach (IList <Judgment> judgments in judgmentsDict.Values)
            {
                if (judgments.Count == 1)
                {
                    antecedent.AND(judgments.First());
                }
                else
                {
                    antecedent.OR(judgments.ToArray());
                }
            }

            return(antecedent);
        }