s-ttp commited on
Commit
e604f4f
·
verified ·
1 Parent(s): d094c05

Title-case strong ratings checked; seats with no publishable prose say so

Browse files
engine/prose.py CHANGED
@@ -701,7 +701,7 @@ LABEL_WINDOW = 48
701
  # a label never reaches across a sentence end, a clause boundary, a comma, or a comparison word: in
702
  # "[[A]] trailing vs [[B]]" or "from [[A]] to [[B]]" the words before the conjunction belong to A
703
  CLAUSE = re.compile(r"[:;—–(),]|[.!?](?:\s|$)|\b(?:vs\.?|versus|against|compared with|from|to|and)\b", re.I)
704
- RATING_WORD = re.compile(r"\b(STRONG[ -]BUY|STRONG[ -]SELL|BUY|SELL|HOLD)\b|\b((?:strong[ -])?(?:buy|sell|hold))[ -](?:view|call|rating|recommendation|stance)\b")
705
  FIRST_PERSON = re.compile(r"\b(?:I|my|we|our|me)\b")
706
  GAP_THEN_DIRECTION = re.compile(r"\[\[([A-Z0-9_]+)\]\]\s+(?:above|below|over|under)\b", re.I)
707
 
 
701
  # a label never reaches across a sentence end, a clause boundary, a comma, or a comparison word: in
702
  # "[[A]] trailing vs [[B]]" or "from [[A]] to [[B]]" the words before the conjunction belong to A
703
  CLAUSE = re.compile(r"[:;—–(),]|[.!?](?:\s|$)|\b(?:vs\.?|versus|against|compared with|from|to|and)\b", re.I)
704
+ RATING_WORD = re.compile(r"\b((?i:strong[ -]buy|strong[ -]sell)|BUY|SELL|HOLD)\b|\b((?:strong[ -])?(?:buy|sell|hold))[ -](?:view|call|rating|recommendation|stance)\b")
705
  FIRST_PERSON = re.compile(r"\b(?:I|my|we|our|me)\b")
706
  GAP_THEN_DIRECTION = re.compile(r"\[\[([A-Z0-9_]+)\]\]\s+(?:above|below|over|under)\b", re.I)
707
 
engine/report_model.py CHANGED
@@ -165,12 +165,19 @@ def build_user_report(s, cat, prose, limitations):
165
  # headlines only: each point shows its topic, the full point opens on a tap
166
  B.append(Block("points", "debate", entry["key_points"], title=None if entry.get("reasoning") else title))
167
 
 
 
 
168
  for role, name, ret_id, p_id in order:
169
  st = seats.get(role) or {}
170
  B.append(_para("debate", r.t(f"{name} — "), r.c(ret_id),
171
  r.t(f" · {(s.scenarios.get(role) or {}).get('label') or ''} · probability "), r.c(p_id), css="seat-head"))
172
  op = seats.get(f"{role}_open") or {}
173
- if op:
 
 
 
 
174
  _notes(op, "Opening case")
175
  _notes(st, "Rebuttal")
176
  else:
 
165
  # headlines only: each point shows its topic, the full point opens on a tap
166
  B.append(Block("points", "debate", entry["key_points"], title=None if entry.get("reasoning") else title))
167
 
168
+ def _has(e):
169
+ return bool((e or {}).get("reasoning") or (e or {}).get("key_points"))
170
+
171
  for role, name, ret_id, p_id in order:
172
  st = seats.get(role) or {}
173
  B.append(_para("debate", r.t(f"{name} — "), r.c(ret_id),
174
  r.t(f" · {(s.scenarios.get(role) or {}).get('label') or ''} · probability "), r.c(p_id), css="seat-head"))
175
  op = seats.get(f"{role}_open") or {}
176
+ if not (_has(op) or _has(st)):
177
+ # nothing this analyst wrote met the report's evidence standards: say so instead of an empty section
178
+ B.append(_para("debate", r.t("This analyst's written reasoning is not shown: none of it met the report's "
179
+ "evidence standards. The scenario and its weight above are the analyst's own.")))
180
+ elif op:
181
  _notes(op, "Opening case")
182
  _notes(st, "Rebuttal")
183
  else:
engine/tests/test_spgi_relations.py CHANGED
@@ -890,3 +890,21 @@ def test_empty_summary_and_pm_sections_fall_back_to_typed_template_sentences(goo
890
  assert "The portfolio manager weights the bear case at" in md
891
  a = RM.audit(rep, run.state, md, RM.render_html(rep))
892
  assert a.passed, [(c.id, c.detail) for c in a.checks if c.status == "FAIL"]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
890
  assert "The portfolio manager weights the bear case at" in md
891
  a = RM.audit(rep, run.state, md, RM.render_html(rep))
892
  assert a.passed, [(c.id, c.detail) for c in a.checks if c.status == "FAIL"]
893
+
894
+
895
+
896
+ def test_title_case_strong_rating_is_checked_and_empty_seats_say_so(good):
897
+ """Live SPGI (c11694dec842419a): the HOLD bull wrote "I maintain a Strong Buy"; the neutral seat had no publishable prose."""
898
+ import report_model as RM
899
+ run, _ = good
900
+ cat = C.build_catalog(run.state, include_deferred=True)
901
+ lab = (run.state.scenarios.get("bull") or {}).get("label")
902
+ r = run.rules(cat, own="SCENARIO_BULL_RETURN_PHRASE", own_label=lab)
903
+ other = "Strong Sell" if lab != "STRONG SELL" else "Strong Buy"
904
+ ok, why = P.check_sentence(f"I maintain a {other} with modestly trimmed upside.", r)
905
+ assert not ok and "rating" in why
906
+ rep = RM.build_user_report(run.state, cat, {"summary": [], "thesis": [], "risks": [], "seats": {}}, [])
907
+ md = RM.render_markdown(rep)
908
+ assert md.count("This analyst's written reasoning is not shown") == 3
909
+ a = RM.audit(rep, run.state, md, RM.render_html(rep))
910
+ assert a.passed, [(c.id, c.detail) for c in a.checks if c.status == "FAIL"]