Package nzilbb.editpath
Implementation of Wagner-Fischer algorithm to determine the minimum edit path.
These classes provide suport for computing the minimum edit path between two lists of objects of any class, and providing access to the mapping from one list to the other, and minimum edit distance.
e.g. The edit path between two lists of Integers can be determined using:
MinimumEditPath<Integer> mp = new MinimumEditPath<Integer>(); List<EditStep<Integer>> path = mp.minimumEditPath(vFrom, vTo) for (EditStep<Integer> step: path) { System.out.println("from " + step.getFrom() + " to " + step.getTo() + " : " + step.getOperation() + " distance " + step.getStepDistance()); }
The equality comparison can be customized, e.g.:
MinimumEditPath<String> mp = new MinimumEditPath<String>( new DefaultEditComparator<String>(new EqualsComparator<String>() { public int compare(String o1, String o2) { return o1.toLowerCase().compareTo(o2.toLowerCase()); } }));
- Author:
- Robert Fromont robert.fromont@canterbury.ac.nz
-
Interface Summary Interface Description EditComparator<T> Interface for comparators between elements.IEditComparator<T> Deprecated. UseEditComparator
instead. -
Class Summary Class Description DefaultEditComparator<T> Default implementation of IEditComparator, for which any from/to pair for which equals() is not true is given an edit distance ofDefaultEditComparator.getChangeDistance()
.EditStep<T> Represents a single step in editing one sequency into another.EqualsComparator<T> Implementation of IComparator that uses java.lang.Object.equals(Object) to determine equality or not.MinimumEditPath<T> Implementation of the Wagner-Fischer algorithm to determine the minimum edit path (or distance) between two sequences.MinimumEditPathString Utility subclass of MinimumEditPath for handling Strings as sequences of Characters -
Enum Summary Enum Description EditStep.StepOperation Enumeration for representing the operation represented by a step