forked from dotnet/fsharp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
EditDistance.fs
27 lines (23 loc) · 1001 Bytes
/
EditDistance.fs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.
namespace FSharp.Compiler.UnitTests
open System
open System.Globalization
open Xunit
open FSharp.Test
module EditDistance =
open Internal.Utilities.EditDistance
[<Theory>]
[<InlineData("RICK", "RICK", "1.000")>]
[<InlineData("MARTHA", "MARHTA", "0.961")>]
[<InlineData("DWAYNE", "DUANE", "0.840")>]
[<InlineData("DIXON", "DICKSONX", "0.813")>]
let JaroWinklerTest (str1 : string, str2 : string, expected : string) : unit =
String.Format(CultureInfo.InvariantCulture, "{0:0.000}", JaroWinklerDistance str1 str2)
|> Assert.shouldBe expected
[<Theory>]
[<InlineData("RICK", "RICK", 0)>]
[<InlineData("MARTHA", "MARHTA", 1)>]
[<InlineData("'T", "'u", 1)>]
let EditDistanceTest (str1 : string, str2 : string, expected : int) : unit =
CalculateEditDistance(str1,str2)
|> Assert.shouldBe expected