当前位置: 首页>>代码示例>>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;未经允许,请勿转载。