/// <summary>
        /// Load Node from XmlNode
        /// </summary>
        /// <param name="node"></param>
        /// <returns></returns>
        public static SimpleSetPredicate loadFromXmlNode(XmlNode node)
        {
            SimpleSetPredicate root = new SimpleSetPredicate();

            root.field     = node.Attributes["field"].Value;
            root.foperator = node.Attributes["booleanOperator"].Value;

            root.farray = new List <string>();
            foreach (XmlNode item in node.ChildNodes)
            {
                if ("extension".Equals(item.Name.ToLowerInvariant()))
                {
                    //root.farray.Add(item.InnerText.Trim());
                }
                else if ("array".Equals(item.Name.ToLowerInvariant()))
                {
                    root.farray.Add(item.InnerText.Trim());
                }
                else
                {
                    throw new NotImplementedException();
                }
            }

            return(root);
        }
Beispiel #2
0
        /// <summary>
        /// Load Segmentation node from XmlElement of PMML file
        /// </summary>
        /// <param name="node">Xml PMML file to read</param>
        /// <returns></returns>
        public static Segment loadFromXmlNode(XmlNode node)
        {
            Segment segment = new Segment();

            /*tree.ModelName = node.Attributes["modelName"].Value;
             *
             * if (node.Attributes["missingValueStrategy"] != null)
             *      tree.MissingValueStrategy = MissingValueStrategyfromString(node.Attributes["missingValueStrategy"].Value);
             *
             * // By default noTrueChildStrategy = returnNullPrediction
             * tree.noTrueChildStrategy = NoTrueChildStrategy.ReturnNullPrediction;
             * if (node.Attributes["noTrueChildStrategy"] != null)
             *      tree.noTrueChildStrategy = NoTrueChildStrategyfromString(node.Attributes["noTrueChildStrategy"].Value);
             */

            foreach (XmlNode item in node.ChildNodes)
            {
                if ("Extension".Equals(item.Name))
                {
                    // Not yet implemented
                }
                else if ("simplepredicate".Equals(item.Name.ToLowerInvariant()))
                {
                    segment.predicate = SimplePredicate.loadFromXmlNode(item);
                }
                else if ("true".Equals(item.Name.ToLowerInvariant()))
                {
                    segment.predicate = new TruePredicate();
                }
                else if ("false".Equals(item.Name.ToLowerInvariant()))
                {
                    segment.predicate = new FalsePredicate();
                }
                else if ("compoundpredicate".Equals(item.Name.ToLowerInvariant()))
                {
                    segment.predicate = CompoundPredicate.loadFromXmlNode(item);
                }
                else if ("simplesetpredicate".Equals(item.Name.ToLowerInvariant()))
                {
                    segment.predicate = SimpleSetPredicate.loadFromXmlNode(item);
                }
                else if ("treemodel".Equals(item.Name.ToLowerInvariant()))
                {
                    segment.model = TreeModel.loadFromXmlNode(item);
                }
                else
                {
                    throw new NotImplementedException();
                }
            }

            return(segment);
        }
        /// <summary>
        /// Load Node from XmlNode
        /// </summary>
        /// <param name="node"></param>
        /// <returns></returns>
        public static CompoundPredicate loadFromXmlNode(XmlNode node)
        {
            CompoundPredicate root = new CompoundPredicate();

            // TODO : Add extention reading

            root.fbooleanOperator = node.Attributes["booleanOperator"].Value;

            root.fpredicates = new List <Predicate>();
            foreach (XmlNode item in node.ChildNodes)
            {
                if ("extension".Equals(item.Name.ToLowerInvariant()))
                {
                    //root.Nodes.Add(Node.loadFromXmlNode(item));
                }
                else if ("simplepredicate".Equals(item.Name.ToLowerInvariant()))
                {
                    root.fpredicates.Add(SimplePredicate.loadFromXmlNode(item));
                }
                else if ("true".Equals(item.Name.ToLowerInvariant()))
                {
                    root.fpredicates.Add(new TruePredicate());
                }
                else if ("false".Equals(item.Name.ToLowerInvariant()))
                {
                    root.fpredicates.Add(new FalsePredicate());
                }
                else if ("compoundpredicate".Equals(item.Name.ToLowerInvariant()))
                {
                    root.fpredicates.Add(CompoundPredicate.loadFromXmlNode(item));
                }
                else if ("simplesetpredicate".Equals(item.Name.ToLowerInvariant()))
                {
                    root.fpredicates.Add(SimpleSetPredicate.loadFromXmlNode(item));
                }
                else
                {
                    throw new NotImplementedException();
                }
            }

            return(root);
        }
Beispiel #4
0
        /// <summary>
        /// Load Node from XmlNode
        /// </summary>
        /// <param name="node"></param>
        /// <returns></returns>
        public static SimpleSetPredicate loadFromXmlNode(XmlNode node)
        {
            SimpleSetPredicate root = new SimpleSetPredicate();

            root.field = node.Attributes["field"].Value;
            root.foperator = node.Attributes["booleanOperator"].Value;

            root.farray = new List<string>();
            foreach(XmlNode item in node.ChildNodes)
            {
                if ("extension".Equals(item.Name.ToLowerInvariant()))
                {
                    //root.farray.Add(item.InnerText.Trim());
                }
                else if ("array".Equals(item.Name.ToLowerInvariant()))
                {
                    root.farray.Add(item.InnerText.Trim());
                }
                else
                    throw new NotImplementedException();
            }

            return root;
        }
Beispiel #5
0
        /// <summary>
        /// Load Node from XmlNode
        /// </summary>
        /// <param name="node"></param>
        /// <returns></returns>
        public static Node loadFromXmlNode(XmlNode node)
        {
            Node root = new Node(new TruePredicate());

            if (node.Attributes["id"] != null)
            {
                root.id = node.Attributes["id"].Value;
            }

            if (node.Attributes["score"] != null)
            {
                root.score = node.Attributes["score"].Value;
            }

            if (node.Attributes["recordCount"] != null)
            {
                root.recordCount = Convert.ToDecimal(node.Attributes["recordCount"].Value, CultureInfo.InvariantCulture);
            }

            root.scoreDistributions = new List <ScoreDistribution>();
            foreach (XmlNode item in node.ChildNodes)
            {
                if ("extension".Equals(item.Name.ToLowerInvariant()))
                {
                    // TODO : implement extension
                    //root.Nodes.Add(Node.loadFromXmlNode(item));
                }
                else if ("node".Equals(item.Name.ToLowerInvariant()))
                {
                    root.Nodes.Add(Node.loadFromXmlNode(item));
                }
                else if ("simplepredicate".Equals(item.Name.ToLowerInvariant()))
                {
                    root.Predicate = SimplePredicate.loadFromXmlNode(item);
                }
                else if ("true".Equals(item.Name.ToLowerInvariant()))
                {
                    root.Predicate = new TruePredicate();
                }
                else if ("false".Equals(item.Name.ToLowerInvariant()))
                {
                    root.Predicate = new FalsePredicate();
                }
                else if ("compoundpredicate".Equals(item.Name.ToLowerInvariant()))
                {
                    root.Predicate = CompoundPredicate.loadFromXmlNode(item);
                }
                else if ("simplesetpredicate".Equals(item.Name.ToLowerInvariant()))
                {
                    root.Predicate = SimpleSetPredicate.loadFromXmlNode(item);
                }
                else if ("scoredistribution".Equals(item.Name.ToLowerInvariant()))
                {
                    root.ScoreDistributions.Add(ScoreDistribution.loadFromXmlNode(item));
                }
                else
                {
                    throw new NotImplementedException();
                }
            }

            return(root);
        }