Normalize built-in row scene metadata
This commit is contained in:
+10
-2
@@ -3,8 +3,10 @@ from __future__ import annotations
|
||||
from typing import Any
|
||||
|
||||
try:
|
||||
from . import row_location as row_location_policy
|
||||
from .prompt_hygiene import combine_negative_text, sanitize_caption_text, sanitize_negative_text, sanitize_prompt_text
|
||||
except ImportError: # Allows local smoke tests with `python tools/prompt_smoke.py`.
|
||||
import row_location as row_location_policy
|
||||
from prompt_hygiene import combine_negative_text, sanitize_caption_text, sanitize_negative_text, sanitize_prompt_text
|
||||
|
||||
|
||||
@@ -77,8 +79,14 @@ def enrich_legacy_row_metadata(row: dict[str, Any]) -> dict[str, Any]:
|
||||
_setdefault_count(row, "men_count", men_count)
|
||||
if women_count is not None and men_count is not None and not str(row.get("person_count") or "").strip():
|
||||
row["person_count"] = int(women_count) + int(men_count)
|
||||
if str(row.get("scene") or "").strip() and not str(row.get("scene_slug") or "").strip():
|
||||
row["scene_slug"] = row.get("scene")
|
||||
scene_slug = str(row.get("scene") or row.get("scene_slug") or "").strip()
|
||||
if scene_slug and not str(row.get("scene_slug") or "").strip():
|
||||
row["scene_slug"] = scene_slug
|
||||
if scene_slug and not str(row.get("scene_text") or "").strip():
|
||||
scene_text = row_location_policy.legacy_scene_text_for_slug(scene_slug)
|
||||
if scene_text:
|
||||
row["scene_text"] = scene_text
|
||||
row.setdefault("scene_entry", {"slug": scene_slug, "prompt": scene_text})
|
||||
return row
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user