Given that the parse forest is a binary tree, a dictionary can be passed into a disambiguation algorithm that tells each node which child to traverse. The disambiguation algorithm is responsible for tracking the current node index which increments every time the function is called.
namespace Pliant.Forest
{
public class ChildSelectDisambiguationAlgorithm : IForestDisambiguationAlgorithm
{
IList<int> _childIndexes ;
int _index ;
public IList<int> ChildIndexes { get { return _childIndexes; } }
public ChildSelectDisambiguationAlgorithm()
{
_childIndexes = new List<int>();
_index = 0;
}
public ChildSelectDisambiguationAlgorithm(IEnumerable<int> childIndexes)
{
_childIndexes = new List<int>(childIndexes);
_index = 0;
}
public IAndForestNode GetCurrentAndNode(IInternalForestNode internalNode)
{
_index ++;
childIndex = _childIndexes [index] ;
return internalNode.Children[childIndex];
}
}
}
Given that the parse forest is a binary tree, a dictionary can be passed into a disambiguation algorithm that tells each node which child to traverse. The disambiguation algorithm is responsible for tracking the current node index which increments every time the function is called.