software/test/performance/src/gov/nih/nci/evs/browser/utils/SearchUtils.java
/**
	 * Returns a score providing a relative comparison of the given
	 * text against a set of keywords.
	 * <p>
	 * Currently the score is evaluated as a simple percentage
	 * based on number of words in the first set that are also in the
	 * second, with minor adjustment for order (matching later
	 * words given slightly higher weight, anticipating often the
	 * subject of search will follow descriptive text).  Weight
	 * is also increased for shorter phrases (measured in # words)
	 * If the text is indicated to be preferred, the score is doubled
	 * to promote 'bubbling to the top'.
	 * <p>
	 * Ranking from the original search is available but not
	 * currently used in the heuristic (tends to throw-off desired
	 * alphabetic groupings later).
	 *
	 * @param text
	 * @param keywords
	 * @param isPreferred
	 * @param searchRank
	 * @return The score; a higher value indicates a stronger match.
	 */
Returns a score providing a relative comparison of the given
text against a set of keywords.

Currently the score is evaluated as a simple percentage
based on number of words in the first set that are also in the
second, with minor adjustment for order (matching later
words given slightly higher weight, anticipating often the
subject of search will follow descriptive text).  Weight
is also increased for shorter phrases (measured in # words)
If the text is indicated to be preferred, the score is doubled
to promote 'bubbling to the top'.

Ranking from the original search is available but not
currently used in the heuristic (tends to throw-off desired
alphabetic groupings later).


Returns a score providing a relative comparison of the given text against a set of keywords . Currently the score is evaluated as a simple percentage based on number of words in the first set that are also in the second with minor adjustment for order ( matching later words given slightly higher weight anticipating often the subject of search will follow descriptive text ) . Weight is also increased for shorter phrases ( measured in # words ) If the text is indicated to be preferred the score is doubled to promote ' bubbling to the top ' . Ranking from the original search is available but not currently used in the heuristic ( tends to throw - off desired alphabetic groupings later ) .
protected float score(String text, List<String> keywords, boolean isPreferred, float searchRank) {
	    List<String> wordsToCompare = toScoreWords(text);
		float totalWords = wordsToCompare.size();
		float matchScore = 0;
		float position = 0;
		for (Iterator<String> words = wordsToCompare.listIterator(); words.hasNext(); position++) {
		    String word = words.next();
			if (keywords.contains(word))
			    matchScore += ((position / 10) + 1);
		}
		return
		    Math.max(0, 100 + (matchScore / totalWords * 100) - (totalWords * 2))
                * (isPreferred ? 2 : 1);
	}
protected float score ( String text , List < String > keywords , boolean isPreferred , float searchRank ) { List < String > wordsToCompare = toScoreWords ( text ) ; float totalWords = wordsToCompare . size ( ) ; float matchScore = 0 ; float position = 0 ; for ( Iterator < String > words = wordsToCompare . listIterator ( ) ; words . hasNext ( ) ; position ++ ) { String word = words . next ( ) ; if ( keywords . contains ( word ) ) matchScore += ( ( position / 10 ) + 1 ) ; } return Math . max ( 0 , 100 + ( matchScore / totalWords * 100 ) - ( totalWords * 2 ) ) * ( isPreferred ? 2 : 1 ) ; }
Returns a score providing a relative comparison of the given
 text against a set of keywords.
Returns a score providing a relative comparison of the given text against a set of keywords .