com.github.liblevenshtein.transducer.StandardPositionComparator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of liblevenshtein-lite Show documentation
Show all versions of liblevenshtein-lite Show documentation
A library for spelling-correction based on Levenshtein Automata.
The newest version!
package com.github.liblevenshtein.transducer;
import java.io.Serializable;
import java.util.Comparator;
/**
* Sorts position vectors for the standard, Levenshtein algorithm.
* @author Dylon Edwards
* @since 2.1.0
*/
public class StandardPositionComparator implements Serializable, Comparator {
private static final long serialVersionUID = 1L;
/**
* {@inheritDoc}
*/
@Override
public int compare(final Position lhs, final Position rhs) {
final int c = lhs.termIndex() - rhs.termIndex();
if (0 != c) {
return c;
}
return lhs.numErrors() - rhs.numErrors();
}
}