Files
spider/internal/ingest/parse.go
toom1996 a939848e84 update
2026-09-16 21:31:32 +08:00

46 lines
1.7 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package ingest
import "strings"
// ParseCollection 从走秀标题解析出 collection_type 与 season。
//
// 仅输出后端白名单枚举(与 backend_v2/internal/pkg/season.Derive 一致):
// collection_type ∈ {rtw, menswear, couture, resort, pre_fall}
// season ∈ {spring, fall}(resort/pre_fall 无 spring/fall 词,season 留空,由 Derive 按 collection 前缀补码)
//
// 常见 Vogue 标题形态:
// "Fall 2024 Ready-to-Wear" → (rtw, fall)
// "Spring 2024 Menswear" → (menswear, spring)
// "Fall 2024 Couture" → (couture, fall)
// "Resort 2024" → (resort, "")
// "Pre-Fall 2024" → (pre_fall, "")
// "Cruise" 视作 resort 的同义表述(Vogue 两词混用);未识别到系列词时兜底为 rtw(成衣)。
func ParseCollection(title string) (collectionType, season string) {
t := strings.ToLower(title)
// season:仅 spring / fall 两种
switch {
case strings.Contains(t, "spring"):
season = "spring"
case strings.Contains(t, "fall"):
season = "fall"
}
// collection_type:按关键字优先级匹配,最后兜底 rtw
switch {
case strings.Contains(t, "menswear"), strings.Contains(t, "men's"):
collectionType = "menswear"
case strings.Contains(t, "couture"):
collectionType = "couture"
case strings.Contains(t, "resort"), strings.Contains(t, "cruise"):
collectionType = "resort"
case strings.Contains(t, "pre-fall"), strings.Contains(t, "pre fall"), strings.Contains(t, "prefall"):
collectionType = "pre_fall"
case strings.Contains(t, "ready-to-wear"), strings.Contains(t, "ready to wear"), strings.Contains(t, "rtw"):
collectionType = "rtw"
default:
collectionType = "rtw"
}
return collectionType, season
}