update
This commit is contained in:
45
internal/ingest/parse.go
Normal file
45
internal/ingest/parse.go
Normal file
@ -0,0 +1,45 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user