当前位置: 首页>>代码示例>>C#>>正文


C# AttributeSource.GetAttribute方法代码示例

本文整理汇总了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>();
 }
开发者ID:ChristopherHaws,项目名称:lucenenet,代码行数:7,代码来源:ShingleFilter.cs

示例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;
        }
开发者ID:ChristopherHaws,项目名称:lucenenet,代码行数:75,代码来源:ThaiWordFilter.cs


注:本文中的Lucene.Net.Util.AttributeSource.GetAttribute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。