/// <summary> Computes a score factor for a simple term and returns an explanation /// for that score factor. /// /// <p/> /// The default implementation uses: /// /// <code> /// idf(searcher.docFreq(term), searcher.MaxDoc); /// </code> /// /// Note that <see cref="Searcher.MaxDoc" /> is used instead of /// <see cref="Lucene.Net.Index.IndexReader.NumDocs()" /> because it is /// proportional to <see cref="Searcher.DocFreq(Term)" /> , i.e., when one is /// inaccurate, so is the other, and in the same direction. /// /// </summary> /// <param name="term">the term in question /// </param> /// <param name="searcher">the document collection being searched /// </param> /// <returns> an IDFExplain object that includes both an idf score factor /// and an explanation for the term. /// </returns> /// <throws> IOException </throws> public virtual Explanation.IDFExplanation IdfExplain(Term term, Searcher searcher) { int df = searcher.DocFreq(term); int max = searcher.MaxDoc; float idf2 = Idf(df, max); return(new AnonymousClassIDFExplanation1(df, max, idf2, this)); }
public MultiPhraseWeight(MultiPhraseQuery enclosingInstance, Searcher searcher) { InitBlock(enclosingInstance); this.similarity = Enclosing_Instance.GetSimilarity(searcher); // compute idf int maxDoc = searcher.MaxDoc; foreach (Term[] terms in enclosingInstance.termArrays) { foreach (Term term in terms) { idf += similarity.Idf(searcher.DocFreq(term), maxDoc); } } }
/// <summary> Computes a score factor for a phrase. /// /// <p/> /// The default implementation sums the idf factor for /// each term in the phrase. /// /// </summary> /// <param name="terms">the terms in the phrase /// </param> /// <param name="searcher">the document collection being searched /// </param> /// <returns> an IDFExplain object that includes both an idf /// score factor for the phrase and an explanation /// for each term. /// </returns> /// <throws> IOException </throws> public virtual Explanation.IDFExplanation IdfExplain(ICollection <Term> terms, Searcher searcher) { int max = searcher.MaxDoc; float idf2 = 0.0f; System.Text.StringBuilder exp = new System.Text.StringBuilder(); foreach (Term term in terms) { int df = searcher.DocFreq(term); idf2 += Idf(df, max); exp.Append(" "); exp.Append(term.Text); exp.Append("="); exp.Append(df); } float fIdf = idf2; return(new AnonymousClassIDFExplanation3(fIdf, exp, this)); }
/// <summary> Computes a score factor for a phrase. /// /// <p/> /// The default implementation sums the idf factor for /// each term in the phrase. /// /// </summary> /// <param name="terms">the terms in the phrase /// </param> /// <param name="searcher">the document collection being searched /// </param> /// <returns> an IDFExplain object that includes both an idf /// score factor for the phrase and an explanation /// for each term. /// </returns> /// <throws> IOException </throws> public virtual Explanation.IDFExplanation IdfExplain(ICollection<Term> terms, Searcher searcher) { int max = searcher.MaxDoc; float idf2 = 0.0f; System.Text.StringBuilder exp = new System.Text.StringBuilder(); foreach (Term term in terms) { int df = searcher.DocFreq(term); idf2 += Idf(df, max); exp.Append(" "); exp.Append(term.Text); exp.Append("="); exp.Append(df); } float fIdf = idf2; return new AnonymousClassIDFExplanation3(fIdf, exp, this); }
/// <summary> Computes a score factor for a simple term and returns an explanation /// for that score factor. /// /// <p/> /// The default implementation uses: /// /// <code> /// idf(searcher.docFreq(term), searcher.MaxDoc); /// </code> /// /// Note that <see cref="Searcher.MaxDoc" /> is used instead of /// <see cref="Lucene.Net.Index.IndexReader.NumDocs()" /> because it is /// proportional to <see cref="Searcher.DocFreq(Term)" /> , i.e., when one is /// inaccurate, so is the other, and in the same direction. /// /// </summary> /// <param name="term">the term in question /// </param> /// <param name="searcher">the document collection being searched /// </param> /// <returns> an IDFExplain object that includes both an idf score factor /// and an explanation for the term. /// </returns> /// <throws> IOException </throws> public virtual Explanation.IDFExplanation IdfExplain(Term term, Searcher searcher) { int df = searcher.DocFreq(term); int max = searcher.MaxDoc; float idf2 = Idf(df, max); return new AnonymousClassIDFExplanation1(df, max, idf2, this); }