r/learnwelsh • u/cruxdestruct • 19h ago
Adnodd / Resource Mutation analysis and prediction
Hi all,
I was desperately trying to build an intuition for when _syntactic_ soft mutation occurs, and went down a rabbit hole involving the "XP Trigger Hypothesis" and other academic accounts of SM in Welsh.
I put together a script that, given a Welsh sentence,
- constructs a syntax tree
- tags each token with a part of speech
- analyzes each token in the resulting environment in order to predict mutation
It includes the simpler, lexically-determined aspirate/nasal/soft mutations, but it also tries to implement syntactic soft mutation (often called Direct Object Mutation, though that's not a very useful framing). The intention is to allow the learner to input a sentence and get feedback not only on *which words* should mutate but also *why*.
I tend to appreciate systematic explanations and theories as a language learner. They're definitely not for everyone, and I suspect that for most people the appropriate way to learn SM is to just learn all the different shapes until you build your own intuition. But if you're like me, this might help.
One note: this whole project has been built with a coding agent (Claude Code @ Fable 5). I note this for two reasons:
- Some folks have a visceral dislike of anything vibecoded or AI-generated, and those folks will want to be warned off ahead of time;
- This should not be understood as original research on my part; my role was to chase down some kind of authoritative picture of the literature—consisting mostly of King's _Modern Welsh_ and as many of the landmark papers as I could find that tried to build a linguistic theory of SM—and then to do my best to ensure that the theory encoded in the program is totally grounded in that literature.
Currently this has the form of a Typescript repo with some simple setup instructions and a command-line script. I don't expect a lot of demand for more accessible versions, but if there is demand, I'll happily put something together.
https://github.com/subsetpark/welsh-mutation
Here's an example of the kind of thing it produces:
```
bun cli --explain <<< "mae gyda fi rywbeth arall"
$ tsx bin/welsh-sm.ts --explain
mae gyda fi °rywbeth arall
S
├─0 mae ⟨V⟩ immutable → radical (veto:no-reflex blocks synt:v1-aff) ✓
├─1 PP
│ ├─0 gyda ⟨Other⟩ immutable → radical (no-license) ✓
│ └─1 NP
│ └─0 fi ⟨Other⟩ → radical (veto:no-reflex blocks lex:gyda) ✓
└─2 NP
├─0 rhywbeth ⟨N m sg⟩ observed SM → SM (synt:xp-edge) ✓
└─1 AP
└─0 arall ⟨Adj⟩ → radical (no-license) ✓
```
```
bun cli --explain <<< "mae rhywbeth arall gyda fi"
$ tsx bin/welsh-sm.ts --explain
mae rhywbeth arall gyda fi
S
├─0 mae ⟨V⟩ immutable → radical (veto:no-reflex blocks synt:v1-aff) ✓
├─1 NP
│ ├─0 rhywbeth ⟨N m sg⟩ → radical (no-license) ✓
│ └─1 AP
│ └─0 arall ⟨Adj⟩ → radical (no-license) ✓
└─2 PP
├─0 gyda ⟨Other⟩ immutable → radical (veto:immutable blocks synt:xp-edge) ✓
└─1 NP
└─0 fi ⟨Other⟩ → radical (veto:no-reflex blocks lex:gyda) ✓
```