20 using Lucene.Net.Support;
23 namespace Lucene.Net.Search
31 private bool checkedRepeats;
55 protected internal override float PhraseFreq()
57 int end = InitPhrasePositions();
60 bool done = (end < 0);
64 int start = pp.position;
65 int next = pq.Top().position;
67 bool tpsDiffer =
true;
68 for (
int pos = start; pos <= next || !tpsDiffer; pos = pp.position)
70 if (pos <= next && tpsDiffer)
72 if (!pp.NextPosition())
78 tpsDiffer = !pp.repeats || (pp2 = TermPositionsDiffer(pp)) == null;
79 if (pp2 != null && pp2 != pp)
85 int matchLength = end - start;
86 if (matchLength <= slop)
89 if (pp.position > end)
105 while ((pp3 = pq.Pop()) != pp2)
110 for (n--; n >= 0; n--)
112 pq.InsertWithOverflow(tmpPos[n]);
133 private int InitPhrasePositions()
138 if (checkedRepeats && repeats == null)
145 if (pp.position > end)
159 checkedRepeats =
true;
161 HashMap<PhrasePositions, object> m = null;
164 int tpPos = pp.position + pp.offset;
167 int tpPos2 = pp2.position + pp2.offset;
172 m =
new HashMap<PhrasePositions, object>();
183 repeats = m.Keys.ToArray();
190 for (
int i = 0; i < repeats.Length; i++)
194 while ((pp2 = TermPositionsDiffer(pp)) != null)
196 if (!pp2.NextPosition())
207 if (pp.position > end)
231 int tpPos = pp.position + pp.offset;
232 for (
int i = 0; i < repeats.Length; i++)
237 int tpPos2 = pp2.position + pp2.offset;
239 return pp.offset > pp2.offset?pp:pp2;