Fuzzy string matching?

Mike Wey mike-wey at example.com
Sat Jul 16 04:35:00 PDT 2011


On 07/16/2011 01:17 AM, Andrej Mitrovic wrote:
> Is there any such method in Phobos?
>
> I have to rename some files based on a string array of known names
> which need to be fuzzy-matched to file names and then rename the files
> to the matches.
>
> E.g.:
>
> string[] strings = ["food", "lamborghini", "architecture"]
>
> files on system:
> .\foo.ext
> .\lmbrghinione.ext
> .\archtwo.ext
>
> and if there's a fuzzy match then the matched files would be renamed to:
> .\food.ext
> .\lamborghini.ext
> .\architecture.ext
>
> Perhaps there's a C library I can use for this?

You could try stc.algorithm.levenshteinDistance to check how much the 
two names differ.

-- 
Mike Wey


More information about the Digitalmars-d-learn mailing list