Example #1
0
 private void AddChildNodes(ShapeBase currentShape, Parse[] childParses)
 {
     foreach (Parse childParse in childParses)
     {
         // if this is not a token node (token node = one of the words of the sentence)
         if (childParse.Type != MaximumEntropyParser.TokenNode)
         {
             ShapeBase childShape = currentShape.AddChild(childParse.Type);
             if (childParse.IsPosTag)
             {
                 childShape.ShapeColor = Color.DarkGoldenrod;
             }
             else
             {
                 childShape.ShapeColor = Color.SteelBlue;
             }
             AddChildNodes(childShape, childParse.GetChildren());
             childShape.Expand();
         }
         else
         {
             Span parseSpan = childParse.Span;
             string token = childParse.Text.Substring(parseSpan.Start, (parseSpan.End) - (parseSpan.Start));
             ShapeBase childShape = currentShape.AddChild(token);
             childShape.ShapeColor = Color.Ivory;
         }
     }
 }
Example #2
0
        /// <summary>
        /// Adds a child node to the currently selected one
        /// </summary>
        public void AddChild()
        {
            if (selectedEntity == null)
            {
                return;
            }

            ShapeBase sh = selectedEntity as ShapeBase;

            if (sh != null)
            {
                sh.AddChild("New node");
                DrawTree();
            }
        }
Example #3
0
        /// <summary>
        /// Adds a random node to the diagram
        /// </summary>
        /// <param name="newName">the text of the newly added shape</param>
        public void AddRandomNode(string newName)
        {
            //Random rnd = new Random();

            int max = Shapes.Count - 1;

            if (max < 0)
            {
                return;
            }

            ShapeBase shape = Shapes[rnd.Next(0, max)];

            shape.AddChild(newName);

            DrawTree();
        }