# Pronunciation rules to apply in the English language Context() using CMUDict:
--------------------------------------------------------------------------------
# General rules to adapt to CMUDict as loaded:
Strip "'"
Lower
# Pronunciation changes:
Turn "the" To "the(2)" IfWordAfterStartsWith "a"
Turn "the" To "the(2)" IfWordAfterStartsWith "e"
Turn "the" To "the(2)" IfWordAfterStartsWith "i"
Turn "the" To "the(2)" IfWordAfterStartsWith "o"
Turn "the" To "the(2)" IfWordAfterStartsWith "u"
Turn "a" To "a(2)" IfWordIsAlone
# Now, this should be fixed in autopron.mbx, but it is easier this way:
Turn "w" To "doubleyou" IfWordIsAlone
----------------------------------------

Turn "reading" To "reading(2)"

# Tense specifics for some verbs:

Change "read" Into "read(2)"
# Note: CMUDict defines word "READ" as "R EH D" and "READ(2)" as "R IH D"
Turn "read(2)" To "read" IfWordAfterIs "as"
Turn "read(2)" To "read" IfWordBeforeIsIn "have, has, had, i, been, being, haven't, hasn't, hadn't, as, is, are, was, were, weren't, be, it, this, never"
Turn "read(2)" To "read" IfWordBeforeEndsWith "'ve"
Turn "read(2)" To "read" IfWordBeforeEndsWith "'s"
Turn "read(2)" To "read" IfWordAfterIs "by"
Turn "read" To "read(2)" IfPartOfPhraseBeforeContainsWord "did"
# Prevent "to read by" to be "to red by":
Turn "read" To "read(2)" IfWordBeforeIsIn "to, must, will, would, should, shall, do, go"

Change "lead" To "lead(2)"
# Note: CMUDict defines word "LEAD" as "L EH D" and "LEAD(2)" as "L IH D"
Turn "lead(2)" To "lead" IfWordBeforeIsIn "have, has, had, i, been, being, haven't, hasn't, hadn't, as, is, are, was, were, weren't, be, it, this, never"
Turn "lead(2)" To "lead" IfWordBeforeEndsWith "'ve"
Turn "lead(2)" To "lead" IfWordBeforeEndsWith "'s"
Turn "lead(2)" To "lead" IfWordAfterIs "by"
Turn "lead" To "lead(2)" IfPartOfPhraseBeforeContainsWord "did"
# Prevent "to lead by" to be "to led by":
Turn "lead" To "lead(2)" IfWordBeforeIsIn "to, must, will, would, should, shall, do, go"

# Distinguish some verbs from nouns:

Turn "present" To "present(2)" IfWordBeforeIsIn "to, will, would, should, shall, do, must, go"
Turn "present" To "present(2)" IfWordAfterIsIn "me, mine, my, you, your, yours, her, hers, his, him, this, that"
Turn "present" To "present(2)" IfWordBeforeEndsWith "'ll"
Turn "present" To "present(2)" IfWordBeforeEndsWith "'d"

Turn "live"  To "live(2)" IfWordBeforeIsIn "i, you, we, they, not, do, did, go, to, gonna, can, could, would, should, will, shall, want"
Turn "live"  To "live(2)" IfWordBeforeEndsWith "'ll"
Turn "live"  To "live(2)" IfWordBeforeEndsWith "'d"
Turn "live"  To "live(2)" IfWordBeforeEndsWith "n't"

Change "lives" To "lives(2)"
Turn "lives(2)" To "lives" IfWordBeforeIsIn "he, she, it"

# Now ms's and mr's dr's etc.:
If  WordHasLength 2
And PunctIs "."
    Turn "*" To "*."
    EndIf

# Words like speakable, iterable etc. should not sound like speak able, iter able...
If  WordEndsWith "able"
And WordNotExists
    ReplaceOriginal "able" With "+able(2)"
    EndIf

If  WordEndsWith "ables"
And WordNotExists
    ReplaceOriginal "ables" With "+ables(2)"
    EndIf

# Some shorthands - these would perhaps be better added in  CMUDict but for now...
# If this file starts to grow with new more important and complex rules, these will definitely be moved to CMUDict, to preserve speed, or better, utils.SeparateWord() will be improved to handle them correctly.
Turn "http"  To "h+t+t+p"
Turn "https" To "h+t+t+p+s"
Turn "www"   To "doubleyou+doubleyou+doubleyou"
Turn "ftp"   To "f+t+p"
Turn "ssh"   To "s+s+h"
Turn "sftp"  To "s+f+t+p"
Turn "html"  To "h+t+m+l"
Turn "htm"   To  "h+t+m"
Turn "xml"   To "x+m+l"
Turn "rss"   To "r+s+s"
Turn "cpu"   To "c+p+u"
Turn "gpu"   To "g+p+u"
Turn "dma"   To "d+m+a(2)"
Turn "mcu"   To "m+c+u"
Turn "rna"   To "r+n+a(2)"
Turn "hr"    To "h+r"
Turn "url"   To "u+r+l"
Turn "nvda"  To "n+v+d+a(2)"

# Now, CMU dict that we have contains only american spelling of color, favor, favorite etc.
# So modify this to allow correct pronunciation in both cases
If  WordContains "our"
And WordNotExists
    ReplaceOriginal "our" With "or"
    Replace "our" With "or"
    EndIf
