Last active
August 29, 2015 14:26
-
-
Save trishagee/0db464587c909006bcbd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static int[][] computeLevenshtein(List<String> wordList, boolean parallel) { | |
final int LIST_SIZE = wordList.size(); | |
int[][] distances = new int[LIST_SIZE][LIST_SIZE]; | |
IntStream range = range(0, LIST_SIZE * LIST_SIZE); | |
if (parallel) { | |
range.parallel(); | |
} | |
range.forEach(value -> { | |
int i = value % LIST_SIZE; | |
int j = value / LIST_SIZE; | |
distances[i][j] = lev(wordList.get(i), wordList.get(j)); | |
}); | |
return distances; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static int[][] computeLevenshtein(List<String> wordList, boolean parallel) { | |
final int LIST_SIZE = wordList.size(); | |
int[][] distances = new int[LIST_SIZE][LIST_SIZE]; | |
IntStream iRange = range(0, LIST_SIZE); | |
if (parallel) { | |
iRange.parallel(); | |
} | |
iRange.forEach(i -> { | |
IntStream range = range(0, LIST_SIZE); | |
if (parallel) { | |
range.parallel(); | |
} | |
range.forEach(j -> distances[i][j] = lev(wordList.get(i), wordList.get(j))); | |
}); | |
return distances; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment