//checks Not Default Predicate Boolean Compound(Dictionary <string, object> inputDic, Node fPred) { Boolean result = false; switch (fPred.Attribute("booleanOperator")) { case "or": for (int i = 0; i < fPred.ChildCount(); i++) { if (Predicate(inputDic, fPred.Child(i))) { result = true; break; } } break; case "and": for (int i = 0; i < fPred.ChildCount(); i++) { result = true; if (!Predicate(inputDic, fPred.Child(i))) { result = false; break; } } break; case "surrogate": for (int i = 0; i < fPred.ChildCount(); i++) { if (Predicate(inputDic, fPred.Child(i)) != null) { result = Predicate(inputDic, fPred.Child(i)) != null; break; } } break; } return(result); }
public TreeNode(Node xmlNd) { xnode = xmlNd; score = xnode.Attribute("score"); for (int i = 0; i < xnode.ChildCount(); i++) { switch (xnode.Child(i).Name()) { case "True": predicate = xnode.Child(i); break; case "False": predicate = xnode.Child(i); break; case "SimplePredicate": predicate = xnode.Child(i); break; case "CompoundPredicate": predicate = xnode.Child(i); break; } } }
// This function checks a Simple Predicate with NOT DEFAULT Predicate Boolean Simple(Dictionary <string, object> inputDic, Node fPred) { Boolean result = false; switch (fPred.Attribute("operator")) { case "equal": if (type[fPred.Attribute("field")] == "double") { result = (Convert.ToDouble(inputDic[fPred.Attribute("field")]) == Convert.ToDouble(fPred.Attribute("value"))); } else { result = (Convert.ToString(inputDic[fPred.Attribute("field")]) == fPred.Attribute("value")); } break; case "notEqual": if (type[fPred.Attribute("field")] == "double") { result = (Convert.ToDouble(inputDic[fPred.Attribute("field")]) != Convert.ToDouble(fPred.Attribute("value"))); } else { result = (Convert.ToString(inputDic[fPred.Attribute("field")]) != fPred.Attribute("value")); } break; case "lessThan": result = (Convert.ToDouble(inputDic[fPred.Attribute("field")]) < Convert.ToDouble(fPred.Attribute("value"))); break; case "lessOrEqual": result = (Convert.ToDouble(inputDic[fPred.Attribute("field")]) <= Convert.ToDouble(fPred.Attribute("value"))); break; case "greaterThan": result = (Convert.ToDouble(inputDic[fPred.Attribute("field")]) > Convert.ToDouble(fPred.Attribute("value"))); break; case "greaterOrEqual": result = (Convert.ToDouble(inputDic[fPred.Attribute("field")]) >= Convert.ToDouble(fPred.Attribute("value"))); break; } return(result); }