From 5fa815db5577f65abc0556052cf5ff6247f1d998 Mon Sep 17 00:00:00 2001 From: Jumpstile Date: Tue, 17 Nov 2026 06:40:31 -0500 Subject: [PATCH] Check the provider group against league tags when classifying a channel (#191) The channel classifier checked the provider group only against category aliases and the league tags (NHL, MLB, NBA...) only against the channel name, so an NHL game feed such as a team-versus-team channel in the NHL group, or a channel with an empty name, got no category. The group text is now also checked against the league tags. A name word and a group word that disagree still give a conflict and no category; unknown stays unknown. On a real 404-channel lineup copy, hockey channels went from 1 to 16 and no channel that already had a category changed it. Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_01NzHAcjThVoUGWWfXrYWsNh --- .../Get-ChannelForgeChannelCategory.ps1 | 4 +++- tests/unit/CategoryReport.Tests.ps1 | 23 +++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/ChannelForge/Private/Get-ChannelForgeChannelCategory.ps1 b/src/ChannelForge/Private/Get-ChannelForgeChannelCategory.ps1 index e8268ab..ebd5d30 100644 --- a/src/ChannelForge/Private/Get-ChannelForgeChannelCategory.ps1 +++ b/src/ChannelForge/Private/Get-ChannelForgeChannelCategory.ps1 @@ -41,7 +41,9 @@ function Get-ChannelForgeChannelCategory { } $nameHits = @(Find-ChannelForgeCategoryWord -Text $Name -Registry $Registry -Property NameTokens) - $groupHits = @(Find-ChannelForgeCategoryWord -Text $ProviderGroup -Registry $Registry -Property Aliases) + # A provider group may be a league tag such as "NHL", so group text is checked against the same league tokens as the name. + $groupHits = @(Find-ChannelForgeCategoryWord -Text $ProviderGroup -Registry $Registry -Property Aliases) + + @(Find-ChannelForgeCategoryWord -Text $ProviderGroup -Registry $Registry -Property NameTokens) $groupSpecific = @($groupHits | Where-Object { $_.Key -ne 'other-sports' }) $isGeneric = $groupHits.Count -gt $groupSpecific.Count $keys = @(@($nameHits) + $groupSpecific | ForEach-Object { $_.Key } | Select-Object -Unique) diff --git a/tests/unit/CategoryReport.Tests.ps1 b/tests/unit/CategoryReport.Tests.ps1 index e43cf02..2cbbf02 100644 --- a/tests/unit/CategoryReport.Tests.ps1 +++ b/tests/unit/CategoryReport.Tests.ps1 @@ -118,3 +118,26 @@ Describe 'Category overrides: corrections the owner keeps' { [IO.File]::ReadAllBytes($script:OverridePath) | Should -Be $before } } + +Describe 'Channel category: league tag in the provider group' { + BeforeAll { + function Get-Decision { param([string]$Name, [string]$Group) & (Get-Module ChannelForge) { param($n, $g) Get-ChannelForgeChannelCategory -Name $n -ProviderGroup $g -Key 'k' } $Name $Group } + } + + It 'puts a game-feed channel in an NHL group under hockey, even with an empty name' { + (Get-Decision 'Vancouver Canucks @ Utah Mammoth [Mammoth Feed]' 'NHL').Category | Should -Be 'hockey' + (Get-Decision '' 'NHL').Category | Should -Be 'hockey' + } + + It 'gives no category when the name and the NHL group disagree' { + $result = Get-Decision 'NBA TV' 'NHL' + $result.Category | Should -BeNullOrEmpty + $result.Decision | Should -Be 'conflict' + } + + It 'keeps the MLB, NBA and NFL categories' { + (Get-Decision 'MLB 01: No event today' 'MLB').Category | Should -Be 'baseball' + (Get-Decision 'NBA (ATL) Atlanta Hawks (A)' 'NBA').Category | Should -Be 'basketball' + (Get-Decision 'NFL RedZone' 'NFL').Category | Should -Be 'football' + } +}