Added string utilities class, fixed some imports

This commit is contained in:
Tim Visée 2015-11-01 15:38:49 +01:00
parent eeec8ca228
commit ab8eee3be9
2 changed files with 23 additions and 4 deletions

View File

@ -1,10 +1,10 @@
package fr.xephi.authme.command.help;
import com.timvisee.dungeonmaze.Core;
import fr.xephi.authme.commands.CommandArgumentDescription;
import fr.xephi.authme.commands.CommandDescription;
import fr.xephi.authme.commands.CommandParts;
import fr.xephi.authme.commands.CommandPermissions;
import fr.xephi.authme.command.CommandArgumentDescription;
import fr.xephi.authme.command.CommandDescription;
import fr.xephi.authme.command.CommandParts;
import fr.xephi.authme.command.CommandPermissions;
import com.timvisee.dungeonmaze.util.StringUtils;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;

View File

@ -0,0 +1,19 @@
package fr.xephi.authme.util;
import net.ricecode.similarity.LevenshteinDistanceStrategy;
import net.ricecode.similarity.StringSimilarityService;
import net.ricecode.similarity.StringSimilarityServiceImpl;
public class StringUtils {
public static double getDifference(String first, String second) {
if(first == null || second == null)
return 1.0;
StringSimilarityService service = new StringSimilarityServiceImpl(new LevenshteinDistanceStrategy());
double score = service.score(first, second);
return Math.abs(score - 1.0);
}
}