Ejemplo n.º 1
0
            private float[] vScores;             // reused in score() to avoid allocating this array for each doc

            // constructor
            internal CustomScorer(CustomScoreQuery enclosingInstance, Similarity similarity, IndexReader reader, CustomWeight w, Scorer subQueryScorer, Scorer[] valSrcScorers) : base(similarity)
            {
                InitBlock(enclosingInstance);
                this.weight         = w;
                this.qWeight        = w.GetValue();
                this.subQueryScorer = subQueryScorer;
                this.valSrcScorers  = valSrcScorers;
                this.reader         = reader;
                this.vScores        = new float[valSrcScorers.Length];
                this.provider       = this.Enclosing_Instance.GetCustomScoreProvider(reader);
            }
Ejemplo n.º 2
0
 public CustomWeight(CustomScoreQuery enclosingInstance, Searcher searcher)
 {
     InitBlock(enclosingInstance);
     this.similarity     = Enclosing_Instance.GetSimilarity(searcher);
     this.subQueryWeight = Enclosing_Instance.subQuery.Weight(searcher);
     this.valSrcWeights  = new Weight[Enclosing_Instance.valSrcQueries.Length];
     for (int i = 0; i < Enclosing_Instance.valSrcQueries.Length; i++)
     {
         this.valSrcWeights[i] = Enclosing_Instance.valSrcQueries[i].CreateWeight(searcher);
     }
     this.qStrict = Enclosing_Instance.strict;
 }
Ejemplo n.º 3
0
 protected internal virtual void  ProcessPayload(Similarity similarity)
 {
     if (positions.IsPayloadAvailable())
     {
         payload      = positions.GetPayload(payload, 0);
         payloadScore = Enclosing_Instance.Enclosing_Instance.function.CurrentScore(doc, Enclosing_Instance.Enclosing_Instance.term.Field(), spans.Start(), spans.End(), payloadsSeen, payloadScore, similarity.ScorePayload(doc, Enclosing_Instance.Enclosing_Instance.term.Field(), spans.Start(), spans.End(), payload, 0, positions.GetPayloadLength()));
         payloadsSeen++;
     }
     else
     {
         // zero out the payload?
     }
 }
Ejemplo n.º 4
0
		protected internal SpanScorer(Spans spans, Weight weight, Similarity similarity, byte[] norms):base(similarity)
		{
			this.spans = spans;
			this.norms = norms;
			this.weight = weight;
			this.value_Renamed = weight.GetValue();
			if (this.spans.Next())
			{
				doc = - 1;
			}
			else
			{
				doc = NO_MORE_DOCS;
				more = false;
			}
		}
Ejemplo n.º 5
0
 protected internal SpanScorer(Spans spans, Weight weight, Similarity similarity, byte[] norms) : base(similarity)
 {
     this.spans         = spans;
     this.norms         = norms;
     this.weight        = weight;
     this.value_Renamed = weight.GetValue();
     if (this.spans.Next())
     {
         doc = -1;
     }
     else
     {
         doc  = NO_MORE_DOCS;
         more = false;
     }
 }
Ejemplo n.º 6
0
 internal override void  Finish()
 {
     System.Diagnostics.Debug.Assert(docIDs.Length == norms.Length);
     if (fieldInfo.isIndexed && !fieldInfo.omitNorms)
     {
         if (docIDs.Length <= upto)
         {
             System.Diagnostics.Debug.Assert(docIDs.Length == upto);
             docIDs = ArrayUtil.Grow(docIDs, 1 + upto);
             norms  = ArrayUtil.Grow(norms, 1 + upto);
         }
         float norm = docState.similarity.ComputeNorm(fieldInfo.name, fieldState);
         norms[upto]  = Similarity.EncodeNorm(norm);
         docIDs[upto] = docState.docID;
         upto++;
     }
 }
Ejemplo n.º 7
0
                public /*protected internal*/ override bool SetFreqCurrentDoc()
                {
                    if (!more)
                    {
                        return(false);
                    }
                    doc          = spans.Doc();
                    freq         = 0.0f;
                    payloadScore = 0;
                    payloadsSeen = 0;
                    Similarity similarity1 = GetSimilarity();

                    while (more && doc == spans.Doc())
                    {
                        int matchLength = spans.End() - spans.Start();

                        freq += similarity1.SloppyFreq(matchLength);
                        ProcessPayload(similarity1);

                        more = spans.Next();                         // this moves positions to the next match in this
                        // document
                    }
                    return(more || (freq != 0));
                }
Ejemplo n.º 8
0
				public PayloadTermSpanScorer(PayloadTermWeight enclosingInstance, TermSpans spans, Weight weight, Similarity similarity, byte[] norms):base(spans, weight, similarity, norms)
				{
					InitBlock(enclosingInstance);
					positions = spans.GetPositions();
				}
Ejemplo n.º 9
0
 internal AnonymousClassSimilarityDelegator(BooleanQuery enclosingInstance, Mono.Lucene.Net.Search.Similarity Param1) : base(Param1)
 {
     InitBlock(enclosingInstance);
 }
Ejemplo n.º 10
0
			protected internal PayloadNearSpanScorer(PayloadNearQuery enclosingInstance, Mono.Lucene.Net.Search.Spans.Spans spans, Weight weight, Similarity similarity, byte[] norms):base(spans, weight, similarity, norms)
			{
				InitBlock(enclosingInstance);
				this.spans = spans;
			}
Ejemplo n.º 11
0
        public override float Score()
        {
            float raw = GetSimilarity().Tf(freq) * value_Renamed;             // raw score

            return(norms == null?raw:raw *Similarity.DecodeNorm(norms[doc])); // normalize
        }
Ejemplo n.º 12
0
 internal AnonymousClassScorer(Mono.Lucene.Net.Search.Scorer scorer, Mono.Lucene.Net.Search.DocIdSetIterator docIdSetIterator, AnonymousClassWeight enclosingInstance, Mono.Lucene.Net.Search.Similarity Param1) : base(Param1)
 {
     InitBlock(scorer, docIdSetIterator, enclosingInstance);
 }
Ejemplo n.º 13
0
				protected internal virtual void  ProcessPayload(Similarity similarity)
				{
					if (positions.IsPayloadAvailable())
					{
						payload = positions.GetPayload(payload, 0);
						payloadScore = Enclosing_Instance.Enclosing_Instance.function.CurrentScore(doc, Enclosing_Instance.Enclosing_Instance.term.Field(), spans.Start(), spans.End(), payloadsSeen, payloadScore, similarity.ScorePayload(doc, Enclosing_Instance.Enclosing_Instance.term.Field(), spans.Start(), spans.End(), payload, 0, positions.GetPayloadLength()));
						payloadsSeen++;
					}
					else
					{
						// zero out the payload?
					}
				}
Ejemplo n.º 14
0
 private void  InitBlock(Mono.Lucene.Net.Search.Weight weight, Mono.Lucene.Net.Search.Similarity similarity, FilteredQuery enclosingInstance)
 {
     this.weight            = weight;
     this.similarity        = similarity;
     this.enclosingInstance = enclosingInstance;
 }
Ejemplo n.º 15
0
 public AnonymousClassWeight(Mono.Lucene.Net.Search.Weight weight, Mono.Lucene.Net.Search.Similarity similarity, FilteredQuery enclosingInstance)
 {
     InitBlock(weight, similarity, enclosingInstance);
 }
Ejemplo n.º 16
0
		internal DocumentsWriter(Directory directory, IndexWriter writer, IndexingChain indexingChain)
		{
			InitBlock();
			this.directory = directory;
			this.writer = writer;
			this.similarity = writer.GetSimilarity();
			flushedDocCount = writer.MaxDoc();
			
			consumer = indexingChain.GetChain(this);
			if (consumer is DocFieldProcessor)
			{
				docFieldProcessor = (DocFieldProcessor) consumer;
			}
		}
Ejemplo n.º 17
0
 internal AnonymousClassConjunctionScorer(int requiredNrMatchers, BooleanScorer2 enclosingInstance, Mono.Lucene.Net.Search.Similarity Param1, System.Collections.ICollection Param2) : base(Param1, Param2)
 {
     InitBlock(requiredNrMatchers, enclosingInstance);
 }
Ejemplo n.º 18
0
 protected internal PayloadNearSpanScorer(PayloadNearQuery enclosingInstance, Mono.Lucene.Net.Search.Spans.Spans spans, Weight weight, Similarity similarity, byte[] norms) : base(spans, weight, similarity, norms)
 {
     InitBlock(enclosingInstance);
     this.spans = spans;
 }
Ejemplo n.º 19
0
 public PayloadTermSpanScorer(PayloadTermWeight enclosingInstance, TermSpans spans, Weight weight, Similarity similarity, byte[] norms) : base(spans, weight, similarity, norms)
 {
     InitBlock(enclosingInstance);
     positions = spans.GetPositions();
 }
Ejemplo n.º 20
0
			private float[] vScores; // reused in score() to avoid allocating this array for each doc 
			
			// constructor
			internal CustomScorer(CustomScoreQuery enclosingInstance, Similarity similarity, IndexReader reader, CustomWeight w, Scorer subQueryScorer, Scorer[] valSrcScorers):base(similarity)
			{
				InitBlock(enclosingInstance);
				this.weight = w;
				this.qWeight = w.GetValue();
				this.subQueryScorer = subQueryScorer;
				this.valSrcScorers = valSrcScorers;
				this.reader = reader;
				this.vScores = new float[valSrcScorers.Length];
                this.provider = this.Enclosing_Instance.GetCustomScoreProvider(reader);
			}
Ejemplo n.º 21
0
			public CustomWeight(CustomScoreQuery enclosingInstance, Searcher searcher)
			{
				InitBlock(enclosingInstance);
				this.similarity = Enclosing_Instance.GetSimilarity(searcher);
				this.subQueryWeight = Enclosing_Instance.subQuery.Weight(searcher);
				this.valSrcWeights = new Weight[Enclosing_Instance.valSrcQueries.Length];
				for (int i = 0; i < Enclosing_Instance.valSrcQueries.Length; i++)
				{
					this.valSrcWeights[i] = Enclosing_Instance.valSrcQueries[i].CreateWeight(searcher);
				}
				this.qStrict = Enclosing_Instance.strict;
			}
Ejemplo n.º 22
0
		internal void  SetSimilarity(Similarity similarity)
		{
			lock (this)
			{
				this.similarity = similarity;
				for (int i = 0; i < threadStates.Length; i++)
					threadStates[i].docState.similarity = similarity;
			}
		}
Ejemplo n.º 23
0
 static NormsWriter()
 {
     defaultNorm = Similarity.EncodeNorm(1.0f);
 }
Ejemplo n.º 24
0
		/// <summary>Expert: Set the Similarity implementation used by this IndexWriter.
		/// 
		/// </summary>
		/// <seealso cref="Similarity.SetDefault(Similarity)">
		/// </seealso>
		public virtual void  SetSimilarity(Similarity similarity)
		{
			EnsureOpen();
			this.similarity = similarity;
			docWriter.SetSimilarity(similarity);
		}