19 using Lucene.Net.Analysis;
20 using Lucene.Net.Analysis.Tokenattributes;
22 namespace Lucene.Net.Search.Highlight
29 private static readonly
int MAX_NUM_TOKENS_PER_GROUP = 50;
31 private Token[] tokens =
new Token[MAX_NUM_TOKENS_PER_GROUP];
32 private float[] scores =
new float[MAX_NUM_TOKENS_PER_GROUP];
33 private int startOffset = 0;
34 private int endOffset = 0;
37 public int MatchStartOffset {
get;
private set; }
38 public int MatchEndOffset {
get;
private set; }
39 public int NumTokens {
get;
private set; }
51 protected internal void AddToken(
float score)
53 if (NumTokens < MAX_NUM_TOKENS_PER_GROUP)
55 int termStartOffset = offsetAtt.StartOffset;
56 int termEndOffset = offsetAtt.EndOffset;
59 startOffset = MatchStartOffset = termStartOffset;
60 endOffset = MatchEndOffset = termEndOffset;
65 startOffset = Math.Min(startOffset, termStartOffset);
66 endOffset = Math.Max(endOffset, termEndOffset);
71 MatchStartOffset = offsetAtt.StartOffset;
72 MatchEndOffset = offsetAtt.EndOffset;
76 MatchStartOffset = Math.Min(MatchStartOffset, termStartOffset);
77 MatchEndOffset = Math.Max(MatchEndOffset, termEndOffset);
82 Token token =
new Token(termStartOffset, termEndOffset);
84 tokens[NumTokens] = token;
85 scores[NumTokens] = score;
90 protected internal bool IsDistinct()
95 protected internal void Clear()
108 return tokens[index];
115 public float GetScore(
int index)
117 return scores[index];
125 get {
return endOffset; }
131 public int StartOffset
133 get {
return startOffset; }
139 public float TotalScore