Improve paired cast continuity and wording

This commit is contained in:
2026-06-24 10:57:46 +02:00
parent a1c6dc2391
commit 51d351679f
5 changed files with 184 additions and 8 deletions
+54 -2
View File
@@ -180,6 +180,18 @@ def _clean_clothing(text: str) -> str:
return text.strip(" ,")
def _body_phrase(body: Any, figure_note: Any = "") -> str:
body = _clean_text(body)
figure_note = _clean_text(figure_note)
if not body:
return figure_note
if not figure_note:
return f"{body} figure"
if "figure" in figure_note.lower():
return f"{body} build and {figure_note}"
return f"{body} figure with {figure_note}"
def _single_caption_front(row: dict[str, Any]) -> dict[str, str]:
caption = _clean_text(row.get("caption"))
if not caption:
@@ -192,7 +204,7 @@ def _single_caption_front(row: dict[str, Any]) -> dict[str, str]:
if not body_phrase:
body = _clean_text(row.get("body_type") or row.get("body"))
figure = _clean_text(row.get("figure"))
body_phrase = f"{body} figure with {figure}" if body and figure else f"{body} figure".strip()
body_phrase = _body_phrase(body, figure)
front = f"{subject}, {age}, {body_phrase}, "
if subject in ("woman", "man") and age and body_phrase and caption.startswith(front):
try:
@@ -290,7 +302,7 @@ def _single_from_row(row: dict[str, Any], detail_level: str, keep_style: bool) -
if not body_phrase:
body = _clean_text(row.get("body_type") or row.get("body") or "")
figure = _clean_text(row.get("figure"))
body_phrase = f"{body} figure with {figure}" if body and figure else f"{body} figure".strip()
body_phrase = _body_phrase(body, figure)
skin = _row_value(row, "skin") or caption_front.get("caption_skin", "")
hair = _row_value(row, "hair") or caption_front.get("caption_hair", "")
@@ -454,8 +466,48 @@ def _group_or_layout_from_row(row: dict[str, Any], detail_level: str, keep_style
return _join_sentences(parts), "metadata(group_layout)"
def _insta_of_pair_from_row(row: dict[str, Any], detail_level: str, keep_style: bool) -> tuple[str, str] | None:
if _clean_text(row.get("mode")).lower() != "insta/of":
return None
soft_row = row.get("softcore_row")
hard_row = row.get("hardcore_row")
if not isinstance(soft_row, dict) or not isinstance(hard_row, dict):
return None
hard_row_for_text = dict(hard_row)
options = row.get("options")
if isinstance(options, dict) and options.get("continuity") == "same_creator_same_room":
if soft_row.get("scene_text"):
hard_row_for_text["scene_text"] = soft_row["scene_text"]
if soft_row.get("composition"):
hard_row_for_text["composition"] = soft_row["composition"]
soft_text, _soft_method = _metadata_to_prose(soft_row, detail_level, keep_style)
hard_text, _hard_method = _metadata_to_prose(hard_row_for_text, detail_level, keep_style)
descriptor = _clean_text(row.get("shared_descriptor"))
cast_descriptors = row.get("shared_cast_descriptors")
if isinstance(cast_descriptors, list):
cast_descriptor_text = _human_join([_clean_text(item) for item in cast_descriptors if _clean_text(item)])
else:
cast_descriptor_text = _clean_text(cast_descriptors)
parts = []
if cast_descriptor_text:
parts.append(f"The shared cast descriptors are {cast_descriptor_text}")
elif descriptor:
parts.append(f"The shared creator descriptor is {descriptor}")
if soft_text:
parts.append(f"Softcore version: {soft_text}")
if hard_text:
parts.append(f"Hardcore version: {hard_text}")
if not parts:
return None
return _join_sentences(parts), "metadata(insta_of_pair)"
def _metadata_to_prose(row: dict[str, Any], detail_level: str, keep_style: bool) -> tuple[str, str]:
for builder in (
_insta_of_pair_from_row,
_configured_cast_from_row,
_single_from_row,
_couple_from_row,