本文整理汇总了C#中ICharTermAttribute.ResizeBuffer方法的典型用法代码示例。如果您正苦于以下问题:C# ICharTermAttribute.ResizeBuffer方法的具体用法?C# ICharTermAttribute.ResizeBuffer怎么用?C# ICharTermAttribute.ResizeBuffer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ICharTermAttribute
的用法示例。
在下文中一共展示了ICharTermAttribute.ResizeBuffer方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: KeywordTokenizer
public KeywordTokenizer(AttributeSource.AttributeFactory factory, Reader input, int bufferSize)
: base(factory, input)
{
termAtt = AddAttribute<ICharTermAttribute>();
offsetAtt = AddAttribute<IOffsetAttribute>();
if (bufferSize <= 0)
{
throw new System.ArgumentException("bufferSize must be > 0");
}
termAtt.ResizeBuffer(bufferSize);
}
示例2: ReversePathHierarchyTokenizer
public ReversePathHierarchyTokenizer(AttributeFactory factory, TextReader input, int bufferSize, char delimiter, char replacement, int skip)
: base(factory, input)
{
if (bufferSize < 0)
{
throw new System.ArgumentException("bufferSize cannot be negative");
}
if (skip < 0)
{
throw new System.ArgumentException("skip cannot be negative");
}
termAtt = AddAttribute<ICharTermAttribute>();
offsetAtt = AddAttribute<IOffsetAttribute>();
posAtt = AddAttribute<IPositionIncrementAttribute>();
termAtt.ResizeBuffer(bufferSize);
this.delimiter = delimiter;
this.replacement = replacement;
this.skip = skip;
resultToken = new StringBuilder(bufferSize);
resultTokenBuffer = new char[bufferSize];
delimiterPositions = new List<int>(bufferSize / 10);
}
示例3: Init
private void Init(LuceneVersion version, int minGram, int maxGram, bool edgesOnly)
{
#pragma warning disable 612, 618
if (!version.OnOrAfter(LuceneVersion.LUCENE_44))
#pragma warning restore 612, 618
{
throw new System.ArgumentException("This class only works with Lucene 4.4+. To emulate the old (broken) behavior of NGramTokenizer, use Lucene43NGramTokenizer/Lucene43EdgeNGramTokenizer");
}
#pragma warning disable 612, 618
charUtils = version.OnOrAfter(LuceneVersion.LUCENE_44) ?
#pragma warning restore 612, 618
CharacterUtils.GetInstance(version) : CharacterUtils.Java4Instance;
if (minGram < 1)
{
throw new System.ArgumentException("minGram must be greater than zero");
}
if (minGram > maxGram)
{
throw new System.ArgumentException("minGram must not be greater than maxGram");
}
termAtt = AddAttribute<ICharTermAttribute>();
posIncAtt = AddAttribute<IPositionIncrementAttribute>();
posLenAtt = AddAttribute<IPositionLengthAttribute>();
offsetAtt = AddAttribute<IOffsetAttribute>();
this.minGram = minGram;
this.maxGram = maxGram;
this.edgesOnly = edgesOnly;
charBuffer = CharacterUtils.NewCharacterBuffer(2 * maxGram + 1024); // 2 * maxGram in case all code points require 2 chars and + 1024 for buffering to not keep polling the Reader
buffer = new int[charBuffer.Buffer.Length];
// Make the term att large enough
termAtt.ResizeBuffer(2 * maxGram);
}