fix(rectification): stop yearless ungrounded varga contrast from minting cards
Only sign-bound varga_style questions may omit a concrete period. Remaining-layer existence and quality probes now drop as yearless_ungrounded_contrast instead of scoring by group order. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -34,6 +34,9 @@ LABEL_MAX = 80
|
||||
_FORBIDDEN = FORBIDDEN_COPY_TOKENS
|
||||
_CLOCK = re.compile(r"(?:[01]?\d|2[0-3]):[0-5]\d")
|
||||
_ANSWER_CLASS_SUFFIX = re.compile(r"·(?:yes|weak_yes|no|unsure)$")
|
||||
_PLACEHOLDER_PERIOD = re.compile(r"^(当前这几个候选|那段时间)$")
|
||||
_CONCRETE_YEAR = re.compile(r"(?:19|20)\d{2}")
|
||||
YEARLESS_PERIOD_COPY_MARKERS = ("时间吻合", "这段")
|
||||
_CONTRACT_PATH = Path(__file__).resolve().parents[2] / "contracts" / "probe-question-v1.json"
|
||||
|
||||
|
||||
@@ -217,4 +220,43 @@ def is_renderable_probe(probe: dict[str, Any]) -> ProbeRenderOk | ProbeRenderErr
|
||||
completed = complete_style_options(probe.get("choice_kind"), probe.get("style_options"))
|
||||
if not completed.get("ok"):
|
||||
return {"ok": False, "reason": str(completed.get("reason") or "not_renderable")}
|
||||
kind = probe_question_kind(probe.get("choice_kind"))
|
||||
options = completed.get("options") or []
|
||||
concrete = False if kind == "varga_style" else _probe_has_concrete_period(probe)
|
||||
if not concrete and not _can_render_yearless_choice(kind, options):
|
||||
return {"ok": False, "reason": "yearless_ungrounded_contrast"}
|
||||
return {"ok": True}
|
||||
|
||||
|
||||
def _probe_has_concrete_period(probe: dict[str, Any]) -> bool:
|
||||
year = probe.get("year") or 0
|
||||
if not isinstance(year, (int, float)) or year <= 0:
|
||||
return False
|
||||
label = str(probe.get("year_label") or probe.get("yearLabel") or "").strip()
|
||||
if not label:
|
||||
return True
|
||||
if _PLACEHOLDER_PERIOD.match(label):
|
||||
return False
|
||||
return bool(_CONCRETE_YEAR.search(label))
|
||||
|
||||
|
||||
def _can_render_yearless_choice(kind: str, options: Sequence[dict[str, str]]) -> bool:
|
||||
if kind != "varga_style":
|
||||
return False
|
||||
by_class = {item.get("answer_class"): item for item in options}
|
||||
yes = by_class.get("yes") or {}
|
||||
weak_yes = by_class.get("weak_yes") or {}
|
||||
none = by_class.get("no") or {}
|
||||
if not str(yes.get("sign") or "").strip() or not str(weak_yes.get("sign") or "").strip():
|
||||
return False
|
||||
if str(none.get("sign") or "").strip():
|
||||
signed = True
|
||||
else:
|
||||
signed = none.get("label") == VARGA_NONE_STYLE_OPTION["label"]
|
||||
if not signed:
|
||||
return False
|
||||
return not any(
|
||||
marker in str(item.get("label") or "")
|
||||
for item in options
|
||||
for marker in YEARLESS_PERIOD_COPY_MARKERS
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user