feat(ml): normalize Camie suggestion names to human-readable #56
Reference in New Issue
Block a user
Delete Branch "dev"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Camie's booru-style vocab strings (
uchiha_sasuke_(naruto),#unicus_(idolmaster),1000-nen_ikiteru_(vocaloid),:/) surfaced raw in SuggestionsPanel — and worse, the same raw string was written totag.nameon Accept, polluting the DB withunderscored_lowercasenames that don't match the operator's Title Case convention.backend/app/services/ml/tag_name.pywithnormalize(raw) → str | None: strip leading junk (#,.,+,;,~,_), drop trailing_(disambiguator)blocks iteratively, strip wrapping quotes, underscores → spaces, space after colon, title-case each space-separated word, preserve hyphens / apostrophes / digits, drop entries with no alphanumerics (emoticons like:/,+_+,^_^).SuggestionService.for_image: alias_map still keyed on the raw Camie string (alias rows are hand-curated against raw keys), butdisplay_nameand the existing-tag lookup use the normalized form. Existing-tag lookup widened tofunc.lower(Tag.name).in_([raw, display])so legacy underscore-named Tag rows from before normalization still surface as "existing" instead of "+ new".Test plan
tests/test_ml_tag_name.py— 24 parametrized cases (all 9 rules + edge cases: emoticons, repeated disambig blocks, quoted forms, leading junk, hyphens preserved, digit-only year tags, apostrophe inside word)tests/test_ml_suggestions.pytwo existing assertions updated to title-cased forms ("Sword", "Brand New Tag")e450145) green across all 6 jobs (lint, frontend-build, backend-lint-and-test, intimp, intapi, intcore)light_purple_hairPlan: Scribe task #590.
Rule 8 'no letters -> drop' was over-eager: bare digit tags like '2005' returned None even though they're legitimate (booru year-tag shape). Widen the keep-condition to any alphanumeric. Emoticons (':/', '^_^', '+_+') still drop since they contain neither letters nor digits.