A few days ago I posted in this . As you can see it seems to be pretty fast, 0.25 mS per word (with a 7 characters KeyWord), and it seems to rate matches reasonably well.
I even wrote a new version of 'l', the search command script mentioned in this .
Here is the function:
FuzzyMatch() { # $1: String, $2: KeyWord. Exit: 0: Always. Returns match rating: 0 .. 1000. Example: 'FuzzyMatch "ClassifyTextFiles" "txt"'. if [ -z "$1" ] || [ -z "$2" ] || [ ${#2} -gt ${#1} ] # Notes: Case insensitive, $1's length should be >= $2's length, Vowel characters are 25% less relevant. then echo 0;return 0 fi local S="${1,,}";local K="${2,,}" # Convert to lower-case. if [ "$S" == "$K" ] then echo 1000;return 0 fi local V="aeiouáéíóúäëïöü";local IV # IV: Is_vowel (boolean). local FMV=0;local MV=0 # FMV: Full match value; MV: Match value. local I=0;local C;local R="" while [ $I -lt ${#K} ] do C="${K:${I}:1}" if [ "$V" != "${V/${C}/}" ] then let "FMV = $FMV + 75" IV=true else let "FMV = $FMV + 100" IV=false fi if [ "$S" != "${S#*${C}}" ] then S="${S#*${C}}" if [ -z "$R" ] then let "R = ${#1} - ${#S} - 1" # R: Number of irrelevant $1's leading characters. fi if $IV then let "MV = $MV + 75" else let "MV = $MV + 100" fi fi let I++ done if [ -n "$R" ] then # If there have been matches. let "R = ${#1} - $R - ${#S}" # R: Nr of relevant characters: For "0123456789", "25": "2345" (number is 4 - of 10). let "FMV = $FMV + 100 - (${R}00 / ${#1})" # No change if Nr_relevant_chars -eq Chars_in_string, FMV increases otherwise (+0..100). fi let "MV = ${MV}000 / $FMV" echo $MV;return 0 } I'd like some feedback. Please use the function and let me know what you think. Can you see a way to improve it? Do you have access to 'fuzzy search' libraries (python)? Could you, please, conduct a test similar to
SOCIAL SHARE CARD GENERATOR