本文整理汇总了Java中org.apache.lucene.analysis.tokenattributes.CharTermAttribute.append方法的典型用法代码示例。如果您正苦于以下问题:Java CharTermAttribute.append方法的具体用法?Java CharTermAttribute.append怎么用?Java CharTermAttribute.append使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.lucene.analysis.tokenattributes.CharTermAttribute
的用法示例。
在下文中一共展示了CharTermAttribute.append方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: incrementToken
import org.apache.lucene.analysis.tokenattributes.CharTermAttribute; //导入方法依赖的package包/类
@Override
public final boolean incrementToken() throws IOException {
if (input.incrementToken()) {
CharTermAttribute termAtt = this.getAttribute(CharTermAttribute.class);
termAtt.setEmpty();
termAtt.append(token);
return true;
} else
return false;
}
示例2: incrementToken
import org.apache.lucene.analysis.tokenattributes.CharTermAttribute; //导入方法依赖的package包/类
@Override
public final boolean incrementToken() throws IOException {
if (input.incrementToken()) {
CharTermAttribute termAtt = this.getAttribute(CharTermAttribute.class);
final String term = termAtt.toString();
termAtt.setEmpty();
PayloadAttribute payloadAtt = this.getAttribute(PayloadAttribute.class);
final BytesRef payload = payloadAtt.getPayload();
if(payload == null) {
return true;
}
float payloadValue = PayloadHelper.decodeFloat(payload.bytes, payload.offset);
if(payloadValue == 0.0f){
return true;
}
String weight = Float.toString(payloadValue);
// set weights to zero if in scientific notation
if(weight.contains("E-")){
return true;
}
String boostedTerm = term + "^" + weight;
termAtt.append(boostedTerm);
return true;
}
return false;
}
示例3: setAttributes
import org.apache.lucene.analysis.tokenattributes.CharTermAttribute; //导入方法依赖的package包/类
protected void setAttributes(String token, float payload) {
CharTermAttribute termAtt = this.getAttribute(CharTermAttribute.class);
termAtt.setEmpty();
termAtt.append(token);
termAtt.setLength(token.length());
PayloadAttribute payloadAtt = this.getAttribute(PayloadAttribute.class);
byte[] bytes = PayloadHelper.encodeFloat(payload);
payloadAtt.setPayload(new BytesRef(bytes));
}