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


Java Spans.getPayload方法代码示例

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


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

示例1: getPayloads

import org.apache.lucene.search.spans.Spans; //导入方法依赖的package包/类
private void getPayloads(Collection<byte []> payloads, SpanQuery query)
    throws IOException {
  Map<Term,TermContext> termContexts = new HashMap<>();
  TreeSet<Term> terms = new TreeSet<>();
  query.extractTerms(terms);
  for (Term term : terms) {
    termContexts.put(term, TermContext.build(context, term));
  }
  for (AtomicReaderContext atomicReaderContext : context.leaves()) {
    final Spans spans = query.getSpans(atomicReaderContext, atomicReaderContext.reader().getLiveDocs(), termContexts);
    while (spans.next() == true) {
      if (spans.isPayloadAvailable()) {
        Collection<byte[]> payload = spans.getPayload();
        for (byte [] bytes : payload) {
          payloads.add(bytes);
        }
      }
    }
  }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:21,代码来源:PayloadSpanUtil.java

示例2: getPayloads

import org.apache.lucene.search.spans.Spans; //导入方法依赖的package包/类
private void getPayloads(Collection<byte []> payloads, SpanQuery query)
    throws IOException {
  Map<Term,TermContext> termContexts = new HashMap<Term,TermContext>();
  TreeSet<Term> terms = new TreeSet<Term>();
  query.extractTerms(terms);
  for (Term term : terms) {
    termContexts.put(term, TermContext.build(context, term, true));
  }
  for (AtomicReaderContext atomicReaderContext : context.leaves()) {
    final Spans spans = query.getSpans(atomicReaderContext, atomicReaderContext.reader().getLiveDocs(), termContexts);
    while (spans.next() == true) {
      if (spans.isPayloadAvailable()) {
        Collection<byte[]> payload = spans.getPayload();
        for (byte [] bytes : payload) {
          payloads.add(bytes);
        }
      }
    }
  }
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:21,代码来源:PayloadSpanUtil.java

示例3: getPayloads

import org.apache.lucene.search.spans.Spans; //导入方法依赖的package包/类
private void getPayloads(Collection<byte []> payloads, SpanQuery query)
    throws IOException {
  Map<Term,TermContext> termContexts = new HashMap<Term,TermContext>();
  TreeSet<Term> terms = new TreeSet<Term>();
  query.extractTerms(terms);
  for (Term term : terms) {
    termContexts.put(term, TermContext.build(context, term));
  }
  for (AtomicReaderContext atomicReaderContext : context.leaves()) {
    final Spans spans = query.getSpans(atomicReaderContext, atomicReaderContext.reader().getLiveDocs(), termContexts);
    while (spans.next() == true) {
      if (spans.isPayloadAvailable()) {
        Collection<byte[]> payload = spans.getPayload();
        for (byte [] bytes : payload) {
          payloads.add(bytes);
        }
      }
    }
  }
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:21,代码来源:PayloadSpanUtil.java

示例4: getSpanInfo

import org.apache.lucene.search.spans.Spans; //导入方法依赖的package包/类
public static List<String> getSpanInfo (IndexReader reader, SpanQuery query)
        throws IOException {
    Map<Term, TermContext> termContexts = new HashMap<>();
    List<String> spanArray = new ArrayList<>();

    for (LeafReaderContext atomic : reader.leaves()) {
        Bits bitset = atomic.reader().getLiveDocs();
        // Spans spans = NearSpansOrdered();
        Spans spans = query.getSpans(atomic, bitset, termContexts);

        while (spans.next()) {
            StringBuffer payloadString = new StringBuffer();
            int docid = atomic.docBase + spans.doc();
            if (spans.isPayloadAvailable()) {
                for (byte[] payload : spans.getPayload()) {
                    /* retrieve payload for current matching span */

                    payloadString.append(byte2int(payload)).append(",");
                    payloadString.append(byte2int(payload, 2));
                    //			payloadString.append(byte2int(payload, 1));
                    payloadString.append(" (" + payload.length + ")");
                    payloadString.append(" | ");
                };
            };
            spanArray.add("Doc: " + docid + " with " + spans.start() + "-"
                    + spans.end() + " || " + payloadString.toString());
        };
    };
    return spanArray;
}
 
开发者ID:KorAP,项目名称:Krill,代码行数:31,代码来源:TestSimple.java

示例5: getSnippet

import org.apache.lucene.search.spans.Spans; //导入方法依赖的package包/类
@Override
    public String getSnippet() throws InterruptedException {
        try {
            List<Query> stqs = new ArrayList<>();
            List<Query> nstqs = new ArrayList<>();
            getSpanTermQueries(query, stqs, nstqs);
            List<Span> formSpans = new ArrayList<>();
            for (Query q : stqs) {
                for (AtomicReaderContext context : indexReader.leaves()) {
                    if (Thread.currentThread().isInterrupted()) {
                        throw new InterruptedException("Snippet extraction thread interrupted during processing");
                    }
                    Spans spans = ((SpanTermQuery) q).getSpans(context, null, new HashMap());
                    spans.skipTo(docNumber - context.docBase - 1);
                    boolean cont = true;
                    boolean contextFound = false;
                    while (cont) {
                        int contextSpanDocNumber = context.docBase + spans.doc();
//                        System.out.println(contextSpanDocNumber);
                        if (docNumber == contextSpanDocNumber) {
                            contextFound = true;
                            cont = docNumber - contextSpanDocNumber >= 0;
                            Collection<byte[]> payloads = spans.getPayload();
                            formSpans.add(new Span(spans.doc(), q.toString(), spans.start(), cz.muni.fi.mias.math.PayloadHelper.decodeFloatFromShortBytes(payloads.iterator().next())));
                        }
                        if (!spans.next()) {
                            cont = false;
                        }
                    }
                    if (contextFound) {
                        break;
                    }
                }
            }
            return getSnippet(formSpans, nstqs);
        } catch (IOException ex) {
            LOG.fatal(ex);
        }
        return "";
    }
 
开发者ID:martinliska,项目名称:MIaS,代码行数:41,代码来源:NiceSnippetExtractor.java


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