FileDocCategorySizeDatePackage
TokenGroup.javaAPI DocApache Lucene 2.1.03046Wed Feb 14 10:46:22 GMT 2007org.apache.lucene.search.highlight

TokenGroup

public class TokenGroup extends Object
One, or several overlapping tokens, along with the score(s) and the scope of the original text
author
MAHarwood

Fields Summary
private static final int
MAX_NUM_TOKENS_PER_GROUP
Token[]
tokens
float[]
scores
int
numTokens
int
startOffset
int
endOffset
float
tot
int
matchStartOffset
int
matchEndOffset
Constructors Summary
Methods Summary
voidaddToken(org.apache.lucene.analysis.Token token, float score)



      
	
	    if(numTokens < MAX_NUM_TOKENS_PER_GROUP)
        {	    
			if(numTokens==0)
			{
				startOffset=matchStartOffset=token.startOffset();
				endOffset=matchEndOffset=token.endOffset();
				tot += score;
			}
			else
			{
				startOffset=Math.min(startOffset,token.startOffset());
				endOffset=Math.max(endOffset,token.endOffset());
        if (score>0) {
          if (tot==0) {
            matchStartOffset=token.startOffset();
            matchEndOffset=token.endOffset();
          } else {
            matchStartOffset=Math.min(matchStartOffset,token.startOffset());
            matchEndOffset=Math.max(matchEndOffset,token.endOffset());
          }
          tot+=score;
        }
      }
			tokens[numTokens]=token;
			scores[numTokens]=score;
			numTokens++;
        }
	
voidclear()

		numTokens=0;
		tot=0;
	
public intgetEndOffset()

return
the end position in the original text

		return endOffset;
	
public intgetNumTokens()

return
the number of tokens in this group

		return numTokens;
	
public floatgetScore(int index)

param
index a value between 0 and numTokens -1
return
the "n"th score

		return scores[index];
	
public intgetStartOffset()

return
the start position in the original text

		return startOffset;
	
public org.apache.lucene.analysis.TokengetToken(int index)

param
index a value between 0 and numTokens -1
return
the "n"th token

		return tokens[index];
	
public floatgetTotalScore()

return
all tokens' scores summed up

		return tot;
	
booleanisDistinct(org.apache.lucene.analysis.Token token)

		return token.startOffset()>=endOffset;