DocFreq() 공개 추상적인 메소드

public abstract DocFreq ( Lucene.Net.Index.Term term ) : int
term Lucene.Net.Index.Term
리턴 int
예제 #1
0
        /// <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 IDFExplanation idfExplain(IList <Lucene.Net.Index.Term> terms, Searcher searcher)
        {
            if (SupportedMethods.overridesCollectionIDF)
            {
                float idf = Idf(terms, searcher);
                return(new IDFExplanation
                {
                    GetIdf = () => idf,
                    Explain = () => "Inexplicable"
                });
            }
            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 IDFExplanation
            {
                GetIdf = () => fIdf,
                Explain = () => exp.ToString()
            });
        }
예제 #2
0
        /// <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 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));
        }
예제 #3
0
        /// <summary> Computes a score factor for a simple term and returns an explanation
        /// for that score factor.
        ///
        /// <p/>
        /// The default implementation uses:
        ///
        /// <pre>
        /// idf(searcher.docFreq(term), searcher.maxDoc());
        /// </pre>
        ///
        /// Note that {@link Searcher#MaxDoc()} is used instead of
        /// {@link Lucene.Net.Index.IndexReader#NumDocs()} because it is
        /// proportional to {@link 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 IDFExplanation IdfExplain(Term term, Searcher searcher)
        {
            if (SupportedMethods.overridesTermIDF)
            {
                float idf = Idf(term, searcher);
                return(new AnonymousClassIDFExplanation(idf, this));
            }
            int   df   = searcher.DocFreq(term);
            int   max  = searcher.MaxDoc();
            float idf2 = Idf(df, max);

            return(new AnonymousClassIDFExplanation1(df, max, idf2, this));
        }
예제 #4
0
            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);
                    }
                }
            }
예제 #5
0
        /// <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 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));
        }
예제 #6
0
        /// <summary> Computes a score factor for a simple term and returns an explanation
        /// for that score factor.
        ///
        /// <p/>
        /// The default implementation uses:
        ///
        /// <pre>
        /// idf(searcher.docFreq(term), searcher.maxDoc());
        /// </pre>
        ///
        /// Info: <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 IDFExplanation IdfExplain(Term term, Searcher searcher)
        {
            if (SupportedMethods.overridesTermIDF)
            {
                float idf = Idf(term, searcher);
                return(new IDFExplanation
                {
                    GetIdf = () => idf,
                    Explain = () => "Inexplicable"
                });
            }
            int   df   = searcher.DocFreq(term);
            int   max  = searcher.MaxDoc();
            float idf2 = Idf(df, max);

            return(new IDFExplanation
            {
                GetIdf = () => idf2,
                Explain = () => "idf(docFreq=" + df + ", maxDocs=" + max + ")"
            });
        }
예제 #7
0
        /// <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 IDFExplanation idfExplain(System.Collections.ICollection terms, Searcher searcher)
        {
            if (SupportedMethods.overridesCollectionIDF)
            {
                float idf = Idf(terms, searcher);
                return(new AnonymousClassIDFExplanation2(idf, this));
            }
            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));
        }
예제 #8
0
		/// <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 IDFExplanation idfExplain(System.Collections.ICollection terms, Searcher searcher)
		{
			if (SupportedMethods.overridesCollectionIDF)
			{
				float idf = Idf(terms, searcher);
				return new AnonymousClassIDFExplanation2(idf, this);
			}
			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);
		}
예제 #9
0
		/// <summary> Computes a score factor for a simple term and returns an explanation
		/// for that score factor.
		/// 
		/// <p/>
		/// The default implementation uses:
		/// 
		/// <pre>
		/// idf(searcher.docFreq(term), searcher.maxDoc());
		/// </pre>
		/// 
		/// Note that {@link Searcher#MaxDoc()} is used instead of
		/// {@link Lucene.Net.Index.IndexReader#NumDocs()} because it is
		/// proportional to {@link 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 IDFExplanation IdfExplain(Term term, Searcher searcher)
		{
			if (SupportedMethods.overridesTermIDF)
			{
				float idf = Idf(term, searcher);
				return new AnonymousClassIDFExplanation(idf, this);
			}
			int df = searcher.DocFreq(term);
			int max = searcher.MaxDoc();
			float idf2 = Idf(df, max);
			return new AnonymousClassIDFExplanation1(df, max, idf2, this);
		}
예제 #10
0
		public virtual float Idf(Term term, Searcher searcher)
		{
			return Idf(searcher.DocFreq(term), searcher.MaxDoc());
		}
예제 #11
0
		/// <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 IDFExplanation idfExplain(IList<Lucene.Net.Index.Term> terms, Searcher searcher)
		{
			if (SupportedMethods.overridesCollectionIDF)
			{
				float idf = Idf(terms, searcher);
                return new IDFExplanation
                {
                    GetIdf = () => idf,
                    Explain = () => "Inexplicable"
                };
			}
			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 IDFExplanation
            {
                GetIdf = () => fIdf,
                Explain = () => exp.ToString()
            };
		}
예제 #12
0
		/// <summary> Computes a score factor for a simple term and returns an explanation
		/// for that score factor.
		/// 
		/// <p/>
		/// The default implementation uses:
		/// 
		/// <pre>
		/// idf(searcher.docFreq(term), searcher.maxDoc());
		/// </pre>
		/// 
		/// Info: <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 IDFExplanation IdfExplain(Term term, Searcher searcher)
		{
			if (SupportedMethods.overridesTermIDF)
			{
				float idf = Idf(term, searcher);
                return new IDFExplanation 
                { GetIdf = () => idf, 
                  Explain = () => "Inexplicable"
                };

			}
			int df = searcher.DocFreq(term);
			int max = searcher.MaxDoc();
			float idf2 = Idf(df, max);
            return new IDFExplanation
            {
                GetIdf = () => idf2,
                Explain = () => "idf(docFreq=" + df + ", maxDocs=" + max + ")"
            };

		}
예제 #13
0
		/// <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 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);
		}
예제 #14
0
		/// <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 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);
		}
예제 #15
0
 /// <summary>Computes a score factor for a simple term.
 ///
 /// <p>The default implementation is:<pre>
 /// return idf(searcher.docFreq(term), searcher.maxDoc());
 /// </pre>
 ///
 /// Note that {@link Searcher#MaxDoc()} is used instead of
 /// {@link IndexReader#NumDocs()} because it is proportional to
 /// {@link 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> a score factor for the term
 /// </returns>
 public virtual float Idf(Term term, Searcher searcher)
 {
     return(Ldf(searcher.DocFreq(term), searcher.MaxDoc()));
 }
예제 #16
0
 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);
         }
     }
 }