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


Java StringSimilarityServiceImpl类代码示例

本文整理汇总了Java中net.ricecode.similarity.StringSimilarityServiceImpl的典型用法代码示例。如果您正苦于以下问题:Java StringSimilarityServiceImpl类的具体用法?Java StringSimilarityServiceImpl怎么用?Java StringSimilarityServiceImpl使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: commandHint

import net.ricecode.similarity.StringSimilarityServiceImpl; //导入依赖的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.StringSimilarityServiceImpl; //导入依赖的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.StringSimilarityServiceImpl; //导入依赖的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.StringSimilarityServiceImpl类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。