コード例 #1
0
ファイル: TermQuery.cs プロジェクト: carrie901/mono
			public TermWeight(TermQuery enclosingInstance, Searcher searcher)
			{
				InitBlock(enclosingInstance);
				this.similarity = Enclosing_Instance.GetSimilarity(searcher);
				idfExp = similarity.IdfExplain(Enclosing_Instance.term, searcher);
				idf = idfExp.GetIdf();
			}
コード例 #2
0
ファイル: SpanWeight.cs プロジェクト: carrie901/mono
		public SpanWeight(SpanQuery query, Searcher searcher)
		{
			this.similarity = query.GetSimilarity(searcher);
			this.query = query;
			terms = new System.Collections.Hashtable();
			query.ExtractTerms(terms);
			idfExp = similarity.idfExplain(new System.Collections.ArrayList(terms.Values), searcher);
			idf = idfExp.GetIdf();
		}
コード例 #3
0
ファイル: Hits.cs プロジェクト: carrie901/mono
		public /*internal*/ bool debugCheckedForDeletions = false; // for test purposes.
		
		internal Hits(Searcher s, Query q, Filter f)
		{
			weight = q.Weight(s);
			searcher = s;
			filter = f;
			nDeletions = CountDeletions(s);
			GetMoreDocs(50); // retrieve 100 initially
			lengthAtStart = length;
		}
コード例 #4
0
ファイル: MultiPhraseQuery.cs プロジェクト: carrie901/mono
			public MultiPhraseWeight(MultiPhraseQuery enclosingInstance, Searcher searcher)
			{
				InitBlock(enclosingInstance);
				this.similarity = Enclosing_Instance.GetSimilarity(searcher);
				
				// compute idf
				System.Collections.IEnumerator i = Enclosing_Instance.termArrays.GetEnumerator();
				while (i.MoveNext())
				{
					Term[] terms = (Term[]) i.Current;
					for (int j = 0; j < terms.Length; j++)
					{
						idf += Enclosing_Instance.GetSimilarity(searcher).Idf(terms[j], searcher);
					}
				}
			}
コード例 #5
0
ファイル: MatchAllDocsQuery.cs プロジェクト: vernon016/mono
 public override Weight CreateWeight(Searcher searcher)
 {
     return(new MatchAllDocsWeight(this, searcher));
 }
コード例 #6
0
 public override Weight CreateWeight(Searcher searcher)
 {
     return(new BooleanWeight(this, searcher));
 }
コード例 #7
0
ファイル: Query.cs プロジェクト: carrie901/mono
		/// <summary> Expert: Constructs an appropriate Weight implementation for this query.
		/// 
		/// <p/>
		/// Only implemented by primitive queries, which re-write to themselves.
		/// </summary>
		public virtual Weight CreateWeight(Searcher searcher)
		{
			throw new System.NotSupportedException();
		}
コード例 #8
0
ファイル: Similarity.cs プロジェクト: vernon016/mono
 public virtual float Idf(Term term, Searcher searcher)
 {
     return(Idf(searcher.DocFreq(term), searcher.MaxDoc()));
 }
コード例 #9
0
ファイル: Query.cs プロジェクト: carrie901/mono
		/// <summary> Expert: Constructs and initializes a Weight for a top-level query.</summary>
		public virtual Weight Weight(Searcher searcher)
		{
			Query query = searcher.Rewrite(this);
			Weight weight = query.CreateWeight(searcher);
			float sum = weight.SumOfSquaredWeights();
			float norm = GetSimilarity(searcher).QueryNorm(sum);
            if (float.IsInfinity(norm) || float.IsNaN(norm))
                norm = 1.0f;
			weight.Normalize(norm);
			return weight;
		}
コード例 #10
0
ファイル: ConstantScoreQuery.cs プロジェクト: vernon016/mono
 public ConstantWeight(ConstantScoreQuery enclosingInstance, Searcher searcher)
 {
     InitBlock(enclosingInstance);
     this.similarity = Enclosing_Instance.GetSimilarity(searcher);
 }
コード例 #11
0
ファイル: Similarity.cs プロジェクト: carrie901/mono
		/// <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 Mono.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);
		}
コード例 #12
0
 /// <summary> Expert: Constructs an appropriate Weight implementation for this query.
 ///
 /// <p/>
 /// Only implemented by primitive queries, which re-write to themselves.
 /// </summary>
 public virtual Weight CreateWeight(Searcher searcher)
 {
     throw new System.NotSupportedException();
 }
コード例 #13
0
ファイル: PhraseQuery.cs プロジェクト: carrie901/mono
		public override Weight CreateWeight(Searcher searcher)
		{
			if (terms.Count == 1)
			{
				// optimize one-term case
				Term term = (Term) terms[0];
				Query termQuery = new TermQuery(term);
				termQuery.SetBoost(GetBoost());
				return termQuery.CreateWeight(searcher);
			}
			return new PhraseWeight(this, searcher);
		}
コード例 #14
0
 /// <summary>Expert: Returns the Similarity implementation to be used for this query.
 /// Subclasses may override this method to specify their own Similarity
 /// implementation, perhaps one that delegates through that of the Searcher.
 /// By default the Searcher's Similarity implementation is returned.
 /// </summary>
 public virtual Similarity GetSimilarity(Searcher searcher)
 {
     return(searcher.GetSimilarity());
 }
コード例 #15
0
ファイル: MultiPhraseQuery.cs プロジェクト: vernon016/mono
 public override Weight CreateWeight(Searcher searcher)
 {
     return(new MultiPhraseWeight(this, searcher));
 }
コード例 #16
0
ファイル: TermQuery.cs プロジェクト: vernon016/mono
 public override Weight CreateWeight(Searcher searcher)
 {
     return(new TermWeight(this, searcher));
 }
コード例 #17
0
ファイル: Similarity.cs プロジェクト: carrie901/mono
		/// <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);
		}
コード例 #18
0
ファイル: Similarity.cs プロジェクト: carrie901/mono
		public virtual float Idf(System.Collections.ICollection terms, Searcher searcher)
		{
			float idf = 0.0f;
			System.Collections.IEnumerator i = terms.GetEnumerator();
			while (i.MoveNext())
			{
				idf += Idf((Term) i.Current, searcher);
			}
			return idf;
		}
コード例 #19
0
ファイル: DisjunctionMaxQuery.cs プロジェクト: carrie901/mono
			protected internal System.Collections.ArrayList weights = new System.Collections.ArrayList(); // The Weight's for our subqueries, in 1-1 correspondence with disjuncts
			
			/* Construct the Weight for this Query searched by searcher.  Recursively construct subquery weights. */
			public DisjunctionMaxWeight(DisjunctionMaxQuery enclosingInstance, Searcher searcher)
			{
				InitBlock(enclosingInstance);
				this.similarity = searcher.GetSimilarity();
				for (System.Collections.IEnumerator iter = Enclosing_Instance.disjuncts.GetEnumerator(); iter.MoveNext(); )
				{
					weights.Add(((Query) iter.Current).CreateWeight(searcher));
				}
			}
コード例 #20
0
ファイル: MultiPhraseQuery.cs プロジェクト: carrie901/mono
		public override Weight CreateWeight(Searcher searcher)
		{
			return new MultiPhraseWeight(this, searcher);
		}
コード例 #21
0
        }         // end of DisjunctionMaxWeight inner class

        /* Create the Weight used to score us */
        public override Weight CreateWeight(Searcher searcher)
        {
            return(new DisjunctionMaxWeight(this, searcher));
        }
コード例 #22
0
ファイル: FilteredQuery.cs プロジェクト: carrie901/mono
		/// <summary> Returns a Weight that applies the filter to the enclosed query's Weight.
		/// This is accomplished by overriding the Scorer returned by the Weight.
		/// </summary>
		public override Weight CreateWeight(Searcher searcher)
		{
			Weight weight = query.CreateWeight(searcher);
			Similarity similarity = query.GetSimilarity(searcher);
			return new AnonymousClassWeight(weight, similarity, this);
		}
コード例 #23
0
ファイル: Similarity.cs プロジェクト: vernon016/mono
        /// <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));
        }
コード例 #24
0
ファイル: ValueSourceQuery.cs プロジェクト: carrie901/mono
		public override Weight CreateWeight(Searcher searcher)
		{
			return new ValueSourceQuery.ValueSourceWeight(this, searcher);
		}
コード例 #25
0
ファイル: Query.cs プロジェクト: carrie901/mono
		/// <summary>Expert: Returns the Similarity implementation to be used for this query.
		/// Subclasses may override this method to specify their own Similarity
		/// implementation, perhaps one that delegates through that of the Searcher.
		/// By default the Searcher's Similarity implementation is returned.
		/// </summary>
		public virtual Similarity GetSimilarity(Searcher searcher)
		{
			return searcher.GetSimilarity();
		}
コード例 #26
0
ファイル: ValueSourceQuery.cs プロジェクト: carrie901/mono
			public ValueSourceWeight(ValueSourceQuery enclosingInstance, Searcher searcher)
			{
				InitBlock(enclosingInstance);
				this.similarity = Enclosing_Instance.GetSimilarity(searcher);
			}
コード例 #27
0
ファイル: Hits.cs プロジェクト: carrie901/mono
		// count # deletions, return -1 if unknown.
		private int CountDeletions(Searcher s)
		{
			int cnt = - 1;
			if (s is IndexSearcher)
			{
				cnt = s.MaxDoc() - ((IndexSearcher) s).GetIndexReader().NumDocs();
			}
			return cnt;
		}
コード例 #28
0
ファイル: MatchAllDocsQuery.cs プロジェクト: carrie901/mono
			public MatchAllDocsWeight(MatchAllDocsQuery enclosingInstance, Searcher searcher)
			{
				InitBlock(enclosingInstance);
				this.similarity = searcher.GetSimilarity();
			}
コード例 #29
0
ファイル: MatchAllDocsQuery.cs プロジェクト: carrie901/mono
		public override Weight CreateWeight(Searcher searcher)
		{
			return new MatchAllDocsWeight(this, searcher);
		}
コード例 #30
0
ファイル: BooleanQuery.cs プロジェクト: carrie901/mono
		// Implement coord disabling.
		// Inherit javadoc.
		public override Similarity GetSimilarity(Searcher searcher)
		{
			Similarity result = base.GetSimilarity(searcher);
			if (disableCoord)
			{
				// disable coord as requested
				result = new AnonymousClassSimilarityDelegator(this, result);
			}
			return result;
		}
コード例 #31
0
ファイル: MatchAllDocsQuery.cs プロジェクト: vernon016/mono
 public MatchAllDocsWeight(MatchAllDocsQuery enclosingInstance, Searcher searcher)
 {
     InitBlock(enclosingInstance);
     this.similarity = searcher.GetSimilarity();
 }
コード例 #32
0
ファイル: BooleanQuery.cs プロジェクト: carrie901/mono
			public BooleanWeight(BooleanQuery enclosingInstance, Searcher searcher)
			{
				InitBlock(enclosingInstance);
				this.similarity = Enclosing_Instance.GetSimilarity(searcher);
				weights = new System.Collections.ArrayList(Enclosing_Instance.clauses.Count);
				for (int i = 0; i < Enclosing_Instance.clauses.Count; i++)
				{
					BooleanClause c = (BooleanClause) Enclosing_Instance.clauses[i];
					weights.Add(c.GetQuery().CreateWeight(searcher));
				}
			}
コード例 #33
0
ファイル: TermQuery.cs プロジェクト: carrie901/mono
		public override Weight CreateWeight(Searcher searcher)
		{
			return new TermWeight(this, searcher);
		}
コード例 #34
0
ファイル: BooleanQuery.cs プロジェクト: carrie901/mono
		public override Weight CreateWeight(Searcher searcher)
		{
			return new BooleanWeight(this, searcher);
		}
コード例 #35
0
ファイル: ConstantScoreQuery.cs プロジェクト: vernon016/mono
 public override Weight CreateWeight(Searcher searcher)
 {
     return(new ConstantScoreQuery.ConstantWeight(this, searcher));
 }
コード例 #36
0
ファイル: ConstantScoreQuery.cs プロジェクト: carrie901/mono
		public override Weight CreateWeight(Searcher searcher)
		{
			return new ConstantScoreQuery.ConstantWeight(this, searcher);
		}
コード例 #37
0
ファイル: SearchableIndex.cs プロジェクト: shaias/mono
		public Result (string Term, Searcher searcher, ScoreDoc[] docs) 
		{
			this.term = Term;
			this.searcher = searcher;
			this.docs = docs;
		}
コード例 #38
0
ファイル: ConstantScoreQuery.cs プロジェクト: carrie901/mono
			public ConstantWeight(ConstantScoreQuery enclosingInstance, Searcher searcher)
			{
				InitBlock(enclosingInstance);
				this.similarity = Enclosing_Instance.GetSimilarity(searcher);
			}
コード例 #39
0
ファイル: DisjunctionMaxQuery.cs プロジェクト: carrie901/mono
		} // end of DisjunctionMaxWeight inner class
		
		/* Create the Weight used to score us */
		public override Weight CreateWeight(Searcher searcher)
		{
			return new DisjunctionMaxWeight(this, searcher);
		}
コード例 #40
0
ファイル: Similarity.cs プロジェクト: carrie901/mono
		public virtual float Idf(Term term, Searcher searcher)
		{
			return Idf(searcher.DocFreq(term), searcher.MaxDoc());
		}