I have scanned text:
Mils, chiiese, wh_ite ch$col_te
And expression list, example:
- cheese
- bread
- white chocolate
- etc.
I need compare broken expression with expression from my list, ex. "white chocolate" with "wh_ite ch$col_te."
Maybe you recommend some frameworks.
What you need to do is measure the difference between two string. To do that, you can use the Levenshtein distance.
For your luck, somebody already implemented this algorihtm in Swift HERE.
To make it work in Swift 1.2, you'll just have to autofix some errors that occour, nothing too fancy.
You can then use it like this:
println(levenshtein("wh_ite ch$col_te", bStr: "white chocolate")) // prints 3, because you have to change 3 letters to get from aStr to bStr
println(levenshtein("wh_ite ch$col_te", bStr: "whsdfdsite chosdfsdfcolate")) // prints 13, because you have to change 13 letters to get from aStr to bStr
You then just set the tolerance and you are done!
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