software/test/performance/src/org/LexGrid/LexBIG/example/ScoreTerm.java
/**
	 * Runs the score algorithm for a specific term.
	 * @param term The text to evaluate.
	 * @param score Lower cutoff (percentage); a value less than or equal
	 * to 0 indicates no cutoff. 
	 * @throws Exception
	 */
Runs the score algorithm for a specific term.
@param term The text to evaluate.
@param score Lower cutoff (percentage); a value less than or equal
to 0 indicates no cutoff.
@throws Exception
Runs the score algorithm for a specific term . @param term The text to evaluate . @param score Lower cutoff ( percentage ) ; a value less than or equal to 0 indicates no cutoff . @throws Exception
public void run(String term, float minScore) throws Exception {
		CodingSchemeSummary css = Util.promptForCodeSystem();
		if (css != null) {
			SortedSet<String> compareWords = toWords(term);
			BidiMap scoredResult = new TreeBidiMap();
			for (ResolvedConceptReferencesIterator matches = resolveConcepts(css, term); matches.hasNext(); ) {
				ResolvedConceptReferenceList refs = matches.next(100);
				for (int i = 0; i < refs.getResolvedConceptReferenceCount(); i++) {
					ResolvedConceptReference ref = refs.getResolvedConceptReference(i);
					String code = ref.getConceptCode();
					Concept ce = ref.getReferencedEntry();
					Presentation[] allTermsForConcept = ce.getPresentation();
					for (int j = 0; j < allTermsForConcept.length; j++) {
						Presentation p = allTermsForConcept[j];
						String text = p.getText().getContent();
						float score = score(toWords(text), compareWords);
						if (score > minScore) {
							if (scoredResult.containsKey(code)) {
								ScoredTerm scoredTerm = (ScoredTerm) scoredResult.get(code);
								if (scoredTerm.score > score)
									continue;
							}
							ScoredTerm scoredTerm = new ScoredTerm();
							scoredTerm.term = text;
							scoredTerm.score = score;
							scoredResult.put(code, scoredTerm);
						}
					}
				}
			}
			printReport(scoredResult);
		}
	}
public void run ( String term , float minScore ) throws Exception { CodingSchemeSummary css = Util . promptForCodeSystem ( ) ; if ( css != null ) { SortedSet < String > compareWords = toWords ( term ) ; BidiMap scoredResult = new TreeBidiMap ( ) ; for ( ResolvedConceptReferencesIterator matches = resolveConcepts ( css , term ) ; matches . hasNext ( ) ; ) { ResolvedConceptReferenceList refs = matches . next ( 100 ) ; for ( int i = 0 ; i < refs . getResolvedConceptReferenceCount ( ) ; i ++ ) { ResolvedConceptReference ref = refs . getResolvedConceptReference ( i ) ; String code = ref . getConceptCode ( ) ; Concept ce = ref . getReferencedEntry ( ) ; Presentation [ ] allTermsForConcept = ce . getPresentation ( ) ; for ( int j = 0 ; j < allTermsForConcept . length ; j ++ ) { Presentation p = allTermsForConcept [ j ] ; String text = p . getText ( ) . getContent ( ) ; float score = score ( toWords ( text ) , compareWords ) ; if ( score > minScore ) { if ( scoredResult . containsKey ( code ) ) { ScoredTerm scoredTerm = ( ScoredTerm ) scoredResult . get ( code ) ; if ( scoredTerm . score > score ) continue ; } ScoredTerm scoredTerm = new ScoredTerm ( ) ; scoredTerm . term = text ; scoredTerm . score = score ; scoredResult . put ( code , scoredTerm ) ; } } } } printReport ( scoredResult ) ; } }
Runs the score algorithm for a specific term.
Runs the score algorithm for a specific term .
// Allow the user to pick the target coding scheme.
 // This could also be hardcoded to a specific coding scheme.
 // Determine the set of individual words to compare against.
 // Create a bucket to store results.
 // Sort the results by score (highest score first) and code key.
 // Resolve and iterate through matches to score each.
 // For this example, we keep the highest score per coded concept.
 // Work in chunks of 100.
 // Check for a previous match on this code for a different presentation.
 // If already present save the item of most relevance. 
 // Print the results.
