Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ function Get-ChannelForgeEventChannelCandidate {
foreach ($item in $Channel) {
$name = & $normalize ([string]$item.DisplayName)
$ppvHit = @(Find-ChannelForgeCategoryWord -Text $name -Registry $ppvWords -Property Aliases)
# The shared matcher is whole-word only; also accept ppv plus digits (PPV1, PPV2). Not SKYPPV.
if ($ppvHit.Count -eq 0) {
$ppvDigits = [regex]::Match($name, '(?<![\p{L}\p{N}])ppv\d+(?![\p{L}\p{N}])')
if ($ppvDigits.Success) { $ppvHit = @([pscustomobject]@{ Key = 'ppv'; Word = $ppvDigits.Value }) }
}
$eventHit = @(Find-ChannelForgeCategoryWord -Text $name -Registry $eventWords -Property Aliases)
$programmes = @($item.Programmes)

Expand All @@ -28,7 +33,10 @@ function Get-ChannelForgeEventChannelCandidate {
if ($hours -le 0) { continue }
$title = & $normalize ([string]$programme.Title)
$total += $hours
if ($fillers -contains $title -or $title -ceq $name) { $placeholder += $hours }
# A title that echoes the channel name (equal, or one starts with the other, shorter side 4+ chars) is a placeholder.
$short = [math]::Min($title.Length, $name.Length)
$echo = $short -ge 4 -and ($name.StartsWith($title, [StringComparison]::Ordinal) -or $title.StartsWith($name, [StringComparison]::Ordinal))
if ($fillers -contains $title -or $title -ceq $name -or $echo) { $placeholder += $hours }
else { $realTitles[$title] = $true; if ($hours -ge 6) { $long += $hours } }
}
$share = if ($total -gt 0) { $placeholder / $total } else { 0.0 }
Expand Down
14 changes: 14 additions & 0 deletions tests/unit/EventChannelCandidate.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,20 @@ Describe 'Event channel candidates' {
$none.Reasons | Should -Contain 'no guide data'
}

It 'rates PPV1 style names high' {
$rated = Get-Rated -Channel @((New-EventChannel -Name 'Prima Sport PPV1' -Titles @('Prima Sport PPV1')))
$rated[0].Confidence | Should -Be 'high'
}

It 'counts a title that echoes the channel name with a suffix as placeholder' {
$rated = Get-Rated -Channel @(
(New-EventChannel -Name 'blue Event D 1' -Titles @('blue Event D 1 Live', 'blue Event D 1 Live'))
(New-EventChannel -Name 'Fight Network' -Titles @('Bout A', 'Bout B', 'Bout C'))
)
($rated | Where-Object DisplayName -ceq 'blue Event D 1').Confidence | Should -Be 'high'
($rated | Where-Object DisplayName -ceq 'Fight Network').Confidence | Should -Be 'medium'
}

It 'does not flag a normal channel full of filler, and reports nothing for a normal channel' {
$rated = Get-Rated -Channel @(
(New-EventChannel -Name 'City News' -Titles @('Off Air', 'SIGN OFF', 'To Be Announced'))
Expand Down
Loading