"""Ingest detailed phonics pattern knowledge into the brain.

Extracts pattern rules, IPA sounds, examples, and pitfalls from the
ELA audit system (word_db.py, validators) and creates rich entities.
"""

import sys
import os
sys.path.insert(0, os.path.expanduser('~/.hermes/brain'))
from brain import create_entity, add_edge


def e(content, eid, etype, category, strength="moderate", pinned=False, metadata=None):
    """Create entity safely."""
    create_entity(content, eid, etype, category, strength, pinned, metadata)
    print(f"  + {eid}")


# -----------------------------------------------------------------------
# 1. Short Vowels
# -----------------------------------------------------------------------
e(
    "# Short Vowels\n\n"
    "## Core Rule\n"
    "Short vowels appear in closed syllables (CVC, CVCC). The vowel is followed "
    "by at least one consonant within the same syllable, keeping the vowel sound short.\n\n"
    "## IPA Sounds\n"
    "- **short_a**: /Γ¦/ β€” as in *cat, basket, garden*\n"
    "- **short_e**: /Ι›/ β€” as in *bed, helmet, elephant*\n"
    "- **short_i**: /Ιͺ/ β€” as in *sit, kitten, insect*\n"
    "- **short_o**: /Ι”/ β€” as in *hot, octopus, doctor*\n"
    "- **short_u**: /ʌ/ β€” as in *cup, umbrella, bubble*\n\n"
    "## Structural Pattern\n"
    "- CVC (cat, bed, sit, hot, cup)\n"
    "- CVCC (duck, lock, stop)\n"
    "- Multi-syllable: stressed syllable contains the short vowel (AN-i-mal, EL-e-phant)\n\n"
    "## Key Words (6+ letters for curriculum)\n"
    "- short_a: basket, garden, animal, blanket\n"
    "- short_e: helmet, elephant\n"
    "- short_i: insect, kitten\n"
    "- short_o: octopus, doctor\n"
    "- short_u: umbrella, bubble\n\n"
    "## Validation Rule\n"
    "Word must contain the target vowel. If it has CVCe structure (consonant + e ending), "
    "it is NOT short β€” the silent e makes the vowel long.\n\n"
    "## Common Pitfall\n"
    "Multi-syllable words taught as short vowel in Week 1 but actually have r-controlled "
    "in a later syllable (e.g., *winter* = short_i + r_control_er, *doctor* = short_o + r_control_or). "
    "These are registered as multi-pattern words.\n\n"
    "## Teaching Tip\n"
    "Tap out syllables and emphasize the stressed one. Short vowels = quick sounds.\n\n"
    "## Week Placement\n"
    "Week 1 β€” Foundation week. Short vowels are the starting point for all other patterns.",
    "phonics_short_vowels",
    "phonics/pattern",
    "phonics",
    "strong",
    pinned=True
)

# -----------------------------------------------------------------------
# 2. Silent E (CVCe)
# -----------------------------------------------------------------------
e(
    "# Silent E (Magic E / CVCe)\n\n"
    "## Core Rule\n"
    "The final silent 'e' makes the preceding vowel say its name (long sound). "
    "The 'e' itself is not pronounced β€” it 'reaches back' to change the vowel.\n\n"
    "## IPA Sounds\n"
    "- **long_a_cvc_e**: a_e β†’ /eΙͺ/ β€” *cake, tape, debate*\n"
    "- **long_e_cvc_e**: e_e β†’ /iː/ β€” *relieve*\n"
    "- **long_i_cvc_e**: i_e β†’ /aΙͺ/ β€” *bike, invite, divide*\n"
    "- **long_o_cvc_e**: o_e β†’ /oʊ/ β€” *home, remote, devote*\n"
    "- **long_u_cvc_e**: u_e β†’ /juː/ β€” *cube, rescue*\n\n"
    "## Structural Pattern\n"
    "- CVCe: consonant + vowel + consonant + e (cake, bike, home, cube)\n"
    "- Minimum 4 letters\n"
    "- Single vowel before the final consonant(s)\n\n"
    "## Multi-Syllable Exceptions (taught as CVCe)\n"
    "- *rescue*: re-scue (ue β†’ /juː/)\n"
    "- *invite*: in-vite (i_e pattern)\n"
    "- *relieve*: re-lieve (ie team)\n"
    "- *divide*: di-vide (i_e pattern)\n"
    "- *strange*: str-a-ng-e (ng digraph)\n\n"
    "## CRITICAL Pitfall β€” Exception Placement\n"
    "In the validator, exceptions MUST be checked at the TOP of validate_silent_e(), "
    "before structural validation. If placed after the '2 vowels' or 'vowel before e' checks, "
    "the function returns False before reaching the exceptions dict.\n\n"
    "## Common Generator Bugs\n"
    "- Comparatives like *faster* claimed as a_e (CVCe) β€” actually *fast + er* (suffix)\n"
    "- Words with ng digraph (*strange, change*) have 2 consonants after vowel\n\n"
    "## Teaching Tip\n"
    "Compare pairs: *cap* β†’ *cape*, *bit* β†’ *bite*, *hop* β†’ *hope*, *cut* β†’ *cube*. "
    "Show how the silent e 'reaches over' the consonant.\n\n"
    "## Week Placement\n"
    "Week 2 β€” Builds directly on short vowels from Week 1.",
    "phonics_silent_e",
    "phonics/pattern",
    "phonics",
    "strong",
    pinned=True
)

# -----------------------------------------------------------------------
# 3. Vowel Teams
# -----------------------------------------------------------------------
e(
    "# Vowel Teams\n\n"
    "## Core Rule\n"
    "Two vowels together β€” the first one does the work (says its name). "
    "The second vowel is silent or modifies the sound.\n\n"
    "## AI / AY β€” Long A (/eΙͺ/)\n"
    "- **ai**: appears in middle of words (rain, paint, railroad, mailbox)\n"
    "- **ay**: appears at end of words (day, play, mainland)\n"
    "- Positional rule: ai = middle, ay = end\n\n"
    "## EE / EA β€” Long E (/iː/)\n"
    "- **ee**: bee, feet, street, cheese, cheerful\n"
    "- **ea**: leaf (but NOT sweater/teacher β€” those are short e ea = /Ι›/)\n"
    "- EA is inconsistent: can be /iː/ (leaf), /Ι›/ (sweater, teacher), or /eΙͺ/ (steak, break)\n\n"
    "## OA β€” Long O (/oʊ/)\n"
    "- oa: boat, sailboat, boatyard, oatmeal\n\n"
    "## OW β€” Two Sounds (/oʊ/ and /aʊ/)\n"
    "- **long_o_ow** (/oʊ/): snow, bowl, yellow, snowball\n"
    "- **short_o_ow** (/aʊ/): cow, town, clown, rainbow (second syllable)\n"
    "- OW is context-dependent β€” must memorize\n\n"
    "## OU β€” Long O (/aʊ/)\n"
    "- ou: house, mouse, fountain, mountain, outdoor\n\n"
    "## EW β€” Two Sounds (/juː/ and /oʊ/)\n"
    "- **long_u_ew** (/juː/): chew, sew (sometimes), newspaper\n"
    "- **short_e_ew** (/oʊ/): sew, new\n\n"
    "## Validator Keys (all must be registered)\n"
    "long_a_ai, long_a_ay, long_e_ea, long_e_ee, long_e_ew,\n"
    "long_i_ee, long_i_igh, long_o_oe, long_o_oa, long_o_ou, long_o_ow,\n"
    "long_u_ew, long_u_oo, short_e_ew, short_o_ow, vowel_team\n\n"
    "## Common Generator Bugs\n"
    "Week 3 swap: sweater/teacher claimed ee instead of ea; cheese/cheerful claimed ea instead of ee. "
    "Always verify the actual letters in the word match the claimed team.\n\n"
    "## Multi-Pattern Words\n"
    "- *rainbow*: long_a_ai (W3 rain) / long_o_ow (W4 bow)\n"
    "- *teacher*: long_e_ea (W3 ea) / digraph_ch (W5 ch)\n\n"
    "## Week Placement\n"
    "Week 3 (ai/ay/ee/ea), Week 4 (oa/ow/ou/ew)",
    "phonics_vowel_teams",
    "phonics/pattern",
    "phonics",
    "strong",
    pinned=True
)

# -----------------------------------------------------------------------
# 4. Digraphs
# -----------------------------------------------------------------------
e(
    "# Digraphs\n\n"
    "## Core Rule\n"
    "Two letters that make ONE sound. The individual letter sounds don't appear β€” "
    "the combination creates a new sound.\n\n"
    "## SH β€” /Κƒ/ (Voiceless postalveolar fricative)\n"
    "- ship, fish, wish, shelter\n"
    "- Position: beginning or end of words\n\n"
    "## CH — /tʃ/ (Voiceless postalveolar affricate)\n"
    "- chin, chat, stretch, teacher, cheese\n"
    "- Position: beginning, middle, or end\n\n"
    "## TH β€” Two Sounds (/ΞΈ/ and /Γ°/)\n"
    "- **voiceless /ΞΈ/**: bath, th, smooth, thunder, mother (actually Γ° here)\n"
    "- **voiced /Γ°/**: this, mother, father, together\n"
    "- Rule of thumb: between vowels = voiced /Γ°/, word-initial/after consonant = voiceless /ΞΈ/\n\n"
    "## WH β€” /w/ (Initial consonant)\n"
    "- when, whether, wheel\n"
    "- Can be hushed /hw/ in some dialects\n\n"
    "## PH β€” /f/ (Greek origin)\n"
    "- phone, dolphin, physics\n"
    "- Almost always from Greek-derived words\n\n"
    "## CK β€” /k/ (After short vowels)\n"
    "- neck, duck, truck, pocket, rocket\n"
    "- Rule: ck appears after a short vowel at the end of a syllable\n\n"
    "## Multi-Pattern Words\n"
    "- *teacher*: digraph_ch (W5) / long_e_ea (W3)\n"
    "- *whether*: digraph_wh (W5) / homophone (W12)\n"
    "- *smooth*: digraph_th (NOT sh β€” common mistake)\n\n"
    "## Common Generator Bug\n"
    "Week 5: *smooth* claimed as sh digraph β€” actually th digraph (/ΞΈ/). "
    "The 'sm' at the start can mislead. Check the actual digraph letters.\n\n"
    "## Week Placement\n"
    "Week 5 β€” Consonant digraphs after vowel teams.",
    "phonics_digraphs",
    "phonics/pattern",
    "phonics",
    "strong",
    pinned=True
)

# -----------------------------------------------------------------------
# 5. Soft C and Soft G
# -----------------------------------------------------------------------
e(
    "# Soft C and Soft G\n\n"
    "## Core Rule\n"
    "C and G have two sounds each. Before e, i, or y they become soft.\n\n"
    "## Soft C β€” /s/ (before e, i, y)\n"
    "- **ci**: city, magic, circle, notice, decide\n"
    "- **ce**: face, dance, ceiling\n"
    "- **cy**: bicycle\n\n"
    "## Soft G β€” /dΚ’/ (before e, i, y)\n"
    "- **gi**: tiger, giant, finger (tricky β€” actually hard /Ε‹Ι‘/)\n"
    "- **ge**: gem, gentle, college, danger, change, garage (tricky β€” first g is hard)\n"
    "- **gy**: gym, energy\n\n"
    "## Tricky Words\n"
    "- *garage*: first g is hard /Ι‘/, second ge is soft /dΚ’/\n"
    "- *finger*: gi is actually hard /Ε‹Ι‘/ despite the i β€” NOT soft g\n"
    "- These are noted in the word_db with phonetic annotations\n\n"
    "## Validation Rule\n"
    "The letter (c or g) must appear before a triggering vowel (e, i, or y). "
    "G before a can be soft or hard β€” flagged for review.\n\n"
    "## Common Pitfall\n"
    "Not all c/g before e/i/y are soft. *get, give, girl, gold* are hard G before e/i/o. "
    "The rule has many exceptions at the 2nd grade level.\n\n"
    "## Week Placement\n"
    "Week 6 β€” After digraphs, builds on understanding that letter combinations matter.",
    "phonics_soft_cg",
    "phonics/pattern",
    "phonics",
    "strong"
)

# -----------------------------------------------------------------------
# 6. R-Controlled Vowels
# -----------------------------------------------------------------------
e(
    "# R-Controlled Vowels (Bossy R)\n\n"
    "## Core Rule\n"
    "When a vowel is followed by r, the r 'bosses' the vowel into a new blended sound. "
    "The vowel no longer says its normal short or long sound.\n\n"
    "## AR β€” /Ι‘r/\n"
    "- star, car, farm, market, farmer\n"
    "- Clear /Ι‘/ + r sound\n\n"
    "## ER β€” /ɝː/\n"
    "- her, silver, better, winter (second syllable)\n"
    "- ER and IR and UR share the SAME sound in American English\n\n"
    "## IR β€” /ɝː/\n"
    "- bird, mirror\n\n"
    "## OR β€” /Ι”r/ or /ɝː/\n"
    "- fork, work, corner, doctor (second syllable β€” reduced)\n"
    "- OR varies: fork has distinct /Ι”r/, work has reduced /ɝː/\n\n"
    "## UR β€” /ɝː/\n"
    "- nurse, purse, work, purr, turtle, purple\n\n"
    "## Key Insight\n"
    "ER, IR, and UR are HOMOPHONES in American English β€” they all produce /ɝː/. "
    "This is a spelling distinction, not a sound distinction.\n\n"
    "## Multi-Pattern Words\n"
    "- *winter*: short_i (W1 first syllable) + r_control_er (W7 second syllable)\n"
    "- *doctor*: short_o (W1 first syllable) + r_control_or (W7 second syllable)\n"
    "- *feather*: short_e + th digraph + er\n"
    "- *whether*: digraph_wh (W5) + homophone (W12) + r_control_er\n\n"
    "## Week Placement\n"
    "Week 7 β€” After soft c/g, completing the vowel modification patterns.",
    "phonics_r_controlled",
    "phonics/pattern",
    "phonics",
    "strong",
    pinned=True
)

# -----------------------------------------------------------------------
# 7. Double Consonants
# -----------------------------------------------------------------------
e(
    "# Double Consonants\n\n"
    "## Core Rule\n"
    "When a consonant is doubled within a word, it keeps the preceding vowel short. "
    "The double consonant acts like a wall that traps the short vowel sound.\n\n"
    "## Effect by Double\n"
    "- **tt**: kitten, bitter, little, sitter, cotton β†’ keeps preceding vowel short\n"
    "- **pp**: hopper β†’ short o\n"
    "- **dd**: muddy, ladder, puddle β†’ keeps preceding vowel short\n"
    "- **gg**: bigger, hugger β†’ keeps preceding vowel short\n"
    "- **zz**: fizzle β†’ short i\n"
    "- **mm**: summer β†’ short u\n"
    "- **nn**: tunnel β†’ short u\n\n"
    "## Structural Pattern\n"
    "CVC(ee)V β€” vowel + double consonant + vowel\n"
    "The double consonant is always between two vowel sounds.\n\n"
    "## Multi-Pattern Words\n"
    "- *kitten*: short_i (W1) / double_consonant (W13)\n"
    "- *summer*: double_consonant (W8) / multiple_meaning (W16)\n\n"
    "## Common Pitfall\n"
    "Words with double consonants at the end of a word (e.g., *bigger, hugger*) "
    "also have suffix -er attached. The doubling is part of the base word rule, "
    "not the suffix. Teach separately.\n\n"
    "## Week Placement\n"
    "Week 8 β€” After r-controlled, completes single-pattern vowel modification.",
    "phonics_double_consonants",
    "phonics/pattern",
    "phonics",
    "strong"
)

# -----------------------------------------------------------------------
# 8. Prefixes
# -----------------------------------------------------------------------
e(
    "# Prefixes\n\n"
    "## Core Rule\n"
    "A prefix is added to the BEGINNING of a base word and changes its meaning. "
    "The base word keeps its original spelling and pronunciation.\n\n"
    "## UN- β€” 'not' or 'reverse'\n"
    "- undo, unlock, untie, unsnap, unfold, unzip\n"
    "- unhappy, unpack, unknown, unsafe\n"
    "- Sound: /ʌn/\n\n"
    "## RE- β€” 'again' or 'back'\n"
    "- remake, redo, return, restart, rename, reload, reopen, remove\n"
    "- Sound: /riː/ or /rΙ™/ (schwa in some words)\n\n"
    "## DIS- β€” 'not' or 'opposite'\n"
    "- disagree, disappear, disconnect, dislike, dismay, dishonest, discover\n"
    "- Sound: /dΙͺs/\n\n"
    "## Other Prefixes (advanced)\n"
    "- **im-**: impossible (before b, m, p)\n"
    "- **in-**: invisible (before most other letters)\n"
    "- **mis-**: mislead (wrong)\n\n"
    "## Teaching Tip\n"
    "Always identify the base word first, then add the prefix. "
    "un + happy = unhappy. The meaning shifts predictably.\n\n"
    "## Common Generator Bug\n"
    "Comparatives ending in -er are NOT prefixes. *faster* = *fast + er* (suffix), "
    "not a prefix. Distinguish by position: prefixes go at the START.\n\n"
    "## Pattern Normalization\n"
    "Generator labels like 'prefix re + turn' normalize to 'prefix_re' in the audit system.\n\n"
    "## Week Placement\n"
    "Week 9 β€” First morphological pattern. Shifts from phonics to meaning.",
    "phonics_prefixes",
    "phonics/pattern",
    "phonics",
    "strong",
    pinned=True
)

# -----------------------------------------------------------------------
# 9. Suffixes
# -----------------------------------------------------------------------
e(
    "# Suffixes\n\n"
    "## Core Rule\n"
    "A suffix is added to the END of a base word and changes its form or meaning. "
    "Base word spelling may change (drop e, double consonant) when adding suffixes.\n\n"
    "## -S / -ES β€” Plural and 3rd person singular\n"
    "- **s** (/s/): jumps, kicks (after voiceless sounds)\n"
    "- **es** (/Ι™z/ or /Ιͺz/): boxes, wishes, brushes, watches, dances\n"
    "- Add -es after: s, z, x, ch, sh endings\n\n"
    "## -ED β€” Past tense (3 pronunciations)\n"
    "- **/t/**: walked, jumped, cooked, helped, painted (after voiceless sounds)\n"
    "- **/d/**: played, called, rained (after voiced sounds)\n"
    "- **/Ιͺd/**: wanted, needed (after t or d β€” adds a syllable)\n\n"
    "## -ING β€” Present participle\n"
    "- jumping, running, walking, playing, singing, swimming, teaching\n"
    "- Sound: /ΙͺΕ‹/\n"
    "- Drop e before -ing: make β†’ making, but some keep it (see β†’ seeing)\n\n"
    "## -ER β€” Comparative / agent noun\n"
    "- taller, faster, smaller, bigger, braver, happier\n"
    "- helper, player (agent: one who helps/plays)\n"
    "- Sound: /Ι™r/\n\n"
    "## -EST β€” Superlative\n"
    "- bravest, strongest, tallest, fastest, smallest, biggest, happiest\n"
    "- Sound: /Ιͺst/\n\n"
    "## -LY β€” Adverb\n"
    "- quickly, slowly, happily, carefully, softly\n"
    "- Sound: /li/\n\n"
    "## -FUL β€” Full of\n"
    "- careful, helpful, playful, hopeful, useful, beautiful, grateful\n"
    "- Sound: /fΙ™l/\n"
    "- Drop e before -ful: hope β†’ hopeful\n\n"
    "## -LESS β€” Without\n"
    "- careless, helpless, fearless, harmless, endless, homeless\n"
    "- Sound: /lΙͺs/\n\n"
    "## -OUS β€” Having the quality of\n"
    "- enormous, famous, nervous\n"
    "- Sound: /Ι™s/\n\n"
    "## -IOUS\n"
    "- delicious, mysterious, furious, cautious\n"
    "- Sound: /ΙͺΙ™s/ or /ΚƒΙ™s/ (varies)\n\n"
    "## -ABLE / -IBLE β€” Capable of\n"
    "- valuable, terrible, fragile\n"
    "- Sound: /Ι™bΙ™l/ or /ΙͺbΙ™l/\n\n"
    "## -NESS β€” State or quality\n"
    "- darkness (dark + ness)\n"
    "- Sound: /nΙ™s/\n\n"
    "## -MENT β€” Action or result\n"
    "- (documented in pattern codes, examples in word_db)\n\n"
    "## -Y β€” Small or full of\n"
    "- tiny (tin + y)\n\n"
    "## Spelling Changes with Suffixes\n"
    "1. **Drop silent e**: hope β†’ hopeful, make β†’ making\n"
    "2. **Double final consonant**: run β†’ running, big β†’ bigger (CVC pattern)\n"
    "3. **Change y to i**: happy β†’ happier, happy β†’ happily (after consonant+y)\n\n"
    "## Week Placement\n"
    "Week 10 (-er, -est, -ly, -ful, -less), Week 11 (-es, -ed, -ing, -s)",
    "phonics_suffixes",
    "phonics/pattern",
    "phonics",
    "strong",
    pinned=True
)

# -----------------------------------------------------------------------
# 10. Homophones
# -----------------------------------------------------------------------
e(
    "# Homophones\n\n"
    "## Core Rule\n"
    "Homophones are words that sound the same but have different spellings and meanings. "
    "They cannot be validated structurally β€” they require context understanding.\n\n"
    "## Homophone Pairs in Word DB\n"
    "- **there / they're / their** β€” place / contraction / possessive\n"
    "- **here / hear** β€” place / sense of hearing\n"
    "- **to / too / two** β€” preposition / also / number\n"
    "- **blue / blew** β€” color / past of blow\n"
    "- **write / right / rite** β€” compose / correct / ritual\n"
    "- **sea / see** β€” ocean / vision\n"
    "- **flour / flower** β€” baking ingredient / plant\n"
    "- **mail / male** β€” postal service / gender\n"
    "- **weather / whether** β€” climate / choice\n"
    "- **night / knight** β€” dark time / medieval warrior\n"
    "- **sun / son** β€” star / child\n"
    "- **bear / bare** β€” animal / naked\n"
    "- **hair / hare** β€” head covering / rabbit\n\n"
    "## Structural Detection\n"
    "Week 12 uses (word, definition, example) format β€” no pattern field. "
    "Scanner detects homophone weeks by:\n"
    "1. Topic label containing 'homophone' (case-insensitive)\n"
    "2. Second field is multi-word string (>3 words, no / separator)\n"
    "3. Second field doesn't match any pattern indicator\n\n"
    "## Multi-Pattern Homophone Words\n"
    "- *whether*: digraph_wh (W5) + homophone with weather (W12)\n"
    "- *flower*: long_o_ow (W4) + homophone with flour (W12)\n\n"
    "## Week Placement\n"
    "Week 12 β€” Requires solid phonics foundation to appreciate why same-sound words differ.",
    "phonics_homophones",
    "phonics/pattern",
    "phonics",
    "strong"
)

# -----------------------------------------------------------------------
# 11. Irregular Words
# -----------------------------------------------------------------------
e(
    "# Irregular Words\n\n"
    "## Core Rule\n"
    "Irregular words DO NOT follow standard phonetic patterns. They must be memorized "
    "as sight words or explained with etymology.\n\n"
    "## Documented Irregulars\n"
    "- **said**: ai β†’ /Ι›/ (defies 'ai = long a' rule)\n"
    "- **friend**: ie β†’ /Ι›/ (defies 'ie' vowel team expectations)\n"
    "- **people**: pe β†’ /iː/ or /pΚƒ/ (irregular plural formation)\n"
    "- **enough**: ough β†’ /ʌf/ (defies 'ough' rule)\n"
    "- **through**: ough β†’ /uː/ (different ough pronunciation)\n"
    "- **because**: eau β†’ /ΙͺkΙ™z/ (defies all vowel rules)\n"
    "- **children**: chβ†’/tΚƒ/ + ilβ†’/Ιͺ/ (irregular plural)\n"
    "- **afraid**: ai β†’ /Ι™/ or /eΙͺ/ (silent f, irregular ai)\n"
    "- **honest**: o β†’ /Ι’/ or /Ι‘/ (silent h)\n"
    "- **ancient**: a β†’ /eΙͺ/ (irregular long a, not CVCe)\n"
    "- **rough**: ough β†’ /ʌf/ (irregular ough)\n\n"
    "## OUGH β€” The Worst Offender\n"
    "- *through* β†’ /uː/\n"
    "- *enough* β†’ /ʌf/\n"
    "- *rough* β†’ /ʌf/\n"
    "- *cough* β†’ /Ι’f/ (not in DB but known)\n"
    "- *though* β†’ /oʊ/ (not in DB but known)\n"
    "- OUGH has 7+ pronunciations in English\n\n"
    "## I Before E Rule\n"
    "- **Standard**: believe (ie β†’ /iː/)\n"
    "- **Exception after c**: receive (ei β†’ /iː/)\n\n"
    "## Validation\n"
    "Irregular words cannot be structurally validated. The validator always returns "
    "True with a [REVIEW] flag β€” they must be checked against the word database.\n\n"
    "## Week Placement\n"
    "Scattered throughout β€” introduced when students encounter them.",
    "phonics_irregular",
    "phonics/pattern",
    "phonics",
    "moderate"
)

# -----------------------------------------------------------------------
# 12. Multiple Meaning Words
# -----------------------------------------------------------------------
e(
    "# Multiple Meaning Words\n\n"
    "## Core Rule\n"
    "Words that have two or more distinct, unrelated meanings. The spelling and "
    "pronunciation are identical, but context determines the meaning.\n\n"
    "## Documented Examples\n"
    "- **present**: a gift / to show or demonstrate\n"
    "- **falcon**: a bird of prey / a fast aircraft (F-16)\n"
    "- **spring**: a season / a coiled piece of metal\n"
    "- **cricket**: a small insect / a sport\n"
    "- **record**: a written account / a music disc\n"
    "- **summer**: season / summer Olympics\n"
    "- **rocket**: spacecraft / rocket science\n"
    "- **basket**: container / basketball\n"
    "- **mirror**: reflection / mirror image\n"
    "- **garden**: plants / garden party\n"
    "- **fountain**: water feature / soda fountain\n"
    "- **mountain**: landform / mountain of work (metaphor)\n\n"
    "## Teaching Tip\n"
    "Have students write sentences using each meaning. Draw pictures showing both meanings.\n\n"
    "## Multi-Pattern Registration\n"
    "Multiple meaning words from earlier weeks are registered in _MULTI_PATTERN_WORDS "
    "with both their phonics pattern AND multiple_meaning.\n\n"
    "## Week Placement\n"
    "Week 16 β€” Requires vocabulary depth to appreciate multiple meanings.",
    "phonics_multiple_meaning",
    "phonics/pattern",
    "phonics",
    "moderate"
)

# -----------------------------------------------------------------------
# 13. Phonics Pattern Progression Map
# -----------------------------------------------------------------------
e(
    "# Phonics Pattern Progression\n\n"
    "## 32-Week Curriculum Arc\n\n"
    "### Phase 1: Foundation (Weeks 1-6)\n"
    "Basic phonetic patterns β€” students learn to decode.\n"
    "1. **W1**: Short vowels + multi-syllable words\n"
    "2. **W2**: Silent E (CVCe)\n"
    "3. **W3**: Vowel teams (ai, ay, ee, ea)\n"
    "4. **W4**: Vowel teams (oa, ow, ou, ew)\n"
    "5. **W5**: Consonant digraphs (sh, ch, th, wh, ph, ck)\n"
    "6. **W6**: Soft C and Soft G\n\n"
    "### Phase 2: Advanced Patterns (Weeks 7-12)\n"
    "Building complexity β€” modifications and exceptions.\n"
    "7. **W7**: R-controlled vowels (ar, er, ir, or, ur)\n"
    "8. **W8**: Double consonants\n"
    "9. **W9**: Prefixes (un-, re-, dis-)\n"
    "10. **W10**: Suffixes (-er, -est, -ly, -ful, -less)\n"
    "11. **W11**: Suffixes (-es, -ed, -ing, -s)\n"
    "12. **W12**: Homophones\n\n"
    "### Phase 3: Vocabulary & Morphology (Weeks 13-18)\n"
    "Word relationships and meaning.\n"
    "13-18: Synonyms, antonyms, multiple meaning, context clues, word families, roots\n\n"
    "### Phase 4: Grammar Focus (Weeks 19-24)\n"
    "Writing conventions, punctuation, parts of speech\n\n"
    "### Phase 5: Mastery (Weeks 25-32)\n"
    "Mixed review, speed drills, comprehensive application\n\n"
    "## Progression Logic\n"
    "Each week builds on previous patterns. A word from W1 can reappear in W7 "
    "with a different teaching focus (e.g., *winter* = short_i in W1, r_control_er in W7). "
    "This spiral approach reinforces earlier patterns while teaching new ones.\n\n"
    "## Skill Dependency Graph\n"
    "short_vowels β†’ silent_e β†’ vowel_teams β†’ digraphs β†’ soft_cg β†’ r_controlled\n"
    "r_controlled β†’ double_consonants β†’ prefixes β†’ suffixes\n"
    "prefixes + suffixes β†’ homophones β†’ multiple_meaning\n"
    "irregular (parallel, introduced as encountered)",
    "phonics_progression",
    "phonics/curriculum",
    "phonics",
    "strong",
    pinned=True
)

# -----------------------------------------------------------------------
# Create edges
# -----------------------------------------------------------------------
print("\nCreating edges...")

# All patterns part of phonics umbrella
patterns = [
    "phonics_short_vowels", "phonics_silent_e", "phonics_vowel_teams",
    "phonics_digraphs", "phonics_soft_cg", "phonics_r_controlled",
    "phonics_double_consonants", "phonics_prefixes", "phonics_suffixes",
    "phonics_homophones", "phonics_irregular", "phonics_multiple_meaning"
]

for p in patterns:
    add_edge(p, "part_of", "phonics_progression", 0.9)
    print(f"  {p} -> phonics_progression")

# Link to existing curriculum entities
curriculum_targets = ["curriculum_ela", "curriculum_pedagogy_2nd_grade", "domain_curriculum"]
for t in curriculum_targets:
    add_edge("phonics_progression", "part_of", t, 0.7)
    print(f"  phonics_progression -> {t}")

# Co-occurrence between related patterns
add_edge("phonics_short_vowels", "co_occurs", "phonics_silent_e", 0.95)
add_edge("phonics_vowel_teams", "co_occurs", "phonics_digraphs", 0.7)
add_edge("phonics_prefixes", "co_occurs", "phonics_suffixes", 0.9)
add_edge("phonics_silent_e", "co_occurs", "phonics_vowel_teams", 0.8)
add_edge("phonics_r_controlled", "co_occurs", "phonics_double_consonants", 0.7)
add_edge("phonics_homophones", "co_occurs", "phonics_irregular", 0.8)
add_edge("phonics_suffixes", "co_occurs", "phonics_double_consonants", 0.7)
print("  Co-occurrence edges created")

# Link to audit system
add_edge("phonics_progression", "co_occurs", "curriculum_audit_quality", 0.8)
print("  phonics_progression -> curriculum_audit_quality")

print("\nDone β€” 13 phonics entities + edges created.")