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


Java Explanation.getValue方法代碼示例

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


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

示例1: explain

import org.apache.lucene.search.Explanation; //導入方法依賴的package包/類
@Override
public Explanation explain(LeafReaderContext context, int doc) throws IOException {
    Explanation subQueryExpl = subQueryWeight.explain(context, doc);
    if (!subQueryExpl.isMatch()) {
        return subQueryExpl;
    }
    Explanation expl;
    if (function != null) {
        Explanation functionExplanation = function.getLeafScoreFunction(context).explainScore(doc, subQueryExpl);
        expl = combineFunction.explain(subQueryExpl, functionExplanation, maxBoost);
    } else {
        expl = subQueryExpl;
    }
    if (minScore != null && minScore > expl.getValue()) {
        expl = Explanation.noMatch("Score value is too low, expected at least " + minScore + " but got " + expl.getValue(), expl);
    }
    return expl;
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:19,代碼來源:FunctionScoreQuery.java

示例2: findPayloadBoostInExplanation

import org.apache.lucene.search.Explanation; //導入方法依賴的package包/類
boolean findPayloadBoostInExplanation(Explanation expl) {
    if (expl.getDescription().startsWith("payloadBoost=") && expl.getValue() != 1f) {
        return true;
    } else {
        boolean found = false;
        for (Explanation sub : expl.getDetails()) {
            found |= findPayloadBoostInExplanation(sub);
        }
        return found;
    }
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:12,代碼來源:OldIndexBackwardsCompatibilityIT.java

示例3: 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

示例4: 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

示例5: 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

示例6: IDFStats

import org.apache.lucene.search.Explanation; //導入方法依賴的package包/類
public IDFStats(String field, Explanation idf, float queryBoost) {
  // TODO: Validate?
  this.field = field;
  this.idf = idf;
  this.queryBoost = queryBoost;
  this.queryWeight = idf.getValue() * queryBoost; // compute query weight
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:8,代碼來源:TFIDFSimilarity.java

示例7: explainScore

import org.apache.lucene.search.Explanation; //導入方法依賴的package包/類
private Explanation explainScore(int doc, Explanation freq, BM25StatsFixed stats, NumericDocValues norms) {
  Explanation boostExpl = Explanation.match(stats.boost, "boost");
  List<Explanation> subs = new ArrayList<>();
  if (boostExpl.getValue() != 1.0f)
    subs.add(boostExpl);
  subs.add(stats.idf);
  Explanation tfNormExpl = explainTFNorm(doc, freq, stats, norms);
  subs.add(tfNormExpl);
  return Explanation.match(
      boostExpl.getValue() * stats.idf.getValue() * tfNormExpl.getValue(),
      "score(doc="+doc+",freq="+freq+"), product of:", subs);
}
 
開發者ID:sebastian-hofstaetter,項目名稱:ir-generalized-translation-models,代碼行數:13,代碼來源:BM25SimilarityLossless.java

示例8: explainScore

import org.apache.lucene.search.Explanation; //導入方法依賴的package包/類
private Explanation explainScore(int doc, Explanation freq, IDFStats stats, NumericDocValues norms) {
  Explanation result = new Explanation();
  result.setDescription("score(doc="+doc+",freq="+freq+"), product of:");

  // explain query weight
  Explanation queryExpl = new Explanation();
  queryExpl.setDescription("queryWeight, product of:");

  Explanation boostExpl = new Explanation(stats.queryBoost, "boost");
  if (stats.queryBoost != 1.0f)
    queryExpl.addDetail(boostExpl);
  queryExpl.addDetail(stats.idf);

  Explanation queryNormExpl = new Explanation(stats.queryNorm,"queryNorm");
  queryExpl.addDetail(queryNormExpl);

  queryExpl.setValue(boostExpl.getValue() *
                     stats.idf.getValue() *
                     queryNormExpl.getValue());

  result.addDetail(queryExpl);

  // explain field weight
  Explanation fieldExpl = new Explanation();
  fieldExpl.setDescription("fieldWeight in "+doc+
                           ", product of:");

  Explanation tfExplanation = new Explanation();
  tfExplanation.setValue(tf(freq.getValue()));
  tfExplanation.setDescription("tf(freq="+freq.getValue()+"), with freq of:");
  tfExplanation.addDetail(freq);
  fieldExpl.addDetail(tfExplanation);
  fieldExpl.addDetail(stats.idf);

  Explanation fieldNormExpl = new Explanation();
  float fieldNorm = norms != null ? decodeNormValue(norms.get(doc)) : 1.0f;
  fieldNormExpl.setValue(fieldNorm);
  fieldNormExpl.setDescription("fieldNorm(doc="+doc+")");
  fieldExpl.addDetail(fieldNormExpl);
  
  fieldExpl.setValue(tfExplanation.getValue() *
                     stats.idf.getValue() *
                     fieldNormExpl.getValue());

  result.addDetail(fieldExpl);
  
  // combine them
  result.setValue(queryExpl.getValue() * fieldExpl.getValue());

  if (queryExpl.getValue() == 1.0f)
    return fieldExpl;

  return result;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:55,代碼來源:TFIDFSimilarity.java


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