software/test/performance/src/org/LexGrid/LexBIG/example/remote2/MetaMatch2.java
/**
     * Display concepts and related text strings matching the given string.
     * @param s The test string.
     * @throws LBException
     */
Display concepts and related text strings matching the given string.
@param s The test string.
Display concepts and related text strings matching the given string . @param s The test string .
protected void matchSynonyms(String s)
        throws LBException
    {
        _buffer.delete(0, _buffer.length());
        Util.StopWatch stopWatch = new Util.StopWatch();
        _buffer.append("*** Matching synonyms (incorporates partial normalization/stemming).\n");
        StringBuffer searchPhrase = new StringBuffer();
        String[] words = toWords(s, true);
        for (int i = 0; i < words.length; i++) {
            if (i > 0)
                searchPhrase.append(" AND ");
            searchPhrase.append(words[i]);
        }
        CodedNodeSet nodes = _lbSvc.getCodingSchemeConcepts(_scheme, _csvt);
        nodes.restrictToMatchingDesignations(
            searchPhrase.toString(), SearchDesignationOption.ALL, "StemmedLuceneQuery", null);
        SortOptionList sortCriteria =
            Constructors.createSortOptionList(new String[]{"matchToQuery"});
        PropertyType[] fetchTypes =
            new PropertyType[] {PropertyType.PRESENTATION};
        ResolvedConceptReferenceList matches =
            nodes.resolveToList(sortCriteria, null, fetchTypes, -1);
        if (matches.getResolvedConceptReferenceCount() > 0) {
            final List<String> matchWords = Arrays.asList(words);
            int ctr = 0;
            for (int i = 0; i < matches.getResolvedConceptReferenceCount(); i++) {
                ResolvedConceptReference ref = matches.getResolvedConceptReference(i);
                if (getReferenceWeight(ref, matchWords) == 1)
                    ctr = printText(ctr, ref);
            }
        } else {
            _buffer.append("\tNo match found.\n");
        }
        _buffer.append("* " + stopWatch.getResult());
        Util.displayMessage(_buffer.toString());
    }
protected void matchSynonyms ( String s ) throws LBException { _buffer . delete ( 0 , _buffer . length ( ) ) ; Util . StopWatch stopWatch = new Util . StopWatch ( ) ; _buffer . append ( "*** Matching synonyms (incorporates partial normalization/stemming).\n" ) ; StringBuffer searchPhrase = new StringBuffer ( ) ; String [ ] words = toWords ( s , true ) ; for ( int i = 0 ; i < words . length ; i ++ ) { if ( i > 0 ) searchPhrase . append ( " AND " ) ; searchPhrase . append ( words [ i ] ) ; } CodedNodeSet nodes = _lbSvc . getCodingSchemeConcepts ( _scheme , _csvt ) ; nodes . restrictToMatchingDesignations ( searchPhrase . toString ( ) , SearchDesignationOption . ALL , "StemmedLuceneQuery" , null ) ; SortOptionList sortCriteria = Constructors . createSortOptionList ( new String [ ] { "matchToQuery" } ) ; PropertyType [ ] fetchTypes = new PropertyType [ ] { PropertyType . PRESENTATION } ; ResolvedConceptReferenceList matches = nodes . resolveToList ( sortCriteria , null , fetchTypes , - 1 ) ; if ( matches . getResolvedConceptReferenceCount ( ) > 0 ) { final List < String > matchWords = Arrays . asList ( words ) ; int ctr = 0 ; for ( int i = 0 ; i < matches . getResolvedConceptReferenceCount ( ) ; i ++ ) { ResolvedConceptReference ref = matches . getResolvedConceptReference ( i ) ; if ( getReferenceWeight ( ref , matchWords ) == 1 ) ctr = printText ( ctr , ref ) ; } } else { _buffer . append ( "\tNo match found.\n" ) ; } _buffer . append ( "* " + stopWatch . getResult ( ) ) ; Util . displayMessage ( _buffer . toString ( ) ) ; }
Display concepts and related text strings matching the given string.
Display concepts and related text strings matching the given string .
// An attempt is made to use a partial normalized form on search by
 // removing stop words and utilizing a stemmed query algorithm.
 // Query is performed over all text representations (preferred and
 // non-preferred) that contain every non-stop word in the given
 // string.
 //
 // On resolve, we sort by lucene score ('matchToQuery' sort algorithm).
 // Define the code set and add restrictions ...
 // Resolve and analyze the result ...
 // Found a match?  If so, sort according to relevance.
 // NOTE that a match so far only indicates that all of the words in the
 // passed in string also exist in a term assigned to the resolved
 // concepts.  It does not, however, exclude results where the terms
 // also have additional words.  This code currently processes only
 // full matches by calling getReferenceWeight and taking only those
 // values with weight '1'.
 // List concept references with exact correlation of at least one
 // concept term to the compare string.
