當前位置: 首頁>>代碼示例>>Java>>正文


Java Explanation.addDetail方法代碼示例

本文整理匯總了Java中org.apache.lucene.search.Explanation.addDetail方法的典型用法代碼示例。如果您正苦於以下問題:Java Explanation.addDetail方法的具體用法?Java Explanation.addDetail怎麽用?Java Explanation.addDetail使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.lucene.search.Explanation的用法示例。


在下文中一共展示了Explanation.addDetail方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: explain

import org.apache.lucene.search.Explanation; //導入方法依賴的package包/類
@Override
public Explanation explain(AtomicReaderContext context, int doc) throws IOException {
  PayloadNearSpanScorer scorer = (PayloadNearSpanScorer) scorer(context, context.reader().getLiveDocs());
  if (scorer != null) {
    int newDoc = scorer.advance(doc);
    if (newDoc == doc) {
      float freq = scorer.freq();
      SimScorer docScorer = similarity.simScorer(stats, context);
      Explanation expl = new Explanation();
      expl.setDescription("weight("+getQuery()+" in "+doc+") [" + similarity.getClass().getSimpleName() + "], result of:");
      Explanation scoreExplanation = docScorer.explain(doc, new Explanation(freq, "phraseFreq=" + freq));
      expl.addDetail(scoreExplanation);
      expl.setValue(scoreExplanation.getValue());
      String field = ((SpanQuery)getQuery()).getField();
      // now the payloads part
      Explanation payloadExpl = function.explain(doc, field, scorer.payloadsSeen, scorer.payloadScore);
      // combined
      ComplexExplanation result = new ComplexExplanation();
      result.addDetail(expl);
      result.addDetail(payloadExpl);
      result.setValue(expl.getValue() * payloadExpl.getValue());
      result.setDescription("PayloadNearQuery, product of:");
      return result;
    }
  }
  
  return new ComplexExplanation(false, 0.0f, "no matching term");
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:29,代碼來源:PayloadNearQuery.java

示例2: explain

import org.apache.lucene.search.Explanation; //導入方法依賴的package包/類
@Override
public Explanation explain(AtomicReaderContext context, int doc) throws IOException {
  PayloadTermSpanScorer scorer = (PayloadTermSpanScorer) scorer(context, context.reader().getLiveDocs());
  if (scorer != null) {
    int newDoc = scorer.advance(doc);
    if (newDoc == doc) {
      float freq = scorer.sloppyFreq();
      SimScorer docScorer = similarity.simScorer(stats, context);
      Explanation expl = new Explanation();
      expl.setDescription("weight("+getQuery()+" in "+doc+") [" + similarity.getClass().getSimpleName() + "], result of:");
      Explanation scoreExplanation = docScorer.explain(doc, new Explanation(freq, "phraseFreq=" + freq));
      expl.addDetail(scoreExplanation);
      expl.setValue(scoreExplanation.getValue());
      // now the payloads part
      // QUESTION: Is there a way to avoid this skipTo call? We need to know
      // whether to load the payload or not
      // GSI: I suppose we could toString the payload, but I don't think that
      // would be a good idea
      String field = ((SpanQuery)getQuery()).getField();
      Explanation payloadExpl = function.explain(doc, field, scorer.payloadsSeen, scorer.payloadScore);
      payloadExpl.setValue(scorer.getPayloadScore());
      // combined
      ComplexExplanation result = new ComplexExplanation();
      if (includeSpanScore) {
        result.addDetail(expl);
        result.addDetail(payloadExpl);
        result.setValue(expl.getValue() * payloadExpl.getValue());
        result.setDescription("btq, product of:");
      } else {
        result.addDetail(payloadExpl);
        result.setValue(payloadExpl.getValue());
        result.setDescription("btq(includeSpanScore=false), result of:");
      }
      result.setMatch(true); // LUCENE-1303
      return result;
    }
  }
  
  return new ComplexExplanation(false, 0.0f, "no matching term");
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:41,代碼來源:PayloadTermQuery.java

示例3: explain

import org.apache.lucene.search.Explanation; //導入方法依賴的package包/類
/**
 * Returns an explanation for the score.
 * <p>Most basic models use the number of documents and the total term
 * frequency to compute Inf<sub>1</sub>. This method provides a generic
 * explanation for such models. Subclasses that use other statistics must
 * override this method.</p>
 */
public Explanation explain(BasicStats stats, float tfn) {
  Explanation result = new Explanation();
  result.setDescription(getClass().getSimpleName() + ", computed from: ");
  result.setValue(score(stats, tfn));
  result.addDetail(new Explanation(tfn, "tfn"));
  result.addDetail(
      new Explanation(stats.getNumberOfDocuments(), "numberOfDocuments"));
  result.addDetail(
      new Explanation(stats.getTotalTermFreq(), "totalTermFreq"));
  return result;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:19,代碼來源:BasicModel.java

示例4: explain

import org.apache.lucene.search.Explanation; //導入方法依賴的package包/類
@Override
protected void explain(
    Explanation expl, BasicStats stats, int doc, float freq, float docLen) {
  if (stats.getTotalBoost() != 1.0f) {
    expl.addDetail(new Explanation(stats.getTotalBoost(), "boost"));
  }
  Explanation normExpl = normalization.explain(stats, freq, docLen);
  Explanation lambdaExpl = lambda.explain(stats);
  expl.addDetail(normExpl);
  expl.addDetail(lambdaExpl);
  expl.addDetail(distribution.explain(
      stats, normExpl.getValue(), lambdaExpl.getValue()));
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:14,代碼來源:IBSimilarity.java

示例5: explain

import org.apache.lucene.search.Explanation; //導入方法依賴的package包/類
@Override
public final Explanation explain(BasicStats stats, float tfn) {
  Explanation result = new Explanation();
  result.setDescription(getClass().getSimpleName() + ", computed from: ");
  result.setValue(score(stats, tfn));
  result.addDetail(new Explanation(tfn, "tfn"));
  result.addDetail(
      new Explanation(stats.getNumberOfDocuments(), "numberOfDocuments"));
  result.addDetail(
      new Explanation(stats.getDocFreq(), "docFreq"));
  return result;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:13,代碼來源:BasicModelIn.java

示例6: explain

import org.apache.lucene.search.Explanation; //導入方法依賴的package包/類
@Override
public final Explanation explain(BasicStats stats, float tfn) {
  Explanation result = new Explanation();
  result.setDescription(getClass().getSimpleName() + ", computed from: ");
  result.setValue(score(stats, tfn));
  result.addDetail(new Explanation(tfn, "tfn"));
  result.addDetail(new Explanation(stats.getTotalTermFreq(), "totalTermFreq"));
  result.addDetail(new Explanation(stats.getDocFreq(), "docFreq"));
  return result;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:11,代碼來源:AfterEffectB.java

示例7: idfExplain

import org.apache.lucene.search.Explanation; //導入方法依賴的package包/類
/**
 * Computes a score factor for a phrase.
 * 
 * <p>
 * The default implementation sums the idf factor for
 * each term in the phrase.
 * 
 * @param collectionStats collection-level statistics
 * @param termStats term-level statistics for the terms in the phrase
 * @return an Explain object that includes both an idf 
 *         score factor for the phrase and an explanation 
 *         for each term.
 */
public Explanation idfExplain(CollectionStatistics collectionStats, TermStatistics termStats[]) {
  final long max = collectionStats.maxDoc();
  float idf = 0.0f;
  final Explanation exp = new Explanation();
  exp.setDescription("idf(), sum of:");
  for (final TermStatistics stat : termStats ) {
    final long df = stat.docFreq();
    final float termIdf = idf(df, max);
    exp.addDetail(new Explanation(termIdf, "idf(docFreq=" + df + ", maxDocs=" + max + ")"));
    idf += termIdf;
  }
  exp.setValue(idf);
  return exp;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:28,代碼來源:BM25Similarity.java

示例8: explainScore

import org.apache.lucene.search.Explanation; //導入方法依賴的package包/類
private Explanation explainScore(int doc, Explanation freq, BM25Stats stats, NumericDocValues norms) {
  Explanation result = new Explanation();
  result.setDescription("score(doc="+doc+",freq="+freq+"), product of:");
  
  Explanation boostExpl = new Explanation(stats.queryBoost * stats.topLevelBoost, "boost");
  if (boostExpl.getValue() != 1.0f)
    result.addDetail(boostExpl);
  
  result.addDetail(stats.idf);

  Explanation tfNormExpl = new Explanation();
  tfNormExpl.setDescription("tfNorm, computed from:");
  tfNormExpl.addDetail(freq);
  tfNormExpl.addDetail(new Explanation(k1, "parameter k1"));
  if (norms == null) {
    tfNormExpl.addDetail(new Explanation(0, "parameter b (norms omitted for field)"));
    tfNormExpl.setValue((freq.getValue() * (k1 + 1)) / (freq.getValue() + k1));
  } else {
    float doclen = decodeNormValue((byte)norms.get(doc));
    tfNormExpl.addDetail(new Explanation(b, "parameter b"));
    tfNormExpl.addDetail(new Explanation(stats.avgdl, "avgFieldLength"));
    tfNormExpl.addDetail(new Explanation(doclen, "fieldLength"));
    tfNormExpl.setValue((freq.getValue() * (k1 + 1)) / (freq.getValue() + k1 * (1 - b + b * doclen/stats.avgdl)));
  }
  result.addDetail(tfNormExpl);
  result.setValue(boostExpl.getValue() * stats.idf.getValue() * tfNormExpl.getValue());
  return result;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:29,代碼來源:BM25Similarity.java

示例9: explain

import org.apache.lucene.search.Explanation; //導入方法依賴的package包/類
@Override
protected void explain(Explanation expl, BasicStats stats, int doc,
    float freq, float docLen) {
  if (stats.getTotalBoost() != 1.0f) {
    expl.addDetail(new Explanation(stats.getTotalBoost(), "boost"));
  }
  expl.addDetail(new Explanation(lambda, "lambda"));
  super.explain(expl, stats, doc, freq, docLen);
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:10,代碼來源:LMJelinekMercerSimilarity.java

示例10: explain

import org.apache.lucene.search.Explanation; //導入方法依賴的package包/類
@Override
public final Explanation explain(BasicStats stats, float tfn) {
  Explanation result = new Explanation();
  result.setDescription(getClass().getSimpleName() + ", computed from: ");
  result.setValue(score(stats, tfn));
  result.addDetail(new Explanation(tfn, "tfn"));
  return result;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:9,代碼來源:AfterEffectL.java

示例11: explain

import org.apache.lucene.search.Explanation; //導入方法依賴的package包/類
@Override
public final Explanation explain(BasicStats stats) {
  Explanation result = new Explanation();
  result.setDescription(getClass().getSimpleName() + ", computed from: ");
  result.setValue(lambda(stats));
  result.addDetail(
      new Explanation(stats.getDocFreq(), "docFreq"));
  result.addDetail(
      new Explanation(stats.getNumberOfDocuments(), "numberOfDocuments"));
  return result;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:12,代碼來源:LambdaDF.java

示例12: explain

import org.apache.lucene.search.Explanation; //導入方法依賴的package包/類
/**
 * Explain the score for a single document
 * @param doc document id within the inverted index segment
 * @param freq Explanation of how the sloppy term frequency was computed
 * @return document's score
 */
public Explanation explain(int doc, Explanation freq) {
  Explanation result = new Explanation(score(doc, freq.getValue()), 
      "score(doc=" + doc + ",freq=" + freq.getValue() +"), with freq of:");
  result.addDetail(freq);
  return result;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:13,代碼來源:Similarity.java

示例13: explain

import org.apache.lucene.search.Explanation; //導入方法依賴的package包/類
/** Returns an explanation for the normalized term frequency.
 * <p>The default normalization methods use the field length of the document
 * and the average field length to compute the normalized term frequency.
 * This method provides a generic explanation for such methods.
 * Subclasses that use other statistics must override this method.</p>
 */
public Explanation explain(BasicStats stats, float tf, float len) {
  Explanation result = new Explanation();
  result.setDescription(getClass().getSimpleName() + ", computed from: ");
  result.setValue(tfn(stats, tf, len));
  result.addDetail(new Explanation(tf, "tf"));
  result.addDetail(
      new Explanation(stats.getAvgFieldLength(), "avgFieldLength"));
  result.addDetail(new Explanation(len, "len"));
  return result;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:17,代碼來源:Normalization.java

示例14: explain

import org.apache.lucene.search.Explanation; //導入方法依賴的package包/類
@Override
protected void explain(Explanation expl,
    BasicStats stats, int doc, float freq, float docLen) {
  if (stats.getTotalBoost() != 1.0f) {
    expl.addDetail(new Explanation(stats.getTotalBoost(), "boost"));
  }
  
  Explanation normExpl = normalization.explain(stats, freq, docLen);
  float tfn = normExpl.getValue();
  expl.addDetail(normExpl);
  expl.addDetail(basicModel.explain(stats, tfn));
  expl.addDetail(afterEffect.explain(stats, tfn));
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:14,代碼來源:DFRSimilarity.java

示例15: explain

import org.apache.lucene.search.Explanation; //導入方法依賴的package包/類
@Override
public final Explanation explain(BasicStats stats) {
  Explanation result = new Explanation();
  result.setDescription(getClass().getSimpleName() + ", computed from: ");
  result.setValue(lambda(stats));
  result.addDetail(
      new Explanation(stats.getTotalTermFreq(), "totalTermFreq"));
  result.addDetail(
      new Explanation(stats.getNumberOfDocuments(), "numberOfDocuments"));
  return result;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:12,代碼來源:LambdaTTF.java


注:本文中的org.apache.lucene.search.Explanation.addDetail方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。