本文整理匯總了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));
}