Skip to content
This repository has been archived by the owner on Apr 23, 2022. It is now read-only.
/ FuzzyMatcher Public archive

Fuzzy-Matching algorithm using Jaro-Winkler distance for measuring similarities in strings

License

Notifications You must be signed in to change notification settings

fredeil/FuzzyMatcher

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Fuzzy-match

Fuzzy-match algorithm using the Jaro Winkler distance to measure the similarity between two strings.

Example

See Program.fs

namespace FuzzyMatch

module main =
    open FuzzyMatcher

    [<EntryPoint>]
    let main _ =

        let availableCommands = ["status"; "commit"; "stash"; "diff"; "all"]

        // Example use case: CLI user wanting to do "git stash",
        // user actually writes "git shtas", 
        // the algorithm returns "stash" as the best suggestion for the command
        let suggestCommand = availableCommands |> fuzzyMatch

        "shtas" |> suggestCommand |> printfn "Did you mean %A?"
        0

See csharp/Program.cs

using System;
using System.Collections.Generic;
using FuzzyMatch;

namespace csharp
{
    class Program
    {
        static void Main(string[] args)
        {
            var availableCommands = new [] { "stash", "diff", "commit" };
            
            Console.WriteLine("Available commands: {0}", string.Join(", ", availableCommands));

            var input = Console.ReadLine();
            var match = FuzzyMatcher.Match(availableCommands, input);
            
            Console.WriteLine($"Did you mean '{match}'?\n");
        }
    }
}