本文整理汇总了Java中org.apache.lucene.util.AttributeSource.getAttribute方法的典型用法代码示例。如果您正苦于以下问题:Java AttributeSource.getAttribute方法的具体用法?Java AttributeSource.getAttribute怎么用?Java AttributeSource.getAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.lucene.util.AttributeSource
的用法示例。
在下文中一共展示了AttributeSource.getAttribute方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setAttributeSource
import org.apache.lucene.util.AttributeSource; //导入方法依赖的package包/类
/**
* Sets attributeSource to a new instance.
*/
void setAttributeSource(AttributeSource attributeSource) {
if (this.attributeSource != attributeSource) {
this.attributeSource = attributeSource;
termAttribute = attributeSource.getAttribute(TermToBytesRefAttribute.class);
posIncrAttribute = attributeSource.addAttribute(PositionIncrementAttribute.class);
offsetAttribute = attributeSource.addAttribute(OffsetAttribute.class);
payloadAttribute = attributeSource.getAttribute(PayloadAttribute.class);
}
}
示例2: match
import org.apache.lucene.util.AttributeSource; //导入方法依赖的package包/类
private SlowSynonymMap match(SlowSynonymMap map) throws IOException {
SlowSynonymMap result = null;
if (map.submap != null) {
AttributeSource tok = nextTok();
if (tok != null) {
// clone ourselves.
if (tok == this)
tok = cloneAttributes();
// check for positionIncrement!=1? if>1, should not match, if==0, check multiple at this level?
CharTermAttribute termAtt = tok.getAttribute(CharTermAttribute.class);
SlowSynonymMap subMap = map.submap.get(termAtt.buffer(), 0, termAtt.length());
if (subMap != null) {
// recurse
result = match(subMap);
}
if (result != null) {
matched.addFirst(tok);
} else {
// push back unmatched token
pushTok(tok);
}
}
}
// if no longer sequence matched, so if this node has synonyms, it's the match.
if (result==null && map.synonyms!=null) {
result = map;
}
return result;
}
示例3: appendPayloads
import org.apache.lucene.util.AttributeSource; //导入方法依赖的package包/类
private void appendPayloads(String[] tags, int length) {
for (int i = 0; i < length; i++) {
AttributeSource attrs = tokenAttrs.get(i);
if (tags[i] != null) {
try {
PayloadAttribute payloadAtt = attrs.hasAttribute(PayloadAttribute.class) ? attrs.getAttribute(PayloadAttribute.class) : attrs.addAttribute(PayloadAttribute.class);
BytesRef bytesRef = new BytesRef(tags[i].toUpperCase(Locale.getDefault()).getBytes("UTF-8"));
payloadAtt.setPayload(bytesRef);
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
}
}
}
示例4: InputWindowToken
import org.apache.lucene.util.AttributeSource; //导入方法依赖的package包/类
public InputWindowToken(AttributeSource attSource) {
this.attSource = attSource;
this.termAtt = attSource.getAttribute(CharTermAttribute.class);
this.offsetAtt = attSource.getAttribute(OffsetAttribute.class);
}
示例5: accept
import org.apache.lucene.util.AttributeSource; //导入方法依赖的package包/类
@Override
public boolean accept(AttributeSource a) {
CharTermAttribute termAtt = a.getAttribute(CharTermAttribute.class);
return termAtt.toString().equalsIgnoreCase("The");
}
示例6: InputWindowToken
import org.apache.lucene.util.AttributeSource; //导入方法依赖的package包/类
public InputWindowToken(AttributeSource attSource) {
this.attSource = attSource;
this.termAtt = attSource.getAttribute(CharTermAttribute.class);
this.offsetAtt = attSource.getAttribute(OffsetAttribute.class);
this.sentenceContext = attSource.getAttribute(PayloadAttribute.class);
}