本文整理汇总了C#中Lucene.Net.Analysis.Token.SetPayload方法的典型用法代码示例。如果您正苦于以下问题:C# Token.SetPayload方法的具体用法?C# Token.SetPayload怎么用?C# Token.SetPayload使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Lucene.Net.Analysis.Token
的用法示例。
在下文中一共展示了Token.SetPayload方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetNextInputToken
private Token GetNextInputToken(Token token)
{
if (!_input.IncrementToken()) return null;
token.SetTermBuffer(_inTermAtt.TermBuffer(), 0, _inTermAtt.TermLength());
token.SetPositionIncrement(_inPosIncrAtt.GetPositionIncrement());
token.SetFlags(_inFlagsAtt.GetFlags());
token.SetOffset(_inOffsetAtt.StartOffset(), _inOffsetAtt.EndOffset());
token.SetType(_inTypeAtt.Type());
token.SetPayload(_inPayloadAtt.GetPayload());
return token;
}
示例2: SetWeight
/// <summary>
/// Stores a 32 bit float in the payload, or set it to null if 1f;
/// </summary>
/// <param name="token"></param>
/// <param name="weight"></param>
public override void SetWeight(Token token, float weight)
{
token.SetPayload(
weight == 1f
? null
: new Payload(PayloadHelper.EncodeFloat(weight))
);
}
示例3: TestCopyTo
public virtual void TestCopyTo()
{
Token t = new Token();
Token copy = (Token) TestSimpleAttributeImpls.AssertCopyIsEqual(t);
Assert.AreEqual("", t.Term());
Assert.AreEqual("", copy.Term());
t = new Token(0, 5);
char[] content = "hello".ToCharArray();
t.SetTermBuffer(content, 0, 5);
char[] buf = t.TermBuffer();
copy = (Token) TestSimpleAttributeImpls.AssertCopyIsEqual(t);
Assert.AreEqual(t.Term(), copy.Term());
Assert.AreNotSame(buf, copy.TermBuffer());
Payload pl = new Payload(new byte[]{1, 2, 3, 4});
t.SetPayload(pl);
copy = (Token) TestSimpleAttributeImpls.AssertCopyIsEqual(t);
Assert.AreEqual(pl, copy.GetPayload());
Assert.AreNotSame(pl, copy.GetPayload());
}
示例4: GetNextSuffixInputToken
private Token GetNextSuffixInputToken(Token token)
{
if (!Suffix.IncrementToken()) return null;
token.SetTermBuffer(_termAtt.TermBuffer(), 0, _termAtt.TermLength());
token.SetPositionIncrement(_posIncrAtt.GetPositionIncrement());
token.SetFlags(_flagsAtt.GetFlags());
token.SetOffset(_offsetAtt.StartOffset(), _offsetAtt.EndOffset());
token.SetType(_typeAtt.Type());
token.SetPayload(_payloadAtt.GetPayload());
return token;
}
示例5: Next
public override Token Next(Token target)
{
target = input.Next(target);
if (target == null)
return null;
target.SetPayload(p); // reuse the payload / byte[]
data[0]++;
return target;
}
示例6: Next
public override Token Next(Token result)
{
if (buffered != null)
{
Token t = buffered;
buffered = null;
return t;
}
Token t2 = input.Next(result);
if (t2 == null)
return null;
if (System.Char.IsDigit(t2.TermBuffer()[0]))
{
t2.SetPositionIncrement(t2.TermBuffer()[0] - '0');
}
if (first)
{
// set payload on first position only
t2.SetPayload(new Payload(new byte[]{100}));
first = false;
}
// index a "synonym" for every token
buffered = (Token) t2.Clone();
buffered.SetPayload(null);
buffered.SetPositionIncrement(0);
buffered.SetTermBuffer(new char[]{'b'}, 0, 1);
return t2;
}