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


Java PriorityQueue.size方法代码示例

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


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

示例1: buildDocHits

import org.apache.lucene.util.PriorityQueue; //导入方法依赖的package包/类
/** Construct the array of doc hits for the hit group. */
private void buildDocHits(int group, ResultGroup resultGroup) 
{
  PriorityQueue queue = hitQueue[group];
  int nFound = queue.size();
  DocHitImpl[] hitArray = new DocHitImpl[nFound];
  for (int i = 0; i < nFound; i++) {
    int index = nFound - i - 1;
    hitArray[index] = (DocHitImpl)queue.pop();
  }

  int start = startDoc[group];
  int max = maxDocs[group];

  int nHits = Math.max(0, Math.min(nFound - start, max));
  resultGroup.docHits = new DocHit[nHits];

  resultGroup.totalDocs = nDocHits(group);
  resultGroup.startDoc = start;
  resultGroup.endDoc = start + nHits;

  for (int i = startDoc[group]; i < nFound; i++)
    resultGroup.docHits[i - start] = hitArray[i];
}
 
开发者ID:CDLUC3,项目名称:dash-xtf,代码行数:25,代码来源:GroupCounts.java

示例2: bestTerms

import org.apache.lucene.util.PriorityQueue; //导入方法依赖的package包/类
private String [] bestTerms(String field,int numTerms) throws IOException {
  PriorityQueue<TermDf> pq = new TermsDfQueue(numTerms);
  IndexReader ir = DirectoryReader.open(dir);
  try {
    int threshold = ir.maxDoc() / 10; // ignore words too common.
    Terms terms = MultiFields.getTerms(ir, field);
    if (terms != null) {
      TermsEnum termsEnum = terms.iterator(null);
      while (termsEnum.next() != null) {
        int df = termsEnum.docFreq();
        if (df<threshold) {
          String ttxt = termsEnum.term().utf8ToString();
          pq.insertWithOverflow(new TermDf(ttxt,df));
        }
      }
    }
  } finally {
    ir.close();
  }
  String res[] = new String[pq.size()];
  int i = 0;
  while (pq.size()>0) {
    TermDf tdf = pq.pop(); 
    res[i++] = tdf.word;
    System.out.println(i+".   word:  "+tdf.df+"   "+tdf.word);
  }
  return res;
}
 
开发者ID:europeana,项目名称:search,代码行数:29,代码来源:QualityQueriesFinder.java

示例3: queueToList

import org.apache.lucene.util.PriorityQueue; //导入方法依赖的package包/类
private static List<TermAndFreq> queueToList(PriorityQueue<TermAndFreq> queue) {
  List<TermAndFreq> terms = new ArrayList<>();
  while (queue.size() > 0) {
    terms.add(queue.pop());
  }
  return terms;
}
 
开发者ID:europeana,项目名称:search,代码行数:8,代码来源:CommonTermsQueryTest.java

示例4: queueToList

import org.apache.lucene.util.PriorityQueue; //导入方法依赖的package包/类
private static List<TermAndFreq> queueToList(PriorityQueue<TermAndFreq> queue) {
  List<TermAndFreq> terms = new ArrayList<CommonTermsQueryTest.TermAndFreq>();
  while (queue.size() > 0) {
    terms.add(queue.pop());
  }
  return terms;
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:8,代码来源:CommonTermsQueryTest.java

示例5: createQuery

import org.apache.lucene.util.PriorityQueue; //导入方法依赖的package包/类
/**
 * Create the More like query from a PriorityQueue
 */
private Query createQuery(IndexReader indexReader, PriorityQueue q)
  throws IOException 
{
  // Pop everything from the queue.
  QueryWord[] queryWords = new QueryWord[q.size()];
  for (int i = q.size() - 1; i >= 0; i--)
    queryWords[i] = (QueryWord)q.pop();

  BooleanQuery query = new BooleanQuery(true /*disable coord*/);

  // At the moment, there's no need to scale by the best score. It simply
  // clouds the query explanation. It doesn't affect the scores, since
  // Lucene applies a query normalization factor anyway.
  //
  //float bestScore = (queryWords.length > 0) ? queryWords[0].score : 0.0f;
  for (int i = 0; i < fieldNames.length; i++) 
  {
    ArrayList fieldClauses = new ArrayList();

    for (int j = 0; j < queryWords.length; j++) 
    {
      QueryWord qw = queryWords[j];
      Term term = new Term(fieldNames[i], qw.word);

      // Skip words not present in this field.
      int docFreq = indexReader.docFreq(term);
      if (docFreq == 0)
        continue;

      // Add it to the query.
      SpanTermQuery tq = new SpanTermQuery(term);
      if (boost)
        tq.setBoost(qw.score);
      fieldClauses.add(tq);
    } // for j

    // If no terms for this field, skip it.
    if (fieldClauses.isEmpty())
      continue;

    SpanQuery[] clauses = (SpanQuery[])fieldClauses.toArray(
      new SpanQuery[fieldClauses.size()]);

    // Now make a special Or-Near query out of the clauses.
    SpanOrNearQuery fieldQuery = new SpanOrNearQuery(clauses, 10, false);

    // Boost if necessary.
    if (fieldBoosts != null)
      fieldQuery.setBoost(fieldBoosts[i]);
    
    // We currently don't support more-like-this queries on the full text.
    // It would involve de-chunking, and also fancier logic to pick the
    // "most interesting" terms in the first place.
    //
    if (fieldNames[i].equals("text"))
      throw new RuntimeException("MoreLikeThisQuery does not support 'text' field.");

    // And add to the main query.
    query.add(fieldQuery, BooleanClause.Occur.SHOULD);
  } // for i

  // All done.
  return query;
}
 
开发者ID:CDLUC3,项目名称:dash-xtf,代码行数:68,代码来源:MoreLikeThisQuery.java


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