當前位置: 首頁>>代碼示例>>Java>>正文


Java LevenshteinDistanceStrategy類代碼示例

本文整理匯總了Java中net.ricecode.similarity.LevenshteinDistanceStrategy的典型用法代碼示例。如果您正苦於以下問題:Java LevenshteinDistanceStrategy類的具體用法?Java LevenshteinDistanceStrategy怎麽用?Java LevenshteinDistanceStrategy使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


LevenshteinDistanceStrategy類屬於net.ricecode.similarity包,在下文中一共展示了LevenshteinDistanceStrategy類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: commandHint

import net.ricecode.similarity.LevenshteinDistanceStrategy; //導入依賴的package包/類
private String commandHint(String command) {
    if (command == null || command.isEmpty()) {
        return "";
    }
    SimilarityStrategy strategy = new LevenshteinDistanceStrategy();
    StringSimilarityService service = new StringSimilarityServiceImpl(strategy);
    double score = 0;
    double s;
    String result = "";
    List<String> crowdinCommands = new LinkedList<>();
    crowdinCommands.add(COMMAND_UPLOAD);
    crowdinCommands.add(COMMAND_UPLOAD_SOURCES);
    crowdinCommands.add(COMMAND_TRANSLATIONS);
    crowdinCommands.add(COMMAND_UPLOAD_TRANSLATIONS);
    crowdinCommands.add(COMMAND_LINT);
    crowdinCommands.add(COMMAND_DOWNLAOD);
    crowdinCommands.add(COMMAND_DOWNLAOD_TRANSLATIONS);
    crowdinCommands.add(COMMAND_GENERATE);
    crowdinCommands.add(COMMAND_PROJECT);
    crowdinCommands.add(COMMAND_LIST_PROJECT);
    crowdinCommands.add(COMMAND_SOURCES);
    crowdinCommands.add(COMMAND_LIST);
    crowdinCommands.add(COMMAND_LIST_SOURCES);
    crowdinCommands.add(COMMAND_LIST_TRANSLATIONS);
    crowdinCommands.add(COMMAND_HELP);
    crowdinCommands.add(COMMAND_PUSH);
    crowdinCommands.add(COMMAND_PULL);
    for (String cmd : crowdinCommands) {
        s = service.score(cmd, command);
        if (s > score) {
            score = s;
            result = cmd;
        }
    }
    if (score < 0.5) {
        result = "";
    }
    return result;
}
 
開發者ID:crowdin,項目名稱:crowdin-cli-2,代碼行數:40,代碼來源:CrowdinCliCommands.java

示例2: getDifference

import net.ricecode.similarity.LevenshteinDistanceStrategy; //導入依賴的package包/類
/**
 * Get the difference value of a string.
 *
 * @param first First value.
 * @param second Second value.
 *
 * @return The string difference value.
 */
public static double getDifference(String first, String second) {
    // Make sure both strings are equal
    if(first == null || second == null)
        return 1.0;

    // Create a string comparison server
    StringSimilarityService service = new StringSimilarityServiceImpl(new LevenshteinDistanceStrategy());

    // Determine the difference score and return it's absolute value
    return Math.abs(service.score(first, second) - 1.0);
}
 
開發者ID:timvisee,項目名稱:GlowstoneLanterns,代碼行數:20,代碼來源:StringUtils.java

示例3: getDifference

import net.ricecode.similarity.LevenshteinDistanceStrategy; //導入依賴的package包/類
/**
 * Get the difference of two strings.
 *
 * @param first  First string
 * @param second Second string
 *
 * @return The difference value
 */
public static double getDifference(String first, String second) {
    // Make sure the strings are valid.
    if (first == null || second == null) {
        return 1.0;
    }

    // Create a string similarity service instance, to allow comparison
    StringSimilarityService service = new StringSimilarityServiceImpl(new LevenshteinDistanceStrategy());

    // Determine the difference value, return the result
    return Math.abs(service.score(first, second) - 1.0);
}
 
開發者ID:AuthMe,項目名稱:AuthMeReloaded,代碼行數:21,代碼來源:StringUtils.java


注:本文中的net.ricecode.similarity.LevenshteinDistanceStrategy類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。