diff --git a/internal/router/compat_test.go b/internal/router/compat_test.go index bbf07268..043453b4 100644 --- a/internal/router/compat_test.go +++ b/internal/router/compat_test.go @@ -172,7 +172,7 @@ func TestModerationsAreAnsweredByTheJudge(t *testing.T) { } _ = json.Unmarshal(rec.Body.Bytes(), &out) if rec.Code != 200 || out.Model != "guard" || len(out.Results) != 1 || !out.Results[0].Flagged || - !out.Results[0].Categories["indiscriminate-weapons"] { + !out.Results[0].Categories["indiscriminate-weapons"] || out.Results[0].Categories["s9"] { t.Errorf("%d %s", rec.Code, rec.Body.String()) } } diff --git a/internal/router/moderations.go b/internal/router/moderations.go index 637ccd2b..bb984de8 100644 --- a/internal/router/moderations.go +++ b/internal/router/moderations.go @@ -57,6 +57,12 @@ func (r *Router) handleModerations(w http.ResponseWriter, req *http.Request) { categories[moderationKey(n)], scores[moderationKey(n)] = false, 0 } for _, c := range cats { + // The judge says both a code and the name it stands for; the + // name is what is shown, when there is one. + var n int + if _, err := fmt.Sscanf(c, "S%d", &n); err == nil && n >= 1 && n <= len(names) { + continue + } categories[moderationKey(c)], scores[moderationKey(c)] = true, 1 } results = append(results, map[string]any{"flagged": unsafe, "categories": categories, "category_scores": scores})