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