本文整理汇总了C#中Lucene.Net.Util.AttributeSource.GetAttribute方法的典型用法代码示例。如果您正苦于以下问题:C# AttributeSource.GetAttribute方法的具体用法?C# AttributeSource.GetAttribute怎么用?C# AttributeSource.GetAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Lucene.Net.Util.AttributeSource
的用法示例。
在下文中一共展示了AttributeSource.GetAttribute方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InputWindowToken
public InputWindowToken(ShingleFilter outerInstance, AttributeSource attSource)
{
this.outerInstance = outerInstance;
this.attSource = attSource;
this.termAtt = attSource.GetAttribute<ICharTermAttribute>();
this.offsetAtt = attSource.GetAttribute<IOffsetAttribute>();
}
示例2: IncrementToken
public override bool IncrementToken()
{
if (hasMoreTokensInClone)
{
int start = breaker.Current();
int end = breaker.Next();
if (end != BreakIterator.DONE)
{
clonedToken.CopyTo(this);
termAtt.CopyBuffer(clonedTermAtt.Buffer(), start, end - start);
if (hasIllegalOffsets)
{
offsetAtt.SetOffset(clonedOffsetAtt.StartOffset(), clonedOffsetAtt.EndOffset());
}
else
{
offsetAtt.SetOffset(clonedOffsetAtt.StartOffset() + start, clonedOffsetAtt.StartOffset() + end);
}
if (handlePosIncr)
{
posAtt.PositionIncrement = 1;
}
return true;
}
hasMoreTokensInClone = false;
}
if (!input.IncrementToken())
{
return false;
}
if (termAtt.Length == 0 || !Regex.IsMatch(termAtt.ToString().Substring(0, 1), @"\p{IsThai}"))
{
return true;
}
hasMoreTokensInClone = true;
// if length by start + end offsets doesn't match the term text then assume
// this is a synonym and don't adjust the offsets.
hasIllegalOffsets = offsetAtt.EndOffset() - offsetAtt.StartOffset() != termAtt.Length;
// we lazy init the cloned token, as in ctor not all attributes may be added
if (clonedToken == null)
{
clonedToken = CloneAttributes();
clonedTermAtt = clonedToken.GetAttribute<ICharTermAttribute>();
clonedOffsetAtt = clonedToken.GetAttribute<IOffsetAttribute>();
}
else
{
this.CopyTo(clonedToken);
}
// reinit CharacterIterator
charIterator.SetText(clonedTermAtt.Buffer(), 0, clonedTermAtt.Length);
breaker.SetText(new string(charIterator.Text, charIterator.Start, charIterator.Length));
int end2 = breaker.Next();
if (end2 != BreakIterator.DONE)
{
termAtt.Length = end2;
if (hasIllegalOffsets)
{
offsetAtt.SetOffset(clonedOffsetAtt.StartOffset(), clonedOffsetAtt.EndOffset());
}
else
{
offsetAtt.SetOffset(clonedOffsetAtt.StartOffset(), clonedOffsetAtt.StartOffset() + end2);
}
// position increment keeps as it is for first token
return true;
}
return false;
}