当前位置: 首页>>代码示例>>Java>>正文


Java AttributeSource.getAttribute方法代码示例

本文整理汇总了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);
  }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:13,代码来源:FieldInvertState.java

示例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;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:35,代码来源:SlowSynonymFilter.java

示例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);
            }
        }
    }
}
 
开发者ID:jprante,项目名称:elasticsearch-analysis-opennlp,代码行数:15,代码来源:OpenNLPTokenFilter.java

示例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);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:6,代码来源:ShingleFilter.java

示例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");
}
 
开发者ID:europeana,项目名称:search,代码行数:6,代码来源:TestTeeSinkTokenFilter.java

示例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);
}
 
开发者ID:ziqizhang,项目名称:jate,代码行数:7,代码来源:ComplexShingleFilter.java


注:本文中的org.apache.lucene.util.AttributeSource.getAttribute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。