Module:pine-pron: Difference between revisions

From Linguifex
Jump to navigation Jump to search
No edit summary
No edit summary
Line 20: Line 20:
["a" .. c.hook] = "æː", ["e" .. c.hook] = "eː", ["i" .. c.hook] = "iː",
["a" .. c.hook] = "æː", ["e" .. c.hook] = "eː", ["i" .. c.hook] = "iː",
["o" .. c.hook] = "oː", ["u" .. c.hook] = "uː", ["y" .. c.hook] = "yː",
["o" .. c.hook] = "oː", ["u" .. c.hook] = "uː", ["y" .. c.hook] = "yː",
}
local long_vowels_test = {
["a"] = "æː", ["e"] = "eː", ["i"] = "iː",
["o"] = "oː", ["u"] = "uː", ["y"] = "yː",
}
}


Line 33: Line 28:
term = term:gsub("[aeiou]", laxen); term = term:gsub("ů", "œ")
term = term:gsub("[aeiou]", laxen); term = term:gsub("ů", "œ")
-- long vowels
-- long vowels
term = term:gsub("([ảẻỉỏủỷ])", function(v)
local nfd_term = mw.ustring.toNFD(term)
v = match(mw.ustring.toNFD(v), "^.")
return long_vowels_test[v]
end)
--[[local nfd_term = mw.ustring.toNFD(term)
nfd_term = nfd_term:gsub("[aeiouy]" .. c.hook, long_vowels)
nfd_term = nfd_term:gsub("[aeiouy]" .. c.hook, long_vowels)
term = mw.ustring.toNFC(nfd_term)]]
term = mw.ustring.toNFC(nfd_term)
term = term:gsub("ɔɑ", "ɑː"); term = term:gsub("ɛœ", "øː")
term = term:gsub("ɔɑ", "ɑː"); term = term:gsub("ɛœ", "øː")
-- diphthongized vowels
-- diphthongized vowels
Line 47: Line 37:
term = term:gsub("vʏy", "ᶣy"); term = term:gsub("vøy", "ᶣø"); term = term:gsub("vʊu", "ʷu")
term = term:gsub("vʏy", "ᶣy"); term = term:gsub("vøy", "ᶣø"); term = term:gsub("vʊu", "ʷu")
term = term:gsub("^ᶣ", "ɥ"); term = term:gsub("^ʷ", "w")
term = term:gsub("^ᶣ", "ɥ"); term = term:gsub("^ʷ", "w")
-- diphthongs
term = term:gsub("([ɛɑ])ʏ", "%1y"); term = term:gsub("ɑy", "æy")
term = term:gsub("([ɛɑɪ]ʊ)", "%1u"); term = term:gsub("ɪœ", "ɪy")
-- geminate consonants
term = term:gsub("(.)%1", "%1ː"); term = term:gsub("ng", "ŋː")
-- simple consonant subtitutions
term = term:gsub("tṡ", "ʧ"); term = term:gsub("ts", "ʦ")
term = term:gsub("ḷ", "ɬ"); term = term:gsub("ḥ", "ʔ")
-- final substitutions
local final_subs = {
["ʧ"] = "t͡ʃ",
["ʦ"] = "t͡s",
["g"] = "ɡ",
["ƛ"] = "t͡ɬ",
["ṃ"] = "m" .. c.ringbelow,
["ṇ"] = "n" .. c.ringbelow,
["ṛ"] = "r" .. c.ringbelow,
}
term = term:gsub("[ʧʦgƛṃṇṛ]", final_subs)
return term
return term

Revision as of 01:07, 18 November 2025



local sub = mw.ustring.sub
local find = mw.ustring.find
local gmatch = mw.ustring.gmatch
local gsub = mw.ustring.gsub
local match = mw.ustring.match
local u = mw.ustring.char
local split = mw.text.split
local gsplit = mw.text.gsplit

local lang = require("Module:languages").getByCode("pine")
local c = require("Module:languages/data").chars
local m_IPA = require("Module:IPA")

local laxen = {
	["y"] = "ʏ", ["i"] = "ɪ", ["e"] = "ɛ",
	["u"] = "ʊ", ["o"] = "ɔ", ["a"] = "ɑ",
}

local long_vowels = {
	["a" .. c.hook] = "æː", ["e" .. c.hook] = "eː", ["i" .. c.hook] = "iː",
	["o" .. c.hook] = "oː", ["u" .. c.hook] = "uː", ["y" .. c.hook] = "yː",
}

local export = {}

function export.crux(term)
	-- default to short lax vowels
	term = term:gsub("[aeiou]", laxen); term = term:gsub("ů", "œ")
	-- long vowels
	local nfd_term = mw.ustring.toNFD(term)
	nfd_term = nfd_term:gsub("[aeiouy]" .. c.hook, long_vowels)
	term = mw.ustring.toNFC(nfd_term)
	term = term:gsub("ɔɑ", "ɑː"); term = term:gsub("ɛœ", "øː")
	-- diphthongized vowels
	term = term:gsub("ʊɔ", "ʊu"); term = term:gsub("œɑ", "øy"); term = term:gsub("œɛ", "ʏy")
	-- labiodiphthongized vowels
	term = term:gsub("vʏy", "ᶣy"); term = term:gsub("vøy", "ᶣø"); term = term:gsub("vʊu", "ʷu")
	term = term:gsub("^ᶣ", "ɥ"); term = term:gsub("^ʷ", "w")
	-- diphthongs
	term = term:gsub("([ɛɑ])ʏ", "%1y"); term = term:gsub("ɑy", "æy")
	term = term:gsub("([ɛɑɪ]ʊ)", "%1u"); term = term:gsub("ɪœ", "ɪy")
	
	
	-- geminate consonants
	term = term:gsub("(.)%1", "%1ː"); term = term:gsub("ng", "ŋː")
	
	-- simple consonant subtitutions
	term = term:gsub("tṡ", "ʧ"); term = term:gsub("ts", "ʦ")
	term = term:gsub("ḷ", "ɬ"); term = term:gsub("ḥ", "ʔ")
	
	-- final substitutions
	local final_subs = {
		["ʧ"] = "t͡ʃ",
		["ʦ"] = "t͡s",
		["g"] = "ɡ",
		["ƛ"] = "t͡ɬ",
		["ṃ"] = "m" .. c.ringbelow,
		["ṇ"] = "n" .. c.ringbelow,
		["ṛ"] = "r" .. c.ringbelow,
	}
	
	term = term:gsub("[ʧʦgƛṃṇṛ]", final_subs)
	
	return term
end

function export.show(frame)
	local parent_args = frame:getParent().args
	local params = {
		[1] = { default = mw.title.getCurrentTitle().nsText == 'Template' and "Niṡkullit" or mw.title.getCurrentTitle().text },
	}
	local args = require("Module:parameters").process(parent_args, params)
	local term = mw.ustring.lower(args[1])
	
	local pronunciations = {
		{pron = "[" .. term .. "]"}
	}

	return "* " .. m_IPA.format_IPA_full{lang = lang, items = pronunciations}
end

return export