Data update

This commit is contained in:
Ingy döt Net 2026-02-01 16:33:20 -08:00
parent 5150844a7d
commit 4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions

View file

@ -1,81 +0,0 @@
function Get-Soundex
{
[CmdletBinding()]
[OutputType([PSCustomObject])]
Param
(
[Parameter(Mandatory=$true,
ValueFromPipeline=$true,
ValueFromPipelineByPropertyName=$true,
Position=0)]
[string[]]
$InputObject
)
Begin
{
$characterGroup = [PSCustomObject]@{
1 = @('B','F','P','V')
2 = @('C','G','J','K','Q','S','X','Z')
3 = @('D','T')
4 = @('L')
5 = @('M','N')
6 = @('R')
}
function ConvertTo-SoundexDigit ([char]$Character)
{
switch ($Character)
{
{$_ -in $characterGroup.1} {return 1}
{$_ -in $characterGroup.2} {return 2}
{$_ -in $characterGroup.3} {return 3}
{$_ -in $characterGroup.4} {return 4}
{$_ -in $characterGroup.5} {return 5}
{$_ -in $characterGroup.6} {return 6}
Default {return 0}
}
}
}
Process
{
foreach ($String in $InputObject)
{
$originalString = $String
$String = $String.ToUpper()
$isHorWcharacter = $false
$soundex = New-Object -TypeName System.Text.StringBuilder
$soundex.Append($String[0]) | Out-Null
for ($i = 1; $i -lt $String.Length; $i++)
{
$currentCharacterDigit = ConvertTo-SoundexDigit $String[$i]
if ($currentCharacterDigit -ne 0)
{
if ($i -eq (ConvertTo-SoundexDigit $String[$i-1]))
{
continue
}
if (($i -gt 2) -and ($isHorWcharacter) -and ($currentCharacterDigit -eq (ConvertTo-SoundexDigit $String[$i-2])))
{
continue
}
$soundex.Append($currentCharacterDigit) | Out-Null
}
$isHorWcharacter = $String[$i] -in @('H','W')
}
$soundexTail = ($soundex.ToString().Substring(1)).TrimStart((ConvertTo-SoundexDigit $String[0]).ToString())
[PSCustomObject]@{
String = $originalString
Soundex = ($soundex[0] + $soundexTail).PadRight(4,"0").Substring(0,4)
}
}
}
}

View file

@ -1,2 +0,0 @@
"Ashcraft", "Ashcroft", "Gauss", "Ghosh", "Hilbert", "Heilbronn", "Lee", "Lloyd",
"Moses", "Pfister", "Robert", "Rupert", "Rubin", "Tymczak", "Soundex", "Example" | Get-Soundex

View file

@ -1,18 +0,0 @@
# script Soundex.ps1
Param([string]$Phrase)
Process {
$src = $Phrase.ToUpper().Trim()
$coded = $src[0..($src.Length - 1)] | %{
if('BFPV'.Contains($_)) { '1' }
elseif('CGJKQSXZ'.Contains($_)) { '2' }
elseif('DT'.Contains($_)) { '3' }
elseif('L'.Contains($_)) { '4' }
elseif('MN'.Contains($_)) { '5' }
elseif('R'.Contains($_)) { '6' }
elseif('AEIOU'.Contains($_)) { 'v' }
else { '.' }
} | Where { $_ -ne '.'}
$coded2 = 0..($coded.Length - 1) | %{ if ($_ -eq 0 -or $coded[$_] -ne $coded[$_ - 1]) { $coded[$_] } else { '' } }
$coded2 = if ($coded[0] -eq 'v' -or $coded2[0] -ne $coded[0]) { $coded2 } else { $coded2[1..($coded2.Length - 1)] }
$src[0] + ((-join $($coded2 | Where { $_ -ne 'v'})) + "000").Substring(0,3)
}

View file

@ -1,15 +0,0 @@
Function t([string]$value, [string]$expect) {
$result = .\Soundex.ps1 -Phrase $value
New-Object TypeName PSObject Prop @{ "Value"=$value; "Expect"=$expect; "Result"=$result; "Pass"=$($expect -eq $result) }
}
@(
(t "Ashcraft" "A261"); (t "Ashcroft" "A261"); (t "Burroughs" "B620"); (t "Burrows" "B620");
(t "Ekzampul" "E251"); (t "Example" "E251"); (t "Ellery" "E460"); (t "Euler" "E460");
(t "Ghosh" "G200"); (t "Gauss" "G200"); (t "Gutierrez" "G362"); (t "Heilbronn" "H416");
(t "Hilbert" "H416"); (t "Jackson" "J250"); (t "Kant" "K530"); (t "Knuth" "K530");
(t "Lee" "L000"); (t "Lukasiewicz" "L222"); (t "Lissajous" "L222"); (t "Ladd" "L300");
(t "Lloyd" "L300"); (t "Moses" "M220"); (t "O'Hara" "O600"); (t "Pfister" "P236");
(t "Rubin" "R150"); (t "Robert" "R163"); (t "Rupert" "R163"); (t "Soundex" "S532");
(t "Sownteks" "S532"); (t "Tymczak" "T522"); (t "VanDeusen" "V532"); (t "Washington" "W252");
(t "Wheaton" "W350");
) | Format-Table -Property Value,Expect,Result,Pass