INNER CODE UNIT · Java
sourceLength
robinhood/ticker · ticker/src/main/java/com/robinhood/ticker/LevenshteinUtils.java:151
final int sourceLength = sourceEnd - sourceStart;
final int targetLength = targetEnd - targetStart;
final int resultLength = Math.max(sourceLength, targetLength);
if (sourceLength == targetLength) {
// No modifications needed if the length of the strings are the same
fillWithActions(columnActions, resultLength, ACTION_SAME);
return;
}
final int numRows = sourceLength + 1;
final int numCols = targetLength + 1;
// Compute the Levenshtein matrix
final int[][] matrix = new int[numRows][numCols];
for (int i = 0; i < numRows; i++) {
matrix[i][0] = i;