Module:IPAc2-mh: Difference between revisions

Content deleted Content added
Fixed epenthetic vowel height bug.
[w] off-glide tweak
 
(4 intermediate revisions by the same user not shown)
Line 20:
local C1_ = "pbtdSZszkgmnNrlyYhH_"
local C1 = "["..C1_.."]"
local CC2_ = ".[jGw]"
local C = ".["..C2_.."]"
local V_ = "aEeiAV7MQOou"
local V = "["..V_.."]"
Line 123 ⟶ 124:
 
 
local PARSE_PSEUDO_GLIDE = {
["y"] = "0",
local PARSE_C_CH_CW
["h"] = "0h",
local PARSE_REMAINING
["w"] = "0w"
}
 
local PARSE_C_CH_CW = {
["k"] = "kG",
["kh"] = "kGh", -- N\A
["kw"] = "kW",
["l"] = "lJ",
["lh"] = "lG",
["lw"] = "lW",
["m"] = "mJ",
["mh"] = "mG",
["mw"] = "mJw", -- N\A
["n"] = "nJ",
["nh"] = "nG",
["nw"] = "nW",
["ng"] = "NG",
["ngh"] = "NGh", -- N\A
["ngw"] = "NW",
["r"] = "rG",
["rh"] = "rGh", -- N\A
["rw"] = "rW",
["0"] = "_J",
["0h"] = "_G",
["0w"] = "_W"
}
 
local PARSE_REMAINING = {
["b"] = "pG",
["d"] = "rj",
["e"] = "E",
["&"] = "e",
["h"] = "hG",
["j"] = "tj",
["J"] = "j",
["p"] = "pj",
["t"] = "tG",
["w"] = "hw",
["W"] = "w",
["y"] = "hj",
["z"] = "yj",
["Z"] = "Yj",
["'"] = ""
}
 
local function parse(code)
Line 143 ⟶ 188:
-- Recognize "y_", "h_", "w_", "_y", "_h", "_w" as pseudo-glides.
PARSE_PSEUDO_GLIDE = PARSE_PSEUDO_GLIDE or {
["y"] = "0", ["h"] = "0h", ["w"] = "0w"
}
text = string.gsub(text, "_*([hwy])_+", PARSE_PSEUDO_GLIDE)
text = string.gsub(text, "_+([hwy])", PARSE_PSEUDO_GLIDE)
Line 167 ⟶ 209:
-- Convert multigraphs to pseudo-X-SAMPA format.
PARSE_C_CH_CW = PARSE_C_CH_CW or {
["k"] = "kG",
["kh"] = "kGh", -- N\A
["kw"] = "kW",
["l"] = "lJ",
["lh"] = "lG",
["lw"] = "lW",
["m"] = "mJ",
["mh"] = "mG",
["mw"] = "mJw", -- N\A
["n"] = "nJ",
["nh"] = "nG",
["nw"] = "nW",
["ng"] = "NG",
["ngh"] = "NGh", -- N\A
["ngw"] = "NW",
["r"] = "rG",
["rh"] = "rGh", -- N\A
["rw"] = "rW",
["0"] = "_J",
["0h"] = "_G",
["0w"] = "_W"
}
text = string.gsub(text, "[klmnr0]g?[hw]?", PARSE_C_CH_CW)
if string.find(text, "g") then
Line 196 ⟶ 215:
-- Convert remaining sequences to pseudo-X-SAMPA format.
PARSE_REMAINING = PARSE_REMAINING or {
["b"] = "pG",
["d"] = "rj",
["e"] = "E",
["&"] = "e",
["h"] = "hG",
["j"] = "tj",
["J"] = "j",
["p"] = "pj",
["t"] = "tG",
["w"] = "hw",
["W"] = "w",
["y"] = "hj",
["z"] = "yj",
["Z"] = "Yj",
["'"] = ""
}
text = string.gsub(text, ".", PARSE_REMAINING)
Line 270 ⟶ 272:
["hj"] = "y", ["hG"] = "h", ["hw"] = "w",
["_j"] = "", ["_G"] = "", ["_w"] = "",
["a"] = "a",
["E"] = "e",
["e"] = "&",
["i"] = "i",
["I"] = "i"
}
local BENDER_MED = assign({}, BENDER_1968, {
Line 284 ⟶ 286:
["lG"] = "ļ",
["lw"] = "ļ°",
["e"] = "ȩ"
})
local BENDER_MOD = assign({}, BENDER_MED, {
Line 295 ⟶ 297:
["lG"] = "ḷ",
["lw"] = "ḷʷ",
["e"] = "ẹ"
})
local BENDER_DEFAULT = assign({}, BENDER_MOD, {
Line 303 ⟶ 305:
["lG"] = "ļ",
["lw"] = "ļʷ",
["e"] = "ȩ"
})
local BENDER_MAPS = {
["1968"] = BENDER_1968,
["med"] = BENDER_MED,
["mod"] = BENDER_MOD
}
 
Line 357 ⟶ 359:
["hj"] = "j", ["hG"] = "ɰ", ["hw"] = "w",
["_j"] = "", ["_G"] = "", ["_w"] = "",
["a"] = "æ",
["E"] = "ɛ",
["e"] = "e",
["i"] = "i",
["I"] = "i"
}
if false then
Line 399 ⟶ 401:
local F2_BACK = 2
local F2_ROUND = 3
local F2 = {
["j"] = F2_FRONT,
["G"] = F2_BACK,
["w"] = F2_ROUND
}
 
local FRONT_VOWEL = {}
Line 503 ⟶ 509:
local njv_X = { aEei, AV7i, QOou }
local hjvtX = { aEei, aEei, QOou }
local hjvkX = { AV7i, AV7i, QOou }
local _Gv_X = { AV7i, AV7M, QOou }
local rGv_X = { AEei, AV7M, QOou } -- not currently used
Line 509 ⟶ 516:
local rwv_X = { AOou, AOou, QOou }
local hwv_X = { AV7M, AOou, QOou }
local hwvtX = { AV7M, AV7uAV7M, QOou }
-- [F2[secondaryL]][F2[secondaryR]][f1]
local _Xv__ = { _jv_X, _Gv_X, _wv_X }
Line 516 ⟶ 523:
local hXv__ = { _jv_X, hGv_X, hwv_X }
local hXvt_ = { hjvtX, hGv_X, hwvtX }
local hXvk_ = { hjvkX, hGv_X, _wv_X }
local hXvr_ = { hjvtX, hGv_X, hwv_X }
-- [primaryR][F2[secondaryL]][F2[secondaryR]][f1]
Line 534 ⟶ 542:
}
local h_vX_ = {
["p"] = hXv__, ["t"] = hXvt_, ["k"] = hXv__hXvk_,
["m"] = hXv__, ["n"] = hXv__, ["N"] = hXv__hXvk_,
["r"] = hXvr_, ["l"] = hXv__
}
Line 593 ⟶ 601:
["r"] = "r",
["l"] = "l",
["Hj"] = "j",
["HG"] = "ʔ",
["Hw"] = "w",
Line 841 ⟶ 850:
if diphthongs then
text = string_gsub2(text, "(.)([jGw])( *)/([aEei])(@?)( *)(.)([jGw])",
"(.)([jGw])( *)/([aEei])(@?)( *)(.)([jGw])",
function(
primaryL, secondaryL, _, vowel, epenth, __, primaryR, secondaryR
Line 952 ⟶ 960:
end
)
-- Vowels after {yi'y} and {'yiy}
-- claim the secondary articulation to the right.
subst = function(prefix, vowel, infix, secondaryR)
return prefix..VOWEL[F1[vowel]][F2[secondaryR]]..infix..secondaryR
end
text = string.gsub(text, "([yY]. *)([aEei])(@? *.)([jGw])", subst)
-- Change certain vowels in a special environment from round to front.
Line 982 ⟶ 983:
-- Tag certain glide-vowel-non-glide sequences for special reflexes.
text = string.gsub(text, "(H[HyY][jw] *)("..V.." *[ptkmnNrl])", "%1/%2")
text = string.gsub(text, "^ *(h[jw] *)("..V.." *[ptkmnNrl])", "%1/%2")
text = string.gsub(text, "(@ *h[jw] *)("..V.." *[ptkmnNrl])", "%1/%2")
text = string.gsub(text,
"([EeiAV7MOou]@? *h[jw] *)([aAQ] *[ptkmnNrl])", "%1/%2")
text = string.gsub(text, "([iMu] *hj *)([EeV7] *[kN]G)", "%1/%2")
text = string.gsub(text,
"(hj *[aEei]@? *hw *)("..V.." *[ptkmnNrl])", "%1/%2")
Line 1,004 ⟶ 1,006:
end
)
-- Exceptional phrase-initial reflex.
text = string.gsub(text, "^ *([Hh]j *)([V7])( *[kN]G)",
function(prefix, vowel, suffix)
return prefix..FRONT_VOWEL[vowel]..suffix
end
)
text = string.gsub(text, "^ *([Hh]w *)M( *tG)", "%1u%2")
end
Line 1,022 ⟶ 1,032:
if not diphthongs then
-- Opportunistically front thisthese vowelvowels.
text = string.gsub(text, "(hj *)A([A7M])( *[kN]G *[kN]?G? *"..V..")", "%1a%2")
function(prefix, vowel, suffix)
return prefix..FRONT_VOWEL[vowel]..suffix
end
)
-- Surface certain glides.
Line 1,030 ⟶ 1,044:
text = string.gsub(text, "^ *h(j *[AV7MQOou])", "H%1")
text = string.gsub(text, "([ptkmnNrl]..@ *)h(w *[Oou])", "%1H%2")
text = string.gsub(text, "([ptkmnNrl]..@ *)h(j *"..V..")", "%1H%2")
"([ptkmnNrl].).@( *)h(j *[AV7MQOou])", "%1%2H%3")
text = string.gsub(text, "([AV7MQOou]@? *)h(j *[AV7MQOou])", "%1H%2")
text = string.gsub(text, "([aEeiAV7M])(@? *)hw( *)([QOou])",
Line 1,064 ⟶ 1,077:
-- Protect word-final epenthetic vowels after non-glides
-- from the next operation.
text = string.gsub(text, "([ptkmnNrl][jGw]."..V..")(@ )", "%1/%2")
-- De-epenthesize vowels if they still neighbor unsurfaced glides.
Line 1,099 ⟶ 1,112:
if vowelL ~= "" then
if vowelR ~= "" then
returnif vowelL (== vowelR and
F2[vowelL..epenthL.._..] == F2_FRONT
then
maxF1(vowelL, vowelR, "E").."^"..__..vowelR
return vowelL.._..__..vowelR
)
else
return (
vowelL..epenthL.._..
maxF1(vowelL, vowelR, "E").."^"..__..vowelR
)
end
else
return vowelL.._..epenthL..maxF1(vowelL, "E").."^"..__
Line 1,116 ⟶ 1,135:
)
-- TurnFlatten this surfacedepenthetic glidevowel intoand ansurfaced epenthetic vowelglide.
text = string.gsubstring_gsub2(text, "([ptkmnNrlaAQ] *"..C..")E@( *[aEei])E%^( *"..V..")a", "%1@1a%2%3a")
-- Collapse this epenthetic vowel and surfaced glide into a semi-vowel.
text = string.gsub(text, "([aEei])@( *)%1%^", "%2%1^")
end
Line 1,288 ⟶ 1,310:
text = string.gsub(text, "(.)@", "(%1)")
text = string.gsub(text, "%)(=?)%(", "%1")
if not diphthongs and W_OFF_GLIDES then
if false and PHONETIC_DETAILS then
text = string.gsub(text, "([pbm]G%()([aEei])", "%1BG%2")
else
text = string.gsub(text, "([pbm]G%()([aEei])", "%1Hw%2")
end
text = string.gsub(text, "([kgnNrl]w%()([aEeiAV7M])", "%1Hw%2")
text = string.gsub(text, "([QOou] *[nrl]w%()Hw", "%1")
text = string.gsub(text, "([QOou] *Nw%()HwM", "%1M")
end
end