Package com.crossbotics.ftchelper.util
Class Spelling
java.lang.Object
com.crossbotics.ftchelper.util.Spelling
"Did you mean ...?" for names typed by hand: a position name, a Tunables field. Used by the library's
messages ("no position called "closd" (did you mean closed?)"); handy in your own too.
String like = Spelling.closest("closd", Arrays.asList("open", "closed")); // "closed"
Docs: docs/modules/util.md-
Method Summary
Modifier and TypeMethodDescriptionstatic Stringclosest(String name, Collection<String> known) The known name thatnameis most likely a typo of, or null if none is close.static intHow many letters must be added, removed or changed to turnaintob(the "edit distance").
-
Method Details
-
closest
The known name thatnameis most likely a typo of, or null if none is close. Capitals and "_" never matter; then a name of 5 or more letters may be 2 letters off (added, missing or changed), a shorter one (3 or 4 letters) 1 letter.- Parameters:
name- what was typed, e.g. "closd"known- the real names- Returns:
- the closest real name, or null
-
distance
How many letters must be added, removed or changed to turnaintob(the "edit distance"). "closd" to "closed" is 1.
-