-
Notifications
You must be signed in to change notification settings - Fork 624
/
FieldInvertState.cs
168 lines (154 loc) · 5.65 KB
/
FieldInvertState.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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
namespace Lucene.Net.Index
{
/*
* 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.
*/
// javadocs
using AttributeSource = Lucene.Net.Util.AttributeSource;
/// <summary>
/// This class tracks the number and position / offset parameters of terms
/// being added to the index. The information collected in this class is
/// also used to calculate the normalization factor for a field.
/// <para/>
/// @lucene.experimental
/// </summary>
public sealed class FieldInvertState
{
// LUCENENET specific - made fields private and added internal setters so they can be set
private string name;
private int position;
private int length;
private int numOverlap;
private int offset;
private int maxTermFrequency;
private int uniqueTermCount;
private float boost;
private AttributeSource attributeSource;
/// <summary>
/// Creates <see cref="FieldInvertState"/> for the specified
/// field name.
/// </summary>
public FieldInvertState(string name)
{
this.name = name;
}
/// <summary>
/// Creates <see cref="FieldInvertState"/> for the specified
/// field name and values for all fields.
/// </summary>
public FieldInvertState(string name, int position, int length, int numOverlap, int offset, float boost)
{
this.name = name;
this.position = position;
this.length = length;
this.numOverlap = numOverlap;
this.offset = offset;
this.boost = boost;
}
/// <summary>
/// Re-initialize the state
/// </summary>
internal void Reset()
{
position = 0;
length = 0;
numOverlap = 0;
offset = 0;
maxTermFrequency = 0;
uniqueTermCount = 0;
boost = 1.0f;
attributeSource = null;
}
/// <summary>
/// Gets the last processed term position. </summary>
/// <returns> the position </returns>
public int Position
{
get => position;
internal set => position = value; // LUCENENET specific to protect private field
}
/// <summary>
/// Gets or Sets total number of terms in this field. </summary>
/// <returns> the length </returns>
public int Length
{
get => length;
set => this.length = value;
}
/// <summary>
/// Gets or Sets the number of terms with <c>positionIncrement == 0</c>. </summary>
/// <returns> the numOverlap </returns>
public int NumOverlap
{
get => numOverlap;
set => this.numOverlap = value;
}
/// <summary>
/// Gets end offset of the last processed term. </summary>
/// <returns> the offset </returns>
public int Offset
{
get => offset;
internal set => offset = value; // LUCENENET specific to protect private field
}
/// <summary>
/// Gets or Sets boost value. This is the cumulative product of
/// document boost and field boost for all field instances
/// sharing the same field name. </summary>
/// <returns> the boost </returns>
public float Boost
{
get => boost;
set => this.boost = value;
}
/// <summary>
/// Get the maximum term-frequency encountered for any term in the field. A
/// field containing "the quick brown fox jumps over the lazy dog" would have
/// a value of 2, because "the" appears twice.
/// </summary>
public int MaxTermFrequency
{
get => maxTermFrequency;
internal set => maxTermFrequency = value; // LUCENENET specific to protect private field
}
/// <summary>
/// Gets the number of unique terms encountered in this field.
/// </summary>
public int UniqueTermCount
{
get => uniqueTermCount;
internal set => uniqueTermCount = value; // LUCENENET specific to protect private field
}
/// <summary>
/// Gets the <see cref="Util.AttributeSource"/> from the
/// <see cref="Analysis.TokenStream"/> that provided the indexed tokens for this
/// field.
/// </summary>
public AttributeSource AttributeSource
{
get => attributeSource;
internal set => attributeSource = value; // LUCENENET specific to protect private field
}
/// <summary>
/// Gets the field's name
/// </summary>
public string Name
{
get => name;
internal set => name = value; // LUCENENET specific to protect private field
}
}
}