software/test/performance/src/org/LexGrid/LexBIG/example/MetaMatch.java
/**
	 * Attempt to approximate term completion.
	 * @param s The test string.
	 * @param lbSvc
	 * @param scheme
	 * @param csvt
	 * @throws LBException
	 */
Attempt to approximate term completion.
@param s The test string.
Attempt to approximate term completion . @param s The test string .
@SuppressWarnings("unchecked")
	protected void matchTermCompletion(String s, EVSApplicationService lbSvc, String scheme, CodingSchemeVersionOrTag csvt)
		throws LBException
	{
		Util.displayMessage("\n*** Term completion ...");
		String prefix = s.toLowerCase();
		String[] words = toWords(s, false);
		CodedNodeSet nodes = lbSvc.getCodingSchemeConcepts(scheme, csvt);
		nodes.restrictToMatchingDesignations(
			prefix, SearchDesignationOption.ALL,
			"startsWith", null);
		SortOptionList sortCriteria =
			Constructors.createSortOptionList(new String[]{"matchToQuery"});
		ResolvedConceptReferenceList matches =
			nodes.resolveToList(sortCriteria, null, new PropertyType[] {}, 5);
		Util.displayMessage("\tstartsWith (limited to 5 hits); short circuit after query...");
		if (matches.getResolvedConceptReferenceCount() > 0) {
			for (int i = 0; i < matches.getResolvedConceptReferenceCount(); i++) {
				ResolvedConceptReference ref = matches.getResolvedConceptReference(i);
				printText(ref, false, prefix, words.length + 1);
			}
		} else {
			Util.displayMessage("\tNo match found.");
		}
		nodes = lbSvc.getCodingSchemeConcepts(scheme, csvt);
		String regex = '^' + prefix + "\\W*\\w*\\Z";
		nodes.restrictToMatchingDesignations(
				regex, SearchDesignationOption.ALL,
				"RegExp", null);
		matches = nodes.resolveToList(sortCriteria, null, new PropertyType[] {}, 5);
		Util.displayMessage("\n\tRegExp match (limited to 5 hits); short circuit on query...");
		if (matches.getResolvedConceptReferenceCount() > 0) {
			for (int i = 0; i < matches.getResolvedConceptReferenceCount(); i++) {
				ResolvedConceptReference ref = matches.getResolvedConceptReference(i);
				printText(ref, false, prefix, words.length + 1);
			}
		} else {
			Util.displayMessage("\tNo match found.");
		}
	}
@ SuppressWarnings ( "unchecked" ) protected void matchTermCompletion ( String s , EVSApplicationService lbSvc , String scheme , CodingSchemeVersionOrTag csvt ) throws LBException { Util . displayMessage ( "\n*** Term completion ..." ) ; String prefix = s . toLowerCase ( ) ; String [ ] words = toWords ( s , false ) ; CodedNodeSet nodes = lbSvc . getCodingSchemeConcepts ( scheme , csvt ) ; nodes . restrictToMatchingDesignations ( prefix , SearchDesignationOption . ALL , "startsWith" , null ) ; SortOptionList sortCriteria = Constructors . createSortOptionList ( new String [ ] { "matchToQuery" } ) ; ResolvedConceptReferenceList matches = nodes . resolveToList ( sortCriteria , null , new PropertyType [ ] { } , 5 ) ; Util . displayMessage ( "\tstartsWith (limited to 5 hits); short circuit after query..." ) ; if ( matches . getResolvedConceptReferenceCount ( ) > 0 ) { for ( int i = 0 ; i < matches . getResolvedConceptReferenceCount ( ) ; i ++ ) { ResolvedConceptReference ref = matches . getResolvedConceptReference ( i ) ; printText ( ref , false , prefix , words . length + 1 ) ; } } else { Util . displayMessage ( "\tNo match found." ) ; } nodes = lbSvc . getCodingSchemeConcepts ( scheme , csvt ) ; String regex = '^' + prefix + "\\W*\\w*\\Z" ; nodes . restrictToMatchingDesignations ( regex , SearchDesignationOption . ALL , "RegExp" , null ) ; matches = nodes . resolveToList ( sortCriteria , null , new PropertyType [ ] { } , 5 ) ; Util . displayMessage ( "\n\tRegExp match (limited to 5 hits); short circuit on query..." ) ; if ( matches . getResolvedConceptReferenceCount ( ) > 0 ) { for ( int i = 0 ; i < matches . getResolvedConceptReferenceCount ( ) ; i ++ ) { ResolvedConceptReference ref = matches . getResolvedConceptReference ( i ) ; printText ( ref , false , prefix , words . length + 1 ) ; } } else { Util . displayMessage ( "\tNo match found." ) ; } }
Attempt to approximate term completion.
Attempt to approximate term completion .
// Term completion is basically 'startsWith'.  Two different
 // queries are tried to match.  The first utilizes the standard
 // startsWith match algorithm.  The second utilizes regular
 // expressions to try and accomplish short-circuiting more
 // efficiently.
 //
 // Queries are currently made against all text representations,
 // but this could be narrowed.
 //
 // On resolve, we sort by lucene score ('matchToQuery' sort algorithm).
 // Resolve and analyze the result ...
 // Found a match?
 // Try again with regular expression.
 // Resolve and analyze the result ...
 // Found a match?
