-
Notifications
You must be signed in to change notification settings - Fork 624
/
Scorer.cs
116 lines (106 loc) · 4.27 KB
/
Scorer.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
using Lucene.Net.Support;
using System.Collections.Generic;
namespace Lucene.Net.Search
{
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using DocsEnum = Lucene.Net.Index.DocsEnum;
/// <summary>
/// Expert: Common scoring functionality for different types of queries.
///
/// <para>
/// A <see cref="Scorer"/> iterates over documents matching a
/// query in increasing order of doc Id.
/// </para>
/// <para>
/// Document scores are computed using a given <see cref="Similarities.Similarity"/>
/// implementation.
/// </para>
///
/// <para><b>NOTE</b>: The values <see cref="float.NaN"/>,
/// <see cref="float.NegativeInfinity"/> and <see cref="float.PositiveInfinity"/> are
/// not valid scores. Certain collectors (eg
/// <see cref="TopScoreDocCollector"/>) will not properly collect hits
/// with these scores.
/// </para>
/// </summary>
public abstract class Scorer : DocsEnum
{
/// <summary>
/// The <see cref="Scorer"/>'s parent <see cref="Weight"/>. In some cases this may be <c>null</c>. </summary>
// TODO can we clean this up?
protected internal readonly Weight m_weight;
/// <summary>
/// Constructs a <see cref="Scorer"/> </summary>
/// <param name="weight"> The scorers <see cref="Weight"/>. </param>
protected Scorer(Weight weight)
{
this.m_weight = weight;
}
/// <summary>
/// Returns the score of the current document matching the query.
/// Initially invalid, until <see cref="DocIdSetIterator.NextDoc()"/> or <see cref="DocIdSetIterator.Advance(int)"/>
/// is called the first time, or when called from within
/// <see cref="ICollector.Collect(int)"/>.
/// </summary>
public abstract float GetScore();
/// <summary>
/// returns parent <see cref="Weight"/>
/// <para/>
/// @lucene.experimental
/// </summary>
public virtual Weight Weight => m_weight;
/// <summary>
/// Returns child sub-scorers
/// <para/>
/// @lucene.experimental
/// </summary>
public virtual ICollection<ChildScorer> GetChildren()
{
return Collections.EmptyList<ChildScorer>();
}
/// <summary>
/// A child <see cref="Scorer"/> and its relationship to its parent.
/// The meaning of the relationship depends upon the parent query.
/// <para/>
/// @lucene.experimental
/// </summary>
public class ChildScorer
{
/// <summary>
/// Child <see cref="Scorer"/>. (note this is typically a direct child, and may
/// itself also have children).
/// </summary>
public Scorer Child { get; private set; }
/// <summary>
/// An arbitrary string relating this scorer to the parent.
/// </summary>
public string Relationship { get; private set; }
/// <summary>
/// Creates a new <see cref="ChildScorer"/> node with the specified relationship.
/// <para/>
/// The relationship can be any be any string that makes sense to
/// the parent <see cref="Scorer"/>.
/// </summary>
public ChildScorer(Scorer child, string relationship)
{
this.Child = child;
this.Relationship = relationship;
}
}
}
}