"""Top-25 most directive files by extended composite z-score.
Updated formula adds the new sentence_register signals:
+ directive_sent_pct (raises authority)
+ configuring_sent_pct (raises authority)
- collaborative_sent_pct (softens — interpersonal)
- permissive_sent_pct (softens — reader-agency / "you can")
- appreciative_sent_pct (softens — gratitude / praise)
"""
def zscore(s):
s = s.astype(float)
return (s - s.mean()) / (s.std(ddof=0) or 1.0)
alt_df["directiveness"] = (
zscore(alt_df["mood_marker_pct"])
+ zscore(alt_df["hard_prohibitions_pct"])
+ zscore(alt_df["caps_imp_pct"])
+ zscore(alt_df["directive_sent_pct"])
+ zscore(alt_df["configuring_sent_pct"])
- zscore(alt_df["collaborative_sent_pct"])
- zscore(alt_df["permissive_sent_pct"])
- zscore(alt_df["appreciative_sent_pct"])
)
top25 = (alt_df.nlargest(25, "directiveness")
[["path", "category", "n_tokens", "directiveness",
"mood_marker_pct", "hard_prohibitions_pct",
"caps_imp_pct",
"directive_sent_pct", "configuring_sent_pct",
"collaborative_sent_pct", "permissive_sent_pct",
"appreciative_sent_pct",
"just_ratio"]]
.reset_index(drop=True))
print(f"composite directiveness range: "
f"{alt_df['directiveness'].min():.2f} ↔ {alt_df['directiveness'].max():.2f}")
display(top25.style.background_gradient(subset=["directiveness"], cmap="Reds")
.format({"directiveness": "{:.2f}",
"mood_marker_pct": "{:.2f}",
"hard_prohibitions_pct": "{:.2f}",
"caps_imp_pct": "{:.2f}",
"directive_sent_pct": "{:.1f}",
"configuring_sent_pct": "{:.1f}",
"collaborative_sent_pct": "{:.1f}",
"permissive_sent_pct": "{:.1f}",
"appreciative_sent_pct": "{:.1f}",
"just_ratio": "{:.2f}"}))
top25_chart = (
alt.Chart(top25)
.mark_bar()
.encode(
x=alt.X("directiveness:Q", title="Composite z-score (higher = more directive)"),
y=alt.Y("path:N", sort="-x", title=None,
axis=alt.Axis(labelLimit=320)),
color=alt.Color("category:N",
scale=alt.Scale(domain=_cat_domain, range=_cat_range)),
tooltip=[
alt.Tooltip("path:N"),
alt.Tooltip("category:N"),
alt.Tooltip("n_tokens:Q", format=","),
alt.Tooltip("directiveness:Q", format=".2f"),
alt.Tooltip("mood_marker_pct:Q",
title="imperative markers %", format=".2f"),
alt.Tooltip("hard_prohibitions_pct:Q",
title="hard prohibitions %", format=".2f"),
alt.Tooltip("caps_imp_pct:Q",
title="CAPS imperative %", format=".2f"),
alt.Tooltip("directive_sent_pct:Q",
title="directive sent %", format=".1f"),
alt.Tooltip("configuring_sent_pct:Q",
title="configuring sent %", format=".1f"),
alt.Tooltip("collaborative_sent_pct:Q",
title="collab sent %", format=".1f"),
alt.Tooltip("permissive_sent_pct:Q",
title="permissive sent %", format=".1f"),
alt.Tooltip("just_ratio:Q", title="justification ratio", format=".2f"),
],
)
.properties(width=560, height=560,
title="Top 25 most directive prompts (extended z-summed composite)")
)
save_chart(top25_chart, "13-top25-directive-prompts")