Files
slogan/server/styleagent/agent/scoring_completeness_rule.go
T
admin a6de9ebd12 Add 'server/' from commit 'e64421295fff83acbb6d6ab3d3b27f3ef8368f00'
git-subtree-dir: server
git-subtree-mainline: c4e617ada7
git-subtree-split: e64421295f
2026-08-04 15:02:35 +08:00

73 lines
1.2 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 agent
// completenessScore 层次完整度(20 分制):上衣+5 下装+5 鞋+5 配饰+5
func completenessScore(o CandidateOutfit) int {
score := 0
for _, it := range o.Items {
switch it.Category {
case "上衣":
score += 5
case "下装":
score += 5
case "鞋":
score += 5
case "配饰":
score += 5
}
}
if o.HasOuterwear {
score += 2
}
if score > 20 {
return 20
}
return score
}
// styleScore 风格一致性(10 分制):命中用户偏好标签每项 +2
func styleScore(o CandidateOutfit, ctx ScoreContext) int {
if len(ctx.StyleTags) == 0 {
return 5
}
score := 0
for _, it := range o.Items {
for _, tag := range ctx.StyleTags {
if tag != "" && it.StyleTags != "" && containsTag(it.StyleTags, tag) {
score += 2
}
}
}
if score > 10 {
return 10
}
return score
}
func containsTag(tags, tag string) bool {
for _, t := range splitTags(tags) {
if t == tag {
return true
}
}
return false
}
func splitTags(s string) []string {
var out []string
cur := ""
for _, c := range s {
if c == ',' || c == '' || c == ' ' {
if cur != "" {
out = append(out, cur)
cur = ""
}
continue
}
cur += string(c)
}
if cur != "" {
out = append(out, cur)
}
return out
}