style: run prettifier plugin on entire frontend
This commit is contained in:
@@ -14,15 +14,17 @@ const CulturalStats = ({ data }: CulturalStatsProps) => {
|
||||
const inGroupWords = identity?.in_group_usage ?? 0;
|
||||
const outGroupWords = identity?.out_group_usage ?? 0;
|
||||
const totalGroupWords = inGroupWords + outGroupWords;
|
||||
const inGroupWordRate = typeof identity?.in_group_ratio === "number"
|
||||
? identity.in_group_ratio * 100
|
||||
: null;
|
||||
const outGroupWordRate = typeof identity?.out_group_ratio === "number"
|
||||
? identity.out_group_ratio * 100
|
||||
: null;
|
||||
const inGroupWordRate =
|
||||
typeof identity?.in_group_ratio === "number"
|
||||
? identity.in_group_ratio * 100
|
||||
: null;
|
||||
const outGroupWordRate =
|
||||
typeof identity?.out_group_ratio === "number"
|
||||
? identity.out_group_ratio * 100
|
||||
: null;
|
||||
const rawEntities = data.avg_emotion_per_entity?.entity_emotion_avg ?? {};
|
||||
const entities = Object.entries(rawEntities)
|
||||
.sort((a, b) => (b[1].post_count - a[1].post_count))
|
||||
.sort((a, b) => b[1].post_count - a[1].post_count)
|
||||
.slice(0, 20);
|
||||
|
||||
const topEmotion = (emotionAvg: Record<string, number> | undefined) => {
|
||||
@@ -42,7 +44,10 @@ const CulturalStats = ({ data }: CulturalStatsProps) => {
|
||||
<div style={{ ...styles.container, ...styles.grid }}>
|
||||
<div style={{ ...styles.card, gridColumn: "span 12" }}>
|
||||
<h2 style={styles.sectionTitle}>Community Framing Overview</h2>
|
||||
<p style={styles.sectionSubtitle}>Simple view of how often people use "us" words vs "them" words, and the tone around that language.</p>
|
||||
<p style={styles.sectionSubtitle}>
|
||||
Simple view of how often people use "us" words vs "them" words, and
|
||||
the tone around that language.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<Card
|
||||
@@ -84,13 +89,17 @@ const CulturalStats = ({ data }: CulturalStatsProps) => {
|
||||
/>
|
||||
<Card
|
||||
label="In-Group Share"
|
||||
value={inGroupWordRate === null ? "—" : `${inGroupWordRate.toFixed(2)}%`}
|
||||
value={
|
||||
inGroupWordRate === null ? "—" : `${inGroupWordRate.toFixed(2)}%`
|
||||
}
|
||||
sublabel="Share of all words"
|
||||
style={{ gridColumn: "span 3" }}
|
||||
/>
|
||||
<Card
|
||||
label="Out-Group Share"
|
||||
value={outGroupWordRate === null ? "—" : `${outGroupWordRate.toFixed(2)}%`}
|
||||
value={
|
||||
outGroupWordRate === null ? "—" : `${outGroupWordRate.toFixed(2)}%`
|
||||
}
|
||||
sublabel="Share of all words"
|
||||
style={{ gridColumn: "span 3" }}
|
||||
/>
|
||||
@@ -98,52 +107,87 @@ const CulturalStats = ({ data }: CulturalStatsProps) => {
|
||||
<Card
|
||||
label="Hedging Words"
|
||||
value={stance?.hedge_total?.toLocaleString() ?? "—"}
|
||||
sublabel={typeof stance?.hedge_per_1k_tokens === "number" ? `${stance.hedge_per_1k_tokens.toFixed(1)} per 1k words` : "Word frequency"}
|
||||
sublabel={
|
||||
typeof stance?.hedge_per_1k_tokens === "number"
|
||||
? `${stance.hedge_per_1k_tokens.toFixed(1)} per 1k words`
|
||||
: "Word frequency"
|
||||
}
|
||||
style={{ gridColumn: "span 3" }}
|
||||
/>
|
||||
<Card
|
||||
label="Certainty Words"
|
||||
value={stance?.certainty_total?.toLocaleString() ?? "—"}
|
||||
sublabel={typeof stance?.certainty_per_1k_tokens === "number" ? `${stance.certainty_per_1k_tokens.toFixed(1)} per 1k words` : "Word frequency"}
|
||||
sublabel={
|
||||
typeof stance?.certainty_per_1k_tokens === "number"
|
||||
? `${stance.certainty_per_1k_tokens.toFixed(1)} per 1k words`
|
||||
: "Word frequency"
|
||||
}
|
||||
style={{ gridColumn: "span 3" }}
|
||||
/>
|
||||
<Card
|
||||
label="Need/Should Words"
|
||||
value={stance?.deontic_total?.toLocaleString() ?? "—"}
|
||||
sublabel={typeof stance?.deontic_per_1k_tokens === "number" ? `${stance.deontic_per_1k_tokens.toFixed(1)} per 1k words` : "Word frequency"}
|
||||
sublabel={
|
||||
typeof stance?.deontic_per_1k_tokens === "number"
|
||||
? `${stance.deontic_per_1k_tokens.toFixed(1)} per 1k words`
|
||||
: "Word frequency"
|
||||
}
|
||||
style={{ gridColumn: "span 3" }}
|
||||
/>
|
||||
<Card
|
||||
label="Permission Words"
|
||||
value={stance?.permission_total?.toLocaleString() ?? "—"}
|
||||
sublabel={typeof stance?.permission_per_1k_tokens === "number" ? `${stance.permission_per_1k_tokens.toFixed(1)} per 1k words` : "Word frequency"}
|
||||
sublabel={
|
||||
typeof stance?.permission_per_1k_tokens === "number"
|
||||
? `${stance.permission_per_1k_tokens.toFixed(1)} per 1k words`
|
||||
: "Word frequency"
|
||||
}
|
||||
style={{ gridColumn: "span 3" }}
|
||||
/>
|
||||
|
||||
<div style={{ ...styles.card, gridColumn: "span 6" }}>
|
||||
<h2 style={styles.sectionTitle}>Mood in "Us" Posts</h2>
|
||||
<p style={styles.sectionSubtitle}>Most likely emotion when in-group wording is stronger.</p>
|
||||
<div style={styles.topUserName}>{topEmotion(identity?.in_group_emotion_avg)}</div>
|
||||
<p style={styles.sectionSubtitle}>
|
||||
Most likely emotion when in-group wording is stronger.
|
||||
</p>
|
||||
<div style={styles.topUserName}>
|
||||
{topEmotion(identity?.in_group_emotion_avg)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div style={{ ...styles.card, gridColumn: "span 6" }}>
|
||||
<h2 style={styles.sectionTitle}>Mood in "Them" Posts</h2>
|
||||
<p style={styles.sectionSubtitle}>Most likely emotion when out-group wording is stronger.</p>
|
||||
<div style={styles.topUserName}>{topEmotion(identity?.out_group_emotion_avg)}</div>
|
||||
<p style={styles.sectionSubtitle}>
|
||||
Most likely emotion when out-group wording is stronger.
|
||||
</p>
|
||||
<div style={styles.topUserName}>
|
||||
{topEmotion(identity?.out_group_emotion_avg)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div style={{ ...styles.card, gridColumn: "span 12" }}>
|
||||
<h2 style={styles.sectionTitle}>Entity Mood Snapshot</h2>
|
||||
<p style={styles.sectionSubtitle}>Most mentioned entities and the mood that appears most with each.</p>
|
||||
<p style={styles.sectionSubtitle}>
|
||||
Most mentioned entities and the mood that appears most with each.
|
||||
</p>
|
||||
{!entities.length ? (
|
||||
<div style={styles.topUserMeta}>No entity-level cultural data available.</div>
|
||||
<div style={styles.topUserMeta}>
|
||||
No entity-level cultural data available.
|
||||
</div>
|
||||
) : (
|
||||
<div style={{ ...styles.topUsersList, maxHeight: 420, overflowY: "auto" }}>
|
||||
<div
|
||||
style={{
|
||||
...styles.topUsersList,
|
||||
maxHeight: 420,
|
||||
overflowY: "auto",
|
||||
}}
|
||||
>
|
||||
{entities.map(([entity, aggregate]) => (
|
||||
<div key={entity} style={styles.topUserItem}>
|
||||
<div style={styles.topUserName}>{entity}</div>
|
||||
<div style={styles.topUserMeta}>
|
||||
{aggregate.post_count.toLocaleString()} posts • Likely mood: {topEmotion(aggregate.emotion_avg)}
|
||||
{aggregate.post_count.toLocaleString()} posts • Likely mood:{" "}
|
||||
{topEmotion(aggregate.emotion_avg)}
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
|
||||
Reference in New Issue
Block a user