MCPcopy Create free account
hub / github.com/Lotus6/AutoRepeater / diff_levenshtein

Method diff_levenshtein

src/burp/Utils/diff_match_patch.java:1419–1441  ·  view source on GitHub ↗

Compute the Levenshtein distance; the number of inserted, deleted or substituted characters. @param diffs LinkedList of Diff objects. @return Number of changes.

(LinkedList<Diff> diffs)

Source from the content-addressed store, hash-verified

1417 * @return Number of changes.
1418 */
1419 public int diff_levenshtein(LinkedList<Diff> diffs) {
1420 int levenshtein = 0;
1421 int insertions = 0;
1422 int deletions = 0;
1423 for (Diff aDiff : diffs) {
1424 switch (aDiff.operation) {
1425 case INSERT:
1426 insertions += aDiff.text.length();
1427 break;
1428 case DELETE:
1429 deletions += aDiff.text.length();
1430 break;
1431 case EQUAL:
1432 // A deletion and an insertion is one substitution.
1433 levenshtein += Math.max(insertions, deletions);
1434 insertions = 0;
1435 deletions = 0;
1436 break;
1437 }
1438 }
1439 levenshtein += Math.max(insertions, deletions);
1440 return levenshtein;
1441 }
1442
1443 /**
1444 * Crush the diff into an encoded string which describes the operations

Callers 1

patch_applyMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected