private SlowSynonymMap Match(SlowSynonymMap map)
{
SlowSynonymMap result = null;
if (map.submap != null)
{
AttributeSource tok = NextTok();
if (tok != null)
{
// clone ourselves.
if (tok == this)
{
tok = CloneAttributes();
}
// check for positionIncrement!=1? if>1, should not match, if==0, check multiple at this level?
var termAtt = tok.GetAttribute<ICharTermAttribute>();
SlowSynonymMap subMap = map.submap.Get(termAtt.Buffer(), 0, termAtt.Length);
if (subMap != null)
{
// recurse
result = Match(subMap);
}
if (result != null)
{
matched.AddFirst(tok);
}
else
{
// push back unmatched token
PushTok(tok);
}
}
}
// if no longer sequence matched, so if this node has synonyms, it's the match.
if (result == null && map.synonyms != null)
{
result = map;
}
return result;
}