krisk / fuse-swift

A lightweight fuzzy-search library, with zero dependencies
MIT License
935 stars 112 forks source link

Best match #8

Open iguron opened 6 years ago

iguron commented 6 years ago

Hi kirsk,

Congrats for this excellent library.

One suggestion that maybe you could implement on the library.

Sometimes we need to find the best match, and only the best match on the string. One example. If we try to find "Hello World." inside "Hellu Wo** round" (returned by OCR) the result´s ranges include "Hell","Wo","r" and "d". It could be really interesting if fuze could return only the best match according to a character distance. For example.

Best Match with distance of 1 character: "Hell_ Wo" (range 0..7) and "r" and "d" would not be included in the result as they are more than one character far away from the best match.

Another example "Hellu Wuid" could return "Hell_ W_d" (range 0..9) with a character distance of 2 characters and "Hell W" with a distance of 1 character.

This porperty could make fuze really really a gem for OCR result´s processing.

Thanks in advance.