software/test/performance/src/org/LexGrid/LexBIG/example/MetaMatch.java
/**
	 * Attempt to approximate word completion.
	 * @param s The test string.
	 * @param lbSvc
	 * @param scheme
	 * @param csvt
	 * @throws LBException
	 */
Attempt to approximate word completion.
@param s The test string.
Attempt to approximate word completion . @param s The test string .
@SuppressWarnings("unchecked")
	protected void matchWordCompletion(String s, EVSApplicationService lbSvc, String scheme, CodingSchemeVersionOrTag csvt)
		throws LBException
	{
		Util.displayMessage("\n*** Word completion (based on '.') ...");
		String prefix = s.toLowerCase();
		String[] words = toWords(prefix, false);
		StringBuffer regex = new StringBuffer();
		regex.append('^');
		for (int i = 0; i < words.length; i++) {
			boolean lastWord = i == words.length - 1;
			String word = words[i];
			regex.append('(');
			if (word.charAt(word.length() - 1) == '.') {
				regex.append(word.substring(0, word.length()));
				regex.append("\\w*");
			}
			else
				regex.append(word);
			regex.append("\\s").append(lastWord ? '*' : '+');
			regex.append(')');
		}
		regex.append("\\Z");
		CodedNodeSet nodes = lbSvc.getCodingSchemeConcepts(scheme, csvt);
		nodes.restrictToMatchingDesignations(
				regex.toString(), SearchDesignationOption.ALL,
				"RegExp", null);
		SortOptionList sortCriteria =
			Constructors.createSortOptionList(new String[]{"matchToQuery"});
		ResolvedConceptReferenceList matches =
			nodes.resolveToList(sortCriteria, null, new PropertyType[] {}, 5);
		Util.displayMessage("\tFound via RegExp match (limited to 5 hits)...");
		if (matches.getResolvedConceptReferenceCount() > 0) {
			int dotIndex = prefix.indexOf('.');
			if (dotIndex < 0)
				dotIndex = prefix.length();
			for (int i = 0; i < matches.getResolvedConceptReferenceCount(); i++) {
				ResolvedConceptReference ref = matches.getResolvedConceptReference(i);
				printText(ref, false, prefix.substring(0, dotIndex), -1);
			}
		} else {
			Util.displayMessage("\tNo match found.");
		}
	}
@ SuppressWarnings ( "unchecked" ) protected void matchWordCompletion ( String s , EVSApplicationService lbSvc , String scheme , CodingSchemeVersionOrTag csvt ) throws LBException { Util . displayMessage ( "\n*** Word completion (based on '.') ..." ) ; String prefix = s . toLowerCase ( ) ; String [ ] words = toWords ( prefix , false ) ; StringBuffer regex = new StringBuffer ( ) ; regex . append ( '^' ) ; for ( int i = 0 ; i < words . length ; i ++ ) { boolean lastWord = i == words . length - 1 ; String word = words [ i ] ; regex . append ( '(' ) ; if ( word . charAt ( word . length ( ) - 1 ) == '.' ) { regex . append ( word . substring ( 0 , word . length ( ) ) ) ; regex . append ( "\\w*" ) ; } else regex . append ( word ) ; regex . append ( "\\s" ) . append ( lastWord ? '*' : '+' ) ; regex . append ( ')' ) ; } regex . append ( "\\Z" ) ; CodedNodeSet nodes = lbSvc . getCodingSchemeConcepts ( scheme , csvt ) ; nodes . restrictToMatchingDesignations ( regex . toString ( ) , SearchDesignationOption . ALL , "RegExp" , null ) ; SortOptionList sortCriteria = Constructors . createSortOptionList ( new String [ ] { "matchToQuery" } ) ; ResolvedConceptReferenceList matches = nodes . resolveToList ( sortCriteria , null , new PropertyType [ ] { } , 5 ) ; Util . displayMessage ( "\tFound via RegExp match (limited to 5 hits)..." ) ; if ( matches . getResolvedConceptReferenceCount ( ) > 0 ) { int dotIndex = prefix . indexOf ( '.' ) ; if ( dotIndex < 0 ) dotIndex = prefix . length ( ) ; for ( int i = 0 ; i < matches . getResolvedConceptReferenceCount ( ) ; i ++ ) { ResolvedConceptReference ref = matches . getResolvedConceptReference ( i ) ; printText ( ref , false , prefix . substring ( 0 , dotIndex ) , - 1 ) ; } } else { Util . displayMessage ( "\tNo match found." ) ; } }
Attempt to approximate word completion.
Attempt to approximate word completion .
// For word completion, we just use a regular expression and
 // substitute any alpha-numeric character for the substitution
 // character ('.').
 // 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?
