You are browsing as a guest. Sign up (or log in) to start making projects!

1h 32m logged

Compare the words! ++

I have reworked how words are compared (again)!

The best CLI EVER (well, now at least)

SpellCLI has been out for some time! I have been using it and I have found a problem. Words that are anagrams of each other often flood the top results and if the word is spelled incorrectly, give (seemingly) completely random words. This is because the placement of a word was not considered at all in the algorithm described in Compare the words! +

The Great Algorithm

The new algorithm now considers the placement of words (how much they moved) and if words are missing!
Take the words “great” and “rat”. ‘r’ haves to move 1 place and ‘a’ and ‘t’ move 2:

G|R|E|A|T 
-|R|   |   |
_|- |- |A|
_|_ |- |- |T

For a total of 5 movements. Than, the ‘g’ and ‘e’ are left, for a total of 2 leftovers.
Leftovers than get a ×max_len multiplier, this wights them so that moving letters is “more similar” that extra letters.
This gives a total of 15 points of differences. The max amount of difference is calculated as (len1+len2) * max_len (40 in this case). this gives a total of 0.375 difference or 0.625 similarity (63% similar)!

The future of SpellCLI

I don’t know how common devlogs will be for SpellCLI now that the project is done. I don’t have any plans to ship the project again, if I make several changes by the end of the summer I might.

See you in my next project 👀, bye!

0
6

Comments 0

No comments yet. Be the first!