本文整理匯總了Java中org.apache.lucene.analysis.tokenattributes.CharTermAttribute.setLength方法的典型用法代碼示例。如果您正苦於以下問題:Java CharTermAttribute.setLength方法的具體用法?Java CharTermAttribute.setLength怎麽用?Java CharTermAttribute.setLength使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.lucene.analysis.tokenattributes.CharTermAttribute
的用法示例。
在下文中一共展示了CharTermAttribute.setLength方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: stemHinglish
import org.apache.lucene.analysis.tokenattributes.CharTermAttribute; //導入方法依賴的package包/類
public static void stemHinglish(CharTermAttribute termAtt)
{
char [] buffer = termAtt.buffer();
String strInput = new String(termAtt.toString());
//System.out.println("Before " + strInput + " " + termAtt.toString());
Iterator itr = lsRegexs.iterator();
while (itr.hasNext())
{
List<Object> lsInputs = (List<Object>)itr.next();
Matcher matcher = ((Pattern)lsInputs.get(0)).matcher(strInput);
if (matcher.matches())
{
Matcher replMatcher = ((Pattern)lsInputs.get(1)).matcher(strInput);
strInput = replMatcher.replaceAll((String)lsInputs.get(2));
}
}
//strInput = strInput.trim();
for (int iCounter = 0; iCounter < strInput.length(); iCounter++)
{
buffer[iCounter] = strInput.charAt(iCounter);
}
termAtt.setLength(strInput.length());
//System.out.println("After " + strInput + " " + termAtt.toString());
}
示例2: 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));
}