org.LexGrid.LexBIG.example
Class ScoreTerm

java.lang.Object
  extended by org.LexGrid.LexBIG.example.ScoreTerm

public class ScoreTerm
extends java.lang.Object

Example showing a simple scoring algorithm that evaluates a provided term against available terms in a code system. A cutoff percentage can optionally be provided.


Nested Class Summary
protected  class ScoreTerm.ScoredTerm
           
 
Constructor Summary
ScoreTerm()
           
 
Method Summary
static void main(java.lang.String[] args)
          Program entry point.
protected  void printReport(org.apache.commons.collections.BidiMap result)
          Display results to the user.
protected  ResolvedConceptReferencesIterator resolveConcepts(CodingSchemeSummary css, java.lang.String query)
          Resolves matching concepts for any word in the given term.
 void run(java.lang.String term, float minScore)
          Runs the score algorithm for a specific term.
protected  float score(java.util.SortedSet wordsToCompare, java.util.SortedSet wordsToCompareAgainst)
          Returns a score providing a relative comparison of the first set of words against the second.
protected  java.util.SortedSet toWords(java.lang.String s)
          Return the words comprising the given string, in order ignoring duplicates, common separators and punctuation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ScoreTerm

public ScoreTerm()
Method Detail

main

public static void main(java.lang.String[] args)
Program entry point.

Parameters:
args - String[]

run

public void run(java.lang.String term,
                float minScore)
         throws java.lang.Exception
Runs the score algorithm for a specific term.

Parameters:
term - The text to evaluate.
score - Lower cutoff (percentage); a value less than or equal to 0 indicates no cutoff.
Throws:
java.lang.Exception

resolveConcepts

protected ResolvedConceptReferencesIterator resolveConcepts(CodingSchemeSummary css,
                                                            java.lang.String query)
                                                     throws LBException
Resolves matching concepts for any word in the given term.

Parameters:
css - The code system to search.
matchWords - The term to match.
Returns:
The list of matching references.
Throws:
LBException

score

protected float score(java.util.SortedSet wordsToCompare,
                      java.util.SortedSet wordsToCompareAgainst)
Returns a score providing a relative comparison of the first set of words against the second.

Currently the score is evaluated as a simple percentage based on number of words in the first set that are also in the second (order independent). This could be enhanced to take order into account, etc.

Parameters:
wordsToCompare -
wordsToCompareAgainst -
Returns:
The score (a percentage); a higher value indicates a stronger match.

printReport

protected void printReport(org.apache.commons.collections.BidiMap result)
Display results to the user.

Parameters:
result -

toWords

protected java.util.SortedSet toWords(java.lang.String s)
Return the words comprising the given string, in order ignoring duplicates, common separators and punctuation.

Parameters:
s -
Returns:
SortedSet

Copyright: (c) 2004-2006 Mayo Foundation for Medical Education and Research (MFMER). All rights reserved. MAYO, MAYO CLINIC, and the triple-shield Mayo logo are trademarks and service marks of MFMER.