Created
January 11, 2017 03:16
-
-
Save phuf/8ba6027a5b678983ce0437a6eb19cc70 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$scriptPath = Join-Path (Get-Location) "TestEditDistance.sql"; | |
$response = Invoke-WebRequest "https://raw.githubusercontent.com/GlobalNamesArchitecture/damerau-levenshtein/master/spec/files/damerau_levenshtein_test.txt" -UseBasicParsing; | |
$lines = $response.Content.Split() | Where-Object { $_ -like "*|*|*|*" }; | |
@" | |
DECLARE @test_cases TABLE | |
( | |
Word1 NVARCHAR(128), | |
Word2 NVARCHAR(128), | |
ExpectedEditDistance INT | |
) | |
VALUES | |
"@ | Out-File $scriptPath -Encoding UTF8; | |
@( | |
$lines.ForEach({ | |
$columns = $_.Split("|"); | |
$rowValue = "`t(N'$($columns[0])', N'$($columns[0])', $($columns[3]))"; | |
if ($_.Equals($lines[-1])) { | |
Write-Output "$rowValue;"; | |
} else { | |
Write-Output "$rowValue," | |
} | |
}); | |
) | Out-File $scriptPath -Append -Encoding UTF8; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment