示例#1
0
        //internal void GetGraphHelper(Graph g) {
        //	//g.Add(this);
        //	bool changes = false;
        //	var myNode = new NodeNode(this, 0);
        //	foreach (var children in _children) {
        //		var childNode = new ChildNode(_family.Production.Rhs, StartPosition, EndPosition);
        //		changes |= g.AddEdge(myNode, childNode);
        //		foreach (var child in children) {
        //			var mychildNode = new NodeNode(child, 0);
        //			changes |= g.AddEdge(childNode, mychildNode);
        //		}
        //	}
        //	if (changes) {
        //		foreach (var children in _children) {
        //			foreach (var child in children) {
        //				child.GetGraphHelper(g);
        //			}
        //		}
        //	}
        //}

        private static void AddNode(SppfNode node, List <ForestNode[]> startList, Sentence rhs, int position)
        {
            ForestNode nodeToAdd;

            if (node is TerminalNode)
            {
                nodeToAdd = new ForestLeaf((TerminalNode)node);
            }
            else
            {
                nodeToAdd = new ForestInternal((SymbolNode)node, (Nonterminal)rhs[position]);
            }
            foreach (var children in startList)
            {
                children[position] = nodeToAdd;
            }
        }
示例#2
0
		public SppfNodeNode(SppfNode node, int rank) {
			Node = node;
			Rank = rank;
		}
示例#3
0
		//internal void GetGraphHelper(Graph g) {
		//	//g.Add(this);
		//	bool changes = false;
		//	var myNode = new NodeNode(this, 0);
		//	foreach (var children in _children) {
		//		var childNode = new ChildNode(_family.Production.Rhs, StartPosition, EndPosition);
		//		changes |= g.AddEdge(myNode, childNode);
		//		foreach (var child in children) {
		//			var mychildNode = new NodeNode(child, 0);
		//			changes |= g.AddEdge(childNode, mychildNode);
		//		}
		//	}
		//	if (changes) {
		//		foreach (var children in _children) {
		//			foreach (var child in children) {
		//				child.GetGraphHelper(g);
		//			}
		//		}
		//	}
		//}

		private static void AddNode(SppfNode node, List<ForestNode[]> startList, Sentence rhs, int position) {
			ForestNode nodeToAdd;
			if (node is TerminalNode) {
				nodeToAdd = new ForestLeaf((TerminalNode)node);
			} else {
				nodeToAdd = new ForestInternal((SymbolNode)node, (Nonterminal)rhs[position]);
			}
			foreach (var children in startList) {
				children[position] = nodeToAdd;
			}
		}
示例#4
0
 internal Family(InteriorNode node1, SppfNode node2)
 {
     _nodes.Add(node1);
     _nodes.Add(node2);
 }
示例#5
0
 internal Family(SppfNode node1)
 {
     _nodes.Add(node1);
 }
示例#6
0
		internal Family(InteriorNode node1, SppfNode node2) {
			_nodes.Add(node1);
			_nodes.Add(node2);
		}
示例#7
0
		internal Family(SppfNode node1) {
			_nodes.Add(node1);
		}