コード例 #1
0
        /// <summary>
        /// Gets set of split nodes from a root node
        /// </summary>
        /// <param name="root">Root node to get split nodes from</param>
        /// <param name="splitNodeLocations">Node locations that form the split node</param>
        /// <returns>Set of split nodes</returns>
        private static List <TreeBankNode> GetSplitNode(TreeBankNode root, string splitNodeLocations)
        {
            List <TreeBankNode> splitNode = new List <TreeBankNode>();

            foreach (string nodeLocation in splitNodeLocations.Split(','))
            {
                splitNode.Add(root.GetNode(nodeLocation));
            }

            if (splitNode.Count <= 1)
            {
                throw new Exception("Invalid split node locations");
            }

            return(splitNode);
        }
コード例 #2
0
 /// <summary>
 /// Gets relation nodes given a root and a location series label
 /// </summary>
 /// <param name="root">Root node to get nodes from</param>
 /// <param name="locationLabel">Location series label</param>
 /// <param name="nodeCollection">Collection to add nodes to</param>
 public static void AddNodesToCollection(TreeBankNode root, string locationLabel, LabeledNodeCollection nodeCollection)
 {
     // split on * then on ,
     string[] corefLocations = locationLabel.Split('*');
     foreach (string corefLocation in corefLocations)
     {
         if (corefLocation.Contains(","))
         {
             nodeCollection.AddSplitNode(GetSplitNode(root, corefLocation));
         }
         else
         {
             nodeCollection.AddSingleNode(root.GetNode(corefLocation));
         }
     }
 }