当前位置: 首页>>代码示例>>Java>>正文


Java Constructors.createSortOptionList方法代码示例

本文整理汇总了Java中org.LexGrid.LexBIG.Utility.Constructors.createSortOptionList方法的典型用法代码示例。如果您正苦于以下问题:Java Constructors.createSortOptionList方法的具体用法?Java Constructors.createSortOptionList怎么用?Java Constructors.createSortOptionList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.LexGrid.LexBIG.Utility.Constructors的用法示例。


在下文中一共展示了Constructors.createSortOptionList方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: run

import org.LexGrid.LexBIG.Utility.Constructors; //导入方法依赖的package包/类
public void run(String text)throws LBException{
	CodingSchemeSummary css = Util.promptForCodeSystem();
	if (css != null) {
		LexBIGService lbSvc = LexBIGServiceImpl.defaultInstance();
		String scheme = css.getCodingSchemeURN();
		CodingSchemeVersionOrTag csvt = new CodingSchemeVersionOrTag();
		csvt.setVersion(css.getRepresentsVersion());
		
		CodedNodeSet nodes = lbSvc.getCodingSchemeConcepts(scheme, csvt)
			.restrictToStatus(ActiveOption.ALL, null)
			.restrictToMatchingDesignations(
				text,
				SearchDesignationOption.ALL,
				MatchAlgorithms.DoubleMetaphoneLuceneQuery.toString(),
				null);

		// Sort by search engine recommendation & code ...
		SortOptionList sortCriteria =
		    Constructors.createSortOptionList(new String[]{"matchToQuery", "code"});
		
		// Analyze the result ...
		ResolvedConceptReferenceList matches =
			nodes.resolveToList(sortCriteria, null, null, 10);
		if (matches.getResolvedConceptReferenceCount() > 0) {
			for (Enumeration refs = matches.enumerateResolvedConceptReference(); refs.hasMoreElements(); ) {
				ResolvedConceptReference ref = (ResolvedConceptReference) refs.nextElement();
				Util.displayMessage("Matching code: " + ref.getConceptCode());
				Util.displayMessage("\tDescription: " + ref.getEntityDescription().getContent());
			}
		} else {
			Util.displayMessage("No match found!");
		}
	}
}
 
开发者ID:NCIP,项目名称:nci-term-browser,代码行数:35,代码来源:SoundsLike.java

示例2: resolveNodeSet

import org.LexGrid.LexBIG.Utility.Constructors; //导入方法依赖的package包/类
public ResolvedConceptReferencesIterator resolveNodeSet(CodedNodeSet cns, boolean includeRetiredConcepts) throws Exception {
	
	if (!includeRetiredConcepts) {
		cns.restrictToStatus(CodedNodeSet.ActiveOption.ACTIVE_ONLY, null);
	}
	CodedNodeSet.PropertyType propTypes[] = new CodedNodeSet.PropertyType[2];
	propTypes[0] = CodedNodeSet.PropertyType.PRESENTATION;
	propTypes[1] = CodedNodeSet.PropertyType.DEFINITION;
	
	SortOptionList sortCriteria = Constructors.createSortOptionList(new String[]{"matchToQuery"});
	
	ResolvedConceptReferencesIterator results = cns.resolve(sortCriteria, null,new LocalNameList(), propTypes, true);
	
	return results;
}
 
开发者ID:NCIP,项目名称:cadsr-semantic-tools,代码行数:16,代码来源:LexEVSQueryServiceImpl.java

示例3: restrictToMatchingProperty

import org.LexGrid.LexBIG.Utility.Constructors; //导入方法依赖的package包/类
public static ResolvedConceptReferencesIterator restrictToMatchingProperty(
	                                        String codingSchemeName,
                                            String version,

                                            LocalNameList propertyList,
                                               CodedNodeSet.PropertyType[] propertyTypes,
                                               LocalNameList sourceList,
                                               NameAndValueList qualifierList,

											    java.lang.String matchText,
										    java.lang.String matchAlgorithm,
										    java.lang.String language)
{
    CodedNodeSet cns = null;
        ResolvedConceptReferencesIterator iterator = null;
        try {
           LexBIGService lbSvc = new RemoteServerUtil().createLexBIGService(url);
           //LexBIGService lbSvc = new LexBIGServiceImpl();

		CodingSchemeVersionOrTag versionOrTag = new CodingSchemeVersionOrTag();
		versionOrTag.setVersion(version);

		if (lbSvc == null)
		{
			_logger.warn("lbSvc = null");
			return null;
		}

		cns = lbSvc.getCodingSchemeConcepts(codingSchemeName, versionOrTag);
		if (cns == null)
		{
			_logger.warn("cns = null");
			return null;
		}

		LocalNameList contextList = null;
           cns = cns.restrictToMatchingProperties(propertyList,
                                          propertyTypes,
                                          sourceList,
                                          contextList,
                                          qualifierList,
                                          matchText,
                                          matchAlgorithm,
                                          language
                                          );

		LocalNameList restrictToProperties = new LocalNameList();
	    SortOptionList sortCriteria =
		    Constructors.createSortOptionList(new String[]{"matchToQuery"});

           try {
               iterator = cns.resolve(sortCriteria, null, restrictToProperties, null);
		} catch (Exception ex) {
			ex.printStackTrace();
			return null;
		}

    } catch (Exception e) {
		e.printStackTrace();
		return null;
    }
	return iterator;
}
 
开发者ID:NCIP,项目名称:nci-term-browser,代码行数:64,代码来源:TestSearch.java

示例4: matchSynonyms

import org.LexGrid.LexBIG.Utility.Constructors; //导入方法依赖的package包/类
/**
 * Display concepts and related text strings matching the given string.
 * @param s The test string.
 * @throws LBException
 */
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");

    // 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).

    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]);
    }

    // Define the code set and add restrictions ...
    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};

    // Resolve and analyze the result ...
    ResolvedConceptReferenceList matches =
        nodes.resolveToList(sortCriteria, null, fetchTypes, -1);

    // Found a match?  If so, sort according to relevance.
    if (matches.getResolvedConceptReferenceCount() > 0) {
        // 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.
        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());
}
 
开发者ID:NCIP,项目名称:nci-term-browser,代码行数:66,代码来源:MetaMatch2.java

示例5: matchWordCompletion

import org.LexGrid.LexBIG.Utility.Constructors; //导入方法依赖的package包/类
/**
 * Attempt to approximate word completion.
 * @param s The test string.
 * @throws LBException
 */
@SuppressWarnings("unchecked")
protected void matchWordCompletion(String s)
    throws LBException
{
    _buffer.delete(0, _buffer.length());
    Util.StopWatch stopWatch = new Util.StopWatch();
    _buffer.append("\n*** Word completion (based on '.') ...\n");

    // 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).

    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"});

    // Resolve and analyze the result ...
    ResolvedConceptReferenceList matches =
        nodes.resolveToList(sortCriteria, null, new PropertyType[] {}, 5);

    // Found a match?
    _buffer.append("* Found via RegExp match (limited to 5 hits)...\n");
    if (matches.getResolvedConceptReferenceCount() > 0) {
        int dotIndex = prefix.indexOf('.');
        if (dotIndex < 0)
            dotIndex = prefix.length();
        int ctr = 0;
        for (int i = 0; i < matches.getResolvedConceptReferenceCount(); i++) {
            ResolvedConceptReference ref = matches.getResolvedConceptReference(i);
            ctr = printText(ctr, ref, false, prefix.substring(0, dotIndex), -1);
        }
    } else {
        _buffer.append("\tNo match found.\n");
    }
    _buffer.append("* " + stopWatch.getResult());
    Util.displayMessage(_buffer.toString());
}
 
开发者ID:NCIP,项目名称:nci-term-browser,代码行数:69,代码来源:MetaMatch2.java

示例6: matchSubquery

import org.LexGrid.LexBIG.Utility.Constructors; //导入方法依赖的package包/类
/**
 * Attempt to approximate compositional or sub-query match (e.g., "peptic ulcer"
 * will match the two separate concepts for "peptic" and "ulcer", in case the
 * ontology does not contain any concept matching the full text "peptic ulcer").
 * @param s The test string.
 * @throws LBException
 */
protected void matchSubquery(String s)
    throws LBException
{
    _buffer.delete(0, _buffer.length());
    Util.StopWatch stopWatch = new Util.StopWatch();
    _buffer.append("\n*** Subquery match (incorporates partial normalization/stemming).\n");

    // Similar to synonym match, only allow match on any single non-stop word
    // and only print presentations matching the query.
    //
    // On resolve, we sort by lucene score ('matchToQuery' sort algorithm).

    StringBuffer searchPhrase = new StringBuffer();
    String[] words = toWords(s, true);
    for (int i = 0; i < words.length; i++) {
        if (i > 0)
            searchPhrase.append(" OR ");
        searchPhrase.append(words[i]);
    }

    // Define the code set and add restrictions ...
    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};

    // Resolve and analyze the result ...
    ResolvedConceptReferenceList matches =
        nodes.resolveToList(sortCriteria, null, fetchTypes, -1);

    // Found a match?  If so, print each associated presentation containing at least
    // one word from the query expression (exclude non-matching synonyms).
    if (matches.getResolvedConceptReferenceCount() > 0) {
        int ctr = 0;
        for (int i = 0; i < matches.getResolvedConceptReferenceCount(); i++) {
            ResolvedConceptReference ref = matches.getResolvedConceptReference(i);
            ctr = printText(ctr, ref, words, 1);
        }
    } else {
        _buffer.append("\tNo match found.\n");
    }
    _buffer.append("* " + stopWatch.getResult());
    Util.displayMessage(_buffer.toString());
}
 
开发者ID:NCIP,项目名称:nci-term-browser,代码行数:55,代码来源:MetaMatch2.java

示例7: matchSynonyms

import org.LexGrid.LexBIG.Utility.Constructors; //导入方法依赖的package包/类
/**
 * Display concepts and related text strings matching the given string.
 * @param s The test string.
 * @param lbSvc
 * @param scheme
 * @param csvt
 * @throws LBException
 */
protected void matchSynonyms(String s, EVSApplicationService lbSvc, String scheme, CodingSchemeVersionOrTag csvt)
	throws LBException
{
	Util.displayMessage("\n*** Matching synonyms (incorporates partial normalization/stemming).");

	// 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).

	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]);
	}

	// Define the code set and add restrictions ...
	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};

	// Resolve and analyze the result ...
	ResolvedConceptReferenceList matches =
		nodes.resolveToList(sortCriteria, null, fetchTypes, -1);

	// Found a match?  If so, sort according to relevance.
	if (matches.getResolvedConceptReferenceCount() > 0) {
		// 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.
		final List<String> matchWords = Arrays.asList(words);
		for (int i = 0; i < matches.getResolvedConceptReferenceCount(); i++) {
			ResolvedConceptReference ref = matches.getResolvedConceptReference(i);
			if (getReferenceWeight(ref, matchWords) == 1)
				printText(ref);
		}
	} else {
		Util.displayMessage("\tNo match found.");
	}
}
 
开发者ID:NCIP,项目名称:nci-term-browser,代码行数:64,代码来源:MetaMatch.java

示例8: matchWordCompletion

import org.LexGrid.LexBIG.Utility.Constructors; //导入方法依赖的package包/类
/**
 * Attempt to approximate word completion.
 * @param s The test string.
 * @param lbSvc
 * @param scheme
 * @param csvt
 * @throws LBException
 */
@SuppressWarnings("unchecked")
protected void matchWordCompletion(String s, EVSApplicationService lbSvc, String scheme, CodingSchemeVersionOrTag csvt)
	throws LBException
{
	Util.displayMessage("\n*** Word completion (based on '.') ...");

	// 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).

	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"});

	// Resolve and analyze the result ...
	ResolvedConceptReferenceList matches =
		nodes.resolveToList(sortCriteria, null, new PropertyType[] {}, 5);

	// Found a match?
	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.");
	}

}
 
开发者ID:NCIP,项目名称:nci-term-browser,代码行数:68,代码来源:MetaMatch.java

示例9: matchSubquery

import org.LexGrid.LexBIG.Utility.Constructors; //导入方法依赖的package包/类
/**
 * Attempt to approximate compositional or sub-query match (e.g., "peptic ulcer"
 * will match the two separate concepts for "peptic" and "ulcer", in case the
 * ontology does not contain any concept matching the full text "peptic ulcer").
 * @param s The test string.
 * @param lbSvc
 * @param scheme
 * @param csvt
 * @throws LBException
 */
protected void matchSubquery(String s, EVSApplicationService lbSvc, String scheme, CodingSchemeVersionOrTag csvt)
	throws LBException
{
	Util.displayMessage("\n*** Subquery match (incorporates partial normalization/stemming).");

	// Similar to synonym match, only allow match on any single non-stop word
	// and only print presentations matching the query.
	//
	// On resolve, we sort by lucene score ('matchToQuery' sort algorithm).

	StringBuffer searchPhrase = new StringBuffer();
	String[] words = toWords(s, true);
	for (int i = 0; i < words.length; i++) {
		if (i > 0)
			searchPhrase.append(" OR ");
		searchPhrase.append(words[i]);
	}

	// Define the code set and add restrictions ...
	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};

	// Resolve and analyze the result ...
	ResolvedConceptReferenceList matches =
		nodes.resolveToList(sortCriteria, null, fetchTypes, -1);

	// Found a match?  If so, print each associated presentation containing at least
	// one word from the query expression (exclude non-matching synonyms).
	if (matches.getResolvedConceptReferenceCount() > 0) {
		for (int i = 0; i < matches.getResolvedConceptReferenceCount(); i++) {
			ResolvedConceptReference ref = matches.getResolvedConceptReference(i);
			printText(ref, words, 1);
		}
	} else {
		Util.displayMessage("\tNo match found.");
	}
}
 
开发者ID:NCIP,项目名称:nci-term-browser,代码行数:53,代码来源:MetaMatch.java


注:本文中的org.LexGrid.LexBIG.Utility.Constructors.createSortOptionList方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。