FileDocCategorySizeDatePackage
TokenGroup.javaAPI DocApache Lucene 1.92491Mon Feb 20 09:18:22 GMT 2006org.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
Constructors Summary
Methods Summary
voidaddToken(org.apache.lucene.analysis.Token token, float score)

	

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

		numTokens=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

		float total=0;
		for (int i = 0; i < numTokens; i++)
		{
			total+=scores[i];
		}
		return total;
	
booleanisDistinct(org.apache.lucene.analysis.Token token)

		return token.startOffset()>=endOffset;