Module:lfv-IPA: Difference between revisions

ਕੋਈ ਸੋਧ ਸਾਰ ਨਹੀਂ
No edit summary
No edit summary
Line 3: Line 3:


-- DATA --
-- DATA --
--[[change the character you want to use to mark secondary stress in the input→]] local secondary_stress_marker = "_"


local data = {
local data = {
Line 50: Line 52:
["lš"] = "ɬɬ",
["lš"] = "ɬɬ",
["lž"] = "ɮɮ",
["lž"] = "ɮɮ",
["tˌl"] = "ˌɬ",
["dˌl"] = "ˌɮ",
["lˌs"] = "ˌɬ",
["lˌz"] = "ˌɮ",
["lˌš"] = "ɬˌɬ",
["lˌž"] = "ɮˌɮ",


["l·s"] = "ɬɬ",
["l·s"] = "ɬɬ",
Line 59: Line 68:
["ltl"] = "ɬɬ",
["ltl"] = "ɬɬ",
["ldl"] = "ɮɮ",
["ldl"] = "ɮɮ",
["l·ˌs"] = "ɬˌɬ",
["l·ˌz"] = "ɮˌɮ",
["lˌlj"] = "ʎˌʎ",
["nˌnj"] = "ɲˌɲ",
["rtˌl"] = "ɬˌɬ",
["rdˌl"] = "ɮˌɮ",
["ltˌl"] = "ɬˌɬ",
["ldˌl"] = "ɮˌɮ",


["lhl"] = "ɬɬ",
["lhl"] = "ɬɬ",
Line 69: Line 87:
["rhr"] = "rr",
["rhr"] = "rr",
["nm"] = "mm",
["nm"] = "mm",
["lˌhl"] = "ɬˌɬ",
["lˌhlj"] = "ʎˌʎ",
["mˌhm"] = "mˌm",
["nˌhm"] = "mˌm",
["nˌhn"] = "nˌn",
["nˌhnj"] = "ɲˌɲ",
["ñˌhñ"] = "ŋˌŋ",
["rˌhr"] = "rˌr",
["nˌm"] = "mˌm",
[" "] = " ",
[" "] = " ",
["."] = "|",
["."] = "|",
--[[change the character you want to use to mark secondary stress in the input→]] ["_"] = "ˌ",
["ˌ"] = "ˌ",
}
}
data[","] = data["."]
data[","] = data["."]
local affixes = mw.loadData("Module:lfv-IPA/affixes")
local prefixes, suffixes = affixes.prefixes, affixes.suffixes


local vowel = {
local vowel = {
Line 88: Line 119:
["y"] = true,
["y"] = true,
}
}
local ortho_vowels = "aeêioôøuy"
for v, _ in pairs(vowel) do
vowel["ˈ" .. v] = true
end


local consonant = {
local consonant = {
Line 119: Line 154:
["ɮ"] = true,
["ɮ"] = true,
}
}
for c, _ in pairs(consonant) do
consonant["ˈ" .. c] = true
end
local ortho_consonants = "bdðfgǧhjklmnñprsštþvwŵzž"
local ortho_digraphs = {"hlj", "hl", "hm", "hnj", "hn", "hñ", "hr","lj", "ls","lz","nj"}


local boundary = {
local boundary = {
Line 132: Line 172:
["ŋ̊"] = "ŋŋ",
["ŋ̊"] = "ŋŋ",
["r̥"] = "rr",
["r̥"] = "rr",
["ˌʎ̥"] = "ʎˌʎ",
["ˌm̥"] = "mˌm",
["ˌn̥"] = "nˌn",
["ˌɲ̊"] = "ɲˌɲ",
["ˌŋ̊"] = "ŋˌŋ",
["ˌr̥"] = "rˌr",
}
}


Line 166: Line 213:
}
}


function generate_IPA(word, phon, col)
function generate_IPA(word, phon, col, nopref, nosuff)


local working_IPA = {}
local working_IPA = {}
local is_affix = false
local is_affix = false
word = word:gsub(secondary_stress_marker, "ˌ")
-- auto secondary stress --
if phon then
if nopref ~= true then
for _, pref in ipairs(prefixes) do
if mw.ustring.find(word, "^" .. pref) then
word = mw.ustring.gsub(word, "^" .. pref, pref .. "ˌ")
break
end
end
end
if nosuff ~= true then
for _, suff in ipairs(suffixes) do
if mw.ustring.find(word, suff .. "$") then
word = mw.ustring.gsub(word, suff .. "$", "ˌ" .. suff)
break
end
end
end
for _, digraph in ipairs(ortho_digraphs) do
word = mw.ustring.gsub(word, digraph .. "ˌ([" .. ortho_vowels .. "])", "ˌ" .. digraph .. "%1")
end
word = mw.ustring.gsub(word, "([" .. ortho_consonants .. "])ˌ([" .. ortho_vowels .. "])", "ˌ%1%2")
end
-- base generation --  
-- base generation --  
while #word > 0 do
while #word > 0 do
if data[mw.ustring.sub(word, 1, 4)] then
if data[mw.ustring.sub(word, 1, 5)] then
table.insert(working_IPA, data[mw.ustring.sub(word, 1, 5)])
word = mw.ustring.sub(word, 6)
elseif data[mw.ustring.sub(word, 1, 4)] then
table.insert(working_IPA, data[mw.ustring.sub(word, 1, 4)])
table.insert(working_IPA, data[mw.ustring.sub(word, 1, 4)])
word = mw.ustring.sub(word, 5)
word = mw.ustring.sub(word, 5)
Line 243: Line 319:
end
end
end
end
mw.logObject(working_IPA)
-- intervocalic voicing and gemination of voiceless sonorants --
-- intervocalic voicing and gemination of voiceless sonorants --
Line 403: Line 481:
if phon then
if phon then
-- /xd/ /xɡ/ --
-- /xd/ /xɡ/ --
if mw.ustring.find(working_IPA, "(x[dɡ][̥̊])") then
if mw.ustring.find(working_IPA, "(x[dɡ][̥̊])") then
Line 430: Line 508:
["nolarge"] = true,
["nolarge"] = true,
["cite"] = true,
["cite"] = true,
["nopref"] = true,
["nosuff"] = true,
}
}
local p = 2
local p = 2
Line 460: Line 540:
if parameters["cite"] then
if parameters["cite"] then
local broad = generate_IPA(outputIPA, false, false)
local broad = generate_IPA(outputIPA, false, false, parameters["nopref"] or false, parameters["nosuff"] or false)
local narrow = generate_IPA(outputIPA, true, parameters["colloquial"] or parameters["col"] or false)
local narrow = generate_IPA(outputIPA, true, parameters["colloquial"] or parameters["col"] or false, parameters["nopref"] or false, parameters["nosuff"] or false)
if "ˈ" .. broad ~= narrow then
if "ˈ" .. broad ~= narrow then
Line 470: Line 550:
else
else
outputIPA = generate_IPA(outputIPA, parameters["phon"] or false, parameters["colloquial"] or parameters["col"] or false)
outputIPA = generate_IPA(outputIPA, parameters["phon"] or false, parameters["colloquial"] or parameters["col"] or false, parameters["nopref"] or false, parameters["nosuff"] or false)
if parameters["phon"] and parameters["format"] then
if parameters["phon"] and parameters["format"] then