本文整理汇总了C#中Token.SetTermBuffer方法的典型用法代码示例。如果您正苦于以下问题:C# Token.SetTermBuffer方法的具体用法?C# Token.SetTermBuffer怎么用?C# Token.SetTermBuffer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Token
的用法示例。
在下文中一共展示了Token.SetTermBuffer方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetNextSuffixInputToken
private Token GetNextSuffixInputToken(Token token)
{
if (!Suffix.IncrementToken()) return null;
token.SetTermBuffer(_termAtt.TermBuffer(), 0, _termAtt.TermLength());
token.PositionIncrement = _posIncrAtt.PositionIncrement;
token.Flags = _flagsAtt.Flags;
token.SetOffset(_offsetAtt.StartOffset, _offsetAtt.EndOffset);
token.Type = _typeAtt.Type;
token.Payload = _payloadAtt.Payload;
return token;
}
示例2: ProduceNextToken
/// <summary>
/// This method exists in order to avoid recursive calls to the method
/// as the complexity of a fairly small matrix then easily would require
/// a gigabyte sized stack per thread.
/// </summary>
/// <param name="reusableToken"></param>
/// <returns>null if exhausted, instance request_next_token if one more call is required for an answer,
/// or instance parameter resuableToken.</returns>
private Token ProduceNextToken(Token reusableToken)
{
if (_currentPermuationTokens != null)
{
_currentShingleLength++;
if (_currentShingleLength + _currentPermutationTokensStartOffset <= _currentPermuationTokens.Count
&& _currentShingleLength <= MaximumShingleSize)
{
// it is possible to create at least one more shingle of the current matrix permutation
if (IsIgnoringSinglePrefixOrSuffixShingle &&
_currentShingleLength == 1 &&
(_currentPermutationRows[_currentPermutationTokensStartOffset].Column.IsFirst || _currentPermutationRows[_currentPermutationTokensStartOffset].Column.IsLast))
{
return GetNextToken(reusableToken);
}
var termLength = 0;
var shingle = new EquatableList<Token>();
for (int i = 0; i < _currentShingleLength; i++)
{
var shingleToken = _currentPermuationTokens[i + _currentPermutationTokensStartOffset];
termLength += shingleToken.TermLength();
shingle.Add(shingleToken);
}
if (SpacerCharacter != null)
termLength += _currentShingleLength - 1;
// only produce shingles that not already has been created
if (!_shinglesSeen.Add(shingle))
return _requestNextToken;
// shingle token factory
var sb = new StringBuilder(termLength + 10); // paranormal ability to foresee the future. ;)
foreach (var shingleToken in shingle)
{
if (SpacerCharacter != null && sb.Length > 0)
sb.Append(SpacerCharacter);
sb.Append(shingleToken.TermBuffer(), 0, shingleToken.TermLength());
}
reusableToken.SetTermBuffer(sb.ToString());
UpdateToken(reusableToken, shingle, _currentPermutationTokensStartOffset, _currentPermutationRows,
_currentPermuationTokens);
return reusableToken;
}
// it is NOT possible to create one more shingles of the current matrix permutation
if (_currentPermutationTokensStartOffset < _currentPermuationTokens.Count - 1)
{
// reset shingle size and move one step to the right in the current tokens permutation
_currentPermutationTokensStartOffset++;
_currentShingleLength = MinimumShingleSize - 1;
return _requestNextToken;
}
// todo does this ever occur?
if (_permutations == null)
return null;
if (!_permutations.HasNext())
{
// load more data (if available) to the matrix
// don't really care, we just read it.
if (_input != null)
ReadColumn();
// get rid of resources
// delete the first column in the matrix
var deletedColumn = Matrix.Columns[0];
Matrix.Columns.RemoveAt(0);
// remove all shingles seen that include any of the tokens from the deleted column.
var deletedColumnTokens = deletedColumn.Rows.SelectMany(row => row.Tokens).ToList();
// I'm a little concerned about this part of the code, because the unit tests currently
// don't cover this scenario. (I put a break point here, and ran the unit tests in debug mode
// and this code block was never hit... I also changed it significatly from the Java version
// to use RemoveWhere and LINQ.
//
// TODO: Write a unit test to cover this and make sure this is a good port! -thoward
// linq version
_shinglesSeen.RemoveWhere(
shingle => (shingle.Find(deletedColumnTokens.Contains) != default(Token)));
//.........这里部分代码省略.........
示例3: GetText
/// <summary> Fills Lucene token with the current token text.</summary>
internal void GetText(Token t)
{
t.SetTermBuffer(zzBuffer, zzStartRead, zzMarkedPos - zzStartRead);
}
示例4: GetNextInputToken
private Token GetNextInputToken(Token token)
{
if (!_input.IncrementToken()) return null;
token.SetTermBuffer(_inTermAtt.TermBuffer(), 0, _inTermAtt.TermLength());
token.PositionIncrement = _inPosIncrAtt.PositionIncrement;
token.Flags = _inFlagsAtt.Flags;
token.SetOffset(_inOffsetAtt.StartOffset, _inOffsetAtt.EndOffset);
token.Type = _inTypeAtt.Type;
token.Payload = _inPayloadAtt.Payload;
return token;
}