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


Java PayloadAttribute.setPayload方法代码示例

本文整理汇总了Java中org.apache.lucene.analysis.tokenattributes.PayloadAttribute.setPayload方法的典型用法代码示例。如果您正苦于以下问题:Java PayloadAttribute.setPayload方法的具体用法?Java PayloadAttribute.setPayload怎么用?Java PayloadAttribute.setPayload使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.lucene.analysis.tokenattributes.PayloadAttribute的用法示例。


在下文中一共展示了PayloadAttribute.setPayload方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setAttributes

import org.apache.lucene.analysis.tokenattributes.PayloadAttribute; //导入方法依赖的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));
}
 
开发者ID:DiceTechJobs,项目名称:RelevancyFeedback,代码行数:11,代码来源:MeanPayloadTokenFilter.java

示例2: appendPayloads

import org.apache.lucene.analysis.tokenattributes.PayloadAttribute; //导入方法依赖的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

示例3: incrementToken

import org.apache.lucene.analysis.tokenattributes.PayloadAttribute; //导入方法依赖的package包/类
@Override
public boolean incrementToken() throws IOException {
    if (input.incrementToken()) {
        PayloadAttribute payloadAtt = getAttribute(PayloadAttribute.class);
        if (payloadAtt != null) {
            payloadAtt.setPayload(null);
        }
        return true;
    }
    return false;
}
 
开发者ID:jprante,项目名称:elasticsearch-analysis-opennlp,代码行数:12,代码来源:StripPayloadsTokenFilter.java

示例4: createState

import org.apache.lucene.analysis.tokenattributes.PayloadAttribute; //导入方法依赖的package包/类
private static AttributeSource.State createState(AttributeSource a, Tok state, int tokenEnd) {
  a.clearAttributes();
  CharTermAttribute termAtt = a.addAttribute(CharTermAttribute.class);
  char[] tokChars = state.token.toString().toCharArray();
  termAtt.copyBuffer(tokChars, 0, tokChars.length);
  int tokenStart = tokenEnd - state.token.length();
  for (Entry<String, String> e : state.attr.entrySet()) {
    String k = e.getKey();
    if (k.equals("i")) {
      // position increment
      int incr = Integer.parseInt(e.getValue());
      PositionIncrementAttribute posIncr = a.addAttribute(PositionIncrementAttribute.class);
      posIncr.setPositionIncrement(incr);
    } else if (k.equals("s")) {
      tokenStart = Integer.parseInt(e.getValue());
    } else if (k.equals("e")) {
      tokenEnd = Integer.parseInt(e.getValue());
    } else if (k.equals("y")) {
      TypeAttribute type = a.addAttribute(TypeAttribute.class);
      type.setType(e.getValue());
    } else if (k.equals("f")) {
      FlagsAttribute flags = a.addAttribute(FlagsAttribute.class);
      int f = Integer.parseInt(e.getValue(), 16);
      flags.setFlags(f);
    } else if (k.equals("p")) {
      PayloadAttribute p = a.addAttribute(PayloadAttribute.class);
      byte[] data = hexToBytes(e.getValue());
      if (data != null && data.length > 0) {
        p.setPayload(new BytesRef(data));
      }
    } else {
      // unknown attribute
    }
  }
  // handle offset attr
  OffsetAttribute offset = a.addAttribute(OffsetAttribute.class);
  offset.setOffset(tokenStart, tokenEnd);
  State resState = a.captureState();
  a.clearAttributes();
  return resState;
}
 
开发者ID:europeana,项目名称:search,代码行数:42,代码来源:SimplePreAnalyzedParser.java

示例5: addPayloadAttribute

import org.apache.lucene.analysis.tokenattributes.PayloadAttribute; //导入方法依赖的package包/类
public void addPayloadAttribute(PayloadAttribute attribute, MWEMetadata ctx) {
    String data = MWEMetadata.serialize(ctx);
    attribute.setPayload(new BytesRef(data));
}
 
开发者ID:ziqizhang,项目名称:jate,代码行数:5,代码来源:OpenNLPTokenizer.java


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