|
@ -55,7 +55,8 @@ public class PlayCommand extends YoshiCommand { |
|
|
sendErrorMessage("Konnte keinen Audiochannel auswählen."); |
|
|
sendErrorMessage("Konnte keinen Audiochannel auswählen."); |
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
|
context.getEvent().getMessage().getTextChannel().sendMessage("Spiele '" + requestedFile + "' in '" + vc.getName() + "' ab").queue(); |
|
|
|
|
|
|
|
|
context.getEvent().getMessage().getTextChannel() |
|
|
|
|
|
.sendMessage("Spiele '" + requestedFile + "' in '" + vc.getName() + "' ab").queue(); |
|
|
YoshiBot.getInstance().playSound(file, vc); |
|
|
YoshiBot.getInstance().playSound(file, vc); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -63,11 +64,12 @@ public class PlayCommand extends YoshiCommand { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private String getBestMatch(String word, List<String> choices) { |
|
|
private String getBestMatch(String word, List<String> choices) { |
|
|
Map<String, Integer> hammingDists = |
|
|
|
|
|
|
|
|
Map<String, Double> hammingDists = |
|
|
choices.parallelStream() |
|
|
choices.parallelStream() |
|
|
.collect(Collectors.toMap(file -> file, |
|
|
.collect(Collectors.toMap(file -> file, |
|
|
file -> maximalMatchingChars(file, word) * choices.size() + |
|
|
|
|
|
file.length())); |
|
|
|
|
|
|
|
|
file -> (double) maximalMatchingChars(file, word) / |
|
|
|
|
|
Math.max(file.length(), |
|
|
|
|
|
word.length()))); |
|
|
return hammingDists.keySet().stream() |
|
|
return hammingDists.keySet().stream() |
|
|
.max((file1, file2) -> (int) Math.signum(hammingDists.get(file1) - hammingDists.get(file2))) |
|
|
.max((file1, file2) -> (int) Math.signum(hammingDists.get(file1) - hammingDists.get(file2))) |
|
|
.orElse(choices.get(0)); |
|
|
.orElse(choices.get(0)); |
|
|