Example #1
0
bool genUnaryNode_io_old(RuleSet& ruleSet,Node& node)
{
	bool mark=false;
	clock_t sec=clock();
	node.setUnaryInOrder(ruleSet);
	setutime+=clock()-sec;
	vector<LabelAndFamily>& uio=node.unaryInOrder();
	for(int i=0;(size_t)i<uio.size();i++)
	{
		LabelAndFamily& laf=uio[i];
		Label& oldLb=node[laf.term()];
		string rightPart=oldLb.nt();
		if(ruleSet.count(rightPart)>0)
		{
			int count=0;
			pair<RuleSet::RSIter,RuleSet::RSIter> iterPair=ruleSet.query(rightPart);
			for(RuleSet::RSIter iter=iterPair.first;iter!=iterPair.second;iter++)
			{
				string leftPart=iter->second.left;
				if(laf.ancestor().count(leftPart)>0)
				{
					double ruleScore=iter->second.prob;
					if(node.find(leftPart)==node.end())
					{
						Label newLabel;
						newLabel.init(leftPart,oldLb.start(),oldLb.stop());
						node[leftPart]=newLabel;
					}
					//jout<<"\n"<<leftPart<<"--->add Child: "<<rightPart<<endl;
					node[leftPart].addChild_io(&oldLb,ruleScore);
					mark=true;
				}
			}
		}
	}
	return mark;
}