local p = {}
local lang = require("Module:languages").getByCode("scn")
local m_IPA = require("Module:IPA")
local m_a = require("Module:accent qualifier")
local a = {}
a = "a`"; a = "a^"
a = "e`"; a = "e^"
a = "i`"; a = "i^"
a = "o`"; a = "o^"
a = "u`"; a = "u^"
local function singleword(str)
local str, accentCount = str:gsub("\195", a); -- diacritics
-- FIXME: redefined local. is this a problem?
str = str:gsub("%^", "") -- ignore circumflex for now
-- TODO: understand whether the circumflex is relevat for pronunciation or not
:gsub("ç", "M") -- as to make it one byte
:gsub("()%1", "*%1") -- geminated consonants
:gsub("()", "n%1"); -- nasal coda
-- put accents on plain words
if accentCount < 1 then
str = str:gsub("()(*i?*)$", "%1`%2");
end
-- velars and palatal affricates
str = str:gsub("", "C"):gsub("g", "G")
:gsub("()()", function (a, b) return a:lower() .. b end)
:gsub("c", "k"):gsub("()h", "%1")
-- temp
-- nongeminated /ts/ in ], etc.
:gsub("(a`?u)z", "%1ts")
-- TODO: agree on whether this should be in the template
-- it could very well just not be here, and the input for (eg) scàuzu would need to be 'scàutsu'
-- some spelling clusters
:gsub("%*d", "*D"):gsub("d%.d", "*d") -- retroflex dd
-- TODO: agree
-- what spelling on the page title
:gsub("gn", "N"):gsub("g%.n", "gn") -- palatal gn
:gsub("ng", "Q"):gsub("n%.g", "ng") -- velar ng
-- TODO: agree
-- theoretically an allophone of /ng/
:gsub("sC", "S"):gsub("s%.C", "sC") -- fricative scj
:gsub("gli", "Li"):gsub("g%.l", "gl") -- palatal glj
-- TODO: agree
-- it is only a regional allophone of ghj, but nothing wrong with supporting the spelling
:gsub("zh", "Z") -- voiced dz
-- TODO: understand what this is
-- marginal phoneme, orthographically undistinct from /ts/, the 'zh' would only appear as input for the template
-- double (and intial) r is another phoneme
:gsub("^r()", "*R%1"):gsub("%*r", "*R")
-- TODO: agree on this
-- always geminated consonants
:gsub("(`?)()", "%1*%2")
:gsub("^()", "*%1")
-- FIXME: is there no other way to do something like (|^)
-- hyphenation
:gsub("()()", "%1-%2") -- syllable break between closed coda and consonant
:gsub("^(*)", "-%1") -- initial syllable break for pure clusters
:gsub("(`?)(*)", "%1-%2") -- syllable break after open coda
:gsub("(`?)(*)", "%1-%2") -- repeat for scaramanzia
-- TODO: agree: the kind of hyphenation I like is highly debatable
-- semivowels
:gsub("()%-()", function (a, b) return a:upper() .. b end) -- unstressed /i u/ before vowels become semivowels
:gsub("(%-)%.()", "%1%2") -- the dot indicates hiatus
:gsub("()I", "%1") -- yod gets absorbed by dento-palatal vowel
:gsub("s%-tr", "*-Hɽ"):gsub("s%-%.tr", "s-tr"); -- retroflex str
return str;
end
local uppercase = {}
uppercase = "ʈ"; uppercase = "ɖ";
uppercase = "ɾ"; uppercase = "r";
uppercase = "c"; uppercase = "ɟ";
uppercase = "ç";
uppercase = "ɲ"; uppercase = "ʎ";
uppercase = "ʃ"; uppercase = "ʂ";
uppercase = "j"; uppercase = "w";
local function refine(str)
-- return str
-- sandhi
-- [[
return str:gsub("%*( ?%-)", "%1") -- can't geminate a closed coda
:gsub("( ?)%*%-", "%1-") -- can't self-geminate after a closed coda
:gsub("%* %-", " *-") -- move gemination, mainly for liaison character
-- add liaison character
:gsub("(`?) (%-)", "%1W%2") -- vowel with coda
:gsub("() %-()", "-%1W%2") -- de-coda-y before vowel
:gsub("( ?%-)j", "%1GI") -- j > ghj
:gsub("(%* ?%-)v", "%1b") -- v > b
end
local function transcription_phonemic(str)
-- symbols
return str --:gsub("tr", "Tɽ"):gsub("dr", "Dɽ") ʈɽ is not phonemic against tr
--:gsub("n( ?%-I)", "ɲ%1") is allophone of /n/ in this case, i guess
--:gsub("kI", "K"):gsub("gI", "A")
:gsub("C", "tʃ"):gsub("G", "dʒ")
:gsub("z", "ts"):gsub("Z", "dz")
:gsub("(.)%*%-(.)", "%1%2%-%2") -- FIXME: to be moved
:gsub("", uppercase)
:gsub("n( ?%-)", "m%1")
--:gsub("n( ?%-)", "ŋ%1")
:gsub("g", "ɡ")
-- stress
:gsub("%-(*`)", "'%1") -- main
:gsub("'()*", ",%1") -- secondary
:gsub(" %-", " "):gsub("^-", "") -- syllable break doesn't remain at the beginning of a word
:gsub("^()%-", "%1") -- no syllable separator for impure clusters if not stressed on the first syllable
:gsub("e", "ɛ"):gsub("o", "ɔ")
:gsub("W", "‿")
-- :gsub("i`", "I"):gsub("i", "ɪ"):gsub("u`", "U"):gsub("u", "ʊ"):lower() -- unstressed /i u/ are /ɪ ʊ/
-- TODO: agree
:gsub("`", ""):gsub("'", "ˈ"):gsub(",", "ˌ"):gsub("%-+", ".");
--]]
end
local function transcription_Palermo(str)
-- symbols
return str:gsub("tr", "Tɽ"):gsub("dr", "Dɽ")
:gsub("n( ?%-I)", "ɲ%1")
:gsub("kI", "K"):gsub("gI", "A")
:gsub("C", "ʃ"):gsub("G", "dʒ"):gsub("nʃ", "ntʃ")
:gsub("z", "ts"):gsub("Z", "dz")
:gsub("Hɽ", "H(ɽ)")
:gsub("(.)%*%-(.)", "%1%2%-%2") -- FIXME: to be moved
:gsub("(`?-)d()", "%1r%2")
:gsub("", uppercase)
:gsub("n( ?%-)", "m%1")
:gsub("n( ?%-k)", "ŋ%1")
:gsub("n( ?%-)g", "ŋ%1ŋ")
:gsub("g", "ɡ")
-- stress
:gsub("%-(*`)", "'%1") -- main
:gsub("'()*", ",%1") -- secondary
:gsub(" %-", " "):gsub("^-", "") -- syllable break doesn't remain at the beginning of a word
:gsub("^()%-", "%1") -- no syllable separator for impure clusters if not stressed on the first syllable
:gsub("W", "‿")
:gsub("()`%-u", "%1`-vu"):gsub("v", "β")
:gsub("i`", "I"):gsub("i", "i̞"):gsub("u`", "U"):gsub("u", "u̞"):lower() -- unstressed /i u/ are /ɪ ʊ/
:gsub("e`", "iɛ̯"):gsub("o`", "uɔ̯"):gsub("e", "ɛ"):gsub("o", "ɔ")
-- TODO: agree
:gsub("`", ""):gsub("'", "ˈ"):gsub(",", "ˌ"):gsub("%-+", ".")
:gsub("*", "");
--]]
end
local initial_Palermo = {};
initial_Palermo = {};
initial_Palermo.nas = "‿n.tʃ"
initial_Palermo.gem = "‿t.tʃ"
initial_Palermo = {};
initial_Palermo.nas = "‿n.n" -- ?? i dont know
initial_Palermo.gem = "‿d.d"
initial_Palermo = {};
initial_Palermo.nas = "‿ŋ.ŋ" -- not sure of this either
initial_Palermo.gem = "‿ɡ.ɡ"
initial_Palermo = {};
initial_Palermo.nas = "‿ŋ.ɡɾ"
initial_Palermo.gem = "‿ɡ.ɡɾ" -- i don't know the distribution of for initial geminated /gr/
local function multiword(str)
local rough = "";
for token in string.gmatch(str, "+") do
rough = rough .. singleword(token) .. " ";
end
local CPA, _ = refine(rough:sub(1, -2)); -- removes final space
local r = transcription_phonemic(CPA);
local pre = "";
local post = "";
if (r:sub(-1) == "*") then -- if final character is *
r = r:sub(0, -2)
post = "<abbr title=\"triggers final syntactic gemination of the following consonant\">*</abbr>";
end
if (r:sub(0, 1) == "*") then -- if initial character is *
r = r:sub(2, -1)
pre = "<abbr title=\"triggers initial auto gemination\">*</abbr>";
end
local pale = transcription_Palermo(CPA);
-- [[
local initpale = initial_Palermo;
local additionalString = "";
if (initpale ~= nil) then
if (initpale.voc ~= nil) then
additionalString = ", " .. m_a.format_qualifiers(lang, {'<abbr title="after a vowel">vow.</abbr>'}) .. " " .. m_IPA.format_IPA(lang, "")
end
if (initpale.gem ~= nil) then
additionalString = additionalString .. ", " .. m_a.format_qualifiers(lang, {'<abbr title="after syntactic gemination">gem.</abbr>'}) .. " " .. m_IPA.format_IPA(lang, "")
end
if (initpale.nas ~= nil) then
additionalString = additionalString .. ", " .. m_a.format_qualifiers(lang, {'<abbr title="after a nasal">nas.</abbr>'}) .. " " .. m_IPA.format_IPA(lang, "")
end
end
return '*' .. m_IPA.format_IPA_full {
lang = lang,
items = {{ pretext = pre, pron = "/" .. r .. "/", posttext = post }},
} .. '\n**' .. m_a.format_qualifiers(lang, {"Palermo"}) .. " " .. m_IPA.format_IPA_full {
lang = lang,
items = {{ pron = "", posttext = additionalString }},
}
--]]
end
function p.IPA (frame)
return multiword(frame.args);
end
return p;