Package nzilbb.editpath
Class MinimumEditPathString
- java.lang.Object
-
- nzilbb.editpath.MinimumEditPath<Character>
-
- nzilbb.editpath.MinimumEditPathString
-
public class MinimumEditPathString extends MinimumEditPath<Character>
Utility subclass of MinimumEditPath for handling Strings as sequences of Characters- Author:
- Robert Fromont robert@fromont.net.nz
-
-
Constructor Summary
Constructors Constructor Description MinimumEditPathString()
Default constructorMinimumEditPathString(EditComparator<Character> comparator)
Constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description double
levenshteinDistance(String sFrom, String sTo)
Computes the minimum edit distance between two sequences.static double
LevenshteinDistance(String sFrom, String sTo)
Computes the minimum edit distance between two strings.double
minimumEditDistance(String sFrom, String sTo)
Computes the minimum edit distance between two sequences.List<EditStep<Character>>
minimumEditPath(String sFrom, String sTo)
Computes the minimum path from one sequence to another.static String
printPath(List<EditStep<Character>> path)
Prints the edit path, by displaying the from string on one line and the to string on the next line, vertically aligned to indicate changes, and marking inserts/deletes with a mid-dot '·' (a character unlikely to really appear in a string, so will likely unambiguously indicate a lack in one of the strings).-
Methods inherited from class nzilbb.editpath.MinimumEditPath
collapse, collapse, errorRate, getComparator, minimumEditDistance, minimumEditPath, setComparator
-
-
-
-
Constructor Detail
-
MinimumEditPathString
public MinimumEditPathString()
Default constructor
-
MinimumEditPathString
public MinimumEditPathString(EditComparator<Character> comparator)
Constructor- Parameters:
comparator
- Element comparator to use.
-
-
Method Detail
-
minimumEditPath
public List<EditStep<Character>> minimumEditPath(String sFrom, String sTo)
Computes the minimum path from one sequence to another.- Parameters:
sFrom
- The source (original) string.sTo
- The destination (final) string.- Returns:
- The edit path between the two sequences that has the minimum edit distance.
-
minimumEditDistance
public double minimumEditDistance(String sFrom, String sTo)
Computes the minimum edit distance between two sequences.- Parameters:
sFrom
- The source (original) string.sTo
- The destination (final) string.- Returns:
- The minimum edit distance between the two sequences.
-
levenshteinDistance
public double levenshteinDistance(String sFrom, String sTo)
Computes the minimum edit distance between two sequences.Equivalent to
minimumEditDistance(sFrom, sTo)
- Parameters:
sFrom
- The source (original) string.sTo
- The destination (final) string.- Returns:
- The minimum edit distance between the two sequences.
-
LevenshteinDistance
public static double LevenshteinDistance(String sFrom, String sTo)
Computes the minimum edit distance between two strings.- Parameters:
sFrom
- The source (original) string.sTo
- The destination (final) string.- Returns:
- The minimum edit distance between the two strings.
-
printPath
public static String printPath(List<EditStep<Character>> path)
Prints the edit path, by displaying the from string on one line and the to string on the next line, vertically aligned to indicate changes, and marking inserts/deletes with a mid-dot '·' (a character unlikely to really appear in a string, so will likely unambiguously indicate a lack in one of the strings).Each line is prefixed, and the second appended, with "\r\n" so that vertical alignment is visually more likely regardless of the surrounding context or the platform.
- Parameters:
path
- The edit path to print.- Returns:
- A string representation of the edit path between two strings.
-
-