releaseparser: Artist/Title boundary resolution + normalized Type field

Three-level core resolution with priority overrides → dictionaries/model → suspects:

1. dicts/overrides.txt (highest priority)
   Point fixes via exact lookup on Raw BEFORE the positional logic.
   Format: <original line> => artist | title. An override fixes
   Artist/Title and shifts the dictionary tail zone by the actual core
   length (overrideCoreLength, fallback 2 tokens).

2. dicts/artists.txt
   Whitelist of hyphenated artists (Iku-Turso, Post-Mortem, ...): a
   [0]-[1] hit → Artist = 2 tokens, Title = [2], tail zone shifted.
   One entry covers all releases of the artist automatically.

3. Suspected title continuation
   Unknown tokens between the title zone and the tail (followed later by
   dictionary markers) no longer pollute UnknownTokens; they go to a
   dedicated TitleExtra field + warning "suspected title continuation" —
   a reviewer hint that the core is probably longer than 2 tokens.
   Catalogue numbers (parenthesized tokens) are resolved with FIRST
   priority and never land in suspects.

Type field (normalized base release type):
- new normalization map dicts/types.txt (<Base> = variants):
  EP = EP, CDS, CDM, 7INCH_VINYL, CDEP, ..., REMASTERED_EP; Demo = ...;
  Split; Single; Compilation; Collaboration (curator-extendable)
- tokens matched against edition/source are additionally normalized to
  the base type (first match wins); edition.txt/source.txt untouched,
  Source stays raw
- TypeDistribution map[string]int added to GroupStats and the report
  (console/JSON)
- OST/INSTRUMENTAL are release traits, not types; excluded from the map

Tests: old cases updated to the new suspect semantics; acceptance tests
added for overrides (Milicia_Oscura-Anti-Cristo), artist dictionary
(Iku-Turso), the suspect section, Type normalization (CDEP → EP with
raw Source=CDEP, first-match-wins) and TypeDistribution.

go build / go vet / go test ./internal/releaseparser/... — all green.
This commit is contained in:
Yevhen Odynets
2026-09-01 13:18:40 +03:00
parent f2629f002c
commit 347f525801
6 changed files with 294 additions and 32 deletions
+12
View File
@@ -1,6 +1,14 @@
package releaseparser
type Override struct {
Artist string
Title string
}
type GroupProfile struct {
ArtistTokens map[string]bool // hyphenated artist whitelist
TypeVariants map[string]string // variant (upper) -> normalized Type
Overrides map[string]Override
FormatTokens map[string]bool
SourceTokens map[string]bool
BitDepthTokens map[string]bool
@@ -16,6 +24,8 @@ type ParsedRelease struct {
Artist string
Year int
Title string
TitleExtra []string
Type string
Source string
Edition string
CatalogNo string
@@ -25,6 +35,7 @@ type ParsedRelease struct {
Comment string
Format string
Core string
Override Override
UnknownTokens []string
Warnings []string
Confidence float64
@@ -38,6 +49,7 @@ type UnknownTokenStats struct {
type GroupStats struct {
Total int
TypeDistribution map[string]int
YearDistribution map[int]int
SourceDistribution map[string]int
BitDepthDistribution map[string]int