## This shell script checks a list of words for potential
## spelling problems.  It is provided for your hacking pleasure.
##
## It is designed to work with a raw list of words, one per line.
## % igcheck <wordlist>
##
## Uncomment the last couple of lines if you have time to browse
## through the (usually legal) violations of 
## "broad with broad", "slender with slender"

### ODD LETTERS
echo 'Checking for non-alphabetic characters...'
cat $1 | egrep "[^a-zA-Z'\-]"

### LENITION and VOWELS
echo 'Checking lenition...'
cat $1 | egrep '[aeiouhjlnrvxz]h' | egrep -v '[aeiou]h[aeiou]' | egrep -v 'Fh?aranhat' | egrep -v '^g?Ch?banhvan' | egrep -v "^([bdm]')?fhorhalla" | egrep -v '(bh)?forhalla' | egrep -v "^([bdm]'|h|[nt]-)?unnailheicsiam"
cat $1 | egrep 'sh[^aeioulnr]'
## check for eclipsis and lenition of same consonant
## so it suffices to check m?bh? later...
cat $1 | egrep 'mbh' | egrep -v "^([bdm]'|h|[nt]-)?io?mbh" | egrep -v "^(d?th?rombhua|g?ch?ambh|([bdm]'|bh)?fh?uaimbhai?c)"
cat $1 | egrep 'ndh' | egrep -v 'fh?lanndhe[ai]rg([ae])?$'
cat $1 | egrep '(bp|ts|dt)h'
cat $1 | egrep '^(gc|ng|bhf)h'
echo 'Checking for repeated letters...'
cat $1 | egrep '([^lnr])\1' | egrep -v '^(b?ph?izza|sh?n|lott)'
cat $1 | egrep '([lnr])\1\1'
cat $1 | egrep '(a|a|e|e|i|i|o|o|u|u)'
echo 'Checking for weird diphthongs...'
cat $1 | egrep '([iou][e]|a)' | egrep -v '^(bhuel|hiana|t?sh?ubpoena)'
cat $1 | egrep '[aeo]u'
cat $1 | egrep '[o][a]' | egrep -v '^(sh?eamp|m?bh?u|g?ch?[a]|reo|t?sh?a)' | egrep -v 'iil' | egrep -v '^n?Gh?am$'
cat $1 | egrep '[aeo]' | egrep -v '^(m?bh?|g?ch?r|n?dh?|n?gh?lae|nao|neamhbh|t?sh?|t?sh?)'
cat $1 | egrep '[a]' | egrep -v '^(m?bh?u|n?dh?la|mh?is|r)'
cat $1 | egrep '(e|[o]|[u]o)'
echo 'Checking for weird triphthongs...'
cat $1 | egrep '[aeiou][aeiou][aeou]' | egrep -v '(ua|i)' | egrep -v "^(([bdm]'|h|[nt]-)?ae|n?gh?lae|hian|nia|nao|b?ph?arania|reo|s[pt]rae)"
cat $1 | egrep '(e|a|io|iu|o|u)i' | egrep -v "^(([bdm]'|h|[nt]-)?aein|n?gh?iuirl|sciuir)" | egrep -v 'uige'
cat $1 | egrep '[aou]' | egrep -v '^(bu|g?ch?ro|dla|sa|spra)' | egrep -v 'gh?na'

## Initial position
echo 'Checking for funny starting combinations...'
cat $1 | egrep '^[bcdfghlmnprt]h?[bcdfgmnpst]' | egrep -v '^(b(p|hf)|[cgt]h?n|gc|mb|n[dg]|ts|dt)' | egrep -v '^mh?n$'
# this one includes "no initial ll,nn,rr"!
cat $1 | egrep '^(s[bdg]|[lmnr][lr]|nn|ps)'

## Terminal position
echo 'Checking for funny ending combinations...'
cat $1 | egrep '[bcdfghmpst][bcdfglmnprs]$' | egrep -v '(sc|dh[a-z]|[ptc]s|ai?sp|iamb|mp|t.*ghd)$'
cat $1 | egrep '[^bcdgmt]h$'
cat $1 | egrep '[bcdefghm]t$' | egrep -v '(ch|ing|abh)t$' | egrep -v '(sh?ei[cf]|ch?raif)t$'
cat $1 | egrep 'l[bdhinorsu]$' | egrep -v '(bh?oi?lb|gh?ild|scoi?lb)$'
cat $1 | egrep 'n[dfhilmopru]$' | egrep -v '(ainm|sh?einm|sh?oicind|^Alaind)$'

## from Litri na Gaeilge 
echo 'Checking for pre-standard spellings (Litri na Gaeilge rules)...'
# Rule 2.a, lch 103
cat $1 | egrep 'tch' | egrep -v '^(g?ch?(airtchl|eartch|ruitchorda)|n?dh?otchis|smitcheo|Sttchiste|d?th?oitcheo|vstchta)'
# Rule 3.I.b, lch 104.  D lch viii -aidhe -> -a
cat $1 | egrep 'dhe$' | egrep -v '(aghaidhe|ridhe)$' | egrep -v "^([bdm]'|h|[nt]-)?(fhlidhe|[ou]idhe|udhe)" | egrep -v '^(luaidhe|(bh)?flidhe|m?bh?idhe|g?Ch?oimdhe|d?th?eidhe|sh?oraidhe|spleidhe)$'
# Rule 3.II.b, lch 105  (exceptions include some "lit." spellings)
cat $1 | egrep 'adha.' | egrep -v "^([bdm]'|h|[nt]-)?adha" | egrep -v '(th?adhai?ll|radhai?rc|n?gh?adhai?r)' | egrep -v '^(m?bh?anadhaltra|n?gh?leadha|spadha)' | egrep -v "^(g?ch?adhai?[ln]|g?ch?eannadhairt|g?ch?ladha|m?bh?ladha|d?th?radhaill|mh?eadhar|ladhar|g?ch?eadharla)" | egrep -v "^([bdm]')?fhe?adha" | egrep -v "^(bh)?fe?adha"
# Rule 3.II.c, lch 105
cat $1 | egrep 'aedh(ea|i)'
# Rule 3.II.e, lch 105
cat $1 | egrep 'idhea' | egrep -v 'idheanna?$' | egrep -v '(infridhearg|fh?idheadireacht)a?$' | egrep -v '(uidheadha|fh?eidheartha)$' | egrep -v '^(g?ch?|d?th?e)idheacha?$'
# Rule 4, lch 106
cat $1 | egrep '[bm]hth' | egrep -v '^(ramh|leath|(bh?)fh?rith|neamh|b?ph?romh|g?ch?oi?mh|romh)th' | egrep -v 'ubhthorai?dh' | egrep -v '^(n?dh?o-chomhthomha|n?gh?eamhthro|d?th?aobhthro|n?dh?ubhthuirs|leamhthuirse$|rabhtha[rs]$)'
# Rule 6.I.b, lch 106
cat $1 | egrep 'ghe$' | egrep -v '^(n?dh?[a]|(bh)?fh?r?a|sh?eo|t?sh?o|d?th?ro|n?dh?eide|mh?a)ighe$' | egrep -v "^[bdm]'fhraighe" | egrep -v "^([bdm]'|h|[nt]-)?([ao]|and|ad|ua)ighe"
# Rule 6.I.c, lch 107, exceptions are literary
cat $1 | egrep 'ugh' | egrep -v '^m?bh?rugh'
# Rule 6.II.b, lch 107, exceptions are literary
cat $1 | egrep '.ghail' | egrep -v 'fh?oghail$' | egrep -v 'iorghaile$' | egrep -v '^(n?dh?oghail|d?th?oghail)$'
# Rule 8.b, lch 108
cat $1 | egrep 'tht'
# Rule 14.a i and ii, lch 113
cat $1 | egrep 'll[rs]' | egrep -v '([oO]lls|bhallra)' | egrep -v '^(n?dh?allr|m?ballra|n?dh?uillsilt|n?gh?illsin|g?ch?allshaoth|g?ch?eallra|stiallscann)'
# Rule 14.b.ii, sonnda is literary, lch 113
cat $1 | egrep 'nnd' | egrep -v 'nndh?e[ai]rg' | egrep -v '^(lionndubh|g?ch?eanndn|sh?onnda$)'
# Rule 14.b.iv, loinnreach/mainnre are genitives, lch 113
cat $1 | egrep 'nnr' | egrep -v '(nnrua|loinnreach)$' | egrep -v '^(g?ch?eannr|mh?ainnre)'
# Rule 14.b.v, annsan is emphatic pronomial, not ==ansin, lch 113
cat $1 | egrep 'nns' | egrep -v '^(g?ch?eanns|n?dh?innseanch|n?gh?rinnscr|b?ph?roinnseomra|g?ch?rannseil|mh?ionnscrbhinn)' | egrep -v '^annsan$'
# Rule 15.a, lch 114
cat $1 | egrep 'ln' | egrep -v '(iailnimh|ilnisinta|ollnva|ulna|ilnithe$)'  | egrep -v '^(b?ph?ailn|m?bh?allnai?sc$)'
# Rule 15.b, oirmhidne is literary genitive, lch 114
cat $1 | egrep 'dn' | egrep -v '(ardnsa|oirmhidne$)' | egrep -v '^(m?bh?ridn|m?bh?airdne$|mh?aidneachai?n$)'
# Rule 16.a.i, lch 115
cat $1 | egrep 'sg' | egrep -v 'aisgh(nomh|abh|air|afa$)|fh?olsghlant|uasghrd|aoisghrpa'  | egrep -v '^(luasgh|b?ph?easghad|g?ch?leasghleac|g?ch?raosghalai?r$|g?ch?rosgho|n?dh?easghn|d?th?re?asgh|n?gh?lasgh|neasghao|rsghairdn?$)'
# Rule 16.a.iii, lch 115
cat $1 | egrep 'sd' | egrep -v '(aisdich|eisdrith|osduine$)' | egrep -v '^(g?ch?osdearg|d?th?easdh|d?th?rasdu|leasde|rsd)'
# Rule 19.g, lch 121, bladha, miadha, mudha, spleadha  literary
cat $1 | egrep 'dha$' | egrep -v '(fhea|uidhea)dha$' | egrep -v '^((bh)?fea|m?bh?la|mh?(ia|u|o)|splea)dha$'
# Rule 23.I.a, lch 123
cat $1 | egrep 'rr'
# Rule 23.I.b, lch 123
cat $1 | egrep 'ir[dl]' | egrep -v '^(lirl|spirl)'
# Rule 24, lch 124
cat $1 | egrep "(-.*-|'.*')" | egrep -v '(earra-le-roinnt$|an-fin-$)' | egrep -v '^[nt]-'
cat $1 | egrep '-' | egrep -v "(-.*-|'.*')" | egrep -v '^([nt]-[aeiou]|an-|n?dh?ea-|x-gha)' | egrep -v '([bcdfglmnprst]h?)-(\1|h)' | egrep -v '[aeiou]-[aeiou]' | egrep -v '[A-Z].*-[A-Z]' | egrep -v "(ion-anl|^(bh|[bdm]')?(fh?o-[abcegirt]|fh?rith-chuaran)|^g?ch?omh-a|^n?dh?o-(chomh|gh|ranna|scartha)|t?sh?o-(bh|gha|ranna)|t?sh?(in-sean|os-lucht)|^([bdm]'|h)?a[mn]-)" | egrep -v '(-ca$|^g?ch?(ois-clois|raobh-abh)|iar-tharraing|rang-ta|^n?dh?iosc-jaca|^d?th?(adhall-ogair|iuf-teaf)|^m?bh?an-ab|^b?ph?romh-(air|bhanaist)|^n?gh?(ma-gha|ar-amha|earr-(aighn|chlscro?bh))|^(ralt|sps)-am(a|anna)?$|^hais-tbla?$|^hurda-gurda|^nua-staire?$|^neamh-(a|chomh|shain)|^mh?r-(ais|il)|^t-lint?e$|^u-chasadh$|^V-mhuinel$)'
# Rule 25, lch 127
cat $1 | egrep "'" | egrep -v "^(m?b|[dm])'"

# Others of a similar nature
# D lch viii  -amhail -> -il
cat $1 | egrep 'amhail$' | egrep -v '(sh?|^)amhail$'
# D lch viii  -aracht -> -ireacht
cat $1 | egrep 'aracht$' | egrep -v '^mh?aracht$'
#  Siadhail notes that 'o' replaces 'a' before a consonant
cat $1 | egrep 'a[bcdfglmnprst]'

### Assumptions from aspell phonetics file
echo 'Checking for exceptions to assumptions made in aspell phonetics file...'
echo '  (errors in this section may imply gaeilge_phonet.dat needs attention)'

echo 'A...'
# ANBHANN
cat $1 | egrep 'nbhann' | egrep -v 'anbhanna?$'

# ANBHAIN
cat $1 | egrep 'anbhai' | egrep -v '(anbhainne?$|^m?bh?uanbhail)'

# AERGA
cat $1 | egrep 'erga' | egrep -v 'aerga$'

# AORG
cat $1 | egrep 'aorg[^h]' | egrep -v '^(mh?|t?sh?)aorg[a]'

# AEILG
cat $1 | egrep 'aeilg' | egrep -v 'Gh?aeilge'

# AILBH
cat $1 | egrep 'ailbh' | egrep -v '[bcs]h?ailbh'

# ALBHI?D
cat $1 | egrep 'albhi?d' | egrep -v '^(g?ch?oinnealbhi?d|n?gh?albhi?d$)'

# ALBH
cat $1 | egrep 'albh[^aeour]'

# ARBHI?D
cat $1 | egrep 'arbhi?d' | egrep -v '^mh?tarbhi?d$'

# ARBHUIL
cat $1 | egrep 'arbhui[^t]' | egrep -v '(arbhuill|^mh?arbhuisc)[e]$'

# ARBHUA
cat $1 | egrep 'arbhua' | egrep -v 'eadarbhuasa'

# ARBHIN
cat $1 | egrep 'arbhin' | egrep -v '^mh?arbhintinn'

# ARBH(EI), ARBH

# ATHFH(AEIOU)---
cat $1 | egrep 'thfh[]' | egrep -v '^d?th?thfhithl'

# ATH(BCD...), ADH

# AGHI---
cat $1 | egrep 'aghi' | egrep -v '^g?ch?orraghiob'

# AGHLOIN
cat $1 | egrep 'aghloi[^t]' | egrep -v '^b?ph?leicseaghloine$'

# AGH

# AOMH(FLNST)---  (first says no fh exception needed)
cat $1 | egrep 'aomhfh' | egrep -v '^naomhfh'
cat $1 | egrep 'aomh[bcdgmpr]'

echo '...'
# IRG-

# DHU
cat $1 | egrep 'dhu' | egrep -v '^b?ph?dhuill[e]$'

# DH
cat $1 | egrep 'dh[^u]' | egrep -v 'dh(il|la)$'

# THFH
cat $1 | egrep 'thfh[aeiou]' | egrep -v '^(d?th?thfhithl|n?gh?nth)'

# TH(BCD...)

echo 'B...'
# BANBH, BHANBH, BAINBH, BHAINBH
cat $1 | egrep 'bh?ai?nb' | egrep -v '^m?bh?ai?nbh(ari?n)?$'

echo 'C...'
# CHAFA--$

# CH?EARCH--
cat $1 | egrep 'ch?earch' | egrep -v '^g?ch?earchaill[e]?$'

# CH?ONF
cat $1 | egrep 'ch?onf' | egrep -v '^g?ch?onfa(cha?|i?dh|igh|)$'

# CH?ANBH--
cat $1 | egrep 'ch?anb' | egrep -v '^g?ch?anbhi?s'

# CH?OLBH
cat $1 | egrep 'ch?olbh' | egrep -v '^g?ch?olbha?$'

# CH?URF
cat $1 | egrep 'ch?urf' | egrep -v '^g?ch?urf(nna)?$'

echo 'D...'
# DH?ORCH

# DH?EARF
cat $1 | egrep 'dh?earf' | egrep -v '^n?dh?earf[a]'

# DH?EIRF
cat $1 | egrep 'dh?eirf' | egrep -v '^(n|leas)?dh?eirf(ar|ir)'

# DH?OIL(BF)
cat $1 | egrep 'dh?oil[bf]' | egrep -v '^n?dh?oil(fe|bh)'

# DH?IFEAR
cat $1 | egrep 'dh?ife' | egrep -v '^n?dh?ifear$'

# DH$
cat $1 | egrep '[^aeiou]dh$'

# DH
cat $1 | egrep 'edh' | egrep -v '(uiscedh|ch?inedheigh)'
cat $1 | egrep 'dh.'
cat $1 | egrep '[^aiou]dh[^aeioulr]'

# DHL-- and DHL(EI)--
cat $1 | egrep '[^aiou]dhl' | egrep -v '(dhl(th|ite)|dhlistean|dhleatha|^neamhdhlthi)'

# DHR rules
cat $1 | egrep '[^aiou]dhr[aou]' | egrep -v '((dh?obhar|uisce)dhro|^mh?arbhdhra)|^scigdhrma?$'
cat $1 | egrep '[^aiou]dhr[ei]' | egrep -v '(dhracht|dhreacha?$|eirdhris)'

echo 'E...'

# EAFAR
cat $1 | egrep 'eafar$' | egrep -v '^(n?g|m)h?eafar$'

# EOFAR

# EILBH

# EIDH

# EOMH
cat $1 | egrep 'eomh[bcdfglmnprst]' | egrep -v '^leomh[ft]'

echo '...'
# ARBH
cat $1 | egrep 'arb' | egrep -v '^n?gh?arbh'

# ARM
cat $1 | egrep 'arm[^h]' | egrep -v 'th?arma'

# ARG
cat $1 | egrep 'arg[^h]' | egrep -v '^(ln)?largai?s$'

# IRG
cat $1 | egrep 'irg[^h]' | egrep -v 'aillirg'

# IRBH
cat $1 | egrep 'irbh' | egrep -v '^(lirbhreith|spirbhe?an$)'

# ALBH
cat $1 | egrep 'albh' | egrep -v '^m?bh?albh'

# AF
cat $1 | egrep 'af' | egrep -v 'af$'

echo 'F...'
# FH?AIRCH
cat $1 | egrep 'fh?airc' | egrep -v 'fh?airch(e||n?)$'

# FH?OIRF
cat $1 | egrep 'foirf' | egrep -v '^(bh)?foirf'

# FH?ONNMH
cat $1 | egrep 'fh?onnm' | egrep -v "^(b'|bh)?fh?onnmhai?r"

# FH?OILMH
cat $1 | egrep 'fh?oilm' | egrep -v "^([bdm]'|bh)?fh?oilmh[e]"

# FAIDH, almost always terminal
cat $1 | egrep 'faidh[^b]'

# FADH, almost always terminal
cat $1 | egrep 'fadh[^bf]' | egrep -v 'fh?adharci?n$'

# FIDH  (fidh only terminal)
cat $1 | egrep 'fidh.'

# FEADH  almost always terminal
cat $1 | egrep 'feadh[^n]' | egrep -v '^(bh)?feadha(in)?$'

# FEAR, FAR

# FINN  almost always terminal
cat $1 | egrep 'finn[^e]'

# FAINN  almost always terminal
cat $1 | egrep 'fainn[^ei]'

# F

# FE  almost always terminal
cat $1 | egrep 'fe.' | egrep -v '^(bh)?fe(di?r|nna$)'

# FA?

# FA?IMI(DS)
cat $1 | egrep 'fa?imi[ds].'

# FA?IDS
cat $1 | egrep 'fa?ids.'

echo 'G...'
# GH?AINMH, GH?EALLMH
cat $1 | egrep 'gh?(ain|eall)mh' | egrep -v '^n?gh?(ain|eall)mh'

# GH?LAFAI?DH

# GH
cat $1 | egrep '[^aiou]gh[^aeioulnr]'
cat $1 | egrep '[^aiou]ghl[i]'

echo 'I...'
# IARG
cat $1 | egrep 'iarg[^h]'

# IARBH

# IDIRBH

# IRBHR
cat $1 | egrep 'irbhr' | egrep -v '^mh?uirbhrchta?(nna)?$'

# IRBHU
cat $1 | egrep 'irbhu' | egrep -v '(eochairbhuill[e]$|^litirbhuama?$)'

# IF$  (lots)

# INMHE(A)
cat $1 | egrep 'inmhe[^a]'

# INNMH
cat $1 | egrep 'innmh' | egrep -v '(fh?uinnmh|^g?ch?oinnmh)'

# IONMHAG, IONMH
cat $1 | egrep 'ionmh' | egrep -v '^(g?ch?ionmhai?r|mh?ionmh)'

# ITHFH
cat $1 | egrep 'ithfh' | egrep -v '(ch?ithfholc|ch?rithfhuacht|fh?rithfh)'

# ITH(BCD...)

# IDH(BCD...)
cat $1 | egrep 'idh[aou]' | egrep -v 'idh$'

# IGH(...)
cat $1 | egrep 'igh[bgmpaou]'

echo '...'
# ORM
cat $1 | egrep 'orm' | egrep -v '(^n?dh?orma?$|fh?ormh)'

# OMH(BCD...)
cat $1 | egrep 'omh[bcdfglmnprst]' | egrep -v '^(b?ph?r|l|r|(n?g|s)h?n)omh'

# THS-
cat $1 | egrep 'th[bcdfglmnpst]' | egrep -v '^g?ch?lths(|eacha?)$'

echo 'J...'
# J
cat $1 | egrep '[jJ]' | egrep -v '^(j|n?dh?iosc-j)'

echo 'K...'
# K
cat $1 | egrep '[kK]' | egrep -v '^karat$'

echo 'L...'
# LEANBH/LINBH always terminal
cat $1 | egrep 'l(ea|i)nbh.'

# L(BGM)H?

echo 'M...'
# MORFA--$  always terminal
cat $1 | egrep 'morfa.' 

# MBANBH, MBAINBH  see BANBH, etc. above

# MH?ARF
cat $1 | egrep 'mharf[^a]'

# MODH, MHODH

echo 'N...'
# NAFA--
cat $1 | egrep 'nafa' | egrep -v '^sh?nafa$'

# NNARB
cat $1 | egrep 'nnarb' | egrep -v 'ionnarb'

# NNEALBH--
cat $1 | egrep 'nnealbh' | egrep -v '^g?ch?oinnealbh'

# NDORCH, NDEARF, NDEIRF, NDOIL, NDIFEAR   see  D-
# NGAINMH, NGEALLMH, NGLAF...  see G-

# NCHA(S)/NCHAIS/NCHAITHE
cat $1 | egrep 'ncha([s]|is|ith)' | egrep -v '(ionchai?s|sh?eancha)'

# NCHAIR(D)
cat $1 | egrep 'nchair' | egrep -v '(nchaird[ei]|(th?ea|th?io|grea)nchair)'

# N(BM)H?

echo 'O...'
# OFAR--$
cat $1 | egrep '[^ae]ofar' | egrep -v '^(n?gh?l?a|mh?)ofara?$'

# OIRCH
cat $1 | egrep 'oirch' | egrep -v '.?.?oirch'

# OCALBH
cat $1 | egrep 'ocalb' | egrep -v 'fh?ocalbh'

# ORBH
cat $1 | egrep 'orbh' | egrep -v 'fh?orbhi?s$'

# ONNCHA
cat $1 | egrep 'onncha' | egrep -v '(Dh?|fh?i)onncha'

# OMHARB
cat $1 | egrep 'omharb' | egrep -v '^g?ch?omharba'

# OMH(BCD...)

# OTH(BCD...)
cat $1 | egrep 'oth[ft]'

# ODHAO
cat $1 | egrep 'odhao' | egrep -v 'fh?odhao(ine|nna)$'

# ODH(ACLNR)
cat $1 | egrep 'odh[bcdfgmpst]' | egrep -v '^d?th?odhcha'

# OGHRP
cat $1 | egrep 'oghrp'  | egrep -v 'fh?oghrpa'

# OGHLUA
cat $1 | egrep 'oghlua'  | egrep -v '(^(n?dh?|sh?)oghluaiste(achta?)?$|^d?th?oghluai?s)'

# OGHAF
cat $1 | egrep 'oghaf' | egrep -v '^n?dh?oghafa'

# OGH(ABCD...)
cat $1 | egrep 'ogh' | egrep -v '^d?th?oghi?n$'

echo '...'
# R[GM]
cat $1 | egrep 'rg[^h]' | egrep -v '(rga$|^mh?rga|^mrgir$)'
cat $1 | egrep 'rm[^h]'  | egrep -v 'th?rma(ch|igh)$'

# GH
cat $1 | egrep 'gh' | egrep -v "^([bdm]'|h|[nt]-)?gh"

echo 'Q...'
# Q
cat $1 | egrep '[qQ]' | egrep -v '^qu(inn|arto)$'

echo 'R...'
# RANFA
cat $1 | egrep 'ranfa' | egrep -v 'fh?rith-chuaranfa?$'

# RAFA, lots, not nec. terminal either

# RRBHA

# REALMH
cat $1 | egrep 'realm' | egrep -v '^d?th?realmh'

# RFEAR
cat $1 | egrep 'rfear' | egrep -v '^((h|n-)?ath)?rfear$'

# ROMH(FT)
cat $1 | egrep 'romh[bcdfglmnprst]' | egrep -v '^b?ph?romh[ft]'

# RFEAN/RFIN
cat $1 | egrep 'rf(ean|in$)' | egrep -v '^(m?bh?e|n?gh?a|t?sh?e|mh?e)irf(ea|i)n$'

# R(BGM)H--

# RBO--
cat $1 | egrep 'rbo' | egrep -v '^g?ch?osarbolg'

echo 'S...'
# SH?ORCH
cat $1 | egrep 'sh?orch' | egrep -v '^(sh?orch|tsorchaithe$)'

# SH?OILBH
cat $1 | egrep 'sh?oilb' | egrep -v '^(sh?oilbhi?r|tsoilbhris$)'

echo 'T...'
# TH?ALMH
cat $1 | egrep 'th?alm' | egrep -v '^d?th?almh[a]'

# TH?INFEADH/FIDH
cat $1 | egrep 'th?inf[ei]' | egrep -v '^d?th?inf(ea|i)dh$'

# TH?AFA
cat $1 | egrep 'th?afa' | egrep -v '^d?th?afai?nn$'

# TSORCH-, TSOILBH  see S-

# TH$ rule
cat $1 | egrep '[^aeiou]th$'

# TH->H, following check for (and find no) potential exceptions (i.e.silent TH)
cat $1 | egrep '[^a]eth' | egrep -v 'uilethac'
cat $1 | egrep 'th' | egrep -v '^n?dh?th'
cat $1 | egrep 'th[^aeiou]'

echo 'U...'
# UFA
cat $1 | egrep 'ufa[r]' | egrep -v '^(m?bh?rufara?|(g?ch?|r)ufa)$'

# UAI?RG
cat $1 | egrep 'uai?rg' | egrep -v '(fh?uarga(chta?)?$|^d?th?ua(irgn|rgai?n))'

# UARBH

# UALGA
cat $1 | egrep 'ualg' | egrep -v '((^n)?dh?ualg|^m?bh?ualghl)ai?s$'

# ULLMH
cat $1 | egrep 'ullm' | egrep -v 'ullmh[au]'

# UMH

# UTH(BCDGMNPR)
cat $1 | egrep 'uthf'
cat $1 | egrep 'uth[^aeiou]' | egrep -v '^t?sh?ruth'

# ULCH

# URCH(A)

# UDH
cat $1 | egrep 'udh' | egrep -v '^mh?udh[aft]?'

# UGH
cat $1 | egrep 'ugh' | egrep -v '^m?bh?rugh'   # repeat of 6.I.c above

echo '...'
# IRG
cat $1 | egrep 'irg' | egrep -v '^liotirg'

# TH(BCDF...)- no 'fh' exception needed
cat $1 | egrep 'th([gmns]|fh)'

echo 'V...'
# V  (see Litri na Gaeilge, Rule 20, lch 121)
cat $1 | egrep '[vV]' | egrep -v "^(.?|[bdm]')[A-Z]" | egrep -v '(vt|vr|volt|nva|vialait|vinil)' | egrep -v "^([bdm]'|h|[nt]-)?(airc|inveirteab)" | egrep -v '^([vV]|sva|leiviata|ribeaflaivin|g?ch?ileav|n?dh?ordveidh|mh?eindiliv)'

echo 'W...'
# W
cat $1 | egrep '[wW]' | egrep -v '^wigwam'

echo 'X...'
# X
cat $1 | egrep '[xX]' | egrep -v '^(Mh?arx.|x([aei]|-gha))'

echo 'Y...'
# Y
cat $1 | egrep '[yY]' | egrep -v '^yy'

echo 'Z...'
# Z
cat $1 | egrep '[zZ]' | egrep -v '^(z|b?ph?izza|b?ph?uza)' | egrep -v "^([bdm]'|h|[nt]-)?z"

## Remainder were inspired by gaeilge_phonet.dat but either
## correspond to defunct rules or exceptions have no logical implications
echo 'Checking for exceptions to defunct rules in phonetics file...'
cat $1 | egrep 'ealbhr' | egrep -v '^n?gh?ealbhruth'
cat $1 | egrep '..*gc[^h]'
cat $1 | egrep 'fph' | egrep -v '^n?gh?rafphip'
cat $1 | egrep 'cdh' | egrep -v '^(m?bh?reacdhorc|sh?priocdht|t?sh?iocdh)'
cat $1 | egrep '..*bp' | egrep -v 'sh?ubpoena'
cat $1 | egrep 'omhb' | egrep -v '^b?ph?romhbhe?an$'
cat $1 | egrep 'bhmh' | egrep -v '^d?th?aobhmhao'
cat $1 | egrep 'cgh' | egrep -v '^(m?bh?rioscghlr|t?sh?earcghr)'
cat $1 | egrep 'chdh' | egrep -v '^(n?dh?rochdh|g?ch?rochdheigh|smeachdhn)'
cat $1 | egrep '[iu]fh'
cat $1 | egrep 'fh' | egrep -v '^n?dh?fh'
cat $1 | egrep 'fh' | egrep -v '^g?ch?lfhoir'

### Optional Broad/Broad, Slender/Slender check... lots of exceptions.
#echo 'Checking for broad/slender or slender/broad...'
#cat $1 | egrep '[aou][bcdfghlmnprst]+[ie]' | more
#cat $1 | egrep '[ie][bcdfghlmnprst]+[aou]' | more
