어린이날 기념 커밋
This commit is contained in:
@@ -259,10 +259,48 @@ function Normalize-CompactText {
|
||||
return ($Value -replace '\s+', [string]::Empty).Trim()
|
||||
}
|
||||
|
||||
function Strip-BasicDistrictDisambiguation {
|
||||
param([string]$Value)
|
||||
|
||||
if ([string]::IsNullOrWhiteSpace($Value))
|
||||
{
|
||||
return [string]::Empty
|
||||
}
|
||||
|
||||
$normalized = $Value.Trim()
|
||||
$regionLabels = @(
|
||||
"%EC%84%9C%EC%9A%B8",
|
||||
"%EB%B6%80%EC%82%B0",
|
||||
"%EB%8C%80%EA%B5%AC",
|
||||
"%EC%9D%B8%EC%B2%9C",
|
||||
"%EA%B4%91%EC%A3%BC",
|
||||
"%EB%8C%80%EC%A0%84",
|
||||
"%EC%9A%B8%EC%82%B0",
|
||||
"%EC%84%B8%EC%A2%85",
|
||||
"%EA%B2%BD%EA%B8%B0",
|
||||
"%EA%B0%95%EC%9B%90",
|
||||
"%EC%B6%A9%EB%B6%81",
|
||||
"%EC%B6%A9%EB%82%A8",
|
||||
"%EC%A0%84%EB%B6%81",
|
||||
"%EC%A0%84%EB%82%A8",
|
||||
"%EA%B2%BD%EB%B6%81",
|
||||
"%EA%B2%BD%EB%82%A8",
|
||||
"%EC%A0%9C%EC%A3%BC"
|
||||
)
|
||||
|
||||
foreach ($encodedLabel in $regionLabels)
|
||||
{
|
||||
$label = Decode-Text $encodedLabel
|
||||
$normalized = $normalized.Replace("($label)", [string]::Empty)
|
||||
}
|
||||
|
||||
return $normalized.Replace("()", [string]::Empty).Trim()
|
||||
}
|
||||
|
||||
function Normalize-BasicDistrictToken {
|
||||
param([string]$Value)
|
||||
|
||||
$normalized = Normalize-CompactText -Value $Value
|
||||
$normalized = Normalize-CompactText -Value (Strip-BasicDistrictDisambiguation -Value $Value)
|
||||
if ([string]::IsNullOrWhiteSpace($normalized))
|
||||
{
|
||||
return [string]::Empty
|
||||
@@ -272,9 +310,32 @@ function Normalize-BasicDistrictToken {
|
||||
$normalized = $normalized.Replace($(Decode-Text "%EA%B5%B0%EC%88%98"), $(Decode-Text "%EA%B5%B0"))
|
||||
$normalized = $normalized.Replace($(Decode-Text "%EC%8B%9C%EC%9E%A5"), $(Decode-Text "%EC%8B%9C"))
|
||||
$normalized = $normalized.Replace($(Decode-Text "%EA%B5%90%EC%9C%A1%EA%B0%90"), [string]::Empty)
|
||||
$normalized = $normalized.Replace("()", [string]::Empty)
|
||||
return $normalized.Trim()
|
||||
}
|
||||
|
||||
function Normalize-BasicDistrictDisplayName {
|
||||
param(
|
||||
[string]$DistrictName,
|
||||
[string]$DisplayName,
|
||||
[string]$RegionName
|
||||
)
|
||||
|
||||
$normalized = if ([string]::IsNullOrWhiteSpace($DistrictName)) { $DisplayName } else { $DistrictName }
|
||||
if ([string]::IsNullOrWhiteSpace($normalized))
|
||||
{
|
||||
return [string]::Empty
|
||||
}
|
||||
|
||||
$normalized = $normalized.Trim()
|
||||
if (-not [string]::IsNullOrWhiteSpace($RegionName) -and $normalized.StartsWith($RegionName.Trim(), [System.StringComparison]::Ordinal))
|
||||
{
|
||||
$normalized = $normalized.Substring($RegionName.Trim().Length).Trim()
|
||||
}
|
||||
|
||||
return Strip-BasicDistrictDisambiguation -Value $normalized
|
||||
}
|
||||
|
||||
function New-OfficialWinnerEntry {
|
||||
param(
|
||||
[pscustomobject]$Cycle,
|
||||
@@ -977,6 +1038,8 @@ foreach ($region in $regions)
|
||||
continue
|
||||
}
|
||||
|
||||
$rawDistrictName = $districtName
|
||||
$districtName = Normalize-BasicDistrictDisplayName -DistrictName $districtName -DisplayName ([string]$winnerItem.wiwName) -RegionName $regionDisplayName
|
||||
$districtKey = Normalize-BasicDistrictToken -Value $districtName
|
||||
if ([string]::IsNullOrWhiteSpace($districtKey))
|
||||
{
|
||||
@@ -998,7 +1061,7 @@ foreach ($region in $regions)
|
||||
$record = $basicRecordsByKey[$recordKey]
|
||||
Add-HistoryEntry -Target $record.WinnerHistory -Entry (New-OfficialWinnerEntry -Cycle $cycle -Item $winnerItem -SourceUrl $winnerSourceUrl)
|
||||
|
||||
$turnoutSnapshot = Resolve-BasicTurnoutSnapshot -DistrictName $districtName -TurnoutItems $turnoutDetails
|
||||
$turnoutSnapshot = Resolve-BasicTurnoutSnapshot -DistrictName $rawDistrictName -TurnoutItems $turnoutDetails
|
||||
if ($null -ne $turnoutSnapshot)
|
||||
{
|
||||
Add-HistoryEntry -Target $record.TurnoutHistory -Entry (New-OfficialTurnoutEntry -Cycle $cycle -Electors $turnoutSnapshot.Electors -Votes $turnoutSnapshot.Votes -SourceUrl $turnoutSourceUrl)
|
||||
|
||||
Reference in New Issue
Block a user