Browse Source

[Fixed] Yonks dumme codeabweichungen lol

master
Paul Glaß 3 years ago
parent
commit
4d398b176b
1 changed files with 4 additions and 12 deletions
  1. +4
    -12
      app/src/main/java/de/yannicpunktdee/yoshibot/command/commands/PlayCommand.java

+ 4
- 12
app/src/main/java/de/yannicpunktdee/yoshibot/command/commands/PlayCommand.java View File

@ -22,7 +22,7 @@ public class PlayCommand extends YoshiCommand {
private static final Map<User, Long> cooldownChecker = new HashMap<>();
private static final int SECOND_DELAY = 10;
private static final int SECOND_DELAY = 5;
public PlayCommand(YoshiCommandContext context) {
@ -113,17 +113,9 @@ public class PlayCommand extends YoshiCommand {
}
private String getBestMatch(String word, List<String> choices) {
double bestScore = 1.0;
String bestMatching = null;
for (String file : choices) {
double score = (new JaccardDistance()).apply(word, file);
if (score < bestScore) {
bestScore = score;
bestMatching = file;
}
}
return bestMatching;
Optional<String> match = choices.parallelStream().filter(word::equals).findAny();
return match.orElse(choices.parallelStream().max(
Comparator.comparingDouble(file -> new JaccardDistance().apply(word, file))).orElse(null));
}
private List<String> getAllFiles() {


Loading…
Cancel
Save