public static String getDidYouMeanString ( Collection < String > available , String it ) { String message = "" ; Collection < String > mins = Levenshtein . findSimilar ( available , it ) ; if ( mins . size ( ) > 0 ) { if ( mins . size ( ) == 1 ) { message += "Did you mean this?" ; } else { message += "Did you mean one of these?" ; } for ( String m : mins ) { message += "\n\t" + m ; } } return message ; }
Finds strings similar to a string the user has entered and then generates a Did you mean one of these message