I am making a typing program where users type lines of words that appear on the screen and I need to check for accuracy. This would seem easy, however, I need to account for an offset. If the given line is "This is a test" and the user types "Thiss is a test", they should only have one error. However, the simplified way to check for accuracy with mark everything after the "ss" offset incorrect, when it should be right. Is there an easy way to do this?
Several string similarity algorithm are described here: http://www.morfoedro.it/doc.php?n=223&lang=en
I have been using the "Ratcliff/Obershelp" algorithm. It works as follows:
/*
* divide s1 and s2 each into three parts
* in the middle is the longest common substring between them
* leaving (the possibly) empty left and right parts
*
* pennsylvania = pennsy|lvan|ia
* pencilvaneya = penci|lvan|eya
*
* pennsy = |pen|nsy ia = i|a|
* penci = |pen|ci eya = ey|a|
*/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With