Files
digital-psychology/apps/api/internal/scale/score.go
T
jackyu66gitandCursor bd22d9dddd feat: P1 合盘/星座/问答与测测完整设计包及模拟器取证工具
落地 synastry/star/ask API 与 H5 页面,补齐 cece-frontend-re complete-design 证据文档,并加入 Android 模拟器截图抓取脚本。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-03 11:37:53 +08:00

43 lines
982 B
Go

// Package scale holds exploration-test scoring helpers.
package scale
// ScoreMajority picks the most frequent answer key and maps to a label set.
func ScoreMajority(answers map[string]string, labels map[string]string, defaultLabel string) (styleKey, label string) {
counts := map[string]int{}
for _, v := range answers {
counts[v]++
}
best, bestN := "", -1
for k, n := range counts {
if n > bestN {
best, bestN = k, n
}
}
if best == "" {
return "", defaultLabel
}
label = labels[best]
if label == "" {
label = defaultLabel
}
return best, label
}
// CommunicationLabels for communication-style scale.
func CommunicationLabels() map[string]string {
return map[string]string{
"A": "理性澄清型",
"B": "感受连接型",
"C": "节奏尊重型",
}
}
// EmotionLabels for emotion-pattern scale.
func EmotionLabels() map[string]string {
return map[string]string{
"A": "觉察表达型",
"B": "安抚稳定型",
"C": "行动调节型",
}
}