11/*
22 * This file is part of Flow Commons, licensed under the MIT License (MIT).
33 *
4- * Copyright (c) 2013 Spout LLC <https://spout.org />
4+ * Copyright (c) 2013 Flow Powered <https://flowpowered.com />
55 *
66 * Permission is hereby granted, free of charge, to any person obtaining a copy
77 * of this software and associated documentation files (the "Software"), to deal
@@ -201,7 +201,7 @@ public static int getLevenshteinDistance(String s, String t) {
201201 }
202202
203203 /*
204- The difference between this impl. and the previous is that, rather
204+ The difference between this impl. and the previous is that, rather
205205 than creating and retaining a matrix of size s.length()+1 by t.length()+1,
206206 we maintain two single-dimensional arrays of length s.length()+1. The first, d,
207207 is the 'current working' distance array that maintains the newest distance cost
@@ -226,17 +226,17 @@ allows us to retain the previous cost counts as required by the algorithm (takin
226226 return n ;
227227 }
228228
229- int p [] = new int [n + 1 ]; //'previous ' cost array, horizontally
230- int d [] = new int [n + 1 ]; // cost array, horizontally
231- int _d []; //placeholder to assist in swapping p and d
229+ int p [] = new int [n + 1 ]; // 'Previous ' cost array, horizontally
230+ int d [] = new int [n + 1 ]; // Cost array, horizontally
231+ int _d []; // Placeholder to assist in swapping p and d
232232
233- // indexes into strings s and t
234- int i ; // iterates through s
235- int j ; // iterates through t
233+ // Indexes into strings s and t
234+ int i ; // Iterates through s
235+ int j ; // Iterates through t
236236
237237 char t_j ; // jth character of t
238238
239- int cost ; // cost
239+ int cost ; // Cost
240240
241241 for (i = 0 ; i <= n ; i ++) {
242242 p [i ] = i ;
@@ -248,18 +248,17 @@ allows us to retain the previous cost counts as required by the algorithm (takin
248248
249249 for (i = 1 ; i <= n ; i ++) {
250250 cost = s .charAt (i - 1 ) == t_j ? 0 : 1 ;
251- // minimum of cell to the left+1, to the top+1, diagonally left and up +cost
251+ // Minimum of cell to the left+1, to the top+1, diagonally left and up +cost
252252 d [i ] = Math .min (Math .min (d [i - 1 ] + 1 , p [i ] + 1 ), p [i - 1 ] + cost );
253253 }
254254
255- // copy current distance counts to 'previous row' distance counts
255+ // Copy current distance counts to 'previous row' distance counts
256256 _d = p ;
257257 p = d ;
258258 d = _d ;
259259 }
260260
261- // our last action in the above loop was to switch d and p, so p now
262- // actually has the most recent cost counts
261+ // Our last action in the above loop was to switch d and p, so p now actually has the most recent cost counts
263262 return p [n ];
264263 }
265264
0 commit comments