software/test/performance/src/org/LexGrid/LexBIG/example/MetaMatch.java
/**
	 * Attempt to approximate spelling suggestions.
	 * @param s The test string.
	 * @param lbSvc
	 * @param scheme
	 * @param csvt
	 * @throws LBException
	 */
Attempt to approximate spelling suggestions.
@param s The test string.
Attempt to approximate spelling suggestions . @param s The test string .
protected void matchSpell(String s, EVSApplicationService lbSvc, String scheme, CodingSchemeVersionOrTag csvt)
		throws LBException
	{
		Util.displayMessage("\n*** Matching spell suggestions ...");
		String[] words = toWords(s, true);
		String prefix = words[0].substring(0, 1);
		CodedNodeSet nodes = lbSvc.getCodingSchemeConcepts(scheme, csvt);
		StringBuffer searchPhrase = new StringBuffer(s).append('~');
		nodes.restrictToMatchingDesignations(
			searchPhrase.toString(), SearchDesignationOption.ALL,
			MatchAlgorithms.LuceneQuery.toString(), null);
		SortOptionList sortCriteria =
			Constructors.createSortOptionList(new String[]{"matchToQuery"});
		ResolvedConceptReferenceList matches =
			nodes.resolveToList(sortCriteria, null, new PropertyType[] {}, 5);
		Util.displayMessage("\tLevenshtein distance (limited to 5 hits): ");
		if (matches.getResolvedConceptReferenceCount() > 0) {
			for (int i = 0; i < matches.getResolvedConceptReferenceCount(); i++) {
				ResolvedConceptReference ref = matches.getResolvedConceptReference(i);
				printText(ref, true, prefix, words.length);
			}
		} else {
			Util.displayMessage("\tNo match found.");
		}
		nodes = lbSvc.getCodingSchemeConcepts(scheme, csvt);
		nodes.restrictToMatchingDesignations(
			s, SearchDesignationOption.ALL,
			MatchAlgorithms.DoubleMetaphoneLuceneQuery.toString(), null);
		matches = nodes.resolveToList(sortCriteria, null, new PropertyType[] {}, 5);
		Util.displayMessage("\n\tSounds-like/DoubleMetaphone (limited to 5 hits): ");
		if (matches.getResolvedConceptReferenceCount() > 0) {
			for (int i = 0; i < matches.getResolvedConceptReferenceCount(); i++) {
				ResolvedConceptReference ref = matches.getResolvedConceptReference(i);
				printText(ref, true, prefix, words.length);
			}
		} else {
			Util.displayMessage("\tNo match found.");
		}
	}
protected void matchSpell ( String s , EVSApplicationService lbSvc , String scheme , CodingSchemeVersionOrTag csvt ) throws LBException { Util . displayMessage ( "\n*** Matching spell suggestions ..." ) ; String [ ] words = toWords ( s , true ) ; String prefix = words [ 0 ] . substring ( 0 , 1 ) ; CodedNodeSet nodes = lbSvc . getCodingSchemeConcepts ( scheme , csvt ) ; StringBuffer searchPhrase = new StringBuffer ( s ) . append ( '~' ) ; nodes . restrictToMatchingDesignations ( searchPhrase . toString ( ) , SearchDesignationOption . ALL , MatchAlgorithms . LuceneQuery . toString ( ) , null ) ; SortOptionList sortCriteria = Constructors . createSortOptionList ( new String [ ] { "matchToQuery" } ) ; ResolvedConceptReferenceList matches = nodes . resolveToList ( sortCriteria , null , new PropertyType [ ] { } , 5 ) ; Util . displayMessage ( "\tLevenshtein distance (limited to 5 hits): " ) ; if ( matches . getResolvedConceptReferenceCount ( ) > 0 ) { for ( int i = 0 ; i < matches . getResolvedConceptReferenceCount ( ) ; i ++ ) { ResolvedConceptReference ref = matches . getResolvedConceptReference ( i ) ; printText ( ref , true , prefix , words . length ) ; } } else { Util . displayMessage ( "\tNo match found." ) ; } nodes = lbSvc . getCodingSchemeConcepts ( scheme , csvt ) ; nodes . restrictToMatchingDesignations ( s , SearchDesignationOption . ALL , MatchAlgorithms . DoubleMetaphoneLuceneQuery . toString ( ) , null ) ; matches = nodes . resolveToList ( sortCriteria , null , new PropertyType [ ] { } , 5 ) ; Util . displayMessage ( "\n\tSounds-like/DoubleMetaphone (limited to 5 hits): " ) ; if ( matches . getResolvedConceptReferenceCount ( ) > 0 ) { for ( int i = 0 ; i < matches . getResolvedConceptReferenceCount ( ) ; i ++ ) { ResolvedConceptReference ref = matches . getResolvedConceptReference ( i ) ; printText ( ref , true , prefix , words . length ) ; } } else { Util . displayMessage ( "\tNo match found." ) ; } }
Attempt to approximate spelling suggestions.
Attempt to approximate spelling suggestions .
// Note: Metaphrase contained an integrated spell check module;
 // LexBIG does not as of the 2.0 release.  Instead, spell
 // suggestion is based off entire phrase in comparison
 // to content stored in the ontology; no external dictionary
 // is utilized.  While a dedicated speller has advantages,
 // there are also advantages to this approach (e.g. automatic
 // tuning of the search to the ontology content).
 //
 // Two different algorithms are highlighted in this code
 // for consideration. The first utilizes the lucene-based
 // Levenshtein distance algorithm.  The second utilizes the
 // DoubleMetaphoneLuceneQuery (sounds-like) algorithm.
 //
 // Queries are currently made against all text representations
 // and not just the primary text representation for ,
 // but this could be narrowed.
 //
 // On resolve, we sort by lucene score ('matchToQuery' sort algorithm).
 // Levenshtein 'edit distance' processing ...
 // Resolve and analyze the result ...
 // Found a match?
 // OK, so we have it narrowed to a concept at this point but not a
 // specific term.  Narrow the choices to those that include the same
 // starting letter and number of words as our test phrase.
 // Sounds-like processing ...
 // Resolve and analyze the result ...
 // Found a match?
 // Once again we have it narrowed to a concept at this point but not
 // a specific term.  Narrow the choices to those that include the same
 // starting letter and number of words as our test phrase.
