fredeil / FuzzyMatcher

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

Home Page:https://www.nuget.org/packages/FuzzyMatcher/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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");
        }
    }
}

About

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

https://www.nuget.org/packages/FuzzyMatcher/

License:MIT License


Languages

Language:F# 71.0%Language:PowerShell 18.5%Language:C# 10.5%