chore: Q3 asset DB cleanup (remove 300 dead rows), Q5 grammar fix for depth-5 questions in emotional_intimacy + stress

This commit is contained in:
null 2026-06-18 22:03:52 -05:00
parent 5ad1456adb
commit 93813255fd
5 changed files with 191 additions and 35 deletions

Binary file not shown.

Binary file not shown.

156
seed/fix_depth5_grammar.py Normal file
View File

@ -0,0 +1,156 @@
#!/usr/bin/env python3
"""
Q5 / Q2 fix grammar errors in depth-5 (and a handful of depth-4) questions.
Three families of template-generated errors:
1. emotional_intimacy "When does [plural/compound noun] affect..."
Subject-verb disagreement: "does" should be "do".
Also: "your deeper fears" (awkward) "your deep fears";
"emotional needs you hide" (missing article) "the emotional needs you hide";
"the parts of you you protect" (double-you) "the parts of yourself you protect".
2. stress_080 stress_150 (every 5th) "after [topic] affects the way we treat each other"
Reads as machine-made and wordy: "the way" is filler. Fixed to
"when [topic] affects how we treat each other".
Edits BOTH the source JSON and the shipped asset DB (data only Room hash untouched).
build_db.py is NOT run. One-off migration kept in repo for traceability.
"""
import json
import os
import sqlite3
HERE = os.path.dirname(os.path.abspath(__file__))
DB_PATH = os.path.join(HERE, "..", "app", "src", "main", "assets", "database", "app.db")
EI_JSON = os.path.join(HERE, "questions", "emotional_intimacy.json")
ST_JSON = os.path.join(HERE, "questions", "stress.json")
# ---------------------------------------------------------------------------
# 1. Exact rewrites keyed by question id
# ---------------------------------------------------------------------------
REWRITES = {
# --- deeper fears block (076 d4 + 077-080 d5) ---
"emotional_intimacy_076": "What do you wish I understood about your deep fears?",
"emotional_intimacy_077": "When do your deep fears affect how close you feel to me?",
"emotional_intimacy_078": "What would help you share more honestly about your deep fears?",
"emotional_intimacy_079": "How can I respond to your deep fears in a way that feels safe instead of fixing you?",
"emotional_intimacy_080": "What is one boundary or reassurance that would help with your deep fears?",
# --- emotional needs you hide block (081 d4 + 082-085 d5) ---
"emotional_intimacy_081": "What do you wish I understood about the emotional needs you hide?",
"emotional_intimacy_082": "When do the emotional needs you hide affect how close you feel to me?",
"emotional_intimacy_083": "What would help you share more honestly about the emotional needs you hide?",
"emotional_intimacy_084": "How can I respond to the emotional needs you hide in a way that feels safe instead of fixing you?",
"emotional_intimacy_085": "What is one boundary or reassurance that would help with the emotional needs you hide?",
# --- moments you feel unseen (087 d5 only — does→do + article) ---
"emotional_intimacy_087": "When do the moments you feel unseen affect how close you feel to me?",
# --- childhood patterns / shame (092, 097 d5 — does→do) ---
"emotional_intimacy_092": "When do childhood patterns affect how close you feel to me?",
"emotional_intimacy_097": "When do shame and tenderness affect how close you feel to me?",
# --- parts of yourself block (146 d4 + 147-150 d5) ---
"emotional_intimacy_146": "What do you wish I understood about the parts of yourself you protect?",
"emotional_intimacy_147": "When do the parts of yourself you protect affect how close you feel to me?",
"emotional_intimacy_148": "What would help you share more honestly about the parts of yourself you protect?",
"emotional_intimacy_149": "How can I respond to the parts of yourself you protect in a way that feels safe instead of fixing you?",
"emotional_intimacy_150": "What is one boundary or reassurance that would help with the parts of yourself you protect?",
}
# Stress block: "after [topic] affects the way we treat each other"
# → "when [topic] affects how we treat each other"
STRESS_SUFFIX_OLD = " affects the way we treat each other?"
STRESS_SUFFIX_NEW = " affects how we treat each other?"
STRESS_PREFIX_OLD = "What repair do we need after "
STRESS_PREFIX_NEW = "What repair do we need when "
STRESS_IDS = [f"stress_{n:03d}" for n in range(80, 155, 5)]
# ---------------------------------------------------------------------------
# helpers
# ---------------------------------------------------------------------------
def fix_stress_text(text: str) -> str | None:
if text.startswith(STRESS_PREFIX_OLD) and text.endswith(STRESS_SUFFIX_OLD):
topic = text[len(STRESS_PREFIX_OLD) : -len(STRESS_SUFFIX_OLD)]
return f"{STRESS_PREFIX_NEW}{topic}{STRESS_SUFFIX_NEW}"
return None
# ---------------------------------------------------------------------------
# JSON pass
# ---------------------------------------------------------------------------
def migrate_json(json_path: str, rewrites: dict, stress_ids: list[str]) -> int:
with open(json_path) as f:
data = json.load(f)
changed = 0
for q in data.get("questions", []):
qid = q["id"]
if qid in rewrites:
q["text"] = rewrites[qid]
changed += 1
if qid in stress_ids:
fixed = fix_stress_text(q["text"])
if fixed:
q["text"] = fixed
changed += 1
if changed:
with open(json_path, "w") as f:
json.dump(data, f, indent=2, ensure_ascii=False)
f.write("\n")
return changed
# ---------------------------------------------------------------------------
# DB pass
# ---------------------------------------------------------------------------
def migrate_db(rewrites: dict, stress_ids: list[str]) -> int:
con = sqlite3.connect(DB_PATH)
cur = con.cursor()
changed = 0
for qid, new_text in rewrites.items():
cur.execute("UPDATE question SET text=? WHERE id=?", (new_text, qid))
if cur.rowcount:
changed += 1
for qid in stress_ids:
row = cur.execute("SELECT text FROM question WHERE id=?", (qid,)).fetchone()
if row:
fixed = fix_stress_text(row[0])
if fixed:
cur.execute("UPDATE question SET text=? WHERE id=?", (fixed, qid))
if cur.rowcount:
changed += 1
con.commit()
con.close()
return changed
if __name__ == "__main__":
n = migrate_json(EI_JSON, REWRITES, [])
print(f"JSON emotional_intimacy: {n} fixed")
n = migrate_json(ST_JSON, {}, STRESS_IDS)
print(f"JSON stress: {n} fixed")
n = migrate_db(REWRITES, STRESS_IDS)
print(f"DB total: {n} fixed")
# Quick sanity check: verify no original bad text remains
con = sqlite3.connect(DB_PATH)
cur = con.cursor()
h = cur.execute("SELECT identity_hash FROM room_master_table").fetchone()[0]
bad = cur.execute(
"SELECT id FROM question WHERE text LIKE '%When does%affect%' OR text LIKE '%needs you hide%' OR text LIKE '%of you you protect%' OR text LIKE '%deeper fears%'"
).fetchall()
con.close()
print(f"Room hash: {h}")
if bad:
print(f"WARNING — still-bad rows: {[r[0] for r in bad]}")
else:
print("Verified: 0 bad rows remaining")

View File

@ -1303,7 +1303,7 @@
"id": "emotional_intimacy_076",
"category_id": "emotional_intimacy",
"type": "written",
"text": "What do you wish I understood about your deeper fears?",
"text": "What do you wish I understood about your deep fears?",
"depth": 4,
"access": "premium",
"tags": [
@ -1320,7 +1320,7 @@
"id": "emotional_intimacy_077",
"category_id": "emotional_intimacy",
"type": "written",
"text": "When does your deeper fears affect how close you feel to me?",
"text": "When do your deep fears affect how close you feel to me?",
"depth": 5,
"access": "premium",
"tags": [
@ -1337,7 +1337,7 @@
"id": "emotional_intimacy_078",
"category_id": "emotional_intimacy",
"type": "written",
"text": "What would help you share more honestly about your deeper fears?",
"text": "What would help you share more honestly about your deep fears?",
"depth": 5,
"access": "premium",
"tags": [
@ -1354,7 +1354,7 @@
"id": "emotional_intimacy_079",
"category_id": "emotional_intimacy",
"type": "written",
"text": "How can I respond to your deeper fears in a way that feels safe instead of fixing you?",
"text": "How can I respond to your deep fears in a way that feels safe instead of fixing you?",
"depth": 5,
"access": "premium",
"tags": [
@ -1371,7 +1371,7 @@
"id": "emotional_intimacy_080",
"category_id": "emotional_intimacy",
"type": "written",
"text": "What is one boundary or reassurance that would help with your deeper fears?",
"text": "What is one boundary or reassurance that would help with your deep fears?",
"depth": 5,
"access": "premium",
"tags": [
@ -1388,7 +1388,7 @@
"id": "emotional_intimacy_081",
"category_id": "emotional_intimacy",
"type": "written",
"text": "What do you wish I understood about emotional needs you hide?",
"text": "What do you wish I understood about the emotional needs you hide?",
"depth": 4,
"access": "premium",
"tags": [
@ -1405,7 +1405,7 @@
"id": "emotional_intimacy_082",
"category_id": "emotional_intimacy",
"type": "written",
"text": "When does emotional needs you hide affect how close you feel to me?",
"text": "When do the emotional needs you hide affect how close you feel to me?",
"depth": 5,
"access": "premium",
"tags": [
@ -1422,7 +1422,7 @@
"id": "emotional_intimacy_083",
"category_id": "emotional_intimacy",
"type": "written",
"text": "What would help you share more honestly about emotional needs you hide?",
"text": "What would help you share more honestly about the emotional needs you hide?",
"depth": 5,
"access": "premium",
"tags": [
@ -1439,7 +1439,7 @@
"id": "emotional_intimacy_084",
"category_id": "emotional_intimacy",
"type": "written",
"text": "How can I respond to emotional needs you hide in a way that feels safe instead of fixing you?",
"text": "How can I respond to the emotional needs you hide in a way that feels safe instead of fixing you?",
"depth": 5,
"access": "premium",
"tags": [
@ -1456,7 +1456,7 @@
"id": "emotional_intimacy_085",
"category_id": "emotional_intimacy",
"type": "written",
"text": "What is one boundary or reassurance that would help with emotional needs you hide?",
"text": "What is one boundary or reassurance that would help with the emotional needs you hide?",
"depth": 5,
"access": "premium",
"tags": [
@ -1490,7 +1490,7 @@
"id": "emotional_intimacy_087",
"category_id": "emotional_intimacy",
"type": "written",
"text": "When does moments you feel unseen affect how close you feel to me?",
"text": "When do the moments you feel unseen affect how close you feel to me?",
"depth": 5,
"access": "premium",
"tags": [
@ -1575,7 +1575,7 @@
"id": "emotional_intimacy_092",
"category_id": "emotional_intimacy",
"type": "written",
"text": "When does childhood patterns affect how close you feel to me?",
"text": "When do childhood patterns affect how close you feel to me?",
"depth": 5,
"access": "premium",
"tags": [
@ -1660,7 +1660,7 @@
"id": "emotional_intimacy_097",
"category_id": "emotional_intimacy",
"type": "written",
"text": "When does shame and tenderness affect how close you feel to me?",
"text": "When do shame and tenderness affect how close you feel to me?",
"depth": 5,
"access": "premium",
"tags": [
@ -2493,7 +2493,7 @@
"id": "emotional_intimacy_146",
"category_id": "emotional_intimacy",
"type": "written",
"text": "What do you wish I understood about the parts of you you protect?",
"text": "What do you wish I understood about the parts of yourself you protect?",
"depth": 4,
"access": "premium",
"tags": [
@ -2510,7 +2510,7 @@
"id": "emotional_intimacy_147",
"category_id": "emotional_intimacy",
"type": "written",
"text": "When does the parts of you you protect affect how close you feel to me?",
"text": "When do the parts of yourself you protect affect how close you feel to me?",
"depth": 5,
"access": "premium",
"tags": [
@ -2527,7 +2527,7 @@
"id": "emotional_intimacy_148",
"category_id": "emotional_intimacy",
"type": "written",
"text": "What would help you share more honestly about the parts of you you protect?",
"text": "What would help you share more honestly about the parts of yourself you protect?",
"depth": 5,
"access": "premium",
"tags": [
@ -2544,7 +2544,7 @@
"id": "emotional_intimacy_149",
"category_id": "emotional_intimacy",
"type": "written",
"text": "How can I respond to the parts of you you protect in a way that feels safe instead of fixing you?",
"text": "How can I respond to the parts of yourself you protect in a way that feels safe instead of fixing you?",
"depth": 5,
"access": "premium",
"tags": [
@ -2561,7 +2561,7 @@
"id": "emotional_intimacy_150",
"category_id": "emotional_intimacy",
"type": "written",
"text": "What is one boundary or reassurance that would help with the parts of you you protect?",
"text": "What is one boundary or reassurance that would help with the parts of yourself you protect?",
"depth": 5,
"access": "premium",
"tags": [
@ -5340,4 +5340,4 @@
]
}
]
}
}

View File

@ -1371,7 +1371,7 @@
"id": "stress_080",
"category_id": "stress",
"type": "written",
"text": "What repair do we need after stress spillover into conflict affects the way we treat each other?",
"text": "What repair do we need when stress spillover into conflict affects how we treat each other?",
"depth": 5,
"access": "premium",
"tags": [
@ -1456,7 +1456,7 @@
"id": "stress_085",
"category_id": "stress",
"type": "written",
"text": "What repair do we need after shutdown under pressure affects the way we treat each other?",
"text": "What repair do we need when shutdown under pressure affects how we treat each other?",
"depth": 5,
"access": "premium",
"tags": [
@ -1541,7 +1541,7 @@
"id": "stress_090",
"category_id": "stress",
"type": "written",
"text": "What repair do we need after irritability during stress affects the way we treat each other?",
"text": "What repair do we need when irritability during stress affects how we treat each other?",
"depth": 5,
"access": "premium",
"tags": [
@ -1626,7 +1626,7 @@
"id": "stress_095",
"category_id": "stress",
"type": "written",
"text": "What repair do we need after unequal workload affects the way we treat each other?",
"text": "What repair do we need when unequal workload affects how we treat each other?",
"depth": 5,
"access": "premium",
"tags": [
@ -1711,7 +1711,7 @@
"id": "stress_100",
"category_id": "stress",
"type": "written",
"text": "What repair do we need after hidden anxiety affects the way we treat each other?",
"text": "What repair do we need when hidden anxiety affects how we treat each other?",
"depth": 5,
"access": "premium",
"tags": [
@ -1796,7 +1796,7 @@
"id": "stress_105",
"category_id": "stress",
"type": "written",
"text": "What repair do we need after pressure around money affects the way we treat each other?",
"text": "What repair do we need when pressure around money affects how we treat each other?",
"depth": 5,
"access": "premium",
"tags": [
@ -1881,7 +1881,7 @@
"id": "stress_110",
"category_id": "stress",
"type": "written",
"text": "What repair do we need after caregiving stress affects the way we treat each other?",
"text": "What repair do we need when caregiving stress affects how we treat each other?",
"depth": 5,
"access": "premium",
"tags": [
@ -1966,7 +1966,7 @@
"id": "stress_115",
"category_id": "stress",
"type": "written",
"text": "What repair do we need after stress and intimacy affects the way we treat each other?",
"text": "What repair do we need when stress and intimacy affects how we treat each other?",
"depth": 5,
"access": "premium",
"tags": [
@ -2051,7 +2051,7 @@
"id": "stress_120",
"category_id": "stress",
"type": "written",
"text": "What repair do we need after chronic exhaustion affects the way we treat each other?",
"text": "What repair do we need when chronic exhaustion affects how we treat each other?",
"depth": 5,
"access": "premium",
"tags": [
@ -2136,7 +2136,7 @@
"id": "stress_125",
"category_id": "stress",
"type": "written",
"text": "What repair do we need after coping habits affects the way we treat each other?",
"text": "What repair do we need when coping habits affects how we treat each other?",
"depth": 5,
"access": "premium",
"tags": [
@ -2221,7 +2221,7 @@
"id": "stress_130",
"category_id": "stress",
"type": "written",
"text": "What repair do we need after avoiding difficult topics affects the way we treat each other?",
"text": "What repair do we need when avoiding difficult topics affects how we treat each other?",
"depth": 5,
"access": "premium",
"tags": [
@ -2306,7 +2306,7 @@
"id": "stress_135",
"category_id": "stress",
"type": "written",
"text": "What repair do we need after feeling alone in stress affects the way we treat each other?",
"text": "What repair do we need when feeling alone in stress affects how we treat each other?",
"depth": 5,
"access": "premium",
"tags": [
@ -2391,7 +2391,7 @@
"id": "stress_140",
"category_id": "stress",
"type": "written",
"text": "What repair do we need after support that misses the mark affects the way we treat each other?",
"text": "What repair do we need when support that misses the mark affects how we treat each other?",
"depth": 5,
"access": "premium",
"tags": [
@ -2476,7 +2476,7 @@
"id": "stress_145",
"category_id": "stress",
"type": "written",
"text": "What repair do we need after stress recovery routines affects the way we treat each other?",
"text": "What repair do we need when stress recovery routines affects how we treat each other?",
"depth": 5,
"access": "premium",
"tags": [
@ -2561,7 +2561,7 @@
"id": "stress_150",
"category_id": "stress",
"type": "written",
"text": "What repair do we need after protecting the relationship during hard seasons affects the way we treat each other?",
"text": "What repair do we need when protecting the relationship during hard seasons affects how we treat each other?",
"depth": 5,
"access": "premium",
"tags": [
@ -5260,4 +5260,4 @@
]
}
]
}
}